libpynq  (release 5EID0-2023 version 0.3.0 of 2024-04-25 09:42 )
PULSECOUNTER library

Enumerations

enum  pulsecounter_index_t { PULSECOUNTER0 = 0, PULSECOUNTER1 = 1, NUM_PULSECOUNTERS = 2 }
 

Functions

void pulsecounter_init (const pulsecounter_index_t pci)
 
void pulsecounter_destroy (const pulsecounter_index_t pci)
 
uint32_t pulsecounter_get_count (const pulsecounter_index_t pci, uint32_t *timestamp)
 
void pulsecounter_reset_count (const pulsecounter_index_t pci)
 
void pulsecounter_set_edge (const pulsecounter_index_t pci, const gpio_level_t edge)
 
gpio_level_t pulsecounter_get_edge (const pulsecounter_index_t pci)
 
void pulsecounter_set_filter_length (const pulsecounter_index_t pci, uint8_t const count)
 
uint8_t pulsecounter_get_filter_length (const pulsecounter_index_t pci)
 

Detailed Description

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.

Enumeration Type Documentation

◆ 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.

Function Documentation

◆ pulsecounter_destroy()

void pulsecounter_destroy ( const pulsecounter_index_t  pci)

Close the shared memory handle for the specified PULSECOUNTER index.

Parameters
pcithe 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.

Here is the call graph for this function:

◆ pulsecounter_get_count()

uint32_t pulsecounter_get_count ( const pulsecounter_index_t  pci,
uint32_t *  timestamp 
)
Parameters
pcithe pulsecounter index.
timestampThe 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()

gpio_level_t pulsecounter_get_edge ( const pulsecounter_index_t  pci)
Parameters
pcithe pulcounter index
Returns
the edge that is used to trigger on. See set_edge.

Definition at line 80 of file pulsecounter.c.

◆ pulsecounter_get_filter_length()

uint8_t pulsecounter_get_filter_length ( const pulsecounter_index_t  pci)
Parameters
pcithe pulcounter index
Returns
the current filter length.

Definition at line 94 of file pulsecounter.c.

◆ pulsecounter_init()

void pulsecounter_init ( const pulsecounter_index_t  pci)

initialize the pulsecounter specified by the index with a shared memory pointer

Parameters
uartthe pulsecounter index to initialize.

Definition at line 39 of file pulsecounter.c.

◆ pulsecounter_reset_count()

void pulsecounter_reset_count ( const pulsecounter_index_t  pci)
Parameters
pcithe pulsecounter index.

Reset the pulsecounter count back to 0.

Definition at line 87 of file pulsecounter.c.

◆ pulsecounter_set_edge()

void pulsecounter_set_edge ( const pulsecounter_index_t  pci,
const gpio_level_t  edge 
)
Parameters
pcithe pulcounter index
edgeThe 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()

void pulsecounter_set_filter_length ( const pulsecounter_index_t  pci,
uint8_t const  count 
)
Parameters
pcithe pulcounter index
countthe 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.