libpynq (release 5EWC0-2023 version 0.2.6 of 2025-11-10 09:56)
Loading...
Searching...
No Matches
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 int edge)
 
int 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)
 
uint32_t pulsecounter_get_pulsetrain (const pulsecounter_index_t pci, uint32_t *const inv, const uint32_t inv_length)
 
uint32_t pulsecounter_get_pulsetrain_count (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)
extern

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 60 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 
)
extern
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 68 of file pulsecounter.c.

◆ pulsecounter_get_edge()

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

Definition at line 87 of file pulsecounter.c.

◆ pulsecounter_get_filter_length()

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

Definition at line 101 of file pulsecounter.c.

◆ pulsecounter_get_pulsetrain()

uint32_t pulsecounter_get_pulsetrain ( const pulsecounter_index_t  pci,
uint32_t *const  inv,
const uint32_t  inv_length 
)
extern
Parameters
pcithe pulsecounter index
invarray of uint32_t of #inv_length long
inv_lengththe array length

Returns the intervals in inv_length.

Returns
number of elements filled into inv.

Definition at line 119 of file pulsecounter.c.

◆ pulsecounter_get_pulsetrain_count()

uint32_t pulsecounter_get_pulsetrain_count ( const pulsecounter_index_t  pci)
extern
Parameters
pcithe pulsecounter index

Returns the number of intervals detected and stored.

Returns
number of intervals measured.

Definition at line 134 of file pulsecounter.c.

◆ pulsecounter_init()

void pulsecounter_init ( const pulsecounter_index_t  pci)
extern

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

Parameters
uartthe pulsecounter index to initialize.

Definition at line 42 of file pulsecounter.c.

Here is the call graph for this function:

◆ pulsecounter_reset_count()

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

Reset the pulsecounter count back to 0.

Definition at line 93 of file pulsecounter.c.

◆ pulsecounter_set_edge()

void pulsecounter_set_edge ( const pulsecounter_index_t  pci,
const int  edge 
)
extern
Parameters
pcithe pulsecounter 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 80 of file pulsecounter.c.

◆ pulsecounter_set_filter_length()

void pulsecounter_set_filter_length ( const pulsecounter_index_t  pci,
uint8_t const  count 
)
extern
Parameters
pcithe pulsecounter index
countthe filter count

Set the debounce filter length. Default is 10 cycles, can be set from 1 to 15 cycles.

Definition at line 108 of file pulsecounter.c.