1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/atmega_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
..
adc.c cpu/atmega_common: Add PM on peripherals 2023-12-01 14:12:23 +01:00
cpuid.c cpu/atmega_common: cpuid: add a word of warning 2019-11-11 18:07:09 +01:00
eeprom.c cpu/atmega_common: some additional periph drivers fixed for atmega8 cpu 2023-07-11 21:22:02 +02: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 cpu/atmega_common: Make GPIO_DISCONNECT alias for GPIO_INPUT 2024-01-23 15:03:34 +01:00
gpio.c cpu/avr8_common: Add AVR8_ISR macro 2023-07-05 20:00:19 +02:00
i2c.c cpu/atmega_common: Add PM on peripherals 2023-12-01 14:12:23 +01:00
Makefile cpu: make use of Makefile.periph 2017-11-06 12:01:19 +01:00
pm.c cpu/atmega_common: add cpu.c and startup.c common code 2018-11-02 16:23:47 +01:00
pwm.c cpu/atmega_common: checking features instead of CPU models 2023-07-04 23:17:21 +02:00
rtc.c cpu/avr8_common: Add AVR8_ISR macro 2023-07-05 20:00:19 +02:00
rtt.c cpu: atmega_common: rtt: Fix vera warnings 2023-07-05 20:00:19 +02:00
spi.c cpu/atmega_common: Add PM on peripherals 2023-12-01 14:12:23 +01:00
timer.c cpu/atmega_common: implement periph_timer_query_freqs 2023-12-07 16:15:22 +01:00
uart.c cpu/avr8_common: Add AVR8_ISR macro 2023-07-05 20:00:19 +02:00
wdt.c cpu/atmega_common: some additional periph drivers fixed for atmega8 cpu 2023-07-11 21:22:02 +02:00