| Microcontroller Wireless Solutions | |||||
Timer related functions for the ATmega128RFA1 Mega RF Single Chip. More...
Go to the source code of this file.
Defines | |
| #define | DELAY_WITHOUT_IRQS_US (100) |
Functions | |
| static bool | compare_time (uint32_t t1, uint32_t t2) |
| void | internal_timer_handler (void) |
| void | pal_get_current_time (uint32_t *current_time) |
| bool | pal_is_timer_running (uint8_t timer_id) |
| retval_t | pal_start_high_priority_timer (uint8_t timer_id, uint16_t timer_count, FUNC_PTR timer_cb, void *param_cb) |
| retval_t | pal_stop_high_priority_timer (uint8_t timer_id) |
| void | pal_timer_delay (uint16_t delay) |
| void | pal_timer_source_select (source_type_t source) |
| retval_t | pal_timer_start (uint8_t timer_id, uint32_t timer_count, timeout_type_t timeout_type, FUNC_PTR timer_cb, void *param_cb) |
| retval_t | pal_timer_stop (uint8_t timer_id) |
| void | pal_trx_read_timestamp (uint32_t *timestamp) |
| static void | prog_ocr (void) |
| void | SCNT_CMP1_vect (void) |
| void | SCNT_CMP2_vect (void) |
| void | SCNT_CMP3_vect (void) |
| static void | start_absolute_timer (uint8_t timer_id, uint32_t point_in_time, FUNC_PTR handler_cb, void *parameter) |
| void | timer_init (void) |
| void | timer_service (void) |
Timer related functions for the ATmega128RFA1 Mega RF Single Chip.
This file implements timer related functions for the ATmega128RFA1.
Definition in file pal_timer.c.
| #define DELAY_WITHOUT_IRQS_US (100) |
Maximum delay in us that function pal_timer_delay() is running with interrupts disabled. If the delay is larger, interrupts need to be enabled inbetween.
Definition at line 87 of file pal_timer.c.
Referenced by pal_timer_delay().
| static bool compare_time | ( | uint32_t | t1, |
| uint32_t | t2 | ||
| ) | [inline, static] |
Compares two 32-bit time values.
This function compares two true 32-bit time values t1 and t2 and returns true if t1 is less than t2.
| t1 | Time |
| t2 | Time |
Definition at line 114 of file pal_timer.c.
Referenced by prog_ocr(), and start_absolute_timer().
| void internal_timer_handler | ( | void | ) |
Internal timer handler.
This function checks for expired timers and rearranges the running timer queue head and expired timer queue head and tail if there are any expired timers.
Definition at line 932 of file pal_timer.c.
References ENTER_CRITICAL_REGION, LEAVE_CRITICAL_REGION, and prog_ocr().
Referenced by pal_timer_stop(), start_absolute_timer(), and timer_service().
| void pal_get_current_time | ( | uint32_t * | current_time | ) |
Gets current time.
This function returns the current time.
| [out] | current_time | Current system time |
Definition at line 697 of file pal_timer.c.
Referenced by ISR().
| bool pal_is_timer_running | ( | uint8_t | timer_id | ) |
Checks if the timer with the requested timer identifier is running.
Checks if the timer of requested timer identifier is running.
| timer_id | Timer identifier |
Definition at line 834 of file pal_timer.c.
| retval_t pal_start_high_priority_timer | ( | uint8_t | timer_id, |
| uint16_t | timer_count, | ||
| FUNC_PTR | timer_cb, | ||
| void * | param_cb | ||
| ) |
Starts high priority timer.
This function starts a high priority timer for the specified timeout.
| timer_id | Timer identifier |
| timer_count | Timeout in microseconds |
| timer_cb | Callback handler invoked upon timer expiry |
| param_cb | Argument for the callback handler |
Definition at line 315 of file pal_timer.c.
References ENTER_CRITICAL_REGION, LEAVE_CRITICAL_REGION, MAC_INVALID_PARAMETER, MAC_SUCCESS, PAL_TMR_ALREADY_RUNNING, and PAL_TMR_INVALID_ID.
| retval_t pal_stop_high_priority_timer | ( | uint8_t | timer_id | ) |
Stops a high priority timer.
This function stops a high priority timer.
| timer_id | Timer identifier |
Definition at line 560 of file pal_timer.c.
References ENTER_CRITICAL_REGION, LEAVE_CRITICAL_REGION, MAC_SUCCESS, and PAL_TMR_NOT_RUNNING.
| void pal_timer_delay | ( | uint16_t | delay | ) |
Performes blocking delay.
Generates blocking delay.
This functions performs a blocking delay of the specified time.
| delay | in microseconds |
Definition at line 730 of file pal_timer.c.
References DELAY_WITHOUT_IRQS_US.
Referenced by pal_alert(), and timer_init().
| void pal_timer_source_select | ( | source_type_t | source | ) |
Selects timer clock source.
This function selects the clock source of the timer.
Unused for the ATmega128RFA1 because the MAC symbol counter automatically switches from XTAL1 to RTC when the transceiver module is put to sleep.
| source |
|
Definition at line 682 of file pal_timer.c.
| retval_t pal_timer_start | ( | uint8_t | timer_id, |
| uint32_t | timer_count, | ||
| timeout_type_t | timeout_type, | ||
| FUNC_PTR | timer_cb, | ||
| void * | param_cb | ||
| ) |
Starts regular timer.
Start regular timer.
This function starts a regular timer and registers the corresponding callback function to handle the timeout event.
| timer_id | Timer identifier |
| timer_count | Timeout in microseconds |
| timeout_type | TIMEOUT_RELATIVE / TIMEOUT_ABSOLUTE |
| timer_cb | Callback handler invoked upon timer expiry |
| param_cb | Argument for the callback handler |
Definition at line 229 of file pal_timer.c.
References MAC_INVALID_PARAMETER, MAC_SUCCESS, MAX_TIMEOUT, MIN_TIMEOUT, PAL_TMR_ALREADY_RUNNING, PAL_TMR_INVALID_ID, PAL_TMR_INVALID_TIMEOUT, start_absolute_timer(), TIMEOUT_ABSOLUTE, and TIMEOUT_RELATIVE.
| retval_t pal_timer_stop | ( | uint8_t | timer_id | ) |
Stops a running timer.
This function stops a running timer with the specified timer_id.
| timer_id | Timer identifier |
Definition at line 398 of file pal_timer.c.
References ENTER_CRITICAL_REGION, internal_timer_handler(), LEAVE_CRITICAL_REGION, MAC_SUCCESS, PAL_TMR_INVALID_ID, PAL_TMR_NOT_RUNNING, and prog_ocr().
| void pal_trx_read_timestamp | ( | uint32_t * | timestamp | ) |
Provides timestamp of the last received frame.
This function provides the timestamp (in microseconds) of the last received frame.
| [out] | timestamp | in microseconds |
Definition at line 716 of file pal_timer.c.
| static void prog_ocr | ( | void | ) | [static] |
Programs the output compare register SCOCR1.
This function programs the SCOCR1 register with the timeout value of the timer present at the head of the running timer queue.
Definition at line 882 of file pal_timer.c.
References compare_time().
Referenced by internal_timer_handler(), pal_timer_stop(), and start_absolute_timer().
| void SCNT_CMP1_vect | ( | void | ) |
Timer1 COMPA ISR.
This is the interrupt service routine for timer1 output compare match. It is triggered when a timer expires.
| void SCNT_CMP2_vect | ( | void | ) |
ISR to limit the MAC symbol counter to 28 bits width.
The current counter value will be advanced to -1, so it rolls over to 0 at the next timer tick.
| void SCNT_CMP3_vect | ( | void | ) |
ISR for high priority timer, triggered by SCOCR2.
This is the interrupt service routine for SCOCR2 output compare match. It is triggered when a high priority timer expires.
| static void start_absolute_timer | ( | uint8_t | timer_id, |
| uint32_t | point_in_time, | ||
| FUNC_PTR | handler_cb, | ||
| void * | parameter | ||
| ) | [static] |
Start a timer by setting its absolute expiration time.
This function starts a timer which should expire at the point_in_time value and upon timer expiry the function held by the handler is called.
| timer_id | Timer identifier |
| point_in_time | Absolute expiration time in microseconds |
| handler_cb | Function called upon timer expiry |
| parameter | Parameter passed to the expired timer handler |
Definition at line 996 of file pal_timer.c.
References compare_time(), ENTER_CRITICAL_REGION, internal_timer_handler(), LEAVE_CRITICAL_REGION, and prog_ocr().
Referenced by pal_timer_start().
| void timer_init | ( | void | ) |
This function is called to initialize the timer module.
Definition at line 590 of file pal_timer.c.
References pal_timer_delay().
Referenced by pal_init().
| void timer_service | ( | void | ) |
Timer handling services.
This Function performs timer handling services. It calls functions which are responsible 1) to put the expired timer into the expired timer queue, and 2) to service expired timers and call the respective callback.
Definition at line 148 of file pal_timer.c.
References ENTER_CRITICAL_REGION, internal_timer_handler(), and LEAVE_CRITICAL_REGION.
Referenced by pal_task().