Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: max32630fthr Adafruit_FeatherOLED USBDevice
SSInterface Class Reference
SSInterface is Maxim's SmartSensor Interface class. More...
#include <SSInterface.h>
Public Member Functions | |
SSInterface (I2C &i2cBus, PinName ss_mfio, PinName ss_reset) | |
SSInterface constructor. | |
SSInterface (SPI &spiBus, PinName ss_mfio, PinName ss_reset) | |
SSInterface constructor. | |
~SSInterface () | |
DSInterface destructor. | |
SS_STATUS | write_cmd (uint8_t *cmd_bytes, int cmd_bytes_len, uint8_t *data, int data_len, int sleep_ms=SS_DEFAULT_CMD_SLEEP_MS) |
Write a command to the SmartSensor and get status response. | |
SS_STATUS | write_cmd (uint8_t *tx_buf, int tx_len, int sleep_ms=SS_DEFAULT_CMD_SLEEP_MS) |
Write a command to the SmartSensor and get status response. | |
SS_STATUS | read_cmd (uint8_t *cmd_bytes, int cmd_bytes_len, uint8_t *data, int data_len, uint8_t *rxbuf, int rxbuf_sz, int sleep_ms=SS_DEFAULT_CMD_SLEEP_MS) |
Write a command to the SmartSensor and get status response. | |
const char * | get_ss_fw_version () |
Get a string representing the SmartSensor firmware version. | |
const char * | get_ss_algo_version () |
Get a string representing the SmartSensor algo version. | |
const char * | get_ss_platform_name () |
Get a string representing the SmartSensor platform type. | |
SS_STATUS | reset_to_main_app () |
Reset the SmartSensor and jump to main application. | |
SS_STATUS | reset_to_bootloader () |
Reset the SmartSensor and jump to bootloader. | |
SS_STATUS | reset () |
Reset the SmartSensor. | |
SS_STATUS | self_test (int idx, uint8_t *result, int sleep_ms=SS_DEFAULT_CMD_SLEEP_MS) |
run the self test commands param[in] idx - the id of the sensor for the self test param[in] result - self-test response param[in] sleep_ms - duration of wait for read command | |
int | in_bootldr_mode () |
Check if SmartSensor is in bootloader mode. | |
SS_STATUS | get_reg (int idx, uint8_t addr, uint32_t *val) |
Read register from a device onboard SmartSensor. | |
SS_STATUS | set_reg (int idx, uint8_t addr, uint32_t val, int byte_size) |
Set register of a device onboard SmartSensor. | |
SS_STATUS | dump_reg (int idx, addr_val_pair *reg_vals, int reg_vals_sz, int *num_regs) |
Dump registers of a device onboard SmartSensor. | |
SS_STATUS | enable_sensor (int idx, int mode, ss_data_req *data_req, uint8_t ext_mode=SH_INPUT_DATA_DIRECT_SENSOR) |
Enable a device on the SmartSensor. | |
SS_STATUS | disable_sensor (int idx) |
Disable a device on the SmartSensor. | |
SS_STATUS | enable_algo (int idx, int mode, ss_data_req *data_req) |
Enable an algorithm on the SmartSensor. | |
SS_STATUS | disable_algo (int idx) |
Disable an algorithm on the SmartSensor. | |
SS_STATUS | set_algo_cfg (int algo_idx, int cfg_idx, uint8_t *cfg, int cfg_sz) |
Set the value of an algorithm configuration parameter. | |
SS_STATUS | get_algo_cfg (int algo_idx, int cfg_idx, uint8_t *cfg, int cfg_sz) |
Get the value of an algorithm configuration parameter. | |
SS_STATUS | set_data_type (int data_type, bool sc_en) |
Set the CommChannel Output Mode options. | |
SS_STATUS | get_data_type (int *data_type, bool *sc_en) |
Get the CommChannel Output Mode options. | |
SS_STATUS | set_fifo_thresh (int thresh) |
Set the number of samples for the SmartSensor to collect before issuing an interrupt. | |
SS_STATUS | get_fifo_thresh (int *thresh) |
Get the number of samples the SmartSensor will collect before issuing an interrupt. | |
SS_STATUS | feed_to_input_fifo (uint8_t *tx_buf, int tx_buf_sz, int *nb_written) |
Pass external sensor data to sensor hub. | |
SS_STATUS | get_num_samples_in_sensor_fifo (uint8_t sensor_id, int *fifo_size) |
Get the number of sambes in Sensor FIFO. | |
SS_STATUS | get_num_bytes_in_input_fifo (int *fifo_size) |
Get the total number of bytes in the Input FIFO. | |
SS_STATUS | get_sensor_fifo_size (uint8_t sensor_id, int *fifo_size) |
Get the total number of samples the Sensor's FIFO can hold. | |
SS_STATUS | get_input_fifo_size (int *fifo_size) |
Get the total number of samples the input FIFO can hold. | |
SS_STATUS | get_sensor_sample_size (uint8_t sensor_id, uint8_t *sample_size) |
Get the number of bytes per sample of a sensor. | |
SS_STATUS | send_raw (uint8_t *rawdata, int rawdata_sz) |
send raw string to I2C | |
SS_STATUS | ss_comm_check () |
Check that the SmartSensor is connected. | |
SS_STATUS | set_ebl_mode (uint8_t mode) |
Set if GPIO or CMD is used to enter bootloader and App before issuing an interrupt. | |
int | get_ebl_mode () |
Get ebl_mode value. |
Detailed Description
SSInterface is Maxim's SmartSensor Interface class.
Definition at line 314 of file SSInterface.h.
Constructor & Destructor Documentation
SSInterface | ( | I2C & | i2cBus, |
PinName | ss_mfio, | ||
PinName | ss_reset | ||
) |
SSInterface constructor.
- Parameters:
-
[in] i2cBus - reference to the I2C bus for the SmartSensor [in] ss_mfio - name of SmartSensor multi-function IO pin [in] ss_reset - name of SmartSensor Reset pin
Definition at line 46 of file SSInterface.cpp.
SSInterface | ( | SPI & | spiBus, |
PinName | ss_mfio, | ||
PinName | ss_reset | ||
) |
SSInterface constructor.
- Parameters:
-
[in] spiBus - reference to the SPI bus for the SmartSensor [in] ss_mfio - name of SmartSensor multi-function IO pin [in] ss_reset - name of SmartSensor Reset pin
Definition at line 59 of file SSInterface.cpp.
~SSInterface | ( | ) |
DSInterface destructor.
Definition at line 72 of file SSInterface.cpp.
Member Function Documentation
SS_STATUS disable_algo | ( | int | idx ) |
Disable an algorithm on the SmartSensor.
- Parameters:
-
[in] idx - Index of device
- Returns:
- SS_SUCCESS on success
Definition at line 693 of file SSInterface.cpp.
SS_STATUS disable_sensor | ( | int | idx ) |
Disable a device on the SmartSensor.
- Parameters:
-
[in] idx - Index of device
- Returns:
- SS_SUCCESS on success
Definition at line 660 of file SSInterface.cpp.
SS_STATUS dump_reg | ( | int | idx, |
addr_val_pair * | reg_vals, | ||
int | reg_vals_sz, | ||
int * | num_regs | ||
) |
Dump registers of a device onboard SmartSensor.
- Parameters:
-
[in] idx - Index of device [in] reg_vals - Array of addr_val_pairs [in] reg_vals_sz - Number of items reg_vals can hold [out] num_regs - Number of registers returned by command
- Returns:
- SS_SUCCESS on success
Definition at line 597 of file SSInterface.cpp.
SS_STATUS enable_algo | ( | int | idx, |
int | mode, | ||
ss_data_req * | data_req | ||
) |
Enable an algorithm on the SmartSensor.
- Parameters:
-
[in] idx - Index of device [in] mode - Mode to set the device to [in] data_req - Data request
- Returns:
- SS_SUCCESS on success
Definition at line 675 of file SSInterface.cpp.
SS_STATUS enable_sensor | ( | int | idx, |
int | mode, | ||
ss_data_req * | data_req, | ||
uint8_t | ext_mode = SH_INPUT_DATA_DIRECT_SENSOR |
||
) |
Enable a device on the SmartSensor.
- Parameters:
-
[in] idx - Index of device [in] mode - Mode to set the device to [in] data_req - Data request [in] ext_ - Data request
- Returns:
- SS_SUCCESS on success
Definition at line 642 of file SSInterface.cpp.
SS_STATUS feed_to_input_fifo | ( | uint8_t * | tx_buf, |
int | tx_buf_sz, | ||
int * | nb_written | ||
) |
Pass external sensor data to sensor hub.
- Parameters:
-
[in] num_samples in tx_buf [in] tx_buf - Host sample data to send sensor hub [in] tx_buf_sz - Number of bytes of tx_buf [out] nb_written - Number of samples to sensor hub's input FIFO
- Returns:
- SS_SUCCESS on success
Definition at line 945 of file SSInterface.cpp.
SS_STATUS get_algo_cfg | ( | int | algo_idx, |
int | cfg_idx, | ||
uint8_t * | cfg, | ||
int | cfg_sz | ||
) |
Get the value of an algorithm configuration parameter.
- Parameters:
-
[in] algo_idx Index of algorithm [in] cfg_idx Index of configuration parameter [in] cfg Array of configuration bytes to be filled in [in] cfg_sz Number of bytes to be read
- Returns:
- SS_SUCCESS on success
Definition at line 720 of file SSInterface.cpp.
SS_STATUS get_data_type | ( | int * | data_type, |
bool * | sc_en | ||
) |
Get the CommChannel Output Mode options.
- Parameters:
-
[out] data_type - 0 for only algorithm data 1 for only raw sensor data 2 for algo + raw sensor data 3 for no data [in] sc_en - If true, SmartSensor prepends data with 1 byte sample count
- Returns:
- SS_SUCCESS on success
Definition at line 757 of file SSInterface.cpp.
int get_ebl_mode | ( | ) |
SS_STATUS get_fifo_thresh | ( | int * | thresh ) |
Get the number of samples the SmartSensor will collect before issuing an interrupt.
- Parameters:
-
[out] thresh - Number of samples (1-255) collected before interrupt
- Returns:
- SS_SUCCESS on success
Definition at line 786 of file SSInterface.cpp.
SS_STATUS get_input_fifo_size | ( | int * | fifo_size ) |
Get the total number of samples the input FIFO can hold.
- Parameters:
-
[out] fifo_size - Input FIFO size
- Returns:
- SS_SUCCESS on success
Definition at line 892 of file SSInterface.cpp.
SS_STATUS get_num_bytes_in_input_fifo | ( | int * | fifo_size ) |
Get the total number of bytes in the Input FIFO.
- Parameters:
-
[out] fifo_size - Input FIFO size
- Returns:
- SS_SUCCESS on success
Definition at line 931 of file SSInterface.cpp.
SS_STATUS get_num_samples_in_sensor_fifo | ( | uint8_t | sensor_id, |
int * | fifo_size | ||
) |
Get the number of sambes in Sensor FIFO.
- Parameters:
-
[in] sensor_id - Sensor id to read FIFO size [out] fifo_size - Sensor's FIFO size
- Returns:
- SS_SUCCESS on success
Definition at line 918 of file SSInterface.cpp.
SS_STATUS get_reg | ( | int | idx, |
uint8_t | addr, | ||
uint32_t * | val | ||
) |
Read register from a device onboard SmartSensor.
- Parameters:
-
[in] idx - Index of device to read [in] addr - Register address [out] val - Register value
- Returns:
- SS_SUCCESS on success
Definition at line 548 of file SSInterface.cpp.
SS_STATUS get_sensor_fifo_size | ( | uint8_t | sensor_id, |
int * | fifo_size | ||
) |
Get the total number of samples the Sensor's FIFO can hold.
- Parameters:
-
[in] sensor_id - Sensor id to read FIFO size [out] fifo_size - Sensor's FIFO size
- Returns:
- SS_SUCCESS on success
Definition at line 905 of file SSInterface.cpp.
SS_STATUS get_sensor_sample_size | ( | uint8_t | sensor_id, |
uint8_t * | sample_size | ||
) |
Get the number of bytes per sample of a sensor.
- Parameters:
-
[in] sensor_id - Sensor id to read sample size [out] sample_size - Sensor's sample size
- Returns:
- SS_SUCCESS on success
Definition at line 879 of file SSInterface.cpp.
const char * get_ss_algo_version | ( | ) |
Get a string representing the SmartSensor algo version.
If in bootloader mode, returns bootloader version
- Returns:
- Pointer to algo version string
Definition at line 282 of file SSInterface.cpp.
const char * get_ss_fw_version | ( | ) |
Get a string representing the SmartSensor firmware version.
If in bootloader mode, returns bootloader version
- Returns:
- Pointer to firmware version string
Definition at line 251 of file SSInterface.cpp.
const char * get_ss_platform_name | ( | ) |
Get a string representing the SmartSensor platform type.
- Returns:
- Pointer to platform type string
Definition at line 314 of file SSInterface.cpp.
int in_bootldr_mode | ( | ) |
Check if SmartSensor is in bootloader mode.
- Returns:
- 1 if in bootloader mode, 0 if in main app, -1 if comm error
Definition at line 237 of file SSInterface.cpp.
SS_STATUS read_cmd | ( | uint8_t * | cmd_bytes, |
int | cmd_bytes_len, | ||
uint8_t * | data, | ||
int | data_len, | ||
uint8_t * | rxbuf, | ||
int | rxbuf_sz, | ||
int | sleep_ms = SS_DEFAULT_CMD_SLEEP_MS |
||
) |
Write a command to the SmartSensor and get status response.
- Parameters:
-
[in] cmd_bytes - Pointer to the command's family and index bytes [in] cmd_idx_len - The number of bytes in the command [in] data - Pointer to the command's data bytes [in] data_len - The number data bytes [in] rxbuf - Buffer to fill in with read data (including status byte) [in] rxbuf_sz - Size of the rx buffer (to prevent overflow)
- Returns:
- SS_STATUS byte
Definition at line 473 of file SSInterface.cpp.
SS_STATUS reset | ( | ) |
Reset the SmartSensor.
If the SmartSensor was in bootloader, it will jump back into bootloader If the SmartSensor was in main app, it will jump back into main app
- Returns:
- SS_STATUS code indicating success
Definition at line 189 of file SSInterface.cpp.
SS_STATUS reset_to_bootloader | ( | ) |
Reset the SmartSensor and jump to bootloader.
- Returns:
- SS_STATUS code indicating success
Definition at line 110 of file SSInterface.cpp.
SS_STATUS reset_to_main_app | ( | ) |
Reset the SmartSensor and jump to main application.
- Returns:
- SS_STATUS code indicating success
Definition at line 76 of file SSInterface.cpp.
SS_STATUS self_test | ( | int | idx, |
uint8_t * | result, | ||
int | sleep_ms = SS_DEFAULT_CMD_SLEEP_MS |
||
) |
run the self test commands param[in] idx - the id of the sensor for the self test param[in] result - self-test response param[in] sleep_ms - duration of wait for read command
- Returns:
- SS_STATUS code indicating success
Definition at line 200 of file SSInterface.cpp.
SS_STATUS send_raw | ( | uint8_t * | rawdata, |
int | rawdata_sz | ||
) |
send raw string to I2C
- Parameters:
-
[in] *rawdata - Raw data string, after slave address [out] rawdata_sz - Raw data size
- Returns:
- SS_SUCCESS on success
Definition at line 734 of file SSInterface.cpp.
SS_STATUS set_algo_cfg | ( | int | algo_idx, |
int | cfg_idx, | ||
uint8_t * | cfg, | ||
int | cfg_sz | ||
) |
Set the value of an algorithm configuration parameter.
- Parameters:
-
[in] algo_idx Index of algorithm [in] cfg_idx Index of configuration parameter [in] cfg Array of configuration bytes [in] cfg_sz Size of cfg array
- Returns:
- SS_SUCCESS on success
Definition at line 708 of file SSInterface.cpp.
SS_STATUS set_data_type | ( | int | data_type, |
bool | sc_en | ||
) |
Set the CommChannel Output Mode options.
- Parameters:
-
[in] data_type - Set to 0 for only algorithm data Set to 1 for only raw sensor data Set to 2 for algo + raw sensor data Set to 3 for no data [in] sc_en - Set to true to receive 1 byte sample count from SmartSensor
- Returns:
- SS_SUCCESS on success
Definition at line 740 of file SSInterface.cpp.
SS_STATUS set_ebl_mode | ( | uint8_t | mode ) |
Set if GPIO or CMD is used to enter bootloader and App before issuing an interrupt.
param[in] mode
- 0: use command to enter bootloader mode
- 1: use EBL GPIO to enter bootloader mode
- Returns:
- SS_SUCCESS on success
Definition at line 179 of file SSInterface.cpp.
SS_STATUS set_fifo_thresh | ( | int | thresh ) |
Set the number of samples for the SmartSensor to collect before issuing an interrupt.
- Parameters:
-
[in] thresh - Number of samples (1-255) to collect before interrupt
- Returns:
- SS_SUCCESS on success
Definition at line 775 of file SSInterface.cpp.
SS_STATUS set_reg | ( | int | idx, |
uint8_t | addr, | ||
uint32_t | val, | ||
int | byte_size | ||
) |
Set register of a device onboard SmartSensor.
- Parameters:
-
[in] idx - Index of device to read [in] addr - Register address [in] val - Register value [in] byte_size - Size of IC register in bytes
- Returns:
- SS_SUCCESS on success
Definition at line 581 of file SSInterface.cpp.
SS_STATUS ss_comm_check | ( | ) |
Check that the SmartSensor is connected.
Definition at line 802 of file SSInterface.cpp.
SS_STATUS write_cmd | ( | uint8_t * | tx_buf, |
int | tx_len, | ||
int | sleep_ms = SS_DEFAULT_CMD_SLEEP_MS |
||
) |
Write a command to the SmartSensor and get status response.
- Parameters:
-
[in] tx_buf - Pointer to the command's family, index bytes and data bytes [in] tx_len - Total transaction lenght to send
- Returns:
- SS_STATUS byte
Definition at line 390 of file SSInterface.cpp.
SS_STATUS write_cmd | ( | uint8_t * | cmd_bytes, |
int | cmd_bytes_len, | ||
uint8_t * | data, | ||
int | data_len, | ||
int | sleep_ms = SS_DEFAULT_CMD_SLEEP_MS |
||
) |
Write a command to the SmartSensor and get status response.
- Parameters:
-
[in] cmd_bytes - Pointer to the command's family and index bytes [in] cmd_idx_len - The number of bytes in the command [in] data - Pointer to the command's data bytes [in] data_len - The number data bytes
- Returns:
- SS_STATUS byte
Definition at line 343 of file SSInterface.cpp.
Generated on Tue Jul 12 2022 20:09:29 by
