Functions to use the PULSECOUNTER.
This interacts with hardware pulsecounter. It can count up to 2**31-1 pulses and has a free-running 32bit counter that can be read out consistently with the pulsecount to get an accurate pulses/time unit. The module runs at ~100MHz.
◆ pulsecounter_index_t
Enum of PULSECOUNTERs. Functions use a switch numbered from 0..NUM_PULSECOUNTERS-1.
Enumerator |
---|
PULSECOUNTER0 | |
PULSECOUNTER1 | |
NUM_PULSECOUNTERS | |
Definition at line 45 of file pulsecounter.h.
◆ pulsecounter_destroy()
Close the shared memory handle for the specified PULSECOUNTER index.
- Parameters
-
pci | the pulsecounter index to remove from the shared memory space. |
- Warning
- fails with program exit if the pulsecounter channel is outside valid range.
Definition at line 52 of file pulsecounter.c.
◆ pulsecounter_get_count()
- Parameters
-
pci | the pulsecounter index. |
timestamp | The timestamp matching the count value. [out] |
Reads the content of the register into data.
- Returns
- the read count and write associated timestamp to *timestamp
Definition at line 60 of file pulsecounter.c.
◆ pulsecounter_get_edge()
- Parameters
-
- Returns
- the edge that is used to trigger on. See set_edge.
Definition at line 80 of file pulsecounter.c.
◆ pulsecounter_get_filter_length()
- Parameters
-
- Returns
- the current filter length.
Definition at line 94 of file pulsecounter.c.
◆ pulsecounter_init()
initialize the pulsecounter specified by the index with a shared memory pointer
- Parameters
-
uart | the pulsecounter index to initialize. |
Definition at line 39 of file pulsecounter.c.
◆ pulsecounter_reset_count()
- Parameters
-
pci | the pulsecounter index. |
Reset the pulsecounter count back to 0.
Definition at line 87 of file pulsecounter.c.
◆ pulsecounter_set_edge()
- Parameters
-
pci | the pulcounter index |
edge | The edge to trigger on |
Set high to trigger on the rising edge, set to low to trigger on falling edge. The signal needs to be stable at 'edge' level for filter length (10 by default) cycles.
Definition at line 72 of file pulsecounter.c.
◆ pulsecounter_set_filter_length()
- Parameters
-
pci | the pulcounter index |
count | the filter count |
Set the debounce filter length. Default is 10 cycles, can be set from 1 to 15 cycles.
Definition at line 101 of file pulsecounter.c.