1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

700 Commits

Author SHA1 Message Date
Marian Buschsieweke
0dfd83938f
{cpu,drivers}/periph_gpio_ll: add missing include
For `gpio_ll_print_conf()` we need to include `<stdio.h>`, when not
using `fmt.h`.
2024-11-27 09:06:56 +01:00
benpicco
1938002526
Merge pull request #20926 from Enoch247/fix-stm32-periph-timer-spurious-irq
cpu/stm32/periph/timer: prevent spurious IRQs
2024-11-20 16:24:49 +00:00
Joshua DeWeese
f24fc69118 cpu/stm32/periph/timer: fix whitespace style 2024-11-19 21:50:23 -05:00
Marian Buschsieweke
2b6f65a08a
build_system/xfa: change API to fix alignment
This changes the API of xfa from

    XFA(array_name, prio) type element_name = INITIALIZER;

to

    XFA(type, array_name, prio) element_name = INITIALIZER;

this allows forcing natural alignment of the type, fixing failing tests
on `native64`.
2024-11-07 16:30:01 +01:00
Marian Buschsieweke
c2c2cc8592
drivers/periph_gpio: let gpio_read() return bool
Since https://github.com/RIOT-OS/RIOT/pull/20935 gpio_write()
uses a `bool` instead of an `int`. This does the same treatment for
`gpio_read()`.

This does indeed add an instruction to `gpio_read()` implementations.
However, users caring about an instruction more are better served with
`gpio_ll_read()` anyway. And `gpio_read() == 1` is often seen in
newcomer's code, which would now work as expected.
2024-10-23 13:24:09 +02:00
Benjamin Valentin
4627f66caa drivers/periph/gpio: make gpio_write() take a bool 2024-10-22 16:39:48 +02:00
Joshua DeWeese
4e357d410c cpu/stm32/periph/timer: prevnt spurious IRQs
This patch hardens the STM32 timer driver against some possible causes
of spurious IRQs.
2024-10-18 15:51:42 -04:00
Didier DONSEZ
84ec09f3cf boards/nucleo-l432kc: add configuration CAN peripheral
Signed-off-by: Didier DONSEZ <didier.donsez@gmail.com>
2024-10-07 17:35:10 +02:00
krzysztof-cabaj
2d52ebd136 cpu/stm32/f4: add ADC support for f439zi 2024-08-16 10:03:33 +02:00
Marian Buschsieweke
8839ccbe50
cpu/stm32: implement periph_gpio_ll_switch_dir
This implements periph_gpio_ll_switch_dir for STM32 except for STM32F1,
which has a different register layout.
2024-08-08 22:17:35 +02:00
Marian Buschsieweke
422042bd00
drivers/periph_gpio_ll_irq: make support for both edges optional
The assumption that every MCU has this feature turned out wrong. Hence,
add a feature to allow testing for support of edge triggered IRQs on
both flanks.
2024-08-02 13:41:36 +02:00
Marian Buschsieweke
4a092862f8
cpu/stm32/periph_eth: adapt to GPIO LL API change 2024-08-02 09:55:25 +02:00
Marian Buschsieweke
36e8526046
drivers/periph_gpio_ll: change API to access GPIO ports
The API was based on the assumption that GPIO ports are mapped in memory
sanely, so that a `GPIO_PORT(num)` macro would work allow for constant
folding when `num` is known and still be efficient when it is not.

Some MCUs, however, will need a look up tables to efficiently translate
GPIO port numbers to the port's base address. This will prevent the use
of such a `GPIO_PORT(num)` macro in constant initializers.

As a result, we rather provide `GPIO_PORT_0`, `GPIO_PORT_1`, etc. macros
for each GPIO port present (regardless of MCU naming scheme), as well as
`GPIO_PORT_A`, `GPIO_PORT_B`, etc. macros if (and only if) the MCU port
naming scheme uses letters rather than numbers.

These can be defined as macros to the peripheral base address even when
those are randomly mapped into the address space. In addition, a C
function `gpio_port()` replaces the role of the `GPIO_PORT()` and
`gpio_port_num()` the `GPIO_PORT_NUM()` macro. Those functions will
still be implemented as efficient as possible and will allow constant
folding where it was formerly possible. Hence, there is no downside for
MCUs with sane peripheral memory mapping, but it is highly beneficial
for the crazy ones.

There are also two benefits for the non-crazy MCUs:
1. We can now test for valid port numbers with `#ifdef GPIO_PORT_<NUM>`
    - This directly benefits the test in `tests/periph/gpio_ll`, which
      can now provide a valid GPIO port for each and every board
    - Writing to invalid memory mapped I/O addresses was treated as
      triggering undefined behavior by the compiler and used as a
      optimization opportunity
2. We can now detect at compile time if the naming scheme of the MCU
   uses letters or numbers, and produce more user friendly output.
    - This is directly applied in the test app
