optoencoder2 2.0.0.0

Functions

void optoencoder2_cfg_setup (optoencoder2_cfg_t *cfg)
 Config Object Initialization function.
 
err_t optoencoder2_init (optoencoder2_t *ctx, optoencoder2_cfg_t *cfg)
 Initialization function.
 
uint8_t optoencoder2_pwm_get (optoencoder2_t *ctx)
 Getting PWM pin state.
 
uint8_t optoencoder2_int_get (optoencoder2_t *ctx)
 Getting INT pin state.
 
int32_t optoencoder2_get_position (optoencoder2_t *ctx)
 Getting encoder position.
 
void optoencoder2_zero_counter (optoencoder2_t *ctx)
 Reset encoder counter.
 
uint8_t optoencoder2_isr (optoencoder2_t *ctx, uint8_t n_cycles)
 Incrementing/decrementing encoder counter.
 

Detailed Description

Function Documentation

◆ optoencoder2_cfg_setup()

void optoencoder2_cfg_setup ( optoencoder2_cfg_t * cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ optoencoder2_get_position()

int32_t optoencoder2_get_position ( optoencoder2_t * ctx)

Getting encoder position.

Parameters
ctxClick object.
Returns
Current encoder position

This function returns current encoder position

◆ optoencoder2_init()

err_t optoencoder2_init ( optoencoder2_t * ctx,
optoencoder2_cfg_t * cfg )

Initialization function.

Parameters
optoencoder2Click object.
cfgClick configuration structure.

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

◆ optoencoder2_int_get()

uint8_t optoencoder2_int_get ( optoencoder2_t * ctx)

Getting INT pin state.

Parameters
ctxClick object.
Returns
0 for INT pin LOW state
1 for INT pin HIGH state

This function gets state of INT pin

◆ optoencoder2_isr()

uint8_t optoencoder2_isr ( optoencoder2_t * ctx,
uint8_t n_cycles )

Incrementing/decrementing encoder counter.

Parameters
n_cyclesNumber of times(cycles) used to detect rising edge on channel A
ctxClick object.
Note
This function - increments/decrements encoder position
              - checks for rising edge on Channel A (INT pin), within specified number of cycles (n_cycles), and increments or decrements encoder position
              - increments encoder position if Channel B (PWM pin) is in LOW state
              - decrements encoder position if Channel B (PWM pin) is in HIGH state
              - can be used to detect direction of rotation by comparing two consecutive encoder positions
Returns
0 if rising edge on channel A had been detected, within specified number of cycles (n_cycles)
1 if rising edge on channel A had not been detected, within specified number of cycles (n_cycles)

◆ optoencoder2_pwm_get()

uint8_t optoencoder2_pwm_get ( optoencoder2_t * ctx)

Getting PWM pin state.

Parameters
ctxClick object.
Returns
0 for PWM pin LOW state
1 for PWM pin HIGH state

This function gets state of PWM pin

◆ optoencoder2_zero_counter()

void optoencoder2_zero_counter ( optoencoder2_t * ctx)

Reset encoder counter.

Parameters
ctxClick object.

This function resets encoder counter to 0(zero)