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

146 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
Francisco Molina
8c8ab47806 cpu/cc2538/rtt: fix rtt_set_counter 2022-01-18 16:39:04 +01:00
Gunar Schorcht
007e29ebb5 cpu/periph/i2c: update implementations to new I2C API
Make all `spi_acquire` implementations return `void` and add assertions to check for valid device identifier where missing.
2021-11-29 06:35:25 +01:00
Benjamin Valentin
97de8afaf6 cpu/cc2538: don't pollute global namespace with cc2538_rfcore.h
`cc2538_rfcore.h` contains enums with non-prefixed single-word constants.
Those cause ugly naming conflicts down the line.
Only include the file when needed, don't include it in `cpu_conf.h` which
gets pulled in everywhere.
2021-09-16 15:31:22 +02:00
Marian Buschsieweke
5964dea70c
cpu/cc2538/periph/spi: move assert to spi_acquire 2021-09-06 10:52:35 +02:00
Francisco
a1cbcc9ede
Merge pull request #15902 from maribu/spi-api-change-1
drivers/periph_spi: let spi_acquire return void
2021-09-02 08:50:56 +02:00
Marian Buschsieweke
f04b522601
cpu/periph_spi: update implementations to new API
Make all spi_acquire() implementations return `void` and add assertions to
check for valid parameters, where missing.
2021-09-01 21:38:40 +02:00
Jan Romann
4384795cb9
treewide: Remove excessive newlines 2021-08-13 19:50:38 +02:00
Francisco Molina
bc737a1f76
cpu/cc2538: add periph_uart_nonblocking
Add periph_uart_nonblocking. Since cc2538 has a transmit FIFO write
to the FIFO first and to a tsrb buffer only when the transmit FIFO
is full.

