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

116 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
Michael Richardson
7140aef74e doc: note that timer_settime() comes from librt on some systems 2024-08-18 16:02:15 -04:00
Ollrogge
2f67249ae1 Revert "cpu/native: extend flashpage API"
This reverts commit cdd9f303cf.
2024-04-04 17:37:15 +02:00
Karl Fessel
3e2ab59f4d
Merge pull request #20431 from cogip/native_fixes
cpu/native: add gpio-mock
2024-03-28 22:07:10 +00:00
MrKevinWeiss
7a68fb0d5e
*Kconfig*: Remove dep-only Kconfig files 2024-03-26 14:54:22 +01:00
Gilles DOFFE
ebf95d2545 cpu/native: enhance GPIO mocking with 2D array representation
This commit introduces a more robust GPIO mocking mechanism by utilizing
a 2-dimensional array. Each element of the array holds a gpio_mock_t
structure describing a pin's attributes such as value, mode, flank,
interruption callback, and callback argument.

This enhancement allows for the arbitrary simulation of GPIOs across
various microcontroller architectures using the current API, while
maintaining consistency through the use of the GPIO_PIN macro.

Additionally, it should be noted that only the maximum number of ports
and maximum number of pins can be altered according to the context.

The implemented API in gpio_mock.c remains rudimentary, providing no
validation but fulfilling the required functions. However, it remains
customizable as all its functions are marked as weak.

Signed-off-by: Gilles DOFFE <g.doffe@gmail.com>
2024-03-24 23:12:24 +01:00
Gilles DOFFE
24d9657b40 cpu/native: mark gpio_mock function as weak
This allows developpers to override gpio behavior into their
applications.

Signed-off-by: Gilles DOFFE <g.doffe@gmail.com>
2024-03-15 20:27:11 +01:00
Gilles DOFFE
5b4c8fe92d cpu/native: return 0 for all gpio_init*() calls
If the gpio is initialized as an input or interruptable pin, the
gpio_mock driver returns -1 leading to failed initialization.
However that is not because nothing can change the GPIO state that it
has to be an error.
Return 0 in all cases.

Signed-off-by: Gilles DOFFE <g.doffe@gmail.com>
2024-03-15 20:27:11 +01:00
Gilles DOFFE
3bfabb4a6c cpu/native/periph/qdec: remove useless loop
Signed-off-by: Gilles DOFFE <g.doffe@gmail.com>
2024-03-15 20:27:11 +01:00
Benjamin Valentin
9e9a906f4d cpu/native: return error code on failed assertion 2024-02-22 16:06:32 +01:00
Mihai Renea
fc3d0d8676 cpu/native: fix native_async_read_remove_handler() + enable all baudrates 2024-02-10 15:46:00 +01:00
Mihai Renea
795415d59e cpu/native/periph/uart: uart_poweroff() closes the file descriptor 2024-02-09 12:55:40 +01:00
benpicco
5bd879b406
Merge pull request #20315 from fzi-haxel/native-x86-64-support
native: Linux/x86_64 support
2024-02-01 17:11:56 +00:00
Armin Wolf
d8dc6d3963 cpu/native: timer: Delete POSIX timer upon error
If `register_interrupt` somehow fails, we leak the already created
POSIX timer by returning immediately.

Fix this by calling `timer_delete` before returning.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-01-30 22:28:13 +01:00
Armin Wolf
eac719166b cpu/native: timer: Stop using err
When using `err`, no stacktrace is generated and the standard panic
functionallity of RIOT is sidestepped.

Use `core_panic` instead.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-01-30 22:28:13 +01:00
Armin Wolf
acbe7a8af3 cpu/native: timer: Remove unnecessary uses of (void)
In `timer_init`, `freq` is being check so its not unused.
In `timer_set_periodic`, `flags` is being used too.

Remove the uses of `(void)` in both cases.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-01-30 22:11:14 +01:00
Frederik Haxel
16eff9b6ed native: Linux/x86_64 support
Initial version to test 64 bit compatibility.

Instead of a separate board, the inital version for Linux/x86_64 is enabled
by setting the environment variable `NATIVE_64BIT=y` and compiling as usual.

