Firmware SDK
twr_pulse_counter

Driver for generic pulse counter. More...

Enumerations

enum  twr_pulse_counter_edge_t {
  TWR_PULSE_COUNTER_EDGE_RISE = TWR_EXTI_EDGE_RISING ,
  TWR_PULSE_COUNTER_EDGE_FALL = TWR_EXTI_EDGE_FALLING ,
  TWR_PULSE_COUNTER_EDGE_RISE_FALL = TWR_EXTI_EDGE_RISING_AND_FALLING
}
 Pulse counter active edges. More...
 
enum  twr_pulse_counter_event_t {
  TWR_PULSE_COUNTER_EVENT_UPDATE ,
  TWR_PULSE_COUNTER_EVENT_OVERFLOW
}
 Pulse counter event. More...
 

Functions

void twr_pulse_counter_init (twr_module_sensor_channel_t channel, twr_pulse_counter_edge_t edge)
 Initialize pulse counter. More...
 
void twr_pulse_counter_set_event_handler (twr_module_sensor_channel_t channel, void(*event_handler)(twr_module_sensor_channel_t, twr_pulse_counter_event_t, void *), void *event_param)
 Set callback function. More...
 
void twr_pulse_counter_set_update_interval (twr_module_sensor_channel_t channel, twr_tick_t interval)
 Set update interval. More...
 
void twr_pulse_counter_set (twr_module_sensor_channel_t channel, unsigned int count)
 Set count. More...
 
unsigned int twr_pulse_counter_get (twr_module_sensor_channel_t channel)
 Get count. More...
 
void twr_pulse_counter_reset (twr_module_sensor_channel_t channel)
 Set count to zero. More...
 

Detailed Description

Driver for generic pulse counter.

Enumeration Type Documentation

◆ twr_pulse_counter_edge_t

Pulse counter active edges.

Enumerator
TWR_PULSE_COUNTER_EDGE_RISE 

Rise edge is active.

TWR_PULSE_COUNTER_EDGE_FALL 

Fall edge is active.

TWR_PULSE_COUNTER_EDGE_RISE_FALL 

Rise and fall edges are active.

Definition at line 15 of file twr_pulse_counter.h.

◆ twr_pulse_counter_event_t

Pulse counter event.

Enumerator
TWR_PULSE_COUNTER_EVENT_UPDATE 

Update event.

TWR_PULSE_COUNTER_EVENT_OVERFLOW 

Overflow.

Definition at line 30 of file twr_pulse_counter.h.

Function Documentation

◆ twr_pulse_counter_get()

unsigned int twr_pulse_counter_get ( twr_module_sensor_channel_t  channel)

Get count.

Parameters
[in]channelSensor Module channel pulse counter is connected to
Returns
Counter count

Definition at line 71 of file twr_pulse_counter.c.

◆ twr_pulse_counter_init()

void twr_pulse_counter_init ( twr_module_sensor_channel_t  channel,
twr_pulse_counter_edge_t  edge 
)

Initialize pulse counter.

Parameters
[in]channelSensor Module channel pulse counter is connected to
[in]edgeActive edge

Definition at line 23 of file twr_pulse_counter.c.

Here is the call graph for this function:

◆ twr_pulse_counter_reset()

void twr_pulse_counter_reset ( twr_module_sensor_channel_t  channel)

Set count to zero.

Parameters
[in]channelSensor Module channel pulse counter is connected to

Definition at line 76 of file twr_pulse_counter.c.

◆ twr_pulse_counter_set()

void twr_pulse_counter_set ( twr_module_sensor_channel_t  channel,
unsigned int  count 
)

Set count.

Parameters
[in]channelSensor Module channel pulse counter is connected to
[in]countCount to be set

Definition at line 66 of file twr_pulse_counter.c.

◆ twr_pulse_counter_set_event_handler()

void twr_pulse_counter_set_event_handler ( twr_module_sensor_channel_t  channel,
void(*)(twr_module_sensor_channel_t, twr_pulse_counter_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]channelSensor Module channel pulse counter is connected to
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 46 of file twr_pulse_counter.c.

◆ twr_pulse_counter_set_update_interval()

void twr_pulse_counter_set_update_interval ( twr_module_sensor_channel_t  channel,
twr_tick_t  interval 
)

Set update interval.

Parameters
[in]channelSensor Module channel pulse counter is connected to
[in]intervalUpdate interval

Definition at line 52 of file twr_pulse_counter.c.

Here is the call graph for this function: