Merge pull request #15802 from miri64/treewide/cleanup/cppcheck-whitelisted
treewide: re-uncrustify whitelisted files
This commit is contained in:
commit
6da60c933d
@ -281,6 +281,7 @@ void __atomic_load_c(size_t size, const void *src, void *dest, int memorder)
|
|||||||
{
|
{
|
||||||
(void)memorder;
|
(void)memorder;
|
||||||
unsigned int mask = irq_disable();
|
unsigned int mask = irq_disable();
|
||||||
|
|
||||||
memcpy(dest, src, size);
|
memcpy(dest, src, size);
|
||||||
irq_restore(mask);
|
irq_restore(mask);
|
||||||
}
|
}
|
||||||
@ -297,6 +298,7 @@ void __atomic_store_c(size_t size, void *dest, const void *src, int memorder)
|
|||||||
{
|
{
|
||||||
(void)memorder;
|
(void)memorder;
|
||||||
unsigned int mask = irq_disable();
|
unsigned int mask = irq_disable();
|
||||||
|
|
||||||
memcpy(dest, src, size);
|
memcpy(dest, src, size);
|
||||||
irq_restore(mask);
|
irq_restore(mask);
|
||||||
}
|
}
|
||||||
@ -315,6 +317,7 @@ void __atomic_exchange_c(size_t size, void *ptr, void *val, void *ret,
|
|||||||
{
|
{
|
||||||
(void)memorder;
|
(void)memorder;
|
||||||
unsigned int mask = irq_disable();
|
unsigned int mask = irq_disable();
|
||||||
|
|
||||||
memcpy(ret, ptr, size);
|
memcpy(ret, ptr, size);
|
||||||
memcpy(ptr, val, size);
|
memcpy(ptr, val, size);
|
||||||
irq_restore(mask);
|
irq_restore(mask);
|
||||||
@ -361,6 +364,7 @@ bool __atomic_compare_exchange_c(size_t len, void *ptr, void *expected,
|
|||||||
(void)failure_memorder;
|
(void)failure_memorder;
|
||||||
unsigned int mask = irq_disable();
|
unsigned int mask = irq_disable();
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
if (memcmp(ptr, expected, len) == 0) {
|
if (memcmp(ptr, expected, len) == 0) {
|
||||||
memcpy(ptr, desired, len);
|
memcpy(ptr, desired, len);
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|||||||
@ -61,6 +61,7 @@ static inline void cib_init(cib_t *__restrict cib, unsigned int size)
|
|||||||
assert(!(size & (size - 1)));
|
assert(!(size & (size - 1)));
|
||||||
|
|
||||||
cib_t c = CIB_INIT(size);
|
cib_t c = CIB_INIT(size);
|
||||||
|
|
||||||
*cib = c;
|
*cib = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#define MACROS_UNITS_H
|
#define MACROS_UNITS_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -101,7 +101,8 @@ static inline uint16_t msg_bus_get_type(const msg_t *msg)
|
|||||||
{
|
{
|
||||||
if (msg->sender_pid & MSB_BUS_PID_FLAG) {
|
if (msg->sender_pid & MSB_BUS_PID_FLAG) {
|
||||||
return msg->type & 0x1F;
|
return msg->type & 0x1F;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return msg->type;
|
return msg->type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,8 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#ifndef CONFIG_BOOT_MSG_STRING
|
#ifndef CONFIG_BOOT_MSG_STRING
|
||||||
#define CONFIG_BOOT_MSG_STRING "main(): This is RIOT! (Version: " RIOT_VERSION ")"
|
#define CONFIG_BOOT_MSG_STRING "main(): This is RIOT! (Version: " \
|
||||||
|
RIOT_VERSION ")"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int main(void);
|
extern int main(void);
|
||||||
@ -73,7 +74,6 @@ static void *idle_thread(void *arg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void kernel_init(void)
|
void kernel_init(void)
|
||||||
{
|
{
|
||||||
irq_disable();
|
irq_disable();
|
||||||
|
|||||||
@ -36,6 +36,7 @@ static void _wake_waiter(thread_t *thread, unsigned irqstate)
|
|||||||
"%" PRIkernel_pid ".\n", thread_getpid(), thread->pid);
|
"%" PRIkernel_pid ".\n", thread_getpid(), thread->pid);
|
||||||
|
|
||||||
uint16_t process_priority = thread->priority;
|
uint16_t process_priority = thread->priority;
|
||||||
|
|
||||||
irq_restore(irqstate);
|
irq_restore(irqstate);
|
||||||
sched_switch(process_priority);
|
sched_switch(process_priority);
|
||||||
}
|
}
|
||||||
@ -46,6 +47,7 @@ static void _wait(list_node_t *wait_list, unsigned irqstate)
|
|||||||
thread_getpid());
|
thread_getpid());
|
||||||
|
|
||||||
thread_t *me = thread_get_active();
|
thread_t *me = thread_get_active();
|
||||||
|
|
||||||
sched_set_status(me, STATUS_MBOX_BLOCKED);
|
sched_set_status(me, STATUS_MBOX_BLOCKED);
|
||||||
thread_add_to_list(wait_list, me);
|
thread_add_to_list(wait_list, me);
|
||||||
irq_restore(irqstate);
|
irq_restore(irqstate);
|
||||||
|
|||||||
@ -52,6 +52,7 @@ static int queue_msg(thread_t *target, const msg_t *m)
|
|||||||
|
|
||||||
DEBUG("queue_msg(): queuing message\n");
|
DEBUG("queue_msg(): queuing message\n");
|
||||||
msg_t *dest = &target->msg_array[n];
|
msg_t *dest = &target->msg_array[n];
|
||||||
|
|
||||||
*dest = *m;
|
*dest = *m;
|
||||||
#if MODULE_CORE_THREAD_FLAGS
|
#if MODULE_CORE_THREAD_FLAGS
|
||||||
target->flags |= THREAD_FLAG_MSG_WAITING;
|
target->flags |= THREAD_FLAG_MSG_WAITING;
|
||||||
@ -242,7 +243,7 @@ int msg_send_bus(msg_t *m, msg_bus_t *bus)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
m->sender_pid = (in_irq ? KERNEL_PID_ISR : thread_getpid())
|
m->sender_pid = (in_irq ? KERNEL_PID_ISR : thread_getpid())
|
||||||
| MSB_BUS_PID_FLAG;
|
| MSB_BUS_PID_FLAG;
|
||||||
|
|
||||||
unsigned state = irq_disable();
|
unsigned state = irq_disable();
|
||||||
|
|
||||||
@ -272,6 +273,7 @@ int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid)
|
|||||||
assert(thread_getpid() != target_pid);
|
assert(thread_getpid() != target_pid);
|
||||||
unsigned state = irq_disable();
|
unsigned state = irq_disable();
|
||||||
thread_t *me = thread_get_active();
|
thread_t *me = thread_get_active();
|
||||||
|
|
||||||
sched_set_status(me, STATUS_REPLY_BLOCKED);
|
sched_set_status(me, STATUS_REPLY_BLOCKED);
|
||||||
me->wait_data = reply;
|
me->wait_data = reply;
|
||||||
|
|
||||||
@ -302,9 +304,11 @@ int msg_reply(msg_t *m, msg_t *reply)
|
|||||||
thread_getpid());
|
thread_getpid());
|
||||||
/* copy msg to target */
|
/* copy msg to target */
|
||||||
msg_t *target_message = (msg_t *)target->wait_data;
|
msg_t *target_message = (msg_t *)target->wait_data;
|
||||||
|
|
||||||
*target_message = *reply;
|
*target_message = *reply;
|
||||||
sched_set_status(target, STATUS_PENDING);
|
sched_set_status(target, STATUS_PENDING);
|
||||||
uint16_t target_prio = target->priority;
|
uint16_t target_prio = target->priority;
|
||||||
|
|
||||||
irq_restore(state);
|
irq_restore(state);
|
||||||
sched_switch(target_prio);
|
sched_switch(target_prio);
|
||||||
|
|
||||||
@ -323,6 +327,7 @@ int msg_reply_int(msg_t *m, msg_t *reply)
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg_t *target_message = (msg_t *)target->wait_data;
|
msg_t *target_message = (msg_t *)target->wait_data;
|
||||||
|
|
||||||
*target_message = *reply;
|
*target_message = *reply;
|
||||||
sched_set_status(target, STATUS_PENDING);
|
sched_set_status(target, STATUS_PENDING);
|
||||||
sched_context_switch_request = 1;
|
sched_context_switch_request = 1;
|
||||||
@ -394,7 +399,7 @@ static int _msg_receive(msg_t *m, int block)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG("_msg_receive: %" PRIkernel_pid ": _msg_receive(): Waking up "
|
DEBUG("_msg_receive: %" PRIkernel_pid ": _msg_receive(): Waking up "
|
||||||
"waiting thread.\n", thread_getpid());
|
"waiting thread.\n", thread_getpid());
|
||||||
|
|
||||||
thread_t *sender =
|
thread_t *sender =
|
||||||
container_of((clist_node_t *)next, thread_t, rq_entry);
|
container_of((clist_node_t *)next, thread_t, rq_entry);
|
||||||
|
|||||||
14
core/mutex.c
14
core/mutex.c
@ -45,9 +45,11 @@
|
|||||||
* function into both @ref mutex_lock and @ref mutex_lock_cancelable is,
|
* function into both @ref mutex_lock and @ref mutex_lock_cancelable is,
|
||||||
* therefore, beneficial for the majority of applications.
|
* therefore, beneficial for the majority of applications.
|
||||||
*/
|
*/
|
||||||
static inline __attribute__((always_inline)) void _block(mutex_t *mutex, unsigned irq_state)
|
static inline __attribute__((always_inline)) void _block(mutex_t *mutex,
|
||||||
|
unsigned irq_state)
|
||||||
{
|
{
|
||||||
thread_t *me = thread_get_active();
|
thread_t *me = thread_get_active();
|
||||||
|
|
||||||
DEBUG("PID[%" PRIkernel_pid "] mutex_lock() Adding node to mutex queue: "
|
DEBUG("PID[%" PRIkernel_pid "] mutex_lock() Adding node to mutex queue: "
|
||||||
"prio: %" PRIu32 "\n", thread_getpid(), (uint32_t)me->priority);
|
"prio: %" PRIu32 "\n", thread_getpid(), (uint32_t)me->priority);
|
||||||
sched_set_status(me, STATUS_MUTEX_BLOCKED);
|
sched_set_status(me, STATUS_MUTEX_BLOCKED);
|
||||||
@ -97,6 +99,7 @@ int mutex_lock_cancelable(mutex_cancel_t *mc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mutex_t *mutex = mc->mutex;
|
mutex_t *mutex = mc->mutex;
|
||||||
|
|
||||||
if (mutex->queue.next == NULL) {
|
if (mutex->queue.next == NULL) {
|
||||||
/* mutex is unlocked. */
|
/* mutex is unlocked. */
|
||||||
mutex->queue.next = MUTEX_LOCKED;
|
mutex->queue.next = MUTEX_LOCKED;
|
||||||
@ -111,7 +114,7 @@ int mutex_lock_cancelable(mutex_cancel_t *mc)
|
|||||||
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable() "
|
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable() "
|
||||||
"cancelled.\n", thread_getpid());
|
"cancelled.\n", thread_getpid());
|
||||||
}
|
}
|
||||||
return (mc->cancelled) ? -ECANCELED: 0;
|
return (mc->cancelled) ? -ECANCELED : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,6 +151,7 @@ void mutex_unlock(mutex_t *mutex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t process_priority = process->priority;
|
uint16_t process_priority = process->priority;
|
||||||
|
|
||||||
irq_restore(irqstate);
|
irq_restore(irqstate);
|
||||||
sched_switch(process_priority);
|
sched_switch(process_priority);
|
||||||
}
|
}
|
||||||
@ -185,10 +189,12 @@ void mutex_unlock_and_sleep(mutex_t *mutex)
|
|||||||
void mutex_cancel(mutex_cancel_t *mc)
|
void mutex_cancel(mutex_cancel_t *mc)
|
||||||
{
|
{
|
||||||
unsigned irq_state = irq_disable();
|
unsigned irq_state = irq_disable();
|
||||||
|
|
||||||
mc->cancelled = 1;
|
mc->cancelled = 1;
|
||||||
|
|
||||||
mutex_t *mutex = mc->mutex;
|
mutex_t *mutex = mc->mutex;
|
||||||
thread_t *thread = mc->thread;
|
thread_t *thread = mc->thread;
|
||||||
|
|
||||||
if (thread_is_active(thread)) {
|
if (thread_is_active(thread)) {
|
||||||
/* thread is still running or about to run, so it will check
|
/* thread is still running or about to run, so it will check
|
||||||
* `mc-cancelled` in time */
|
* `mc-cancelled` in time */
|
||||||
@ -197,8 +203,8 @@ void mutex_cancel(mutex_cancel_t *mc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((mutex->queue.next != MUTEX_LOCKED)
|
if ((mutex->queue.next != MUTEX_LOCKED)
|
||||||
&& (mutex->queue.next != NULL)
|
&& (mutex->queue.next != NULL)
|
||||||
&& list_remove(&mutex->queue, (list_node_t *)&thread->rq_entry)) {
|
&& list_remove(&mutex->queue, (list_node_t *)&thread->rq_entry)) {
|
||||||
/* Thread was queued and removed from list, wake it up */
|
/* Thread was queued and removed from list, wake it up */
|
||||||
if (mutex->queue.next == NULL) {
|
if (mutex->queue.next == NULL) {
|
||||||
mutex->queue.next = MUTEX_LOCKED;
|
mutex->queue.next = MUTEX_LOCKED;
|
||||||
|
|||||||
@ -48,8 +48,10 @@ const char assert_crash_message[] = "FAILED ASSERTION.";
|
|||||||
/* flag preventing "recursive crash printing loop" */
|
/* flag preventing "recursive crash printing loop" */
|
||||||
static int crashed = 0;
|
static int crashed = 0;
|
||||||
|
|
||||||
void __attribute__((weak)) panic_arch(void) {}
|
void __attribute__((weak)) panic_arch(void)
|
||||||
void __attribute__((weak)) panic_app(core_panic_t crash_code, const char *message)
|
{}
|
||||||
|
void __attribute__((weak)) panic_app(core_panic_t crash_code,
|
||||||
|
const char *message)
|
||||||
{
|
{
|
||||||
(void)crash_code;
|
(void)crash_code;
|
||||||
(void)message;
|
(void)message;
|
||||||
|
|||||||
@ -102,6 +102,7 @@ void thread_sleep(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned state = irq_disable();
|
unsigned state = irq_disable();
|
||||||
|
|
||||||
sched_set_status(thread_get_active(), STATUS_SLEEPING);
|
sched_set_status(thread_get_active(), STATUS_SLEEPING);
|
||||||
irq_restore(state);
|
irq_restore(state);
|
||||||
thread_yield_higher();
|
thread_yield_higher();
|
||||||
@ -183,6 +184,7 @@ uintptr_t thread_measure_stack_free(const char *stack)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t space_free = (uintptr_t)stackp - (uintptr_t)stack;
|
uintptr_t space_free = (uintptr_t)stackp - (uintptr_t)stack;
|
||||||
|
|
||||||
return space_free;
|
return space_free;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -199,7 +201,7 @@ kernel_pid_t thread_create(char *stack, int stacksize, uint8_t priority,
|
|||||||
int total_stacksize = stacksize;
|
int total_stacksize = stacksize;
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_THREAD_NAMES
|
#ifndef CONFIG_THREAD_NAMES
|
||||||
(void) name;
|
(void)name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* align the stack on a 16/32bit boundary */
|
/* align the stack on a 16/32bit boundary */
|
||||||
@ -342,7 +344,7 @@ const char *thread_state_to_string(thread_status_t state)
|
|||||||
const char *name = state_names[state] ? state_names[state] : NULL;
|
const char *name = state_names[state] ? state_names[state] : NULL;
|
||||||
|
|
||||||
assert(name != NULL); /* if compiling with assertions, this is an error that
|
assert(name != NULL); /* if compiling with assertions, this is an error that
|
||||||
indicates that the table above is incomplete */
|
indicates that the table above is incomplete */
|
||||||
|
|
||||||
return (name != NULL) ? name : STATE_NAME_UNKNOWN;
|
return (name != NULL) ? name : STATE_NAME_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "thread_flags.h"
|
#include "thread_flags.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
@ -26,7 +25,8 @@
|
|||||||
#define ENABLE_DEBUG 0
|
#define ENABLE_DEBUG 0
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
static inline int __attribute__((always_inline)) _thread_flags_wake(thread_t *thread)
|
static inline int __attribute__((always_inline)) _thread_flags_wake(
|
||||||
|
thread_t *thread)
|
||||||
{
|
{
|
||||||
unsigned wakeup;
|
unsigned wakeup;
|
||||||
thread_flags_t mask = (uint16_t)(unsigned)thread->wait_data;
|
thread_flags_t mask = (uint16_t)(unsigned)thread->wait_data;
|
||||||
@ -118,6 +118,7 @@ thread_flags_t thread_flags_wait_one(thread_flags_t mask)
|
|||||||
_thread_flags_wait_any(mask);
|
_thread_flags_wait_any(mask);
|
||||||
thread_t *me = thread_get_active();
|
thread_t *me = thread_get_active();
|
||||||
thread_flags_t tmp = me->flags & mask;
|
thread_flags_t tmp = me->flags & mask;
|
||||||
|
|
||||||
/* clear all but least significant bit */
|
/* clear all but least significant bit */
|
||||||
tmp &= (~tmp + 1);
|
tmp &= (~tmp + 1);
|
||||||
return _thread_flags_clear_atomic(me, tmp);
|
return _thread_flags_clear_atomic(me, tmp);
|
||||||
@ -146,6 +147,7 @@ void thread_flags_set(thread_t *thread, thread_flags_t mask)
|
|||||||
DEBUG("thread_flags_set(): setting 0x%08x for pid %" PRIkernel_pid "\n",
|
DEBUG("thread_flags_set(): setting 0x%08x for pid %" PRIkernel_pid "\n",
|
||||||
mask, thread->pid);
|
mask, thread->pid);
|
||||||
unsigned state = irq_disable();
|
unsigned state = irq_disable();
|
||||||
|
|
||||||
thread->flags |= mask;
|
thread->flags |= mask;
|
||||||
if (_thread_flags_wake(thread)) {
|
if (_thread_flags_wake(thread)) {
|
||||||
irq_restore(state);
|
irq_restore(state);
|
||||||
|
|||||||
1
dist/tools/uncrustify/blacklist.txt
vendored
1
dist/tools/uncrustify/blacklist.txt
vendored
@ -0,0 +1 @@
|
|||||||
|
cpu/fe310/include/atomic_utils_arch.h
|
||||||
3
dist/tools/uncrustify/whitelist.txt
vendored
3
dist/tools/uncrustify/whitelist.txt
vendored
@ -4,5 +4,4 @@ cpu/fe310/.*\.c
|
|||||||
cpu/fe310/include/.*\.h
|
cpu/fe310/include/.*\.h
|
||||||
cpu/fe310/periph/.*\.c
|
cpu/fe310/periph/.*\.c
|
||||||
sys/ztimer/.*\.c
|
sys/ztimer/.*\.c
|
||||||
sys/ztimer.h
|
sys/include/ztimer.*\.h
|
||||||
sys/include/ztimer/.*\.h
|
|
||||||
|
|||||||
@ -412,7 +412,7 @@ void ztimer_set_msg(ztimer_clock_t *clock, ztimer_t *timer, uint32_t offset,
|
|||||||
int ztimer_msg_receive_timeout(ztimer_clock_t *clock, msg_t *msg,
|
int ztimer_msg_receive_timeout(ztimer_clock_t *clock, msg_t *msg,
|
||||||
uint32_t timeout);
|
uint32_t timeout);
|
||||||
|
|
||||||
/* created with dist/tools/define2u16.py */
|
/* created with dist/tools/define2u16.py */
|
||||||
#define MSG_ZTIMER 0xc83e /**< msg type used by ztimer_msg_receive_timeout */
|
#define MSG_ZTIMER 0xc83e /**< msg type used by ztimer_msg_receive_timeout */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -485,7 +485,8 @@ void ztimer_sleep(ztimer_clock_t *clock, uint32_t duration);
|
|||||||
* @param[in] clock ztimer clock to use
|
* @param[in] clock ztimer clock to use
|
||||||
* @param[in] duration duration to spin, in @p clock time units
|
* @param[in] duration duration to spin, in @p clock time units
|
||||||
*/
|
*/
|
||||||
static inline void ztimer_spin(ztimer_clock_t *clock, uint32_t duration) {
|
static inline void ztimer_spin(ztimer_clock_t *clock, uint32_t duration)
|
||||||
|
{
|
||||||
uint32_t end = ztimer_now(clock) + duration;
|
uint32_t end = ztimer_now(clock) + duration;
|
||||||
|
|
||||||
/* Rely on integer overflow. `end - now` will be smaller than `duration`,
|
/* Rely on integer overflow. `end - now` will be smaller than `duration`,
|
||||||
|
|||||||
@ -87,7 +87,8 @@ static inline uint64_t xtimer_now_usec64(void)
|
|||||||
return ztimer_now(ZTIMER_USEC);
|
return ztimer_now(ZTIMER_USEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _ztimer_sleep_scale(ztimer_clock_t *clock, uint32_t time, uint32_t scale)
|
static inline void _ztimer_sleep_scale(ztimer_clock_t *clock, uint32_t time,
|
||||||
|
uint32_t scale)
|
||||||
{
|
{
|
||||||
const uint32_t max_sleep = UINT32_MAX / scale;
|
const uint32_t max_sleep = UINT32_MAX / scale;
|
||||||
|
|
||||||
@ -104,7 +105,8 @@ static inline void xtimer_sleep(uint32_t seconds)
|
|||||||
/* TODO: use ZTIMER_SEC */
|
/* TODO: use ZTIMER_SEC */
|
||||||
if (IS_ACTIVE(MODULE_ZTIMER_MSEC)) {
|
if (IS_ACTIVE(MODULE_ZTIMER_MSEC)) {
|
||||||
_ztimer_sleep_scale(ZTIMER_MSEC, seconds, 1000);
|
_ztimer_sleep_scale(ZTIMER_MSEC, seconds, 1000);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
_ztimer_sleep_scale(ZTIMER_USEC, seconds, 1000000);
|
_ztimer_sleep_scale(ZTIMER_USEC, seconds, 1000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,7 +115,8 @@ static inline void xtimer_msleep(uint32_t milliseconds)
|
|||||||
{
|
{
|
||||||
if (IS_ACTIVE(MODULE_ZTIMER_MSEC)) {
|
if (IS_ACTIVE(MODULE_ZTIMER_MSEC)) {
|
||||||
ztimer_sleep(ZTIMER_MSEC, milliseconds);
|
ztimer_sleep(ZTIMER_MSEC, milliseconds);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
_ztimer_sleep_scale(ZTIMER_USEC, milliseconds, 1000);
|
_ztimer_sleep_scale(ZTIMER_USEC, milliseconds, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,6 +207,7 @@ static inline void xtimer_spin(xtimer_ticks32_t ticks)
|
|||||||
{
|
{
|
||||||
assert(ticks < US_PER_MS);
|
assert(ticks < US_PER_MS);
|
||||||
ztimer_now_t start = ztimer_now(ZTIMER_USEC);
|
ztimer_now_t start = ztimer_now(ZTIMER_USEC);
|
||||||
|
|
||||||
while (ztimer_now(ZTIMER_USEC) - start < ticks) {
|
while (ztimer_now(ZTIMER_USEC) - start < ticks) {
|
||||||
/* busy waiting */
|
/* busy waiting */
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,6 +64,7 @@ static uint32_t ztimer_convert_frac_op_now(ztimer_clock_t *z)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uint32_t scaled = frac_scale(&self->scale_now, lower_now);
|
uint32_t scaled = frac_scale(&self->scale_now, lower_now);
|
||||||
|
|
||||||
DEBUG("ztimer_convert_frac_op_now() %" PRIu32 "->%" PRIu32 "\n", lower_now,
|
DEBUG("ztimer_convert_frac_op_now() %" PRIu32 "->%" PRIu32 "\n", lower_now,
|
||||||
scaled);
|
scaled);
|
||||||
return scaled;
|
return scaled;
|
||||||
|
|||||||
@ -169,8 +169,10 @@ ztimer_now_t _ztimer_now_extend(ztimer_clock_t *clock)
|
|||||||
assert(clock->max_value);
|
assert(clock->max_value);
|
||||||
unsigned state = irq_disable();
|
unsigned state = irq_disable();
|
||||||
uint32_t lower_now = clock->ops->now(clock);
|
uint32_t lower_now = clock->ops->now(clock);
|
||||||
|
|
||||||
DEBUG(
|
DEBUG(
|
||||||
"ztimer_now() checkpoint=%" PRIu32 " lower_last=%" PRIu32 " lower_now=%" PRIu32 " diff=%" PRIu32 "\n",
|
"ztimer_now() checkpoint=%" PRIu32 " lower_last=%" PRIu32
|
||||||
|
" lower_now=%" PRIu32 " diff=%" PRIu32 "\n",
|
||||||
(uint32_t)clock->checkpoint, clock->lower_last, lower_now,
|
(uint32_t)clock->checkpoint, clock->lower_last, lower_now,
|
||||||
_add_modulo(lower_now, clock->lower_last, clock->max_value));
|
_add_modulo(lower_now, clock->lower_last, clock->max_value));
|
||||||
clock->checkpoint += _add_modulo(lower_now, clock->lower_last,
|
clock->checkpoint += _add_modulo(lower_now, clock->lower_last,
|
||||||
@ -178,6 +180,7 @@ ztimer_now_t _ztimer_now_extend(ztimer_clock_t *clock)
|
|||||||
clock->lower_last = lower_now;
|
clock->lower_last = lower_now;
|
||||||
DEBUG("ztimer_now() returning %" PRIu32 "\n", (uint32_t)clock->checkpoint);
|
DEBUG("ztimer_now() returning %" PRIu32 "\n", (uint32_t)clock->checkpoint);
|
||||||
ztimer_now_t now = clock->checkpoint;
|
ztimer_now_t now = clock->checkpoint;
|
||||||
|
|
||||||
irq_restore(state);
|
irq_restore(state);
|
||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,6 +50,7 @@ void _timestamp_to_gmt_civil(struct tm *_tm, uint32_t epoch)
|
|||||||
epoch /= 86400;
|
epoch /= 86400;
|
||||||
uint32_t h = s / 3600;
|
uint32_t h = s / 3600;
|
||||||
uint32_t m = s / 60 % 60;
|
uint32_t m = s / 60 % 60;
|
||||||
|
|
||||||
s = s % 60;
|
s = s % 60;
|
||||||
uint32_t x = (epoch * 4 + 102032) / 146097 + 15;
|
uint32_t x = (epoch * 4 + 102032) / 146097 + 15;
|
||||||
uint32_t b = epoch + 2442113 + x - (x / 4);
|
uint32_t b = epoch + 2442113 + x - (x / 4);
|
||||||
@ -82,6 +83,7 @@ static uint32_t _ztimer_periph_rtc_now(ztimer_clock_t *clock)
|
|||||||
(void)clock;
|
(void)clock;
|
||||||
|
|
||||||
struct tm time;
|
struct tm time;
|
||||||
|
|
||||||
rtc_get_time(&time);
|
rtc_get_time(&time);
|
||||||
|
|
||||||
return _gmt_civil_to_timestamp(time.tm_year + 1900, time.tm_mon,
|
return _gmt_civil_to_timestamp(time.tm_year + 1900, time.tm_mon,
|
||||||
|
|||||||
@ -80,6 +80,7 @@ void ztimer_periph_timer_init(ztimer_periph_timer_t *clock, tim_t dev,
|
|||||||
clock->super.ops = &_ztimer_periph_timer_ops;
|
clock->super.ops = &_ztimer_periph_timer_ops;
|
||||||
clock->super.max_value = max_val;
|
clock->super.max_value = max_val;
|
||||||
int ret = timer_init(dev, freq, _ztimer_periph_timer_callback, clock);
|
int ret = timer_init(dev, freq, _ztimer_periph_timer_callback, clock);
|
||||||
|
|
||||||
(void)ret;
|
(void)ret;
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
ztimer_init_extend(&clock->super);
|
ztimer_init_extend(&clock->super);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user