Rely on the FIFO TXIFLSEL condition to fill up FIFO as space becomes
available.
2020-12-11 09:36:16 +01:00
6e658868e0
cpu/cc2538: enable UART IRQ only if cb is not NULL 2020-11-28 10:30:33 +01:00
3c10425b4c
cc2538: Adapt to flashpage/flashpage_pagewise API 2020-11-11 23:16:38 +01:00
Francisco Molina
dcfc7f1158
cpu/cc2538: add flashpage & flashpage_raw 2020-11-06 18:00:17 +01:00
Marian Buschsieweke
125c892c03
drivers/periph/timer: Use uint32_t for frequency
For all currently supported platforms `unsigned long` is 32 bit in width. But
better use `uint32_t` to be safe.
2020-10-30 22:02:12 +01:00
Bas Stottelaar
22243aec7a cpu/*: realign ENABLE_DEBUG 2020-10-23 00:46:26 +02:00
Bas Stottelaar
ab6188cea3 cpu/*: add missing include of assert.h 2020-10-22 11:13:08 +02:00
Francisco Molina
eb8f747a34
cpu/cc2538: reset rtt on init 2020-10-02 12:49:06 +02:00
Benjamin Valentin
18fe16298c cpu/cc2538: add Watchdog implementation
The Watchdog on the CC2538 only supports 4 intervals (2ms, 16ms, 250ms & 1s).
Since the watchdog timer API specifies a `max_time`, the interval equal or
below that time is selected.

E.g. for `max_time=125ms` the 16ms interval would be selected.
This is outside the tolerance of the `tests/periph_wdt` test.

Co-authored-by: Thomas Geithner <thomas.geithner@dai-labor.de>
2020-08-30 11:46:39 +02:00
Francisco Molina
8ed8daa493
cpu/cc2538/timer: fix 32 bit timer reload value
The interval load value was only set to 0xffff regardless of the counter
mode used which mad the 32bit timer apparently stop after 0xffff (it
would never reach values >0xffff).

When a GPTM is configured to one of the 32-bit modes, TAILR appears as a
32-bit register (the upper 16-bits correspond to the contents of the
GPTM Timer B Interval Load (TBILR) register). In a 16-bit mode, the
upper 16 bits of this register read as 0s and have no effect on the
state of TBILR.

Thsi commit set the correct value for TAILR depending on the configured
timer mode.
2020-08-12 11:35:42 +02:00
Benjamin Valentin
a8d5f13ad9
cpu/cc2538: rtt: allow to set alarm and overflow cb independently
Previously the setting the alarm would overwrite the overflow callback
and vice versa.

Since we can only set one alarm in hardware, always set the alarm to the
closest event of the two.
2020-08-04 16:22:44 +02:00
Benjamin Valentin
852fd7f531
cpu/cc2538: rtt: implement rtt_get_alarm()
We can't read back the alarm, so just store it in a variable.
2020-08-04 16:21:19 +02:00
Benjamin Valentin
d7f722e98f
cpu/cc2538: rtt: implement rtt_set_counter()
We can't set the hardware counter directly, so always add an offset.
2020-08-04 16:21:17 +02:00
Benjamin Valentin
08b3e2bd6b cpu/cc2538: GPIO: use bitarithm_test_and_clear() 2020-07-28 12:44:23 +02:00
Francisco Molina
da171f2254
cpu/cc2538/uart: uart_write wait for all bytes to be sent
uart_write should block until all bytes are sent out, so wait for
transmit fifo to empty before returning.
2020-07-22 12:56:12 +02:00
Francisco Molina
dcd6b7f226
cpu/cc2538/timer: fix GPT enabling wait 2020-03-25 20:16:23 +01:00
benpicco
457c5245ce
Merge pull request #13507 from benpicco/cpu/cc2538-gpio-cycles
cpu/cc2538: gpio: save a few cycles in handle_isr()
2020-03-23 20:53:52 +01:00
Francisco Molina
0cc6a51ea8
cpu/cc2538/periph/timer: cleanup styling 2020-03-23 10:59:53 +01:00
Francisco Molina
7e913fe0d9
cpu/cc2538/periph/timer: set pending timer_set_absolute
GPT timer needs to be gated to write to TnMATCHR register. If set
when timer is stopped save values and set on next timer_start()
2020-03-23 10:59:30 +01:00
Francisco Molina
ce696c6caa
cpu/cc2538/timer: enable GPT clock in active, sleep and PM0 2020-03-23 10:58:56 +01:00
Benjamin Valentin
345827ce7b cpu/cc2538: gpio: save a few cycles in handle_isr()
If only one it is set in state (one GPIO pin caused an interrupt),
don't loop over all 8 bits.

Use clz to get the position of the first interrupt bit and clear it,
looping only as many times as there are actual interrupts.
2020-03-23 09:21:14 +01:00
Francisco Molina
9a2190cd24
cpu/cc2538/periph/pm: unset OSC_PD when running on 32Mhz
Setting OSC_PD before WFI allows for faster wakeup from sleep.

Wait for cc2538_sys_ctrl_clk_sta and not cc2538_sys_ctrl_clk_ctrl
to be set.
2020-03-21 19:32:24 +01:00
Francisco Molina
226e1b5daf
cpu/cc2538: fix GPT3 timer IRQ definition 2020-03-19 16:31:57 +01:00
Francisco
d77ecc1cde
Merge pull request #13598 from benpicco/cpu/cc2538-spi-fix
cpu/cc2538: fix spi_transfer_bytes()
2020-03-17 17:29:49 +01:00
benpicco
5d038a24bf
Merge pull request #13510 from benpicco/cpu/cc2538-pm
cpu/cc2538: implement periph/pm
2020-03-12 12:18:18 +01:00
Dylan Laduranty
077a15f254 cpu/cc2538: use generic hw fc module 2020-03-10 14:22:34 +01:00
Benjamin Valentin
5d8c00e302 cpu/cc2538: implement periph/pm
cc2538 implements 4 sleep modes.
In the lightest mode (3) any interrupt source can wake up the CPU.
In mode 2, only RTT, GPIO or USB may wake the CPU.
In mode 1 only RTT and GPIO can wake the CPU.
In mode 0 only GPIO can wake the CPU.

In mode 0 and 1 the lower 16k RAM are lost. This is a problem since those
are usually used by RIOT.

The linkerscripts in cc2538/ldscripts take different approaches towards that.
Some only use the upper 16k and leave the other half to be managed by the
application.

`cc2538sf53.ld` which is used by `openmote-b` uses the entire RAM starting
at the lower half, so it will not be able to wake up from those modes.

A quick fix to test those modes with `tests/periph_pm` would be

--- a/cpu/cc2538/ldscripts/cc2538sf53.ld
+++ b/cpu/cc2538/ldscripts/cc2538sf53.ld
@@ -21,7 +21,7 @@ MEMORY
 {
     rom (rx)    : ORIGIN = 0x00200000, LENGTH = 512K - 44
     cca         : ORIGIN = 0x0027ffd4, LENGTH = 44
-    ram (w!rx)  : ORIGIN = 0x20000000, LENGTH = 32K
+    ram (w!rx)  : ORIGIN = 0x20004000, LENGTH = 16K
 }
2020-03-10 10:35:46 +01:00
Benjamin Valentin
80392dc644 cpu/cc2538: spi: unify spi_transfer_bytes()
Use a common helper function to read/write the data register.
2020-03-09 16:37:07 +01:00
Benjamin Valentin
68b2c57d2d cpu/cc2538: spi: fix spi_transfer_bytes() with in_buf = NULL
We have to read the DR for every byte that we write.
Just reading DR while SPI is busy in a loop can lead to bytes being
left in the fifo, corrupting subsequent reads.
2020-03-09 16:22:37 +01:00
Gunar Schorcht
42db6861e1 cpu/cc2538: fix I2C compilation error with NDEBUG
When NDEBUG macro is defined during compilation, the assert macro produces empty code. The dev parameter is then unused.
2020-01-30 11:57:36 +01:00
Marian Buschsieweke
c4a84f01c0
cpu/cc2538/periph: adc_sample() now returns int32_t 2020-01-10 14:13:14 +01:00
Francisco Molina
1801f4f085 cpu/cc2538: add periph_rtt 2020-01-08 09:16:49 +01:00
b01c6707a5 cpu/cc2538: fix typos 2019-11-23 22:39:36 +01:00
Francois Berder
4a31f94cfc many typo fixes
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
2019-11-23 22:39:07 +01:00
Kevin "Tristate Tom" Weiss
5bbfe92c11
Merge pull request #12336 from benpicco/cc2538-spi_fix
cpu/cc2538: fix spi_transfer_bytes()
2019-10-02 10:52:16 +02:00
Gunar Schorcht
02d81b717e
Merge pull request #12063 from maribu/i2c_release
drivers/periph/i2c: Updated i2c_release() to return void
2019-10-01 19:50:38 +02:00
Benjamin Valentin
bf1eca338f cpu/cc2538: fix spi_transfer_bytes()
Always wait for RNE before reading DR.
Fixes always reading in the !out_buf case.
2019-09-30 13:11:11 +02:00
Sebastian Meiling
cabaaebff4 cpu/cc2538: adapt timer to return 0 on success
Adapt periph/timer implementation of cc2538 based MCUs
to return 0 on success for all functions.
2019-09-11 13:44:46 +02:00
Marian Buschsieweke
1a51b01db9
cpu/cc2538/periph/i2c: Made cppcheck happy 2019-08-27 13:59:23 +02:00
Marian Buschsieweke
6917934946
cpu/cc2538: Updated i2c_release() 2019-08-22 12:03:07 +02:00
MrKevinWeiss
0aa6b04249 cpu/cc2538: Add periph_uart_mode implementation
This commit adds the periph_uart_mode USEMODULE
It implements all functionality defined in the common uart driver
This means all parity modes, data bits, and stop bits
2019-05-15 09:26:56 +02:00