2024-08-02 09:55:24 +02:00
krzysztof-cabaj
99b5bc1f4f cpu/stm32/l4: enable missing star-up time 2024-07-24 12:09:42 +02:00
crasbe
f93aa40186 cpu/stm32: add ADC support for WB55 2024-07-08 11:18:57 +02:00
krzysztof-cabaj
f6e1ce779e boards/nucleo-l4xxx: fix ADC init 2024-07-01 21:49:55 +02:00
benpicco
fb4e0ccf10
Merge pull request #20609 from Enoch247/improve-stm32-periph-enable.2
cpu/stm32: de-duplicate ifdefs
2024-05-24 09:52:06 +00:00
Joshua DeWeese
6c91865916 cpu/stm32: add missing include of cpu_common.c's header
Following best practice, this patch adds the module's header as its
first include. Resulting compiler errors are also fixed by adding the
header's missing include of cpu_conf.h.
2024-05-23 22:27:01 -04:00
Joshua DeWeese
c05b119fa9 cpu/stm32: de-duplicate ifdefs
This patch consolidates mutliple conditional compile blocks. This is
done to simplify adding new STM32 CPU's and ease maintenance of existing
ports.
2024-05-23 22:27:01 -04:00
Joshua DeWeese
410e55d912 cpu/{gd32v,stm32}/periph/adc: ensure max ADC speed is honored
This patch ensures that the ADC's max clock speed is not exceded.
2024-05-10 22:06:10 -04:00
Joshua DeWeese
4218fca673 cpu/{gd32v,stm32}/periph/adc: make ADC clock setable
This patch allows boards to select a max ADC clock speed. This could be
handy if the board wants to clock the ADC differently according to the
board's front end analog circuitry or MCU model's ADC capabilities.
2024-05-10 21:58:22 -04:00
Marian Buschsieweke
14795d4de0
cpu/stm32/periph/eth: update to new API 2024-05-08 21:06:00 +02:00
Joshua DeWeese
aef5dfec2b cpu/stm32/gpio_ll: make style consistent
This block of code inconsistently made use of else-if statments. The
patch makes the use consistent. The change also makes the code a bit
simpler to read.
2024-04-02 11:51:20 -04:00
Joshua DeWeese
1b1fbfeb5c cpu/stm32/gpio_ll: fix ifdef
APB12 is never defined as a macro. It is an element in the bus_t enum.
Therefore, the test to check if it is defined will always fail.

APB12 is not a real bus. It is the second register of the APB1 bus. I am
not aware of any STM32 family where the ABP2 bus is implmented (ie
RCC_APB2ENR_SYSCFGEN is defined) and devices attached to said bus are
enabled via the APB1 second register. For this reason, the fix is to
simply remove the check.
2024-04-02 11:34:50 -04:00
benpicco
ad51739c26
Merge pull request #20521 from Ollrogge/rtc_support
cpu/stm32u5: Enable rtc support
2024-04-01 19:06:06 +00:00
Ollrogge
013e884550 cpu/stm32u5: Enable rtc support 2024-03-29 10:19:42 +01:00
MrKevinWeiss
e0fdc3c16c
*Kconfig*: Modify Kconfig to remove dep model 2024-03-27 10:28:12 +01:00
MrKevinWeiss
7a68fb0d5e
*Kconfig*: Remove dep-only Kconfig files 2024-03-26 14:54:22 +01:00
MrKevinWeiss
0a9c51fdf9
*.config: Modify all .config kconfig files 2024-03-26 14:53:40 +01:00
MrKevinWeiss
0f2b71c60e
*Makefile.features: Remove TEST_KCONFIG includes 2024-03-26 14:53:39 +01:00
9f51daeb53
Merge pull request #20495 from Enoch247/simplify-stm32-clk-includes
cpu/stm32: remove redundant conditional compile block
2024-03-22 12:04:49 +00:00
Joshua DeWeese
1e4526111f cpu/stm32: moved includes out of header where not used 2024-03-21 11:02:29 -04:00
Marian Buschsieweke
ad4b8f202c
Merge pull request #20479 from Enoch247/simplify-stm32-gpio-code
cpu/stm32/periph/gpio: simplify condition code
2024-03-21 12:33:25 +00:00
Joshua DeWeese
fd105b7e77 cpu/stm32: remove redundant conditional compile
This patch removes a largely redundant block of conditional includes.

