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

66 Commits

Author SHA1 Message Date
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
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
chrysn
02285fd63a
drivers/periph: Add timer_poll feature and timer_poll_channel function 2023-12-19 11:13:41 +01:00
Marian Buschsieweke
b40ab8f833
cpu/nrf5x_common: implement periph_timer_query_freqs 2023-12-08 23:23:07 +01:00
Marian Buschsieweke
a28003f0fa
cpu/nrf5x_common: add whitespace to please linter
Fixes the "comma should be followed by whitespace" warning from
`static-tests`.
2023-11-26 21:33:23 +01:00
Marian Buschsieweke
63faa5f162
cpu/nrf5x: clean up periph_uart
- nRF51: Use `uart_conf_t` for consistency with nRF52
- nRF52832: Use UARTE (UART with EasyDMA) over UART (without DMA), as
  done for all other nRF52 family members
- use `UARTE_PRESENT` to detect whether an UARTE can be used, rather
  than family names
2023-11-26 21:33:23 +01:00
Dylan Laduranty
63310189a5 cpu/nrfxx: move I2C/SPI/UART structs to nrf5x_common
This will reduces code duplication across nRF52,nRF53 and nRF9160 families

Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-07-11 20:07:26 +02:00
Dylan Laduranty
6ea5081da9 cpu/nrf5x_common: share nRF52 PWM driver with nRF53/nRF9160
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-07-08 16:53:41 +02:00
Dylan Laduranty
37cf43a132 cpu/nrf5x_common: move usbdev driver to nrf5x_common
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-07-07 10:53:55 +02:00
Dylan Laduranty
5df8bf6fca cpu/nrfxx: move uart_conf_t struct to periph_cpu_common.h
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-07-04 17:18:18 +02:00
Dylan Laduranty
de6939aa43 cpu/nrf53: add initial support
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-07-04 17:14:06 +02:00
Marian Buschsieweke
a8f1a7e007
cpu/nrf5x_common: Implement timer_set()
The fallback implementation of timer_set() in `drivers/periph_common`
is known to fail on short relative sets. This adds a robust
implementation.
2022-12-23 14:48:08 +01:00
Marian Buschsieweke
b533fcf543
cpu/nrf5x_common: improve doc on timer_conf_t::channels 2022-11-22 13:43:05 +01:00
Hauke Petersen
068c4f1c3b pkg: add nrfx as package 2022-06-02 14:59:50 +02:00
Hauke Petersen
5430c145f8 cpu/nrf5x: rename nrfx.h -> nrfx_riot.h
The nrfx compatibility header is renamed to allow for optinally
including the real nrfx headers using a RIOT package.
2022-06-02 14:59:50 +02:00
Marian Buschsieweke
f0586dbf8f
cpu/nrf5x_common: implement periph/gpio_ll{,_irq}
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
2022-04-23 19:47:00 +02:00
3b1bdd6b3c
nrf5x_common: Add qdec peripheral implementation 2021-11-16 15:21:51 +01:00
5e52a0ea4c cpu/nrf5x_common: nrfx.h: add missing "kernel_defines.h" include 2021-10-20 11:36:55 +02:00
Jan Romann
4384795cb9
treewide: Remove excessive newlines 2021-08-13 19:50:38 +02:00
dylad
5b85a5750e cpu/nrf9160: add initial support 2021-07-28 20:11:26 +02:00
Hauke Petersen
cc2df0c508 cpu/nrf5x: use IS_ACTIVE to enable the DCDC conv 2021-02-19 17:19:28 +01:00
bcb23da368
Merge pull request #16005 from benpicco/cpu/nrf52_gpio_count
cpu/nrf5x_common: make GPIO_PIN macro model independent
2021-02-16 16:18:29 +01:00
Benjamin Valentin
eb89482a75 cpu/nrf5x_common: make GPIO_PIN macro model independent
We can use the `GPIO_COUNT` vendor macro to check if there is more than
one GPIO port on nRF52.
This is the case for nRF52840 and nRF52833.
2021-02-14 00:30:25 +01:00
Benjamin Valentin
a8fcc7b238 cpu/nrf5x: only enable DCDC for REG0 if REG0 exists
nRF52833 has POWER_MAINREGSTATUS_MAINREGSTATUS_High, but no POWER->DCDCEN0
register.

This breaks all builds on this MCU.

