#include <stdio.h>
#include "lpc_sys.h"
#include "wireless.h"
#include "lpc_timers.h"
#include "io.hpp"
#include "FreeRTOS.h"
#include "task.h"

Macros | |
#define | LPC_SYS_TIME_FOR_BCKGND_TASK_US (1 * 1000) |
Periodic interrupt for mesh networking. This timer match interrupt is disabled if FreeRTOS starts to run. More... | |
#define | LPC_SYS_WATCHDOG_RESET_TIME_US ((SYS_CFG_WATCHDOG_TIMEOUT_MS / 2) * 1000) |
Time in microseconds that will feed the watchdog, which should be roughly half of the actual watchdog reset. More... | |
Enumerations | |
enum | { mr0_mcr_for_overflow = (UINT32_C(1) << 0), mr1_mcr_for_mesh_bckgnd_task = (UINT32_C(1) << 3), mr2_mcr_for_ir_sensor_timeout = (UINT32_C(1) << 6), mr3_mcr_for_watchdog_reset = (UINT32_C(1) << 9) } |
These bitmasks should match up with the timer MCR register to trigger interrupt upon match. More... | |
Functions | |
void | lpc_sys_setup_system_timer (void) |
uint64_t | sys_get_uptime_us (void) |
void | TIMER0_IRQHandler () |
void | sys_get_mem_info_str (char buffer[280]) |
Variables | |
LPC_TIM_TypeDef * | gp_timer_ptr = NULL |
Pointer to the timer struct based on SYS_CFG_SYS_TIMER. More... | |
Macro Definition Documentation
#define LPC_SYS_TIME_FOR_BCKGND_TASK_US (1 * 1000) |
Periodic interrupt for mesh networking. This timer match interrupt is disabled if FreeRTOS starts to run.
#define LPC_SYS_WATCHDOG_RESET_TIME_US ((SYS_CFG_WATCHDOG_TIMEOUT_MS / 2) * 1000) |
Time in microseconds that will feed the watchdog, which should be roughly half of the actual watchdog reset.
Enumeration Type Documentation
anonymous enum |
Function Documentation
void lpc_sys_setup_system_timer | ( | void | ) |
Sets up the system timer that drives the time needed to get uptime in ms and us along with some background services.
- See also
- SYS_CFG_SYS_TIMER at sys_config.h
MR0: Setup the match register to take care of the overflow. Upon the roll-over, we increment the roll-over count and the timer restarts from zero.
void sys_get_mem_info_str | ( | char | buffer[280] | ) |
Prints memory information to the given buffer The buffer needs to be at least 280 bytes
uint64_t sys_get_uptime_us | ( | void | ) |
- Returns
- the system up time in microseconds
Loop until we can safely read both the rollover value and the timer value. When the timer rolls over, the TC value will start from zero, and the "after" value will be less than the before value in which case, we will loop again and pick up the new rollover count. This avoid critical section and simplifies the logic of reading higher 16-bit (roll-over) and lower 32-bit (timer value).
void TIMER0_IRQHandler | ( | void | ) |
Actual ISR function (
- See also
- startup.cpp)
Variable Documentation
LPC_TIM_TypeDef* gp_timer_ptr = NULL |
Pointer to the timer struct based on SYS_CFG_SYS_TIMER.