The removed includes are moved into the family specific headers so that
the more specific headers may override defaults defined in the shared
headers.
2024-03-20 11:29:25 -04:00
Teufelchen
30e745d242
Merge pull request #20467 from dylad/pr/cpu/stm32/usbdev_fs/dont_autopull_ztimer
cpu/stm32/periph/usbdev_fs: avoid using ztimer when not needed
2024-03-20 12:03:32 +00:00
Teufelchen1
d19182c3e6 llvm: cpu/stm32: Fix unused function warning 2024-03-19 17:20:17 +01:00
Joshua DeWeese
8555a66e23 cpu/stm32/periph/gpio: simplify conditional code
This patch similifies some of the handling of differences between STM32
chips. The intent is to improve scaling of the code as more chips are
added.
2024-03-19 09:04:21 -04:00
Dylan Laduranty
df044f4f56 cpu/stm32/periph/usbdev_fs: avoid using ztimer when not needed
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2024-03-13 21:39:07 +01:00
Ollrogge
53d53d8cc8 boards/nucleo-u575zi-q: Add support 2024-03-01 11:18:18 +01:00
Kasper Hjort Berthelsen
9e6276351d periph/eeprom: fix off-by-one error in debug statement
Since p is incremented DEBUG prints the next value instead of the current
I also took the liberty to add debugs to the `write` function
2024-02-21 13:26:36 +01:00
Marian Buschsieweke
aeca9a52c6
cpu/stm32: implement periph_spi_reconfigure
Fixes https://github.com/RIOT-OS/RIOT/issues/20227
2024-02-15 19:11:37 +01:00
Marian Buschsieweke
4ed287cec8
cpu/stm32/periph_adc: fix register access
The register access to SMPR1/SMPR2 was incorrect in three aspects:

1. For channels < 10, SMPR1 was cleared but SMPR2 should have been
   cleared
2. The code was not thread-safe
3. An unneeded write was issued. (The compiler won't combine the
   in-place bitwise operations into a single read-modify-write
   sequence on `volatile` memory.)

Fixes https://github.com/RIOT-OS/RIOT/issues/20261
2024-02-08 14:51:25 +01:00
Marian Buschsieweke
8bf61336a2
Merge pull request #20290 from maribu/drivers/periph/gpio_ll/features
drivers/periph_gpio_ll: Fix GPIO_DISCONNECT handling and add compile time feature checks
2024-02-05 07:30:54 +00:00
Marian Buschsieweke
6028097132
cpu/stm32/periph_gpio_ll: Fix and clean up
The separate Schmitt trigger bit in the configuration is dropped, as
the Schmitt trigger is only every disabled when in `GPIO_DISCONNECT`
mode. So no need to encode the same information twice.

The `gpio_state_t` is improved to be a bitmask that holds the
MODER register value and a flag indicating whether open-drain mode
should be enabled.

Finally, `GPIO_DISCONNECT` is implemented. This is done by placing the
GPIO in analog mode, which by disabling the Schmitt trigger reduces
power consumption.
2024-02-05 08:21:51 +01:00
Benjamin Valentin
895a6f87ed cpu/stm32/rtc: add support for STM32G0 2024-02-04 19:44:56 +01:00
benpicco
4ea27d4c13
Merge pull request #20300 from jparker324/stm32c0_and_nucleo_c031c6
cpu/stm32: add support for STM32C0 and NUCLEO-C031C6
2024-01-31 15:09:25 +00:00
Jason Parker
b5d72d8242 cpu/stm32: add CPU_FAM_STM32C0 support 2024-01-29 14:44:10 -05:00
Marian Buschsieweke
bd3f54ac8f
drivers/periph_gpio_ll: Add features for compile-time-checks
This adds the features

 - periph_gpio_ll_input_pull_down:
        To indicate support for input mode with internal pull down
 - periph_gpio_ll_input_pull_keep:
        To indicate support for input mode with internal resistor
        pulling towards current level
 - periph_gpio_ll_input_pull_up:
        To indicate support for input mode with internal pull up
 - periph_gpio_ll_disconnect:
        To indicate a GPIO can be disconnected
 - periph_gpio_ll_open_drain:
        To indicate support for open drain mode
 - periph_gpio_ll_open_drain_pull_up:
        To indicate support for open drain mode with internal pull up
 - periph_gpio_ll_open_source:
        To indicate support for open source mode
 - periph_gpio_ll_open_source_pull_down:
        To indicate support for open source mode with internal pull down
2024-01-23 15:03:34 +01:00
Marian Buschsieweke
922276296e
drivers/periph/gpio_ll: pass gpio_conf_t by value
Now that `gpio_conf_t` is on all implemented platforms no larger than
a register, we can more efficiently pass it by value rather than via
pointer.
2024-01-21 09:19:08 +01:00
Marian Buschsieweke
2a00ec13e5
drivers/periph/gpio_ll: shrink gpio_conf_t
This commit optimizes the `gpio_conf_t` type in the following
regards:

- The "base" `gpio_conf_t` is stripped from members that only some
  platforms support, e.g. drive strength, slew rate, and disabling of
  the Schmitt Trigger are no longer universally available but
  platform-specific extensions
- The `gpio_conf_t` is now crammed into a bit-field that is 8 bit or
  16 bit wide. This allows for storing lots of them e.g. in
  `driver_foo_params_t` or `uart_conf_t` etc.
- A `union` of the `struct` with bit-field members and a `bits` is used
  to allow accessing all bits in a simple C statement and to ensure
  alignment for efficient handling of the type

Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
2024-01-21 08:38:40 +01:00