smartsens2 2.0.0.0
Smart Sens 2 Click Driver

API for configuring and manipulating Smart Sens 2 Click driver. More...

Topics

 Smart Sens 2 Registers List
 List of registers of Smart Sens 2 Click driver.
 
 Smart Sens 2 Registers Settings
 Settings for registers of Smart Sens 2 Click driver.
 
 Smart Sens 2 MikroBUS Map
 MikroBUS pin mapping of Smart Sens 2 Click driver.
 

Functions

void smartsens2_cfg_setup (smartsens2_cfg_t *cfg)
 Smart Sens 2 configuration object setup function.
 
void smartsens2_drv_interface_selection (smartsens2_cfg_t *cfg, smartsens2_drv_t drv_sel)
 Smart Sens 2 driver interface setup function.
 
err_t smartsens2_init (smartsens2_t *ctx, smartsens2_cfg_t *cfg)
 Smart Sens 2 initialization function.
 
err_t smartsens2_default_cfg (smartsens2_t *ctx)
 Smart Sens 2 default configuration function.
 
err_t smartsens2_generic_write (smartsens2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Smart Sens 2 data writing function.
 
err_t smartsens2_generic_read (smartsens2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Smart Sens 2 data reading function.
 
err_t smartsens2_byte_write (smartsens2_t *ctx, uint8_t reg, uint8_t data_in)
 Byte writing function.
 
err_t smartsens2_byte_read (smartsens2_t *ctx, uint8_t reg, uint8_t *data_out)
 Byte reading function.
 
uint8_t smartsens2_get_interrupt (smartsens2_t *ctx)
 Get interrupt.
 
err_t smartsens2_cmd_write (smartsens2_t *ctx, uint16_t cmd, uint8_t *cmd_buf, uint16_t cmd_len)
 Send command.
 
err_t smartsens2_status_read (smartsens2_t *ctx, uint16_t *cmd, uint8_t *cmd_buf, uint16_t *cmd_len)
 Read Status and Debug FIFO.
 
err_t smartsens2_get_parameter (smartsens2_t *ctx, uint16_t parameter, uint8_t *parameter_buf, uint16_t *parameter_len)
 Get command parameters response.
 
void smartsens2_reset (smartsens2_t *ctx)
 Reset device.
 
err_t smartsens2_sw_reset (smartsens2_t *ctx)
 SW Reset device.
 
err_t smartsens2_update_firmware (smartsens2_t *ctx)
 Upload firmware image to the device.
 
err_t smartsens2_boot_firmware (smartsens2_t *ctx)
 Boot firmware image.
 
err_t smartsens2_power_on_device (smartsens2_t *ctx)
 Power on device boot/upload firmware to device.
 
err_t smartsens2_update_virtual_sensor_list (smartsens2_t *ctx)
 Update the callback table's information.
 
err_t smartsens2_get_virt_sensor_list (smartsens2_t *ctx, uint8_t *sensor_list)
 Get the virtual sensor list.
 
err_t smartsens2_set_virt_sensor_cfg (smartsens2_t *ctx, uint8_t sensor_id, float sample_rate, uint32_t latency)
 Set configuration fro virtual sensor.
 
err_t smartsens2_get_and_process_fifo (smartsens2_t *ctx, uint8_t *work_buffer, uint32_t buffer_size)
 Get and process the FIFO.
 
err_t smartsens2_register_fifo_parse_callback (smartsens2_t *ctx, uint8_t sensor_id, smartsens2_fifo_parse_callback_t callback, void *callback_ref)
 Link a callback to virtual sensor.
 

Detailed Description

API for configuring and manipulating Smart Sens 2 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

◆ smartsens2_boot_firmware()

err_t smartsens2_boot_firmware ( smartsens2_t * ctx)

Boot firmware image.

This function boots firmware and starts firmware from RAM or FLASH depending of your define setup.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
If you want to upload firmware to the device Flash you need to set SMARTSENS2_FLASH to 1, but if you want to boot from RAM that macro should be set to 0 and set SMARTSENS2_RAM to 1.

◆ smartsens2_byte_read()

err_t smartsens2_byte_read ( smartsens2_t * ctx,
uint8_t reg,
uint8_t * data_out )

Byte reading function.

This function reads a byte from the selected register.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read byte.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ smartsens2_byte_write()

err_t smartsens2_byte_write ( smartsens2_t * ctx,
uint8_t reg,
uint8_t data_in )

Byte writing function.

This function writes a byte to the selected register.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: Byte to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ smartsens2_cfg_setup()

void smartsens2_cfg_setup ( smartsens2_cfg_t * cfg)

Smart Sens 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ smartsens2_cmd_write()

err_t smartsens2_cmd_write ( smartsens2_t * ctx,
uint16_t cmd,
uint8_t * cmd_buf,
uint16_t cmd_len )

Send command.

This function sends command and it's parameters to the device.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
[in]cmd: Command.
[in]cmd_buf: Command parameter buffer.
[in]cmd_len: Command parameter buffer length.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
If command doesn't have parameter set cmd_buf to NULL and cmd_len to 0.

◆ smartsens2_default_cfg()

err_t smartsens2_default_cfg ( smartsens2_t * ctx)

Smart Sens 2 default configuration function.

This function executes a default configuration of Smart Sens 2 click board.

Parameters
[in]ctx: Click context object. See smartsens2_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.

◆ smartsens2_drv_interface_selection()

void smartsens2_drv_interface_selection ( smartsens2_cfg_t * cfg,
smartsens2_drv_t drv_sel )

Smart Sens 2 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 smartsens2_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See smartsens2_drv_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be call 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.

◆ smartsens2_generic_read()

err_t smartsens2_generic_read ( smartsens2_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Smart Sens 2 data reading function.

This function reads a desired number of data bytes starting from the selected register.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ smartsens2_generic_write()

err_t smartsens2_generic_write ( smartsens2_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Smart Sens 2 data writing function.

This function writes a desired number of data bytes starting from the selected register.

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

◆ smartsens2_get_and_process_fifo()

err_t smartsens2_get_and_process_fifo ( smartsens2_t * ctx,
uint8_t * work_buffer,
uint32_t buffer_size )

Get and process the FIFO.

Function to get and process the FIFOs.

Parameters
[in]work_buffer: Reference to the data buffer where the FIFO data is copied to before parsing.
[in]buffer_size: Size of the data buffer.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ smartsens2_get_interrupt()

uint8_t smartsens2_get_interrupt ( smartsens2_t * ctx)

Get interrupt.

This function reads interrupt pin state.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
Returns
Interrupt pin state.

◆ smartsens2_get_parameter()

err_t smartsens2_get_parameter ( smartsens2_t * ctx,
uint16_t parameter,
uint8_t * parameter_buf,
uint16_t * parameter_len )

Get command parameters response.

This function sends command and awaits response from status and debug FIFO.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
[in]parameter: Command to read parameters from.
[out]parameter_buf: Command parameter buffer.
[out]parameter_len: Command parameter buffer length.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ smartsens2_get_virt_sensor_list()

err_t smartsens2_get_virt_sensor_list ( smartsens2_t * ctx,
uint8_t * sensor_list )

Get the virtual sensor list.

Function to get the virtual sensor list.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
[out]sensor_list: Reference to the 32byte data buffer that stores the sensor list as a bit format.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ smartsens2_init()

err_t smartsens2_init ( smartsens2_t * ctx,
smartsens2_cfg_t * cfg )

Smart Sens 2 initialization function.

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

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

◆ smartsens2_power_on_device()

err_t smartsens2_power_on_device ( smartsens2_t * ctx)

Power on device boot/upload firmware to device.

This function sends command and its parameters to the device.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
If you want to upload firmware to the device Flash you need to set SMARTSENS2_FLASH to 1, but if you want to boot from RAM that macro should be set to 0 and set SMARTSENS2_RAM to 1.

◆ smartsens2_register_fifo_parse_callback()

err_t smartsens2_register_fifo_parse_callback ( smartsens2_t * ctx,
uint8_t sensor_id,
smartsens2_fifo_parse_callback_t callback,
void * callback_ref )

Link a callback to virtual sensor.

Function to link a callback and relevant reference when the sensor event is available in the FIFO.

Parameters
[in]sensor_id: Sensor ID of the virtal sensor
[in]callback: Reference of the callback function
[in]callback_ref: Reference needed inside the callback function. Can be NULL.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ smartsens2_reset()

void smartsens2_reset ( smartsens2_t * ctx)

Reset device.

This function hardware resets device by toggling rst pin.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
Returns
Nothing.

◆ smartsens2_set_virt_sensor_cfg()

err_t smartsens2_set_virt_sensor_cfg ( smartsens2_t * ctx,
uint8_t sensor_id,
float sample_rate,
uint32_t latency )

Set configuration fro virtual sensor.

Function to set the sample rate and latency of the virtual sensor.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
[in]sensor_id: Sensor ID of the virtual sensor
[in]sample_rate: Sample rate in Hz
[in]latency: Report latency in milliseconds
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ smartsens2_status_read()

err_t smartsens2_status_read ( smartsens2_t * ctx,
uint16_t * cmd,
uint8_t * cmd_buf,
uint16_t * cmd_len )

Read Status and Debug FIFO.

This function reads status and debug fifo for command and it's length, if cmd_len is >0 it will also read command parameter resposne.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
[out]cmd: Command read.
[out]cmd_buf: Command parameter buffer.
[out]cmd_len: Command parameter buffer length.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.

◆ smartsens2_sw_reset()

err_t smartsens2_sw_reset ( smartsens2_t * ctx)

SW Reset device.

This function software resets device by setting reset bit in Reset Request register(0x14).

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

◆ smartsens2_update_firmware()

err_t smartsens2_update_firmware ( smartsens2_t * ctx)

Upload firmware image to the device.

This function will upload firmware image to device RAM or FLASH depending of your define setup.

Parameters
[in]ctx: Click context object. See smartsens2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
If you want to upload firmware to the device Flash you need both SMARTSENS2_FLASHIMG and SMARTSENS2_FLASH to set to 1, but if you want to use only device RAM both of that macros should be set to 0 and SMARTSENS2_RAM should be set to 1.

◆ smartsens2_update_virtual_sensor_list()

err_t smartsens2_update_virtual_sensor_list ( smartsens2_t * ctx)

Update the callback table's information.

Function to update the callback table's information

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