co2 2.0.0.0
CO2 Click Driver

API for configuring and manipulating CO2 Click driver. More...

Topics

 CO2 Registers List
 List of registers of CO2 Click driver.
 
 CO2 Registers Settings
 Settings for registers of CO2 Click driver.
 
 CO2 MikroBUS Map
 MikroBUS pin mapping of CO2 Click driver.
 

Functions

void co2_cfg_setup (co2_cfg_t *cfg)
 CO2 configuration object setup function.
 
err_t co2_init (co2_t *ctx, co2_cfg_t *cfg)
 CO2 initialization function.
 
err_t co2_default_cfg (co2_t *ctx)
 CO2 default configuration function.
 
err_t co2_generic_write (co2_t *ctx, uint16_t reg, uint16_t *tx_buf, uint8_t tx_len)
 CO2 I2C writing function.
 
err_t co2_generic_read (co2_t *ctx, uint16_t reg, uint16_t *rx_buf, uint8_t rx_len)
 CO2 I2C reading function.
 
err_t co2_reset (co2_t *ctx)
 Reset device.
 
err_t co2_get_id (co2_t *ctx)
 Read device and serial ID's.
 
err_t co2_set_reference (co2_t *ctx, uint16_t humidity, uint16_t pressure)
 Set device refrence values for gas calculation.
 
err_t co2_read_gas (co2_t *ctx, float *gas_concentration, float *temperature)
 Read CO2 concentration and temperature value.
 
err_t co2_disable_crc (co2_t *ctx)
 Disable use of CRC.
 

Detailed Description

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

◆ co2_cfg_setup()

void co2_cfg_setup ( co2_cfg_t * cfg)

CO2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ co2_default_cfg()

err_t co2_default_cfg ( co2_t * ctx)

CO2 default configuration function.

This function executes a default configuration of CO2 click board.

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

◆ co2_disable_crc()

err_t co2_disable_crc ( co2_t * ctx)

Disable use of CRC.

This function sends command to disable crc data for device.

Parameters
[in]ctx: Click context object. See co2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
For safety related applications it is strongly recommended to not disable the CRC.

◆ co2_generic_read()

err_t co2_generic_read ( co2_t * ctx,
uint16_t reg,
uint16_t * rx_buf,
uint8_t rx_len )

CO2 I2C reading function.

This function reads a desired number of data starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See co2_t object definition for detailed explanation.
[in]reg: Start register address.
[out]rx_buf: Output read data.
[in]rx_len: Number of words to be read.
Returns
  • 0 - Success,
  • -1 - Error,
  • -3 - CRC Error.
See #err_t definition for detailed explanation.
Note
None.

◆ co2_generic_write()

err_t co2_generic_write ( co2_t * ctx,
uint16_t reg,
uint16_t * tx_buf,
uint8_t tx_len )

CO2 I2C writing function.

This function writes a desired number of data starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See co2_t object definition for detailed explanation.
[in]reg: Start register address.
[in]tx_buf: Data to be written.
[in]tx_len: Number of words to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ co2_get_id()

err_t co2_get_id ( co2_t * ctx)

Read device and serial ID's.

This function reads device and serial ID's and set places that data in the context object.

Parameters
[in,out]ctx: Click context object. See co2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ co2_init()

err_t co2_init ( co2_t * ctx,
co2_cfg_t * cfg )

CO2 initialization function.

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

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

◆ co2_read_gas()

err_t co2_read_gas ( co2_t * ctx,
float * gas_concentration,
float * temperature )

Read CO2 concentration and temperature value.

This function reads CO2 gas concentration and temperature from device.

Parameters
[in]ctx: Click context object. See co2_t object definition for detailed explanation.
[out]gas_concentration: CO2 concentartion data in %.
[out]temperature: Temperature data in degC.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ co2_reset()

err_t co2_reset ( co2_t * ctx)

Reset device.

This function sends command to reset device.

Parameters
[in]ctx: Click context object. See co2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.

◆ co2_set_reference()

err_t co2_set_reference ( co2_t * ctx,
uint16_t humidity,
uint16_t pressure )

Set device refrence values for gas calculation.

This function set reference values for device to calculate gas concetration. If reference values aren't set device will look at them like 0.

Parameters
[in]ctx: Click context object. See co2_t object definition for detailed explanation.
[in]humidity: Humidity value in %.
[in]pressure: Pressure value in mBar.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.