opto7 2.1.0.0
Opto 7 Click Driver

API for configuring and manipulating Opto 7 Click driver. More...

Topics

 Opto 7 Device Settings
 Settings for registers of Opto 7 Click driver.
 
 Opto 7 MikroBUS Map
 MikroBUS pin mapping of Opto 7 Click driver.
 

Functions

void opto7_cfg_setup (opto7_cfg_t *cfg)
 Opto 7 configuration object setup function.
 
void opto7_drv_interface_selection (opto7_cfg_t *cfg, opto7_drv_t drv_sel)
 Opto 7 driver interface setup function.
 
err_t opto7_init (opto7_t *ctx, opto7_cfg_t *cfg)
 Opto 7 initialization function.
 
err_t opto7_default_cfg (opto7_t *ctx)
 Opto 7 default configuration function.
 
err_t opto7_generic_write (opto7_t *ctx, uint8_t *data_in, uint16_t len)
 Opto 7 data writing function.
 
err_t opto7_generic_read (opto7_t *ctx, uint8_t *data_out, uint16_t len)
 Opto 7 data reading function.
 
void opto7_set_gp1_pin (opto7_t *ctx, uint8_t pin_state)
 Opto 7 set GP1 pin function.
 
uint8_t opto7_get_gp2_pin (opto7_t *ctx)
 Opto 7 get GP2 pin function.
 

Detailed Description

API for configuring and manipulating Opto 7 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

◆ opto7_cfg_setup()

void opto7_cfg_setup ( opto7_cfg_t * cfg)

Opto 7 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ opto7_default_cfg()

err_t opto7_default_cfg ( opto7_t * ctx)

Opto 7 default configuration function.

This function executes a default configuration of Opto 7 click board.

Parameters
[in]ctx: Click context object. See opto7_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ opto7_drv_interface_selection()

void opto7_drv_interface_selection ( opto7_cfg_t * cfg,
opto7_drv_t drv_sel )

Opto 7 driver interface setup function.

This function sets a serial driver interface which will be used further in the click driver.

Parameters
[out]cfg: Click configuration structure. See opto7_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See opto7_drv_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be called before init function to configure the driver to work with the serial interface which is consistent with the real state of the hardware. If this function is not called, the default driver interface will be set.

◆ opto7_generic_read()

err_t opto7_generic_read ( opto7_t * ctx,
uint8_t * data_out,
uint16_t len )

Opto 7 data reading function.

This function reads a desired number of data bytes by using UART serial interface.

Parameters
[in]ctx: Click context object. See opto7_t object definition for detailed explanation.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • >0 - Number of data bytes read,
  • <=0 - Error/Empty Ring buffer. See #err_t definition for detailed explanation.
Note
None.

◆ opto7_generic_write()

err_t opto7_generic_write ( opto7_t * ctx,
uint8_t * data_in,
uint16_t len )

Opto 7 data writing function.

This function writes a desired number of data bytes by using UART serial interface.

Parameters
[in]ctx: Click context object. See opto7_t object definition for detailed explanation.
[in]data_in: Data buffer for sending.
[in]len: Number of bytes for sending.
Returns
  • >=0 - Success,
  • <0 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ opto7_get_gp2_pin()

uint8_t opto7_get_gp2_pin ( opto7_t * ctx)

Opto 7 get GP2 pin function.

This function is used to get GP2 pin state.

Parameters
[in]ctx: Click context object. See opto7_t object definition for detailed explanation.
Returns
  • 1 - Pin state high,
  • 0 - Pin state low.
Note
None.

◆ opto7_init()

err_t opto7_init ( opto7_t * ctx,
opto7_cfg_t * cfg )

Opto 7 initialization function.

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

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

◆ opto7_set_gp1_pin()

void opto7_set_gp1_pin ( opto7_t * ctx,
uint8_t pin_state )

Opto 7 set GP1 pin function.

This function is used to set GP1 pin state.

Parameters
[in]ctx: Click context object. See opto7_t object definition for detailed explanation.
[in]pin_state: GP1 Pin state.
Returns
Nothing.
Note
None.