dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

PiOS Delay functionality. More...

Data Structures

struct  rtc_callback_entry
 

Macros

#define SYSTICK_HZ   1250
 
#define RTC_DIVIDER   2 /* Must be power of 2; this results in 625Hz "RTC" */
 
#define PIOS_RTC_MAX_CALLBACKS   3
 

Functions

int32_t PIOS_DELAY_Init (void)
 
int32_t PIOS_DELAY_WaituS (uint32_t uS)
 
int32_t PIOS_DELAY_WaitmS (uint32_t mS)
 
uint32_t PIOS_DELAY_GetuS ()
 Query the Delay timer for the current uS. More...
 
uint32_t PIOS_DELAY_GetuSSince (uint32_t t)
 Calculate time in microseconds since a previous time. More...
 
uint32_t PIOS_DELAY_GetuSExpired (uint32_t t)
 Calculates whether a given time has passed. More...
 
uint32_t PIOS_DELAY_GetRaw ()
 Get the raw delay timer, useful for timing. More...
 
uint32_t PIOS_DELAY_DiffuS (uint32_t raw)
 Subtract raw time from now and convert to us. More...
 
uint32_t PIOS_DELAY_DiffuS2 (uint32_t raw, uint32_t later)
 Subrtact two raw times and convert to us. More...
 
static uint32_t get_monotonic_us_time (void)
 
static void PIOS_DELAY_Systick_Handler (void)
 
float PIOS_RTC_Rate ()
 
float PIOS_RTC_MsPerTick ()
 
bool PIOS_RTC_RegisterTickCallback (void(*fn)(uintptr_t id), uintptr_t data)
 
static void PIOS_RTC_Tick ()
 

Variables

static uint32_t base_time
 
static uint32_t us_ticks
 
static uint32_t us_modulo
 
static struct rtc_callback_entry rtc_callback_list [PIOS_RTC_MAX_CALLBACKS]
 

Detailed Description

PiOS Delay functionality.

Macro Definition Documentation

#define PIOS_RTC_MAX_CALLBACKS   3

Definition at line 39 of file pios_delay.c.

#define RTC_DIVIDER   2 /* Must be power of 2; this results in 625Hz "RTC" */

Definition at line 37 of file pios_delay.c.

#define SYSTICK_HZ   1250

Definition at line 36 of file pios_delay.c.

Function Documentation

static uint32_t get_monotonic_us_time ( void  )
static

Definition at line 73 of file pios_delay.c.

uint32_t PIOS_DELAY_DiffuS ( uint32_t  raw)

Subtract raw time from now and convert to us.

Returns
A microsecond value

Definition at line 159 of file pios_delay.c.

uint32_t PIOS_DELAY_DiffuS2 ( uint32_t  raw,
uint32_t  later 
)

Subrtact two raw times and convert to us.

Returns
Interval between raw times in microseconds

Definition at line 164 of file pios_delay.c.

uint32_t PIOS_DELAY_GetRaw ( )

Get the raw delay timer, useful for timing.

Returns
Unitless value (uint32 wrap around)

Definition at line 153 of file pios_delay.c.

uint32_t PIOS_DELAY_GetuS ( )

Query the Delay timer for the current uS.

Returns
A microsecond value
Todo:
fixup to be more precise

Definition at line 173 of file pios_delay.c.

uint32_t PIOS_DELAY_GetuSExpired ( uint32_t  t)

Calculates whether a given time has passed.

Parameters
[in]tthe time in question
Returns
true if the time is in the past.

Definition at line 193 of file pios_delay.c.

uint32_t PIOS_DELAY_GetuSSince ( uint32_t  t)

Calculate time in microseconds since a previous time.

Parameters
[in]tprevious time
Returns
time in us since previous time t.

Definition at line 183 of file pios_delay.c.

int32_t PIOS_DELAY_Init ( void  )

Initialises the Timer used by PIOS_DELAY functions
This is called from pios.c as part of the main() function at system start up.

Returns
< 0 if initialisation failed

Initialises the Timer used by PIOS_DELAY functions.

Returns
always zero (success)

Definition at line 98 of file pios_delay.c.

static void PIOS_DELAY_Systick_Handler ( void  )
static

Definition at line 48 of file pios_delay.c.

int32_t PIOS_DELAY_WaitmS ( uint32_t  ms)

Waits for a specific number of mS
Example:

// Wait for 500 mS
PIOS_DELAY_Wait_mS(500);
Parameters
[in]mSdelay (1..65535 milliseconds)
Returns
< 0 on errors

Waits for a specific number of mS

Example:

// Wait for 500 mS
PIOS_DELAY_Wait_mS(500);
Parameters
[in]mSdelay (1..65535 milliseconds)
Returns
< 0 on errors

Definition at line 140 of file pios_delay.c.

int32_t PIOS_DELAY_WaituS ( uint32_t  us)

Waits for a specific number of uS
Example:

// Wait for 500 uS
PIOS_DELAY_Wait_uS(500);
Parameters
[in]uSdelay (1..65535 microseconds)
Returns
< 0 on errors

Waits for a specific number of uS

Example:

// Wait for 500 uS
PIOS_DELAY_Wait_uS(500);
Parameters
[in]uSdelay
Returns
< 0 on errors

Definition at line 116 of file pios_delay.c.

float PIOS_RTC_MsPerTick ( )

Definition at line 180 of file pios_delay.c.

float PIOS_RTC_Rate ( )

Definition at line 175 of file pios_delay.c.

bool PIOS_RTC_RegisterTickCallback ( void(*)(uintptr_t id fn,
uintptr_t  data 
)

Definition at line 185 of file pios_delay.c.

static void PIOS_RTC_Tick ( )
static

Definition at line 203 of file pios_delay.c.

Variable Documentation

uint32_t base_time
static

This is the value used as a base. Strictly not required, as times can be expected to wrap... But it makes sense to get sane numbers at first that will agree with the PIOS_Thread ones etc.

Definition at line 42 of file pios_delay.c.

struct rtc_callback_entry rtc_callback_list[PIOS_RTC_MAX_CALLBACKS]
static

Definition at line 46 of file pios_delay.c.

uint32_t us_modulo
static

Definition at line 39 of file pios_delay.c.

uint32_t us_ticks
static

Definition at line 38 of file pios_delay.c.