counter2 2.2.0
Loading...
Searching...
No Matches
Counter 2 Click Driver

API for configuring and manipulating Counter 2 Click driver. More...

Topics

 Counter 2 Settings
 Settings of Counter 2 Click driver.
 Counter 2 MikroBUS Map
 MikroBUS pin mapping of Counter 2 Click driver.

Functions

void counter2_cfg_setup (counter2_cfg_t *cfg)
 Counter 2 configuration object setup function.
err_t counter2_init (counter2_t *ctx, counter2_cfg_t *cfg)
 Counter 2 initialization function.
void counter2_set_rst_pin (counter2_t *ctx, uint8_t state)
 Counter 2 set RST pin state function.
void counter2_reset_counter (counter2_t *ctx)
 Counter 2 reset counter function.
uint8_t counter2_get_loop_pin (counter2_t *ctx)
 Counter 2 get LOOP pin function.
uint8_t counter2_check_loop (counter2_t *ctx)
 Counter 2 check loop toggle function.
err_t counter2_get_counter (counter2_t *ctx, uint32_t *counter)
 Counter 2 get counter value function.
err_t counter2_read_free_data (counter2_t *ctx, uint32_t *free_data)
 Counter 2 read free data register function.
err_t counter2_write_free_data (counter2_t *ctx, uint32_t free_data)
 Counter 2 write free data register function.
err_t counter2_sw_reset_counter (counter2_t *ctx)
 Counter 2 software counter reset function.

Detailed Description

API for configuring and manipulating Counter 2 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ counter2_cfg_setup()

void counter2_cfg_setup ( counter2_cfg_t * cfg)

Counter 2 configuration object setup function.

This function initializes Click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See counter2_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ counter2_check_loop()

uint8_t counter2_check_loop ( counter2_t * ctx)

Counter 2 check loop toggle function.

This function checks if the LOOP pin state has changed since the last call.

Parameters
[in]ctx: Click context object. See counter2_t object definition for detailed explanation.
Returns
  • 0 - LOOP pin did not change,
  • 1 - LOOP pin changed (toggled).
Note
None.

◆ counter2_get_counter()

err_t counter2_get_counter ( counter2_t * ctx,
uint32_t * counter )

Counter 2 get counter value function.

This function reads the current 24-bit counter value via I2C.

Parameters
[in]ctx: Click context object. See counter2_t object definition for detailed explanation.
[out]counter: Pointer to variable where 24-bit counter value will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ counter2_get_loop_pin()

uint8_t counter2_get_loop_pin ( counter2_t * ctx)

Counter 2 get LOOP pin function.

This function reads the logic level of the LOOP pin.

Parameters
[in]ctx: Click context object. See counter2_t object definition for detailed explanation.
Returns
Current logic state of the LOOP pin.
Note
None.

◆ counter2_init()

err_t counter2_init ( counter2_t * ctx,
counter2_cfg_t * cfg )

Counter 2 initialization function.

This function initializes all necessary pins and peripherals used for this Click board.

Parameters
[out]ctx: Click context object. See counter2_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See counter2_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ counter2_read_free_data()

err_t counter2_read_free_data ( counter2_t * ctx,
uint32_t * free_data )

Counter 2 read free data register function.

This function reads a 21-bit value from the free data register of the device.

Parameters
[in]ctx: Click context object. See counter2_t object definition for detailed explanation.
[out]free_data: Pointer to variable where free data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ counter2_reset_counter()

void counter2_reset_counter ( counter2_t * ctx)

Counter 2 reset counter function.

This function performs a hardware counter reset by toggling the RST pin and synchronizing with the LOOP pin.

Parameters
[in]ctx: Click context object. See counter2_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ counter2_set_rst_pin()

void counter2_set_rst_pin ( counter2_t * ctx,
uint8_t state )

Counter 2 set RST pin state function.

This function sets the RST (reset) pin to the specified logic level.

Parameters
[in]ctx: Click context object. See counter2_t object definition for detailed explanation.
[in]state: Logic level to set (0 or 1).
Returns
None.
Note
None.

◆ counter2_sw_reset_counter()

err_t counter2_sw_reset_counter ( counter2_t * ctx)

Counter 2 software counter reset function.

This function performs a software counter reset by modifying and writing the free data register.

Parameters
[in]ctx: Click context object. See counter2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
Note
Internally checks and synchronizes with LOOP pin state.

◆ counter2_write_free_data()

err_t counter2_write_free_data ( counter2_t * ctx,
uint32_t free_data )

Counter 2 write free data register function.

This function writes a 21-bit value to the free data register of the device.

Parameters
[in]ctx: Click context object. See counter2_t object definition for detailed explanation.
[in]free_data: 21-bit value to be written.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.