Not currently implemented:
* Architectures other than x86_64 or operating systems other than Linux
    * No FreeBSD support
    * No Aarch support
* Rust support for x86_64
2024-01-30 16:33:19 +01:00
Armin Wolf
6070c57e21 cpu/native: Add support for periph_timer_query_freqs
Add support for querying the frequency supported by
`periph_timer`. This allows applications which require
this feature to run on the `native` board.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
2024-01-30 02:01:50 +01:00
Marian Buschsieweke
cea7fcec2f
cpu/native: fix bug in periph_timer
Also use `CLOCK_MONOTONIC` for the timeouts, not just for
`timer_read()`. This fixes mismatches between when a timeout
occurs and what is expected in the context of the values returned by
`timer_read()`.
2023-11-02 14:12:54 +01:00
Marian Buschsieweke
51127f674a
drivers/periph/rtc: improve doc on rtc_set_alarm
- point out behavior on denormalized time stamps
- use errno codes to indicate errors (and adapt the few instances of
  actual error handling to use them)
2023-05-30 17:41:36 +02:00
Benjamin Valentin
6fe5d85e11 cpu/native: unmount fs on exit 2023-04-26 00:53:14 +02:00
Teufelchen1
10cada1b8d native/syscalls: rename real_clock_gettime to clock_gettime 2023-04-17 15:21:52 +02:00
bors[bot]
fae992e82b
Merge #19343 #19349 #19353 #19361 #19363
19343: ztimer: add ztimer_stopwatch convenience functions r=benpicco a=benpicco



19349: cpu/native: Switch to ztimer for gettimeofday r=benpicco a=MrKevinWeiss

### Contribution description

A xtimer is somewhat taken over by ztimer this explicitly uses ztimer instead of relying on the compatibility layer.

### Testing procedure

`make all test -C tests/cpp11_mutex/`

and green murdock I guess.

### Issues/PRs references


19353: doc: add quicklink to boards in navbar r=benpicco a=OlegHahm

### Contribution description

Finding a list of supported boards and how to use them is an essential information. Currently this list is somewhat hidden under "Modules" which is not very intuitive. Hence, I propose to (at least) put a link in the side menu to this overview page.

### Testing procedure

1. Call `make doc`
2. Check the sidebar `${RIOT_BASE}/doc/doxygen/html/index.html` for an entry "Supported Boards"

19361: nanocoap_sock: ensure response address is the same as request address r=benpicco a=benpicco



19363: Fix stm32 timer periodic r=benpicco a=Enoch247

### Contribution description

From the commit msg:

>     cpu/stm32/periph/timer: remove unneeded header
>     
>     I see no reason this header should be included. It does not exist in
>     RIOT's source tree. This patch removes the include.

and 

>     cpu/stm32/periph/timer: fix execution flow
>     
>     The implmentation of `timer_set_absolute()` has The following problems.
>     First, it attempts to restore the auto reload register (ARR) to it's
>     default if the ARR was previosly set by `timer_set_periodic()` by
>     comparing it to the channel's capture compare (CC) register _after_ it
>     has already set the CC register. Secondly, it clears spurious IRQs
>     _after_ the CC register has been set. If the value being set is equal to
>     the timer's current count (or the two become equal before the supurios
>     IRQ clearing happens), this could cause a legitimate IRQ to be cleared.
>     
>     The implmentation of `timer_set()` has the same error in handling the
>     ARR as described above.
>     
>     This patch reorders the operations of both functions to do:
>     
>     1. handle ARR
>     2. clear spurious IRQs
>     3. set channel's CC
>     4. enable IRQ
>     
>     Additionally, the calulation of `value` in `timer_set()` is moved
>     earlier in the function's exec path as a pedantic measure.


### Testing procedure

I tested by doing the following:

1. `make -C tests/periph_timer BOARD=nucleo-f767zi all flash term`
2. press s
3. press [ENTER]
4. observe test passes
5. `make -C tests/periph_timer_periodic BOARD=nucleo-f767zi all flash term`
6. press s
7. press [ENTER]
8. observe test passes
9. `make -C tests/periph_timer_short_relative_set BOARD=nucleo-f767zi all flash term`
10. press s
11. press [ENTER]
12. observe test passes


