NHS31xx SW API

Detailed Description

The timer functions provide a high-level abstraction API to access the different timers in an NHS31xx for specific uses.

Functions

void Timer_Init (void)
 
void Timer_StartHostTimeout (int seconds)
 
void Timer_StopHostTimeout (void)
 
bool Timer_CheckHostTimeout (void)
 
void Timer_StartMeasurementTimeout (int seconds)
 
void Timer_StopMeasurementTimeout (void)
 
bool Timer_CheckMeasurementTimeout (void)
 
void Timer_StartFreeRunning (void)
 
void Timer_StopFreeRunning (void)
 
uint32_t Timer_GetFreeRunning (void)
 

Function Documentation

◆ Timer_Init()

void Timer_Init ( void  )

Initialize the timers so that the other function calls become available.

Precondition
This must be the first call to this block of code.

◆ Timer_StartHostTimeout()

void Timer_StartHostTimeout ( int  seconds)

Starts or restarts a timer. The timer will keep on running in Sleep and Deep Sleep modes.

Note
The 16-bit timer is used. It will run as slow as possible, i.e the resolution will be low, assuming accuracy is not a concern here.
Parameters
secondsThe timeout interval. Use Timer_CheckHostTimeout to check whether the interval has expired. Use Timer_StopHostTimeout to check the status.
Precondition
seconds must be a strict positive number

◆ Timer_StopHostTimeout()

void Timer_StopHostTimeout ( void  )

Stops the 16-bit timer.

Postcondition
A call to Timer_CheckHostTimeout will now return false.

◆ Timer_CheckHostTimeout()

bool Timer_CheckHostTimeout ( void  )

Check if time as set by Timer_StartHostTimeout has elapsed.

Returns
True when the timer was started and the interrupt was fired. false otherwise.
Note
When the timer has timed out, an explicit call to Timer_StartHostTimeout is required to restart the 16-bit timer.

◆ Timer_StartMeasurementTimeout()

void Timer_StartMeasurementTimeout ( int  seconds)

Starts or restarts a timer.

Note
The RTC timer is used, which will continue running when going to the Deep Power Down mode, and wake up the IC when it expires.
Parameters
secondsThe timeout interval. Use Timer_CheckMeasurementTimeout to check whether the interval has expired.
Precondition
seconds must be a strict positive number.
Postcondition
The internal status is reset: an immediate call to Timer_CheckMeasurementTimeout will now return false.

◆ Timer_StopMeasurementTimeout()

void Timer_StopMeasurementTimeout ( void  )

Stops the RTC timer.

Postcondition
An immediate or later call to Timer_CheckMeasurementTimeout will now return false.

◆ Timer_CheckMeasurementTimeout()

bool Timer_CheckMeasurementTimeout ( void  )

Check if time as set by Timer_StartMeasurementTimeout has elapsed.

Returns
True when the timer was started and the interrupt was fired. false otherwise.
Note
When the timer has timed out, an explicit call to Timer_StartMeasurementTimeout is required to restart the RTC timer.

◆ Timer_StartFreeRunning()

void Timer_StartFreeRunning ( void  )

Starts the 32-bit timer. The timer will keep on running in Sleep and Deep Sleep modes.

Note
The 32-bit timer is used without setting any interrupts. It will run as fast as possible.

◆ Timer_StopFreeRunning()

void Timer_StopFreeRunning ( void  )

Stops the 32-bit timer.

Postcondition
All subsequent call to Timer_GetFreeRunning will now return the same value.

◆ Timer_GetFreeRunning()

uint32_t Timer_GetFreeRunning ( void  )

Retrieve the current timer value.

Returns
A positive number. When the moment of calling this function is not deterministic, the outcome can be used as a source of entropy.