counter 2.0.0.0
Public function

Functions

void counter_cfg_setup (counter_cfg_t *cfg)
 Config Object Initialization function.
 
COUNTER_RETVAL counter_init (counter_t *ctx, counter_cfg_t *cfg)
 Initialization function.
 
void counter_default_cfg (counter_t *ctx)
 Click Default Configuration function.
 
void counter_generic_transfer (counter_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
 Generic transfer function.
 
void counter_write_mdr0 (counter_t *ctx, uint8_t settings)
 Writes data into MDR0.
 
void counter_write_mdr1 (counter_t *ctx, uint8_t settings)
 Writes data into MDR1.
 
void counter_write_dtr (counter_t *ctx, uint8_t *buffer)
 Writes data into DTR.
 
void counter_load_cntr (counter_t *ctx)
 Loads CNTR from DTR.
 
void counter_load_otr (counter_t *ctx)
 Loads OTR from CNTR.
 
uint8_t counter_read_mdr0 (counter_t *ctx)
 Reads MDR0.
 
uint8_t counter_read_mdr1 (counter_t *ctx)
 Reads MDR1.
 
int32_t counter_read_otr (counter_t *ctx)
 Reads OTR.
 
int32_t counter_read_cntr (counter_t *ctx)
 Reads CNTR.
 
int32_t counter_read_dtr (counter_t *ctx)
 Reads DTR.
 
uint8_t counter_read_str (counter_t *ctx)
 Reads STR.
 
void counter_clear_mrd0 (counter_t *ctx)
 Clears MDR0.
 
void counter_clead_mrd1 (counter_t *ctx)
 Clears MDR1.
 
void counter_clear_cntr (counter_t *ctx)
 Clears CNTR.
 
void counter_clear_str (counter_t *ctx)
 Clears STR.
 
void counter_initialisation (counter_t *ctx)
 Initialisation of click board with default settings.
 
void counter_init_advanced (counter_t *ctx, uint8_t mdr0_set, uint8_t mdr1_set)
 Initialisation of click board with specific settings.
 
void counter_enable (counter_t *ctx)
 Enables counting ( Software mode )
 
void counter_disable (counter_t *ctx)
 Disables counting ( Software mode )
 
void counter_chip_enable (counter_t *ctx)
 Enables counting ( Hardware mode )
 
void counter_chip_disable (counter_t *ctx)
 Disables counting ( Hardware mode )
 
uint8_t get_int_state (counter_t *ctx)
 Function for get int-pin state.
 

Detailed Description

Function Documentation

◆ counter_cfg_setup()

void counter_cfg_setup ( counter_cfg_t * cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

@description This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ counter_chip_disable()

void counter_chip_disable ( counter_t * ctx)

Disables counting ( Hardware mode )

Parameters
ctxClick object.

@description This function disables counting in hardware mode.

◆ counter_chip_enable()

void counter_chip_enable ( counter_t * ctx)

Enables counting ( Hardware mode )

Parameters
ctxClick object.

@description This function enables counting in hardware mode.

◆ counter_clead_mrd1()

void counter_clead_mrd1 ( counter_t * ctx)

Clears MDR1.

Parameters
ctxClick object.

@description This function clears MDR1.

◆ counter_clear_cntr()

void counter_clear_cntr ( counter_t * ctx)

Clears CNTR.

Parameters
ctxClick object.

@description This function clears CNTR.

◆ counter_clear_mrd0()

void counter_clear_mrd0 ( counter_t * ctx)

Clears MDR0.

Parameters
ctxClick object.

@description This function clears MDR0.

◆ counter_clear_str()

void counter_clear_str ( counter_t * ctx)

Clears STR.

Parameters
ctxClick object.
Note
Resets all status bits except CEN and U/D. In quadrature mode, if the
quadrature clocks have been halted, the status bits CY, BW and CMP are not
affected by a “CLR STR” command under the following conditions:
     CY: If CNTR = FFFFFFFF with status bit U/D = 1
     BW: If CNTR = 0 with status bit U/D = 0
     CMP: If CNTR = DTR
In non-quadrature mode the same rules apply if input A is held at
logic low.

@description This function clears STR

◆ counter_default_cfg()

void counter_default_cfg ( counter_t * ctx)

Click Default Configuration function.

Parameters
ctxClick object.

@description This function executes default configuration for Counter click.

◆ counter_disable()

void counter_disable ( counter_t * ctx)

Disables counting ( Software mode )

Parameters
ctxClick object.

@description This function disables counting in software mode.

◆ counter_enable()

void counter_enable ( counter_t * ctx)

Enables counting ( Software mode )

Parameters
ctxClick object.

@description This function enables counting in software mode.

◆ counter_generic_transfer()

void counter_generic_transfer ( counter_t * ctx,
uint8_t * wr_buf,
uint16_t wr_len,
uint8_t * rd_buf,
uint16_t rd_len )

Generic transfer function.

Parameters
ctxClick object.
wr_bufWrite data buffer
wr_lenNumber of byte in write data buffer
rd_bufRead data buffer
rd_lenNumber of byte in read data buffer

@description Generic SPI transfer, for sending and receiving packages

◆ counter_init()

COUNTER_RETVAL counter_init ( counter_t * ctx,
counter_cfg_t * cfg )

Initialization function.

Parameters
counterClick object.
cfgClick configuration structure.

@description This function initializes all necessary pins and peripherals used for this click.

◆ counter_init_advanced()

void counter_init_advanced ( counter_t * ctx,
uint8_t mdr0_set,
uint8_t mdr1_set )

Initialisation of click board with specific settings.

Parameters
ctxClick object.
mdr0_setSettings for mdr0.
mdr1_setSettings for mdr1.

@description This function initialize of click board with specific settings.

◆ counter_initialisation()

void counter_initialisation ( counter_t * ctx)

Initialisation of click board with default settings.

Parameters
ctxClick object.
Note
MDR0 settings :
     4X quad
     Free run
     Counter index disabled
     Filter clock division 1

MDR1 settings :
     Counter mode 32
     Counter disabled
     Flags disabled

@description This function initialize of click board with default settings.

◆ counter_load_cntr()

void counter_load_cntr ( counter_t * ctx)

Loads CNTR from DTR.

Parameters
ctxClick object.
Note
The CNTR is a software configurable 8, 16, 24 or 32-bit up/down counter which counts the up/down pulses resulting from the quadrature clocks applied at the A and B inputs, or alternatively, in non-quadrature mode, pulses applied at the A input.

@description This function loads CNTR from DTR, using click object.

◆ counter_load_otr()

void counter_load_otr ( counter_t * ctx)

Loads OTR from CNTR.

Parameters
ctxClick object.
Note
The OTR is a software configuration 8, 16, 24 or 32-bit register which can be read back on the MISO output. Since instantaneous CNTR value is often needed to be read while the CNTR continues to count, the OTR serves as a convenient dump site for instantaneous CNTR data which can then be read without interfering with the counting process.

@description This function loads OTR from CNTR, using click object.

◆ counter_read_cntr()

int32_t counter_read_cntr ( counter_t * ctx)

Reads CNTR.

Parameters
ctxClick object.
Returns
CNTR register data.

@description This function reads CNTR, using click object.

◆ counter_read_dtr()

int32_t counter_read_dtr ( counter_t * ctx)

Reads DTR.

Parameters
ctxClick object.
Returns
DTR register data.

@description This function reads DTR, using click object.

◆ counter_read_mdr0()

uint8_t counter_read_mdr0 ( counter_t * ctx)

Reads MDR0.

Parameters
ctxClick object.
Returns
Data from MDR0.

@description This function reads MDR0, using click object.

◆ counter_read_mdr1()

uint8_t counter_read_mdr1 ( counter_t * ctx)

Reads MDR1.

Parameters
ctxClick object.
Returns
Data from MDR1.

@description This function reads MDR1, using click object.

◆ counter_read_otr()

int32_t counter_read_otr ( counter_t * ctx)

Reads OTR.

Parameters
ctxClick object.
Returns
OTR register data.

@description This function reads OTR, using click object.

◆ counter_read_str()

uint8_t counter_read_str ( counter_t * ctx)

Reads STR.

Parameters
ctxClick object.
Returns
Status register data.
Note
The STR is an 8-bit status register which stores count related status
information.

B0 - Sign bit. 1: negative, 0: positive
B1 - Count direction indicator: 0: count down, 1: count up
B2 - Power loss indicator latch; set upon power up
B3 - Count enable status: 0: counting disabled, 1: counting enabled
B4 - Index latch
B5 - Compare (CNTR = DTR) latch
B6 - Borrow (CNTR underflow) latch
B7 - Carry (CNTR overflow) latch

@description This function reads STR, using click object.

◆ counter_write_dtr()

void counter_write_dtr ( counter_t * ctx,
uint8_t * buffer )

Writes data into DTR.

Parameters
ctxClick object.
bufferData to be written into DTR.
Note
The DTR is a software configurable 8, 16, 24 or 32-bit input data register which can be written into directly from MOSI, the serial input. The DTR data can be transferred into the 32-bit counter (CNTR) under program control or by hardware index signal.

@description This function writes data into DTR, using click object.

◆ counter_write_mdr0()

void counter_write_mdr0 ( counter_t * ctx,
uint8_t settings )

Writes data into MDR0.

Parameters
ctxClick object.
settingsMDR0 settings.
Note
The MDR0 (Mode Register 0) is an 8-bit read/write register that sets up the operating mode for the LS7366. Upon power up MDR0 is cleared to zero.

@description This function writes data into MDR0, using click object.

◆ counter_write_mdr1()

void counter_write_mdr1 ( counter_t * ctx,
uint8_t settings )

Writes data into MDR1.

Parameters
ctxClick object.
settingsMDR1 settings.
Note
The MDR1 (Mode Register 1) is an 8-bit read/write register which is appended to MDR0 for additional modes. Upon power-up MDR1 is cleared to zero.

@description This function writes data into MDR1, using click object.

◆ get_int_state()

uint8_t get_int_state ( counter_t * ctx)

Function for get int-pin state.

Parameters
ctxClick object.
Returns
Int pin state.

@description This function gets int-pin state.