smartsens2 2.0.0.0
|
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. | |
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.
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.
[in] | ctx | : Click context object. See smartsens2_t object definition for detailed explanation. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. 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.
[in] | ctx | : Click context object. See smartsens2_t object definition for detailed explanation. |
[in] | reg | : Start register address. |
[out] | data_out | : Output read byte. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. 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.
[in] | ctx | : Click context object. See smartsens2_t object definition for detailed explanation. |
[in] | reg | : Register address. |
[in] | data_in | : Byte to be written. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. void smartsens2_cfg_setup | ( | smartsens2_cfg_t * | cfg | ) |
Smart Sens 2 configuration object setup function.
This function initializes click configuration structure to initial values.
[out] | cfg | : Click configuration structure. See smartsens2_cfg_t object definition for detailed explanation. |
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.
[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. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. 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.
[in] | ctx | : Click context object. See smartsens2_t object definition for detailed explanation. |
0
- Success, -1
- Error.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.
[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. |
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.
[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. |
0
- Success, -1
- Error.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.
[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. |
0
- Success, -1
- Error.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.
[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. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. uint8_t smartsens2_get_interrupt | ( | smartsens2_t * | ctx | ) |
Get interrupt.
This function reads interrupt pin state.
[in] | ctx | : Click context object. See smartsens2_t object definition for detailed explanation. |
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.
[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. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. 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.
[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. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. 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.
[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. |
0
- Success, -1
- Error.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.
[in] | ctx | : Click context object. See smartsens2_t object definition for detailed explanation. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. 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.
[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. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. void smartsens2_reset | ( | smartsens2_t * | ctx | ) |
Reset device.
This function hardware resets device by toggling rst pin.
[in] | ctx | : Click context object. See smartsens2_t object definition for detailed explanation. |
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.
[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 |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. 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.
[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. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. 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).
[in] | ctx | : Click context object. See smartsens2_t object definition for detailed explanation. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. 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.
[in] | ctx | : Click context object. See smartsens2_t object definition for detailed explanation. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation. err_t smartsens2_update_virtual_sensor_list | ( | smartsens2_t * | ctx | ) |
Update the callback table's information.
Function to update the callback table's information
[in] | ctx | : Click context object. See smartsens2_t object definition for detailed explanation. |
0
- Success, -1
- Error. See #err_t definition for detailed explanation.