smartsens 2.0.0.0

Modules | Functions
Smart Sens Click Driver

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

## Modules
| Smart Sens Registers List
| List of registers of Smart Sens Click driver.
| Smart Sens Registers Settings
| Settings for registers of Smart Sens Click driver.
| Smart Sens MikroBUS Map
| MikroBUS pin mapping of Smart Sens Click driver.

## Functions
void | smartsens_cfg_setup (smartsens_cfg_t *cfg)
| Smart Sens configuration object setup function. More...
void | smartsens_drv_interface_selection (smartsens_cfg_t *cfg, smartsens_drv_t drv_sel)
| Smart Sens driver interface setup function. More...
err_t | smartsens_init (smartsens_t *ctx, smartsens_cfg_t *cfg)
| Smart Sens initialization function. More...
err_t | smartsens_default_cfg (smartsens_t *ctx)
| Smart Sens default configuration function. More...
err_t | smartsens_generic_write (smartsens_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
| Smart Sens data writing function. More...
err_t | smartsens_generic_read (smartsens_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
| Smart Sens data reading function. More...
err_t | smartsens_byte_write (smartsens_t *ctx, uint8_t reg, uint8_t data_in)
| Byte writing function. More...
err_t | smartsens_byte_read (smartsens_t *ctx, uint8_t reg, uint8_t *data_out)
| Byte reading function. More...
uint8_t | smartsens_get_interrupt (smartsens_t *ctx)
| Get interrupt. More...
err_t | smartsens_cmd_write (smartsens_t *ctx, uint16_t cmd, uint8_t *cmd_buf, uint16_t cmd_len)
| Send command. More...
err_t | smartsens_status_read (smartsens_t *ctx, uint16_t *cmd, uint8_t *cmd_buf, uint16_t *cmd_len)
| Read Status and Debug FIFO. More...
err_t | smartsens_get_parameter (smartsens_t *ctx, uint16_t parameter, uint8_t *parameter_buf, uint16_t *parameter_len)
| Get command parameters response. More...
void | smartsens_reset (smartsens_t *ctx)
| Reset device. More...
err_t | smartsens_sw_reset (smartsens_t *ctx)
| SW Reset device. More...
err_t | smartsens_update_firmware (smartsens_t *ctx)
| Upload firmware image to the device. More...
err_t | smartsens_boot_firmware (smartsens_t *ctx)
| Boot firmware image. More...
err_t | smartsens_power_on_device (smartsens_t *ctx)
| Power on device boot/upload firmware to device. More...
err_t | smartsens_update_virtual_sensor_list (smartsens_t *ctx)
| Update the callback table's information. More...
err_t | smartsens_get_virt_sensor_list (smartsens_t *ctx, uint8_t *sensor_list)
| Get the virtual sensor list. More...
err_t | smartsens_set_virt_sensor_cfg (smartsens_t *ctx, uint8_t sensor_id, float sample_rate, uint32_t latency)
| Set configuration fro virtual sensor. More...
err_t | smartsens_get_and_process_fifo (smartsens_t *ctx, uint8_t *work_buffer, uint32_t buffer_size)
| Get and process the FIFO. More...
err_t | smartsens_register_fifo_parse_callback (smartsens_t *ctx, uint8_t sensor_id, smartsens_fifo_parse_callback_t callback, void *callback_ref)
| Link a callback to virtual sensor. More...

## Detailed Description

API for configuring and manipulating Smart Sens Click driver.

## Function Documentation

## ◆ smartsens_boot_firmware()

err_t smartsens_boot_firmware | ( | smartsens_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 smartsens_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 SMARTSENS_FLASH to 1, but if you want to boot from RAM that macro should be set to 0 and set SMARTSENS_RAM to 1.

## ◆ smartsens_byte_read()

err_t smartsens_byte_read | ( | smartsens_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 smartsens_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.

## ◆ smartsens_byte_write()

err_t smartsens_byte_write | ( | smartsens_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 smartsens_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.

## ◆ smartsens_cfg_setup()

void smartsens_cfg_setup | ( | smartsens_cfg_t * | cfg | ) |

Smart Sens configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters

  [out] | cfg | : Click configuration structure. See smartsens_cfg_t object definition for detailed explanation.

Returns
  Nothing.

Note
  The all used pins will be set to unconnected state.

## ◆ smartsens_cmd_write()

err_t smartsens_cmd_write | ( | smartsens_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 smartsens_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.

## ◆ smartsens_default_cfg()

err_t smartsens_default_cfg | ( | smartsens_t * | ctx | ) |

Smart Sens default configuration function.

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

Parameters

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

## ◆ smartsens_drv_interface_selection()

void smartsens_drv_interface_selection | ( | smartsens_cfg_t * | cfg,
|  | smartsens_drv_t | drv_sel
| ) |  |

Smart Sens 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 smartsens_cfg_t object definition for detailed explanation.
  [in] | drv_sel | : Driver interface selection. See smartsens_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.

## ◆ smartsens_generic_read()

err_t smartsens_generic_read | ( | smartsens_t * | ctx,
|  | uint8_t | reg,
|  | uint8_t * | data_out,
|  | uint8_t | len
| ) |  |

Smart Sens data reading function.

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

Parameters

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

## ◆ smartsens_generic_write()

err_t smartsens_generic_write | ( | smartsens_t * | ctx,
|  | uint8_t | reg,
|  | uint8_t * | data_in,
|  | uint8_t | len
| ) |  |

Smart Sens data writing function.

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

Parameters

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

## ◆ smartsens_get_and_process_fifo()

err_t smartsens_get_and_process_fifo | ( | smartsens_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.

## ◆ smartsens_get_interrupt()

uint8_t smartsens_get_interrupt | ( | smartsens_t * | ctx | ) |

Get interrupt.

This function reads interrupt pin state.

Parameters

  [in] | ctx | : Click context object. See smartsens_t object definition for detailed explanation.

Returns
  Interrupt pin state.

## ◆ smartsens_get_parameter()

err_t smartsens_get_parameter | ( | smartsens_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 smartsens_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.

## ◆ smartsens_get_virt_sensor_list()

err_t smartsens_get_virt_sensor_list | ( | smartsens_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 smartsens_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.

## ◆ smartsens_init()

err_t smartsens_init | ( | smartsens_t * | ctx,
|  | smartsens_cfg_t * | cfg
| ) |  |

Smart Sens initialization function.

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

Parameters

  [out] | ctx | : Click context object. See smartsens_t object definition for detailed explanation.
  [in] | cfg | : Click configuration structure. See smartsens_cfg_t object definition for detailed explanation.

Returns
  - `0` - Success,
  - `-1` - Error.
  See #err_t definition for detailed explanation.

Note
  None.

## ◆ smartsens_power_on_device()

err_t smartsens_power_on_device | ( | smartsens_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 smartsens_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 SMARTSENS_FLASH to 1, but if you want to boot from RAM that macro should be set to 0 and set SMARTSENS_RAM to 1.

## ◆ smartsens_register_fifo_parse_callback()

err_t smartsens_register_fifo_parse_callback | ( | smartsens_t * | ctx,
|  | uint8_t | sensor_id,
|  | smartsens_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.

## ◆ smartsens_reset()

void smartsens_reset | ( | smartsens_t * | ctx | ) |

Reset device.

This function hardware resets device by toggling rst pin.

Parameters

  [in] | ctx | : Click context object. See smartsens_t object definition for detailed explanation.

Returns
  Nothing.

## ◆ smartsens_set_virt_sensor_cfg()

err_t smartsens_set_virt_sensor_cfg | ( | smartsens_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 smartsens_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.

## ◆ smartsens_status_read()

err_t smartsens_status_read | ( | smartsens_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 smartsens_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.

## ◆ smartsens_sw_reset()

err_t smartsens_sw_reset | ( | smartsens_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 smartsens_t object definition for detailed explanation.

Returns
  - `0` - Success,
  - `-1` - Error. See #err_t definition for detailed explanation.

## ◆ smartsens_update_firmware()

err_t smartsens_update_firmware | ( | smartsens_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 smartsens_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 SMARTSENS_FLASHIMG and SMARTSENS_FLASH to set to 1, but if you want to use only device RAM both of that macros should be set to 0 and SMARTSENS_RAM should be set to 1.

## ◆ smartsens_update_virtual_sensor_list()

err_t smartsens_update_virtual_sensor_list | ( | smartsens_t * | ctx | ) |

Update the callback table's information.

Function to update the callback table's information

Parameters

  [in] | ctx | : Click context object. See smartsens_t object definition for detailed explanation.

Returns
  - `0` - Success,
  - `-1` - Error. See #err_t definition for detailed explanation.