#include "atomport.h"
Go to the source code of this file.
Data Structures | |
struct | atom_timer |
Typedefs | |
typedef void(* | TIMER_CB_FUNC )(POINTER cb_data) |
typedef struct atom_timer | ATOM_TIMER |
Functions | |
uint8_t | atomTimerRegister (ATOM_TIMER *timer_ptr) |
uint8_t | atomTimerCancel (ATOM_TIMER *timer_ptr) |
uint8_t | atomTimerDelay (uint32_t ticks) |
uint32_t | atomTimeGet (void) |
void | atomTimeSet (uint32_t new_time) |
typedef struct atom_timer ATOM_TIMER |
typedef void( * TIMER_CB_FUNC)(POINTER cb_data) |
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 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 |