Fix the ifdef to fix the build.
2021-02-14 00:06:34 +01:00
benpicco
3e3c4d06fb
Merge pull request #15955 from aabadie/pr/boards/microbit-v2
boards: add support for microbit v2
2021-02-13 23:48:43 +01:00
Hauke Petersen
9d7a37a571 cpu/nrf5x: also enable DCDC for REG0 if used 2021-02-12 10:37:43 +01:00
36ca3845c2
cpu/nrf5x_common: fix pin support for nrf52833xxaa model 2021-02-10 13:39:51 +01:00
Hauke Petersen
9d1692c45a cpu/nrf5x: allow to request/release HFXO clk src 2021-01-29 11:10:15 +01:00
chrysn
2053a1785a cpu/nrf52: Ensure that uninitialized PWM outputs are disabled 2020-09-30 13:16:59 +02:00
16ff94b4fe
nrf5x: remove common nrf5x spi peripheral driver 2020-05-18 19:18:28 +02:00
99a59c5dbd
nrf5x: Extend gpio with exti channel retrieval 2020-05-18 19:17:29 +02:00
64f04e4da9
nrf5x: Add built-in DC/DC converter enable function
The internal DC/DC converter is more efficient compared to the LDO
regulator.  The downside of the DC/DC converter is that it requires an
external inductor to be present on the board. Enabling the DC/DC
converter is guarded with NRF5X_ENABLE_DCDC, this macro must be defined
if the DC/DC converter is to be enabled.
2020-03-07 17:37:40 +01:00
9cebd757a2
cpu/nrf5x: update GPIO_UNDEF value
The gpio_t value is uint8_t so use UINT8_MAX for GPIO_UNDEF
2020-02-19 19:16:58 +01:00
f568162f9b
cpu/nrf5x: provide specific gpio_t definition 2020-02-19 19:16:58 +01:00
Yegor Yefremov
fa3b0ff04b doxygen/SPI: don't include overridden typedefs
Add missing #ifndefs to overridden SPI typedefs.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2019-11-15 10:35:32 +01:00
40619d18ca
cpu/nrf5x_common: implement periph_wdt driver 2019-09-20 20:45:42 +02:00
benpicco
1ffe2e5e30
Merge pull request #11512 from skullbox305/cpu-nrf5x
cpu/nrf52: i2c bugfix
2019-09-03 18:43:38 +02:00
Hauke Petersen
cc5f2cae20 cpu/nrf5x: fix bitrate doc for nrfmin driver 2019-08-14 11:15:08 +02:00
Igor Knippenberg
dbd8c2774f cpu/nrf52: i2c bugfix 2019-05-13 11:32:57 +02:00
Martine Lenders
bd08ea1409 nrfmin: remove long address support
The driver is claiming it is needed for IPv6 / 6LoWPAN support, which
is not true (the long address is never used for NRFMIN in fact) and
this assumption actually leads to an assertion when compiled as with
the `gnrc_border_router` example.
2019-01-16 14:59:28 +01:00
Semjon Kerner
2063e98b13 cpu/nrf52: initial PWM implementation 2018-08-21 11:28:23 +02:00
Hauke Petersen
e99010ac3e cpu/nrf5x: include nrfx.h compatibility header 2018-06-06 13:52:57 +02:00
Hauke Petersen
a92b577bc1 cpu/nrf5x: added nrfble radio driver 2018-04-06 11:18:53 +02:00
dnahm
6f9a5004c6 drivers: add adc driver for nrf52 2017-11-15 11:15:10 +01:00
Hauke Petersen
5920d99752 pm: fix weak-based default implementations
Instead of using `weak` function definitions, this PR handles
default implementations using `PROVIDES_x` defines, allowing
for cpus/pm realted modules to use their own implementations.
2017-10-16 14:27:35 +02:00
Hauke Petersen
3060d96bfd cpu/nrf5x: unified clock initialization code 2017-04-05 18:07:23 +02:00
Hauke Petersen
334b2a6dc1 cpu/nrf52: added support for nRF52840
- added vendor header files for nrf52840
- added config for nrf52840
- added additional isr vectors for the nrf52840
- enabled port 1 in GPIO driver
- adapted periph drivers to cope with GPIO driver changes
- adapted the GPIO config of the I2C driver for the nrf51
2017-04-05 16:43:49 +02:00
Joakim Nohlgård
6cda6a6560 periph/cpuid: Unify implementations to a common driver for several platforms 2017-04-05 09:03:49 +02:00
Martine Lenders
29842bb5e4 netdev2: rename to netdev and remove gnrc_netdev
With some minor hand-edits I used the following chain of commands:

```sh
git rm sys/include/net/gnrc/netdev.h
git grep --name-only -i netdev2 | \
        xargs sed -i -e 's/^\(NETDEV\)2\(.*\)\( [("]\)/\1\2 \3/g' \
                     -e 's/\(netdev\)2\(.*\)\( \/\*\*<\)/\1\2 \3/I' \
                     -e 's/\(netdev\)2/\1/gI'
git add -p
git commit --amend
git ls-tree --full-tree -r HEAD --name-only | \
        grep "netdev2" | xargs -I'{}' dirname '{}' | uniq | \
        grep "netdev2" | while read dir; do
                new_dir="$(echo "$dir" | sed "s/netdev2/netdev/g")"
                git mv -f "$dir" "$new_dir"
        done
git commit --amend
git ls-tree --full-tree -r HEAD --name-only | \
        grep "netdev2" | while read file; do
                new_file="$(echo "$file" | sed "s/netdev2/netdev/g")"
                git mv -f "$file" "$new_file"
        done
git commit --amend
git grep --name-only "\<drivers_netdev_netdev\>" | \
        xargs sed -i "s/\<drivers_netdev_netdev\>/drivers_netdev_api/g"
git add -p
git commit --amend
```
2017-03-15 09:31:20 +01:00
Martine Lenders
5b026c5753 netdev2: unify doc 2017-02-07 21:37:52 +01:00