optoencoder2  2.0.0.0
Functions

Functions

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

Detailed Description

Function Documentation

◆ optoencoder2_cfg_setup()

void optoencoder2_cfg_setup ( optoencoder2_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.

◆ optoencoder2_get_position()

int32_t optoencoder2_get_position ( optoencoder2_t ctx)

Getting encoder position.

Parameters
ctxClick object.
Returns
Current encoder position

@description This function returns current encoder position

◆ optoencoder2_init()

OPTOENCODER2_RETVAL optoencoder2_init ( optoencoder2_t ctx,
optoencoder2_cfg_t cfg 
)

Initialization function.

Parameters
optoencoder2Click object.
cfgClick configuration structure.

@description 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

@description 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

@description This function gets state of PWM pin

◆ optoencoder2_zero_counter()

void optoencoder2_zero_counter ( optoencoder2_t ctx)

Reset encoder counter.

Parameters
ctxClick object.

@description This function resets encoder counter to 0(zero)