Myriota Flex SDK 2.5.0
Loading...
Searching...
No Matches
Pulse Counter

Configure and control the FlexSense Pulse Counter. More...

Typedefs

typedef void(* FLEX_PCNTWakeupHandler) (void)
 Wakeup Handler Function Pointer Declaration.
 

Enumerations

enum  FLEX_PulseCounterOption { FLEX_PCNT_DEFAULT_OPTIONS = 0 , FLEX_PCNT_EDGE_FALLING = 1 << 0 , FLEX_PCNT_DEBOUNCE_DISABLE , __attribute__ =((deprecated)) }
 Pulse Counter Options, bit-wise, can be ORed. More...
 

Functions

int FLEX_PulseCounterInit (const uint32_t Limit, const uint32_t Options)
 
uint64_t FLEX_PulseCounterGet (void)
 
void FLEX_PulseCounterDeinit (void)
 De-initialise the pulse counter.
 
int FLEX_PulseCounterHandlerModify (const FLEX_PCNTWakeupHandler Handler, const FLEX_HandlerModifyAction Action)
 

Detailed Description

Configure and control the FlexSense Pulse Counter.

Enumeration Type Documentation

◆ FLEX_PulseCounterOption

Pulse Counter Options, bit-wise, can be ORed.

Enumerator
FLEX_PCNT_DEFAULT_OPTIONS 

default option, counts on rising edge

FLEX_PCNT_EDGE_FALLING 

count on falling edge, default rising edge

FLEX_PCNT_DEBOUNCE_DISABLE 

disable hardware debouncing, default enabled for about 160us

__attribute__ 

Flag has been deprecated the FlexSenses pulse counter internal pull-up/down state is handled internally.

Function Documentation

◆ FLEX_PulseCounterInit()

int FLEX_PulseCounterInit ( const uint32_t Limit,
const uint32_t Options )

Initialise the pulse counter and configure the event generation logic. An event is generated when pulse count hits a multiple of Limit. Limit can be set to a value from 0 to 256, or a multiple of 256.

Note
Set Limit to 0 to disable event generation.
Parameters
[in]Limitmaximum value to count to before overflow occurs and reset counter to 0.
[in]Optionsconfiguration options selected from FLEX_PulseCounterOption.
Returns
FLEX_SUCCESS (0) if succeeded and < 0 if failed.

◆ FLEX_PulseCounterGet()

uint64_t FLEX_PulseCounterGet ( void )

Get the total count of the pulse counter.

Returns
the total count.

◆ FLEX_PulseCounterHandlerModify()

int FLEX_PulseCounterHandlerModify ( const FLEX_PCNTWakeupHandler Handler,
const FLEX_HandlerModifyAction Action )

Add or remove a wakeup handler that will be called when the pulse counter is triggered.

Parameters
[in]Handlerfunction pointer to the Pulse Count wakeup handler.
[in]ActionAdd/Remove the input Pulse Count wakeup handler.
Returns
FLEX_SUCCESS (0) if succeeded and < 0 if failed.
Return values
-FLEX_ERROR_EALREADYhandler already exists, remove first
-FLEX_ERROR_EINVALattempt to remove non-existent handler