lpc_sys.h File Reference

Provides the following system services : More...

#include <stdint.h>
#include <stdbool.h>
#include "LPC17xx.h"
#include "fault_registers.h"
#include "rtc.h"
#include "sys_config.h"
Include dependency graph for lpc_sys.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sys_mem_t
 

Typedefs

typedef void(* void_func_t) (void)
 
typedef char(* char_func_t) (char)
 

Enumerations

enum  sys_boot_t {
  boot_unknown = 0, boot_power_on = 1, boot_reset = 2, boot_watchdog = 4,
  boot_watchdog_recover, boot_brown_out
}
 

Functions

void lpc_sys_setup_system_timer (void)
 
uint64_t sys_get_uptime_us (void)
 
sys_mem_t sys_get_mem_info ()
 
void sys_get_mem_info_str (char buffer[280])
 
sys_boot_t sys_get_boot_type ()
 
rtc_t sys_get_boot_time ()
 
void sys_set_outchar_func (char_func_t func)
 
void sys_set_inchar_func (char_func_t func)
 

Detailed Description

Provides the following system services :

  • Memory info of the system.
  • Configure function to use for printf/scanf
  • Get boot type and time
  • Watchdog

12082013 : Added functionality to see next heap pointer from mem_info_t

Typedef Documentation

typedef char(* char_func_t) (char)

Function pointer of a function returning a char and taking a char as parameter

typedef void(* void_func_t) (void)

Void function pointer

Enumeration Type Documentation

enum sys_boot_t

Enumeration of the reboot type

Enumerator
boot_unknown 
boot_power_on 

Cold boot (power on)

boot_reset 

Boot after reset condition.

boot_watchdog 

Boot after watchdog reset (intentional)

boot_watchdog_recover 

Boot after watchdog reset after an error (or crash)

boot_brown_out 

Boot after under-voltage.

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.

rtc_t sys_get_boot_time ( )
Returns
the boot-time recorded in the system
sys_boot_t sys_get_boot_type ( )

Defined at system_init.c

Returns
the reboot reason as detected during system startup
sys_mem_t sys_get_mem_info ( )

Gets System Memory information The information includes Global Memory usage, and dynamic memory usage. This function is defined at memory.cpp

Returns
MemoryInfoType structure
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 sys_set_inchar_func ( char_func_t  func)

Sets the function used to input a char by scanf() or stdio input functions

Parameters
funcThe function pointer to use to get a char
void sys_set_outchar_func ( char_func_t  func)

Defined at syscalls.c Sets the function used to output a char by printf() or stdio output functions

Parameters
funcThe function pointer to use to output a char