-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
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>
- Loading branch information
Showing
13 changed files
with
193 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (C) 2023 ML!PA Consulting GmbH | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @defgroup sys_ztimer_stopwatch ztimer stop watch | ||
* @ingroup sys_ztimer | ||
* @brief Measure time with ztimer | ||
* | ||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com> | ||
* @{ | ||
*/ | ||
#ifndef ZTIMER_STOPWATCH_H | ||
#define ZTIMER_STOPWATCH_H | ||
|
||
#include "ztimer.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief ztimer stop watch struct | ||
*/ | ||
typedef struct { | ||
ztimer_clock_t *clock; /**< the clock to use */ | ||
uint32_t start_time; /**< start of measurement */ | ||
} ztimer_stopwatch_t; | ||
|
||
/** | ||
* @brief Initialize a ztimer stop watch | ||
* The stop watch is not running yet. | ||
* | ||
* @param[in] clock The clock to use for the stopwatch | ||
* @param[out] timer The stop watch clock to initialize | ||
*/ | ||
static inline void ztimer_stopwatch_init(ztimer_clock_t *clock, ztimer_stopwatch_t *timer) | ||
{ | ||
timer->clock = clock; | ||
} | ||
|
||
/** | ||
* @brief Start the stop watch timer | ||
* | ||
* @param[in] timer The stop watch timer to start | ||
*/ | ||
static inline void ztimer_stopwatch_start(ztimer_stopwatch_t *timer) | ||
{ | ||
ztimer_acquire(timer->clock); | ||
timer->start_time = ztimer_now(timer->clock); | ||
} | ||
|
||
/** | ||
* @brief Take a measurement from the stop watch timer | ||
* | ||
* @param[in] timer The stop watch timer to take a measurement of | ||
* | ||
* @return Timer ticks since the stop watch was started / reset | ||
*/ | ||
static inline uint32_t ztimer_stopwatch_measure(ztimer_stopwatch_t *timer) | ||
{ | ||
return ztimer_now(timer->clock) - timer->start_time; | ||
} | ||
|
||
/** | ||
* @brief Reset the stop watch start time. | ||
* The Stop Watch will start counting from 0 again. | ||
* | ||
* @param[in] timer The stop watch timer to reset | ||
* | ||
* @return Timer ticks since the last reset / start of the watch | ||
*/ | ||
static inline uint32_t ztimer_stopwatch_reset(ztimer_stopwatch_t *timer) | ||
{ | ||
uint32_t now = ztimer_now(timer->clock); | ||
uint32_t diff = now - timer->start_time; | ||
|
||
timer->start_time = now; | ||
return diff; | ||
} | ||
|
||
/** | ||
* @brief Stop the stop watch. | ||
* The stop watch will no longer run. | ||
* | ||
* @param[in] timer The stop watch timer to stop | ||
*/ | ||
static inline void ztimer_stopwatch_stop(ztimer_stopwatch_t *timer) | ||
{ | ||
ztimer_release(timer->clock); | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* ZTIMER_STOPWATCH_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.