sensor-xensiv-pasco2
XENSIV PAS CO2 Sensor platform functions

General Description

XENSIV PAS CO2 Sensor platform functions.

To adapt the driver to your platform you need to provide an implementation for the functions declared in this file. See example implementation in xensiv_pasco2_mtb.c using the PSoC6 HAL.

Functions

int32_t xensiv_pasco2_plat_i2c_transfer (void *ctx, uint16_t dev_addr, const uint8_t *tx_buffer, size_t tx_len, uint8_t *rx_buffer, size_t rx_len)
 Target platform-specific function to perform I2C write/read transfer. More...
 
int32_t xensiv_pasco2_plat_uart_read (void *ctx, uint8_t *data, size_t len)
 Target platform-specific function to read over UART. More...
 
int32_t xensiv_pasco2_plat_uart_write (void *ctx, uint8_t *data, size_t len)
 Target platform-specific function to write over UART. More...
 
void xensiv_pasco2_plat_delay (uint32_t ms)
 Target platform-specific function that waits for a specified time period in milliseconds. More...
 
uint16_t xensiv_pasco2_plat_htons (uint16_t x)
 Target platform-specific function to reverse the byte order (16-bit) A sample implementation would look like. More...
 
void xensiv_pasco2_plat_assert (int expr)
 Target platform-specific function that implements a runtime assertion; used to verify the assumptions made by the program and take appropiate actions if assumption is false. More...
 

Function Documentation

◆ xensiv_pasco2_plat_i2c_transfer()

int32_t xensiv_pasco2_plat_i2c_transfer ( void *  ctx,
uint16_t  dev_addr,
const uint8_t *  tx_buffer,
size_t  tx_len,
uint8_t *  rx_buffer,
size_t  rx_len 
)

Target platform-specific function to perform I2C write/read transfer.

Synchronously writes a block of data and optionally receive a block of data.

Parameters
[in]ctxTarget platform object
[in]dev_addrdevice address (7-bit)
[in]tx_bufferI2C send data
[in]tx_lenI2C send data size
[in]rx_bufferI2C receive data
Note
Can be NULL to indicate no read access.
Parameters
[in]rx_lenI2C receive data size
Returns
XENSIV_PASCO2_OK if the I2C transfer was successful; an error indicating what went wrong otherwise

◆ xensiv_pasco2_plat_uart_read()

int32_t xensiv_pasco2_plat_uart_read ( void *  ctx,
uint8_t *  data,
size_t  len 
)

Target platform-specific function to read over UART.

Parameters
[in]ctxUART object
[out]dataReceive buffer
[in]lenNumber of bytes to receive
Returns
XENSIV_PASCO2_OK if the UART read was successful; an error indicating what went wrong otherwise

◆ xensiv_pasco2_plat_uart_write()

int32_t xensiv_pasco2_plat_uart_write ( void *  ctx,
uint8_t *  data,
size_t  len 
)

Target platform-specific function to write over UART.

Parameters
[in]ctxUART object
[in]dataTransmit buffer
[in]lenNumber of bytes to transmit
Returns
XENSIV_PASCO2_OK if the UART write was successful; an error indicating what went wrong otherwise

◆ xensiv_pasco2_plat_delay()

void xensiv_pasco2_plat_delay ( uint32_t  ms)

Target platform-specific function that waits for a specified time period in milliseconds.

Parameters
[in]msNumber of miliseconds to wait for

◆ xensiv_pasco2_plat_htons()

uint16_t xensiv_pasco2_plat_htons ( uint16_t  x)

Target platform-specific function to reverse the byte order (16-bit) A sample implementation would look like.

return ((uint16_t)(((x & 0x00ffU) << 8) |
((x & 0xff00U) >> 8)));
Parameters
[in]xValue to reverse
Returns
Reversed value

◆ xensiv_pasco2_plat_assert()

void xensiv_pasco2_plat_assert ( int  expr)

Target platform-specific function that implements a runtime assertion; used to verify the assumptions made by the program and take appropiate actions if assumption is false.

Parameters
[in]exprExpression to be verified