1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/nrf5x_common/periph
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
..
flashpage.c cpu/nrf5x_common: update periph_flashpage for nRF9160 support 2021-11-17 14:05:51 +01:00
gpio_ll_irq.c drivers/periph_gpio_ll: change API to access GPIO ports 2024-08-02 09:55:24 +02:00
gpio_ll.c drivers/periph/gpio_ll: pass gpio_conf_t by value 2024-01-21 09:19:08 +01:00
gpio.c cpu/nrf5x: fix erroneous mask with INTENSET reg 2024-06-09 11:08:37 +01:00
hwrng.c cpu/nrf52: remove specific handling of softdevice 2020-10-29 09:02:12 +01:00
i2c_nrf52_nrf9160.c cpu/nrf52 i2c: Wait for complete transmission when writing NOSTOP 2024-01-27 09:41:26 +01:00
Makefile cpu/nrf53: enable I2C/SPI support 2023-07-11 23:43:35 +02:00
pm.c cpu/nrf5x: implement pm_off() for nRF53/9160 2024-04-18 13:33:36 +02:00
pwm_nrfxx.c cpu/nrf5x_common: share nRF52 PWM driver with nRF53/nRF9160 2023-07-08 16:53:41 +02:00
qdec.c nrf5x_common: Add qdec peripheral implementation 2021-11-16 15:21:51 +01:00
rtt.c cpu/nrf5x_common/periph/rtt: add IRQ conf for nRF53 and nRF9160 2023-07-07 09:18:51 +02:00
spi_nrf52_nrf9160.c cpu/nrfxx: use shared serial IRQ 2023-07-11 22:42:10 +02:00
temperature.c drivers/saul: use const qualifier for data to write 2022-05-23 08:35:27 +02:00
timer.c cpu/nrf5x: Tolerate NULL callback in timers 2023-12-19 11:13:40 +01:00
uart.c cpu/nrf5x_common: clean up UART implementation 2023-11-27 09:49:01 +01:00
usbdev.c cpu/nrf5x_common: move usbdev driver to nrf5x_common 2023-07-07 10:53:55 +02:00
wdt.c cpu/nrf5x/periph/wdt: add compatibility wrapper for nRF9160/nRF53 2023-07-05 09:48:44 +02:00