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

22 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
fc907f9251
cpu/msp430/periph_gpio: resolve conflict with GPIO LL
In case both periph_gpio_irq and periph_gpio_ll_irq are used, the
periph_gpio_irq implementation now uses periph_gpio_ll_irq, so that
they can coexist.
2024-08-02 13:41:37 +02:00
Marian Buschsieweke
355f2335d5
cpu/msp430: implement gpio_ll_irq 2024-08-02 13:41:37 +02:00
Marian Buschsieweke
0ce7b8dfde
cpu/msp430: add periph_gpio_ll 2024-08-02 13:41:37 +02:00
Marian Buschsieweke
43f07fa261
cpu/msp430: implement power management
This implements `pm_set_lowest()` for the MSP430. Unlike most other
platforms, it intentionally does not use pm_layered. It is pretty
similar to `pm_layered` in that is does use reference counters, but it
uses them for two independent clock sources.

The main difference is that the low frequency clock domain can be
disabled even when the high frequency clock is still active. With the
layers, disabling layer n-1 while layer n is still blocked would not
work.
2024-04-26 15:52:41 +02:00
Marian Buschsieweke
4c0d6f8f7d
cpu/msp430/perriph_usci: fix prescaler values for ACLK
For super low symbol rates the auxiliary clock (ACLK) is used to
conserve power. But with only 32,678 Hz clock just prescaling will
result in poor bit timing, hence correct modulation control settings
to compensate are needed. Since computing this is too expensive, a
look-up table (as switch statement) for the four most common symbol
rates was used.

The datasheet gave the prescaler values ordered by ascending symbol
rate, the switch statement was ordered descending.
This changes the order to match the datasheets order and matches the
correct prescaler setting to the corresponding symbol rate.

Fixes https://github.com/RIOT-OS/RIOT/issues/20620
2024-04-25 22:39:45 +02:00
Teufelchen
5bc8ca5318
Merge pull request #18093 from Ollrogge/remove_flashpage_free_funcs
periph/flashpage: remove deprecated flashpage_*_free functions
2024-04-16 08:47:11 +00:00
Marian Buschsieweke
30c9204322
Merge pull request #20572 from maribu/cpu/msp430/uart_usci
cpu/msp430/periph_uart: Fix uart_write() for USCI peripheral
2024-04-15 13:52:45 +00:00
Marian Buschsieweke
f4baa0f2e1
cpu/msp430/periph_uart: Fix uart_write() for USCI peripheral
In TX-only mode the UART was previously release before all bits of the
last byte were shifted out. This adds a busy loop waiting while the
peripheral is still busy, fixing the issue.

Co-authored-by: benpicco <benpicco@googlemail.com>
2024-04-15 14:43:10 +02:00
Marian Buschsieweke
53edb4e981
Merge pull request #20571 from maribu/cpu/msp430/timer
cpu/msp430/periph_timer: add a static_assert() for clear mask
2024-04-15 10:21:52 +00:00
Marian Buschsieweke
5adf1f1a28
cpu/msp430/periph_timer: fix timer_query_freqs()
`timer_query_freqs()` should return 0 when index is out of range
according to the doc. This changes the code to live up to the
spec.
2024-04-14 20:20:36 +02:00
Marian Buschsieweke
49d59d166d
cpu/msp430/periph_timer: add a static_assert() for clear mask
The driver assumes that timer A and timer B have the same register
layout regarding all the features exposed by the driver. This is
backed by the MCU family datasheets for the MSP430 x1xx and the
MSP430 G2xx / F2xx MCUs (and likely more families).

The assert() is pretty limited in coverage, but more to document why
a "timer A clear" mask is used but still claiming the driver also
works for timer B. It just looks too much like a bug otherwise.
2024-04-14 16:01:58 +02:00
Ollrogge
4b8355e1d3 Revert "cpu/msp430_common: extend flashpage API"
This reverts commit 741943f021.
2024-04-04 17:57:19 +02:00
Marian Buschsieweke
4b3308cdef
Merge pull request #20357 from maribu/cpu/msp430/usci
cpu/msp430/f2xx: clean up periph_uart,periph_spi
2024-03-27 19:57:47 +00:00
Marian Buschsieweke
aef5b65244
cpu/msp430/f2xx: clean up periph_uart,periph_spi
This cleans up the USCI based UART and SPI implementations and allows
multiple instances of either interface to be configured by the
boards. In addition, it allows sharing the USCI peripherals to provide
multiple serial interfaces with the same hardware (round-robin).
2024-03-27 18:54:07 +01:00
MrKevinWeiss
7a68fb0d5e
*Kconfig*: Remove dep-only Kconfig files 2024-03-26 14:54:22 +01:00
Marian Buschsieweke
675dcc381c
cpu/msp430: rework MSP430 x1xx periph drivers
- Move common code for USART (shared SPI / UART peripheral) to its
  own file and allow sharing the USART peripheral to provide both
  UART and SPI in round-robin fashion.
- Configure both UART and SPI bus via a `struct` in the board's
  `periph_conf.h`
    - this allows allocating the two UARTs as needed by the use case
    - since both USARTs signals have a fixed connection to a single
      GPIO, most configuration is moved to the CPU
    - the board now only needs to decide which bus is provided by
      which USART

Note: Sharing an USART used as UART requires cooperation from the app:
- If the UART is used in TX-only mode (no RX callback), the driver
  will release the USART while not sending
- If the UART is used to also receive, the application needs to power
  the UART down while not expecting something to send. An
  `spi_acquire()` will be blocked while the UART is powered up.
2024-01-22 16:59:23 +01:00
Marian Buschsieweke
7044699388
cpu/msp430: improve periph_timer
- add support for multiple timers
- add support for selecting clock source in the board's `periph_conf.h`
- add support for the prescaler
- implement `periph_timer_query_freqs`
- add a second timer to all MSP430 boards
    - the first timer is fast ticking, high-power
    - the second is slow ticking, low-power
2023-12-10 09:11:23 +01:00
Marian Buschsieweke
dd88935f46
cpu/msp430: consistently use msp430 prefix in names
Previously sometimes `msp_` was used as prefix, sometimes `msp430_`.
This makes the naming consistent.
2023-12-06 17:10:11 +01:00
Marian Buschsieweke
45b353c6ef
cpu/msp430: make use of vendor header files
The MSP430 vendor files already provide macros containing register
constants and symbols (provided via linker scripts) containing addresses
of peripheral registers. So lets make use of that rather than
maintaining a long list of constants.
2023-07-04 20:21:05 +02:00
Marian Buschsieweke
ff7f8ae2f0
cpu/msp430: reorganize code
RIOT supports two distinct families of the MSP430: The [MSP430 x1xx]
MCU family and the [MSP430 F2xx/G2xx] MCU family. For both incompatible
MCU families the code was located in the msp430fxyz folder, resulting
in case of the UART driver in particularly bizarre code looking roughly
like this:

    #ifndef UART_USE_USCI
    /* implementation of x1xx peripheral ... */
    #else
    /* implementation of F2xx/G2xx peripheral ... */
    #endif
    /* zero shared code between both variants */

This splits the peripheral drivers for USCI and USART serial IP blocks
into separate files and relocates everything in cpu/msp430, similar to
how cpu/stm32 is organized.

[MSP430 x1xx]: https://www.ti.com/lit/ug/slau049f/slau049f.pdf
[MSP430 F2xx/G2xx]: https://www.ti.com/lit/ug/slau144k/slau144k.pdf
2023-06-19 17:14:57 +02:00