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

225 Commits

Author SHA1 Message Date
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
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
Marian Buschsieweke
1351c61c6a
cpu/efm32: expose pull up on GPIO_DISCONNECT
Allow enabling the pull on on `GPIO_DISCONNECT` and query that
correctly.
2024-02-05 08:21:51 +01: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
Gunar Schorcht
59daab0ba7 cpu/efm32: add EFM32GG11 family 2023-09-18 12:40:33 +02:00
Gunar Schorcht
165f86ad4c cpu/efm32: add family EFM32GG11 (generated with EFM2RIOT) 2023-09-18 12:40:33 +02:00
Gunar Schorcht
e934d5220a cpu/efm32: include periph_conf.h for system-related methods 2023-08-30 16:47:52 +02:00
Gunar Schorcht
3499b822ee cpu/efm32: add DAC support for EFM32 Series1 (VDAC) 2023-08-30 16:47:52 +02:00
Gunar Schorcht
817bb48843 cpu/efm32: fix DAC reference voltage configuration
The EFM32 MCU allows the reference voltage to be configured per DAC device, not per DAC channel. Also, the DAC reference voltage was defined in the configuration but not used anywhere.
2023-08-15 13:58:39 +02:00
625f1f546e
cpu/efm32: fix dependency to cmsis-dsp module 2023-05-14 21:18:50 +02:00
2467ff0961
cpu/efm32: add CMSIS DSP include for arm_math.h 2023-05-14 21:08:30 +02:00
Gunar Schorcht
9f894bc1ac cpu/efm32: clarify units in USB FIFO size definitions
Since the USB OTG FIFO sizes are partly defined in 32-bit words and partly in bytes, the documentation of the of the USB OTG FIFO size definitions is extended by the respective unit.
2023-04-16 22:59:11 +02:00
Gunar Schorcht
9528733a99 cpu/efm32: remove USB OTG HS definitions in vendor definitions
EFM32 MCUs do not support USB OTG HS mode. The according definitions are therefore removed from vendor definitions.
2023-04-16 22:59:11 +02:00
chrysn
664b209e7a cpu/efm32: pwm_init errors are zeros 2023-03-17 13:02:20 +01:00
Gunar Schorcht
a235442b2b cpu/efm32: add number of EPs provided by USB OTG peripheral 2023-03-12 13:15:44 +01:00
chrysn
b04af7920c efm32/dac: Shift instead of masking
Closes: https://github.com/RIOT-OS/RIOT/issues/19317
2023-02-25 13:38:56 +01:00
Benjamin Valentin
124b849503 cpu: call early_init() 2023-01-08 22:26:12 +01:00
Gunar Schorcht
c6bae0b4bf cpu/efm32: increase RIOTBOOT_LEN for riotboot_dfu 2022-12-07 16:38:51 +01:00
Gunar Schorcht
4f47dc13fe cpu/efm32: add CPU_FAM_EFM32xx define 2022-12-07 16:38:51 +01:00
Gunar Schorcht
dd6c46e289 cpu/efm32: fix PM configuration
`cpu/cortexm_common/include/cpu.h` has to be included in `cpu/efm32/periph_cpu.h` so that `PROVIDES_PM_SET_LOWEST` is defined if only `periph_cpu.h` is included. Otherwise `pm_set_lowest` is defined multiple times if the `pm_layered` module is not used. `PROVIDES_PM_OFF` has to be defined in case `pm_layered` is not used, e.g. in riotboot.
2022-12-07 16:38:51 +01:00
Gunar Schorcht
6d233f1308 cpu/efm32: enable usbdev_synopsys_dwc2 driver as periph_usbdev 2022-12-07 16:34:34 +01:00
Gunar Schorcht
6146a3ea91 cpu/efm32: add support for Synopsys USB OTG FS IP core 2022-12-07 16:34:34 +01:00
Juergen Fitschen
a6ff838a4b
Merge pull request #18933 from jue89/feature/cpu_efm32_series_2_adc
cpu/efm32: add periph_adc support for Gecko Series 2
2022-11-24 11:32:56 +01:00
Juergen Fitschen
18e9167c73 cpu/efm32/adc: add support for Gecko Series 2
Series 2 features IADCs instead of ADCs.
2022-11-22 14:44:56 +01:00
Jue
2a81a2ab5c cpu/efm32: provide periph_uart_modecfg feature for every board 2022-11-21 23:20:19 +01:00
Jue
80b491d7dd cpu/efm32/uart: add modecfg support for Gecko Series 2 2022-11-21 23:17:52 +01:00
Jue
54e915e40d cpu/efm32/timer_series2: sync STATUS register
Make sure the STATUS register has been synced between the different clock domains.

Especially the LETIMER needs some time to update the STATUS register after it has been enabled. If the LETIMER is started and stopped with just a short delay, pm_layered gets confused because the timer seems to be inactive ...
2022-10-28 11:34:55 +02:00
Jue
e6d18af3ad cpu/efm32/timer_series2: fix timer_start() interaction with pm_layered
The timer hasn't been enabled yet, if the STATUS isn't RUNNING, yet ...
2022-10-28 11:34:55 +02:00
Juergen Fitschen
6190738bf0 cpu/efm32: include periph_conf.h for system-related methods
This allows boards to define different crystal frequencies. The correct frequency is required by the system-related methods to ensure proper function of the underlying emlib.
2022-10-27 15:22:58 +02:00
Jue
ee2f5e981c cpu/efm32: add efr32zg23 family
Generated with the EFM2RIOT tool: https://github.com/basilfx/EFM2RIOT
2022-10-24 23:16:39 +02:00
Jue
2ce1df5cd6 cpu/efm32/wdt: add series 2 support 2022-10-24 23:16:39 +02:00
Jue
ccf327a32b cpu/efm32/hwrng: add series 2 periph driver 2022-10-24 23:16:39 +02:00
Jue
53e444ebc7 cpu/efm32/i2c: add series 2 support 2022-10-24 23:16:39 +02:00
Jue
2c2790dde2 cpu/efm32/spi: add series 2 support 2022-10-24 23:16:39 +02:00
Jue
568448f68c cpu/efm32/timer: add series 2 periph driver 2022-10-24 23:16:39 +02:00
Jue
42c9a3c9f1 cpu/efm32/uart: add series 2 periph driver 2022-10-24 23:16:38 +02:00
Jue
2b1a260c43 cpu/efm32/gpio: fix clock enable sequence for series 2 2022-10-24 23:16:38 +02:00
Jue
1c60c95733 cpu/efm32: setup EM4 mode for series 2 CPUs 2022-10-24 23:16:38 +02:00
Jue
775861510c cpu/efm32: allow series 2 boards to setup clock trees flexibly 2022-10-24 23:16:38 +02:00
Juergen Fitschen
67b380034a cpu/efm32/pm: add debug output 2022-10-19 18:17:43 +02:00
Juergen Fitschen
360b36af16 cpu/efm32/pm: allow blocking EM1
Aligns pm logic to #17883
2022-10-19 17:51:12 +02:00
Juergen Fitschen
dc8fe69789 cpu/efm32: satisfy vera++ 2022-10-18 23:30:08 +02:00
Jue
68625e5aa9 cpu/efm32/gpio: block power modes if IRQs are enabled 2022-10-18 23:30:08 +02:00