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

168 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
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
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
Marian Buschsieweke
dd585f9e9d
cpu/esp32/gpio_ll: fix & cleanup
- `gpio_ll_toggle()` now is race-free
- avoid using a look up table but branch to the two different registers
  in the `gpio_ll*()` functions
    - in most cases the GPIO port is a compile time constant and the
      dead branch is eliminated by the optimizer, making this vastly
      more efficient
    - some MCUs do only have a single port, in which case
      `GPIO_PORT_NUM(port)` is known to return `0` even if `port` is
      not known, resulting in one of the branch being eliminated as
      dead branch no matter what
    - in case it really is unknown at compile time which port to work
      on, the branch can still be implemented efficiently by the
      compiler e.g. using a conditional move; likely more efficient
      than fetching a value from the look up table.
2024-04-30 14:16:28 +02: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
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
Gunar Schorcht
92657f5fd2 cpu/esp32: add SDMMC support 2024-01-05 07:22:27 +01:00
Gunar Schorcht
85f7d8b244 cpu/esp32: fix compilation of esp_can 2023-05-11 07:22:52 +02:00
Gunar Schorcht
61bfa5372a cpu/esp32: fix compilation of esp_hw_counter 2023-05-11 06:56:36 +02:00
Marian Buschsieweke
64f4f9a9be
cpu/esp32/periph/pwm.c: fix format specifier
Use %u to print `unsigned`.
2023-05-10 13:02:47 +02:00
Gunar Schorcht
0de2570802 cpu/esp32: fix compilation with gcc 12.2 2023-04-17 07:32:48 +02:00
Gunar Schorcht
343369476b cpu/esp32: remove ESP-IDF periph_ctrl interface API 2023-03-27 03:10:56 +02:00
Gunar Schorcht
5fac30bc9a cpu/esp32: remove ESP-IDF dac interface API 2023-03-27 03:10:56 +02:00
Gunar Schorcht
d93972c369 cpu/esp32: remove ESP-IDF adc interface API 2023-03-27 03:10:56 +02:00
Gunar Schorcht
32168da8d6 cpu/esp32: add flashpage support
f
2023-01-07 14:49:36 +01:00
Gunar Schorcht
6f9c64c6cb cpu/esp32: add flashpage support to Kconfig 2023-01-07 10:38:52 +01:00
Marian Buschsieweke
e8fd65566a
cpu/esp32/periph_timer: allow changing callback or freq
Allow multiple calls to timer_init(), as this is the only way to
change the timer frequency or the callback function.
2022-11-24 22:38:15 +01:00
Benjamin Valentin
cd9c8c354e cpu/esp32: allow GPIO_UNDEF in SPI config
e.g. a display or string of LEDs might not have a MISO pin defined
2022-10-08 22:02:49 +02:00
Benjamin Valentin
2b2298b796 cpu/esp32: implement periph_spi_reconfigure 2022-10-08 22:02:49 +02:00
Gunar Schorcht
94b4f03b47 cpu/esp32: implement periph/gpio_ll_irq 2022-09-02 15:03:45 +02:00
Gunar Schorcht
581c2dd9be cpu/esp32: implement periph/gpio_ll 2022-09-02 15:03:45 +02:00
Gunar Schorcht
48d59e97a2 cpu/esp32: replace macros for GPIO access by inline functions 2022-09-02 15:03:45 +02:00
Gunar Schorcht
b94931191e cpu/esp32: small cleanups in periph/gpio 2022-08-31 12:21:46 +02:00
Gunar Schorcht
06bb755c03 cpu/esp32: add ESP32-S2 support in peripheral drivers 2022-08-29 17:19:39 +02:00
Gunar Schorcht
945a960fa7 cpu/esp32: add ESP32-S3 support in peripheral drivers 2022-08-17 02:04:07 +02:00
Gunar Schorcht
53c657ff61 cpu/esp32: extend GPIO wake-up from deep sleep
Depending on SoC capabilities, ESP32x SoC variants support different logical combinations to wake-up from deep sleep.
2022-08-07 08:43:54 +02:00
Gunar Schorcht
43d71f276d cpu/esp32: add ESP32-C3 support in peripheral drivers 2022-08-05 22:26:22 +02:00
Gunar Schorcht
b4fafef6e7 cpu/esp_common: replace FLASH_MODE_* by CONFIG_*FLASHMODE_* defines
The former FLASH_MODE_{DOUT,DIO,QOUT,QIO} defines are replaced by the corresponding CONFIG_FLASHMODE_{DOUT,DIO,QOUT,QIO} and CONFIG_ESPTOOLPY_FLASHMODE_{DOUT,DIO,QOUT,QIO} as used by the ESP-IDF. This is also needed for the migration of defining flash mode in Kconfig.
2022-08-01 15:17:33 +02:00
benpicco
8cc31c21e1
Merge pull request #18334 from gschorcht/cpu/esp32/fix_periph_rtt_32k_crystal_module_dependeny
cpu/esp32: fix dependency for periph/rtt and module esp_rtc_timer_32k
2022-07-20 17:27:05 +02:00
benpicco
c3e5415a5e
Merge pull request #18333 from gschorcht/cpu/esp32/cleanups_to_reduce_vera_warnings
cpu/esp*: cleanups mainly to reduce the vera++ warnings
2022-07-20 15:08:55 +02:00
Gunar Schorcht
63cc84ac25 cpu/esp32: fix dependency for module esp_rtc_timer_32k 2022-07-20 08:05:44 +02:00
Gunar Schorcht
a24ddb8517 cpu/esp*: cleanups mainly to reduce the vera++ warnings 2022-07-20 06:29:43 +02:00
Gunar Schorcht
9c1498636c cpu/esp32/periph: add some sanity checks 2022-07-20 06:28:55 +02:00
benpicco
bafb7d53c5
Merge pull request #18326 from gschorcht/cpu/esp32/use_variant_specific_adc_and_gpio
cpu/esp32: extend file names of CPU specific files by CPU family
2022-07-19 15:13:44 +02:00
benpicco
e1bc1767af
Merge pull request #18260 from gschorcht/cpu/esp32/add_riscv_platform_code
cpu/esp32: add platform code for RISC-V based ESP32x SoCs
2022-07-18 17:43:02 +02:00
Gunar Schorcht
5f45ca5a2a cpu/esp32: extend file names of CPU specific files by CPU family
To allow the compilation of different ESP32x SoC variants, the file names of ESP32 specific periph/adc_arch.c and periph/gpio_arch.c are extended by the ESP32x SoC family.
2022-07-18 17:08:34 +02:00
benpicco
263b918d7c
Merge pull request #18316 from gschorcht/cpu/esp32/use_cpu_fam
cpu/esp32: use CPU_FAM and CPU_ARCH for ESP32x SoC variant dependent compilation
2022-07-18 15:43:59 +02:00
Gunar Schorcht
b59f8b59da cpu/esp32: platform-independent formatting in DEBUG 2022-07-18 13:51:33 +02:00
Gunar Schorcht
ff8baaae79 cpu/esp32: use CPU_FAM_* instead of MCU_*
To support ESP32x families with the existing implementation, CPU_FAM_* is used instead of MCU_* in source code.
2022-07-18 13:05:21 +02:00
Gunar Schorcht
14fd3735a2 cpu/esp32: move ESP32 specific Kconfigs to ESP32 submenu 2022-07-18 09:52:26 +02:00
benpicco
365fbed906
Merge pull request #18279 from gschorcht/cpu/esp32/periph_hal_esp32_i2c
cpu/esp32: use ESP-IDF i2c HAL for ESP32 periph/i2c
2022-07-17 22:24:54 +02:00
benpicco
2c9f338791
Merge pull request #18271 from gschorcht/periph_hal_esp32_adc
cpu/esp32: use ESP-IDF adc/dac HAL for periph/adc and periph/dac
2022-07-17 20:06:09 +02:00
Gunar Schorcht
c0becd2819 cpu/esp32: port periph/i2c_hw to ESP-IDF i2c HAL 2022-07-17 18:48:23 +02:00
Gunar Schorcht
43d2340eea cpu/esp32: port periph/dac to ESP-IDF dac API 2022-07-17 17:16:49 +02:00
Gunar Schorcht
11c9703675 cpu/esp32: port periph/adc to ESP-IDF interface API 2022-07-17 17:16:49 +02:00
benpicco
6ba048f80c
Merge pull request #18280 from gschorcht/cpu/esp32/periph_hal_esp32_pm
cpu/esp32: use ESP-IDF sleep API for periph/pm
2022-07-17 14:17:51 +02:00