#include <stdio.h>
#include "atom.h"
Data Structures | |
struct | delay_timer |
Typedefs | |
typedef struct delay_timer | DELAY_TIMER |
Functions | |
uint8_t | atomTimerRegister (ATOM_TIMER *timer_ptr) |
uint8_t | atomTimerCancel (ATOM_TIMER *timer_ptr) |
uint32_t | atomTimeGet (void) |
void | atomTimeSet (uint32_t new_time) |
void | atomTimerTick (void) |
uint8_t | atomTimerDelay (uint32_t ticks) |
Timer and system tick library.
This module implements kernel system tick / clock functionality and timer functionality for kernel and application code.
typedef struct delay_timer DELAY_TIMER |
uint32_t atomTimeGet | ( | void | ) |
atomTimeGet
Returns the current system tick time.
This function can be called from interrupt context.
Current | system tick count |
uint8_t atomTimerCancel | ( | ATOM_TIMER * | timer_ptr | ) |
atomTimerCancel
Cancel a timer callback previously registered using atomTimerRegister().
This function can be called from interrupt context, but loops internally through the time list, so the potential execution cycles cannot be determined in advance.
[in] | timer_ptr | Pointer to timer to cancel |
ATOM_OK | Success | |
ATOM_ERR_PARAM | Bad parameters | |
ATOM_ERR_NOT_FOUND | Timer registration was not found |
References ATOM_ERR_NOT_FOUND, ATOM_ERR_PARAM, ATOM_OK, CRITICAL_END, CRITICAL_START, CRITICAL_STORE, atom_timer::next_timer, and uint8_t.
Referenced by atomMutexDelete(), atomMutexPut(), atomQueueDelete(), atomSemDelete(), and atomSemPut().
uint8_t atomTimerDelay | ( | uint32_t | ticks | ) |
atomTimerDelay
Suspend a thread for the given number of system ticks.
Note that the wakeup time is the number of ticks from the current system tick, therefore, for a one tick delay, the thread may be woken up at any time between the atomTimerDelay() call and the next system tick. For a minimum number of ticks, you should specify minimum number of ticks + 1.
This function can only be called from thread context.
[in] | ticks | Number of system ticks to delay (must be > 0) |
ATOM_OK | Successful delay | |
ATOM_ERR_PARAM | Bad parameter (ticks must be non-zero) | |
ATOM_ERR_CONTEXT | Not called from thread context |
References ATOM_ERR_CONTEXT, ATOM_ERR_PARAM, ATOM_ERR_TIMER, ATOM_OK, atomCurrentContext(), atomSched(), atomTimerRegister(), atom_timer::cb_data, atom_timer::cb_func, atom_timer::cb_ticks, CRITICAL_END, CRITICAL_START, CRITICAL_STORE, FALSE, POINTER, atom_tcb::suspend_timo_cb, atom_tcb::suspended, delay_timer::tcb_ptr, TRUE, and uint8_t.
uint8_t atomTimerRegister | ( | ATOM_TIMER * | timer_ptr | ) |
atomTimerRegister
Register a timer callback.
Callers should fill out and pass in a timer descriptor, containing the number of system ticks until they would like a callback, together with a callback function and optional parameter. The number of ticks must be greater than zero.
On the relevant system tick count, the callback function will be called.
These timers are used by some of the OS library routines, but they can also be used by application code requiring timer facilities at system tick resolution.
This function can be called from interrupt context, but loops internally through the time list, so the potential execution cycles cannot be determined in advance.
[in] | timer_ptr | Pointer to timer descriptor |
ATOM_OK | Success | |
ATOM_ERR_PARAM | Bad parameters |
References ATOM_ERR_PARAM, ATOM_OK, atom_timer::cb_func, atom_timer::cb_ticks, CRITICAL_END, CRITICAL_START, CRITICAL_STORE, atom_timer::next_timer, and uint8_t.
Referenced by atomMutexGet(), atomQueueGet(), atomQueuePut(), atomSemGet(), and atomTimerDelay().
void atomTimerTick | ( | void | ) |
atomTimerTick
System tick handler.
User ports are responsible for calling this routine once per system tick.
On each system tick this routine is called to do the following: 1. Increase the system tick count 2. Call back to any registered timer callbacks
References atomOSStarted.
void atomTimeSet | ( | uint32_t | new_time | ) |
atomTimeSet
This is an internal function not for use by application code.
Sets the current system tick time.
Currently only required for automated test suite to test clock behaviour.
This function can be called from interrupt context.
[in] | new_time | New system tick time value |