### Issues/PRs references

- none known


Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de>
Co-authored-by: MrKevinWeiss <weiss.kevin604@gmail.com>
Co-authored-by: Oleg Hahm <oleg@hobbykeller.org>
Co-authored-by: Benjamin Valentin <benjamin.valentin@bht-berlin.de>
Co-authored-by: Joshua DeWeese <jdeweese@primecontrols.com>
2023-03-08 02:09:42 +00:00
MrKevinWeiss
66570cb0fb
cpu/native: Use ztimer instead of xtimer 2023-03-07 13:08:58 +01:00
Benjamin Valentin
ce36460b16 cpu/native: implement periph_rtc_ms 2023-03-05 02:56:28 +01:00
Teufelchen1
c9e9a8d2f1 native: Remove code used for __MACH__ target 2022-12-22 17:57:25 +01:00
Teufelchen1
35a06c4806 boards/native: Remove macOS as native target 2022-10-25 19:11:23 +02:00
Teufelchen1
1231807bab Documentation: Renaming OS X to macOS 2022-06-23 17:25:48 +02:00
Benjamin Valentin
4326b5ca54 cpu/native: timer: implement TIM_FLAG_SET_STOPPED 2022-04-28 13:27:59 +02:00
326b0c980a
cpu/native: migrate periph_rtc to ztimer 2021-11-11 10:54:30 +01:00
Ollrogge
cdd9f303cf cpu/native: extend flashpage API 2021-10-25 15:07:37 +02:00
Hugues Larrive
f292cfc8ce drivers/periph_spi: remove duplicated includes introduced in #15902 2021-09-02 09:40:31 +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
Karl Fessel
15f2d0008a native/rtc: ensure no struct tm extra information is used 2021-04-01 18:19:15 +02:00
Karl Fessel
72213ec99a native/rtc: avoid dealing with DST 2021-04-01 18:19:15 +02:00
Francisco
c91499997e
Merge pull request #16030 from benpicco/drivers/mtd_flashpage-fix_native
drivers/mtd_flashpage: fixes for native (and stm32l0, stm32l4)
2021-02-23 15:12:06 +01:00
Benjamin Valentin
65093a47a3 cpu/native: timer: fix style issue 2021-02-23 09:52:05 +01:00
Benjamin Valentin
7eb159c2a2 cpu/native: timer: implement timer_set_periodic()
The native timer is not free running, so we can't honor it's flags.
But setitimer() already provides an interval option, we only have to enable it.
2021-02-23 09:51:53 +01:00
Benjamin Valentin
033c0110d0 cpu/native: flashpage: sector-slign the flashpage area 2021-02-18 14:22:11 +01:00
Benjamin Valentin
1acbd6e560 cpu/native: add periph/flashpage implementation
Add a simple RAM-backed flashpage implementation for native, to
allow for easier testing of flashpage based applications / features.
2021-02-05 23:31:46 +01:00
Daniel Lockau
33afc0ddab cpu/native/rtc: add rtc_set_time implementation 2020-12-15 12:52:35 +01:00
Benjamin Valentin
d7ed3418b5 cpu/native: pm: fix build with pm_layered 2020-12-08 18:24:02 +01:00
Leandro Lanzieri
43cc7beb26
cpu/native: add periph_spidev module to Kconfig 2020-11-18 10:08:01 +01:00
Leandro Lanzieri
2306516d0d
drivers/periph_common: add CPU specific RTC Kconfig 2020-11-18 10:08:00 +01:00
Leandro Lanzieri
8715f19c26
cpu/native/periph: add Native GPIO modules to Kconfig 2020-11-18 10:07:59 +01:00
Leandro Lanzieri
d4be753df8
cpu/native: remove unused can_linux module
b4f29035ce adapted the can_linux module to
the periph_can interface. This is a cleanup of some things that stayed
behind. Here the makefile is removed, the references to can_linux in the
dependency resolution and configuration Makefile are changed to the
standard periph_can, and the startup code is adapted.
2020-11-13 09:11:50 +01:00
Bas Stottelaar
94171b7389 cpu/*: replace #if ENABLE_DEBUG with IS_ACTIVE 2020-11-02 21:34:12 +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