Sensor Hub#
Modules#
Enumerations#
Enumeration for Sensor HUB data reading mode.
Enumeration for Sensors HUB Callback Events.
Enumeration for GPIO Interrupt Configurations.
Enumeration for Sensor HUB data delivery mode.
Enumeration for Sensors Status.
Typedefs#
ADC bus interface configuration structure.
Functions#
Initialization Peripherals of Sensor HUB.
Detect the sensors.
Delete the specific sensor from the Sensor HUB.
Create a sensor instance in the sensor hub.
Start the sensor operation for the given sensor.
Stop the sensor operation of the given sensor.
Post the events to event manager(EM) to be notified to the application.
Task to handle the sensor operations.
Task to handle the system power operations.
Task to handle the operations of the Event Manager(EM)
Initialize the I2C Interface based on configuration.
Initialize SPI Interface based on configuration.
Scan the I2C sensors.
to get sensor implementation.
Create the sensor list index.
Get the sensor index for the sensor list.
Delete the sensor index for the sensor list.
get the sensor info from the sensor configuration structure.
Call back function to the application.
Sensor OS timer callback function.
Configuring the different types of NPSS GPIO interrupts in the Sensor HUB.
Enable and set the priority of NPSS GPIO interrupt.
Mask and Disable the NPSS GPIO interrupt.
Start the sensor hub Tasks.
set the alarm interrupt time.
initialize the Alarm block.
Configure the wake-up source for the system.
Configures sleep/wakeup sources for the system.
Change the system status from PS4 to PS2.
Change the system status from PS2 to PS4.
Initialize ADC Interface based on configuration.
Initialize and configure the systic timer for the RTOS.
I2C event handler.
Fetch ADC bus interface information.
ADC callback from RSI_ADC_InterruptHandler.
Initialize the sdc Interface based on the configuration.
Macros#
Sensor task stack size.
EM task stack size.
Power task stack size.
Max wait time of message queue in Event task.
Size of the sensors interrupt MAP table.
NPSS gpio IRQ handler.
NPSS gpio IRQ Number 21.
Periodic alarm configuration in milliseconds.
RC clock trigger time.
RO clock trigger time.
Number of hours in a day.
Number of minutes in an hour.
Number of Seconds in a minute.
Number of milliseconds in a second.
Number of months in a year.
Start year for alarm configuration.
Month with 28 days.
Month with 29 days.
Month with 30 days.
Month with 31 days.
Alarm IRQ handler.
Alarm IRQ number 28.
Creating OS timer for the sensor failed.
Deleting OS timer of the sensor failed.
Starting OS timer of the sensor failed.
Stopping OS timer of the sensor failed.
Max number of sensor limit reached.
Memory allocation for sensor data storage failed.
Sensor API is called for a sensor without creating it.
Sensor set power command execution failed.
Sensor set range command execution failed.
Sensor self-test command execution failed.
Generic error code for any invalid parameters.
Invalid gpio number.
No hal implementation found for given sensor type.
Interrupt type configuration failed.
Allocating memory for sensor hal failed.
Sensor not created.
Sensor configuration not found.
No sensor found at given address.
Invalid interrupt type is given for the sensor.
Invalid mode is given for the sensor.
Invalid delivery mode is given for the sensor.
Create sensor in HAL failed.
Delete sensor in HAL failed.
Sample sensor in HAL failed.
Control sensor in HAL failed.
Power task creation failed.
Sensor task creation failed.
EM task creation failed.
All(i2c,spi,adc) peripheral's initialization failed.
Enumeration Documentation#
sl_sensor_mode_t#
sl_sensor_mode_t
Enumeration for Sensor HUB data reading mode.
Enumerator | |
---|---|
SL_SH_POLLING_MODE | POLLING_MODE. |
SL_SH_INTERRUPT_MODE | INTERRUPT_MODE. |
SL_SH_NO_MODE |
sl_sensorhub_event_t#
sl_sensorhub_event_t
Enumeration for Sensors HUB Callback Events.
Enumerator | |
---|---|
SL_SENSOR_CREATION_FAILED | |
SL_SENSOR_STARTED | |
SL_SENSOR_STOPPED | |
SL_SENSOR_DATA_READY | |
SL_SENSOR_CNFG_INVALID | |
SL_SENSOR_START_FAILED | |
SL_SENSOR_STOP_FAILED | |
SL_SENSOR_DELETED | |
SL_SENSOR_DELETE_FAILED |
sl_gpio_intr_type_t#
sl_gpio_intr_type_t
Enumeration for GPIO Interrupt Configurations.
Enumerator | |
---|---|
SL_SH_RISE_EDGE | Interrupt at GPIO rise edge. |
SL_SH_FALL_EDGE | Interrupt at GPIO fall edge. |
SL_SH_LOW_LEVEL | Interrupt at GPIO low level. |
SL_SH_HIGH_LEVEL | Interrupt at GPIO high level. |
sl_data_deliver_mode_t#
sl_data_deliver_mode_t
Enumeration for Sensor HUB data delivery mode.
Enumerator | |
---|---|
SL_SH_THRESHOLD | Threshold value for sensor data delivery. |
SL_SH_TIMEOUT | Timeout value for sensor data delivery. |
SL_SH_NUM_OF_SAMPLES | Number of samples for sensor data delivery. |
SL_SH_NO_DATA_MODE |
sl_sensor_status_t#
sl_sensor_status_t
Enumeration for Sensors Status.
Enumerator | |
---|---|
SL_SENSOR_INVALID | Sensor is Invalid. |
SL_SENSOR_VALID | Sensor is Valid. |
SL_SENSOR_START | Sensor is Started. |
SL_SENSOR_STOP | Sensor is Stoped. |
Typedef Documentation#
Function Documentation#
sl_si91x_sensorhub_init#
sl_status_t sl_si91x_sensorhub_init ( -, -)
Initialization Peripherals of Sensor HUB.
Type | Direction | Argument Name | Description |
---|---|---|---|
[in] | - | NULL | |
[out] | - | Return the Sensor Hub bus Initialization status |
This function will initialize the Peripherals, based on the user configuration. like - I2C/SPI/ADC
Returns
status 0 if successful, else error code as follow:
SL_STATUS_FAIL (0x0001)- Fail, Peripherals initialization failed
SL_STATUS_OK (0X000)- Success, Peripherals initialization done properly
sl_si91x_sensorhub_detect_sensors#
sl_status_t sl_si91x_sensorhub_detect_sensors (sl_sensor_id_t sensor_id_info, uint8_t num_of_sensors, -)
Detect the sensors.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_sensor_id_t | [in] | sensor_id_info | - Sensor IDs |
uint8_t | [in] | num_of_sensors | - Number of sensors given by user |
[out] | - | None |
This function will detect the sensor, based on the user configuration. and it will store the scanned sensor ID in the structure.
Returns
if successful, Return number of sensors scanned else error code
sl_si91x_sensorhub_delete_sensor#
sl_status_t sl_si91x_sensorhub_delete_sensor (sl_sensor_id_t sensor_id, -)
Delete the specific sensor from the Sensor HUB.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_sensor_id_t | [in] | sensor_id | - Sensor ID |
[out] | - | Return the delete sensors status |
This function will delete the specific sensor from the sensor list, modify the sensor status to invalid, and publish the events to the event task.
Returns
status 0 if successful, else error code as follow:
SL_STATUS_FAIL (0x0001) - Fail, Delete sensor failed
SL_STATUS_OK (0X000) - Success, Delete sensor Success
sl_si91x_sensorhub_create_sensor#
sl_status_t sl_si91x_sensorhub_create_sensor (sl_sensor_id_t sensor_id, -)
Create a sensor instance in the sensor hub.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_sensor_id_t | [in] | sensor_id | - Id of sensor |
[out] | - | Return the create sensors status |
This function creates a sensor instance as per user configuration.It also allocates max sample memory for the configured sensor.
Returns
status 0 if successful, else error code as follow:
SL_STATUS_FAIL (0x0001)- Fail, Create sensor instance failed
SL_STATUS _OK (0X000) - Create sensor instanceSuccess ,
sl_si91x_sensorhub_start_sensor#
sl_status_t sl_si91x_sensorhub_start_sensor (sl_sensor_id_t sensor_id, -)
Start the sensor operation for the given sensor.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_sensor_id_t | [in] | sensor_id | - Id of sensor |
[out] | - | Return the Start sensors status |
This function can be called after creating a sensor with given sensor ID It does following operations
Starts timer for sensor with polling mode.
Enable IRQ handle for sensor with interrupt mode.
Returns
status 0 if successful, else error code as follow:
SL_STATUS_FAIL (0x0001)- Fail, Sensor start failed
SL_STATUS _OK (0X000) - Success ,Sensor start done properly
sl_si91x_sensorhub_stop_sensor#
sl_status_t sl_si91x_sensorhub_stop_sensor (sl_sensor_id_t sensor_id, -)
Stop the sensor operation of the given sensor.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_sensor_id_t | [in] | sensor_id | - Id of sensor |
[out] | - | Return the Stop sensor status |
This function does following operations
Stop the sensor operations of the given sensor.
Based on the sensor mode it will stop the Polling/interrupt mode operations and updates the sensor statutes.
Disable IRQ handles of the interrupt mode sensors.
Returns
status 0 if successful, else error code as follows:
SL_STATUS_FAIL (0x0001)- Fail, Sensor stop failed
SL_STATUS _OK (0X000) - Success ,Sensor stop done properly
sl_si91x_em_post_event#
void sl_si91x_em_post_event (sl_sensor_id_t sensor_id, sl_sensorhub_event_t event, void * dataPtr, TickType_t ticks_to_wait, -)
Post the events to event manager(EM) to be notified to the application.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_sensor_id_t | [in] | sensor_id | - id of the sensor |
sl_sensorhub_event_t | [in] | event | - sensor hub events |
void * | [in] | dataPtr | - sensor data pointer |
TickType_t | [in] | ticks_to_wait | - max time to wait for the post |
[out] | - | None |
It waits for mutex till ticks_to_wait and updates event queue if mutex is acquired
Returns
- NULL
sl_si91x_sensor_task#
void sl_si91x_sensor_task (void , -)
Task to handle the sensor operations.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None | |
[out] | - | None |
Sensor Task does following operations
Create the OS event and mutex to perform the sensor operations.
Sample the Sensor data based on the event flags.
Check the events and post the sensor data to the em task based on the sensor data delivery mode.
Returns
- NULL
sl_si91x_power_state_task#
void sl_si91x_power_state_task (void , -)
Task to handle the system power operations.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None | |
[out] | - | None |
Power state task changes the system from one power save mode to another power save mode like(PS4 to PS2),(PS2toPS4),(Sleep_mode) using Binary semaphore
Returns
- NULL
sl_si91x_em_task#
void sl_si91x_em_task (void , -)
Task to handle the operations of the Event Manager(EM)
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None | |
[out] | - | None |
Em task does following operaions
Create the osMessageQueue and mutex to perform the event operations.
Calls the callback event Returns
- NULL
sli_si91x_i2c_init#
int32_t sli_si91x_i2c_init (void , -)
Initialize the I2C Interface based on configuration.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None | |
[out] | - | None |
This function will configure/Initialize I2C Interface based on configuration.
Returns
I2C Initializtion status
sli_si91x_spi_init#
int32_t sli_si91x_spi_init (void , -)
Initialize SPI Interface based on configuration.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None | |
[out] | - | None |
This function will configure/Initialize SPI Interface based on configuration.
Returns
SPI Initializtion status.
sli_si91x_i2c_sensors_scan#
int32_t sli_si91x_i2c_sensors_scan (uint16_t address, -)
Scan the I2C sensors.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | [in] | address | - Address of sensor |
[out] | - | None |
This function will scan the I2C sensors based on the sensor address.
Returns
status 0 if successful, else it will wait for the sensor response.
sli_si91x_get_sensor_implementation#
sl_sensor_impl_type_t * sli_si91x_get_sensor_implementation (int32_t sensor_id, -)
to get sensor implementation.
Type | Direction | Argument Name | Description |
---|---|---|---|
int32_t | [in] | sensor_id | - Id of sensor |
[out] | - | None |
This function will get the sensor implementation of the sensor based on sensor ID.
Returns
if successful, returns the Sensor implementation structure else returns an error code.
sli_si91x_create_sensor_list_index#
int32_t sli_si91x_create_sensor_list_index ( -, -)
Create the sensor list index.
Type | Direction | Argument Name | Description |
---|---|---|---|
[in] | - | None | |
[out] | - | Returns the Sensor ID from the implementation struct |
This function will Create the sensor list index based on the sensor status For the maximum sensors available in the sensor hub
Returns
returns the sensor index in sensor_list
sli_si91x_get_sensor_index#
uint32_t sli_si91x_get_sensor_index (sl_sensor_id_t sensor_id, -)
Get the sensor index for the sensor list.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_sensor_id_t | [in] | sensor_id | - Id of sensor |
[out] | - | None |
This function will retrieve the sensor index from the sensor list based on the sensor status and sensor ID for the maximum number of sensors available in the sensor hub.
Returns
if successful, returns the sensor index else returns SL_SH_SENSOR_INDEX_NOT_FOUND(0XFF).
sli_si91x_delete_sensor_list_index#
uint32_t sli_si91x_delete_sensor_list_index (sl_sensor_id_t sensor_id, -)
Delete the sensor index for the sensor list.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_sensor_id_t | [in] | sensor_id | - Id of sensor |
[out] | - | None |
This function will delete the sensor from the sensor list based on The sensor ID for the maximum number of sensors available in the sensor hub.
Returns
if successful, returns the sensor index else returns error code SL_SH_SENSOR_INDEX_NOT_FOUND(0XFF).
sli_si91x_get_sensor_info#
sl_sensor_info_t * sli_si91x_get_sensor_info (sl_sensor_id_t sensor_id, -)
get the sensor info from the sensor configuration structure.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_sensor_id_t | [in] | sensor_id | - Id of sensor |
[out] | - | None |
This function will retrieve sensor data from the sensor configuration structure to update the sensor list configuration structure for the maximum number of sensors available in the sensor hub.
Returns
if successful, returns the sensor information. else returns NULL.
sl_si91x_sensorhub_notify_cb_register#
sl_status_t sl_si91x_sensorhub_notify_cb_register (sl_sensor_signalEvent_t cb_event, sl_sensor_id_t * cb_ack, -)
Call back function to the application.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_sensor_signalEvent_t | [in] | cb_event | - Pointer to the callback event |
sl_sensor_id_t * | [in] | cb_ack | - Pointer to callback acknowledge to the application |
[out] | - | None |
This function will update the callback function event and acknowledgment.
Returns
- If successful returns SL_STATUS_OK else returns error code
sl_si91x_sensors_timer_cb#
void sl_si91x_sensors_timer_cb (TimerHandle_t xTimer, -)
Sensor OS timer callback function.
Type | Direction | Argument Name | Description |
---|---|---|---|
TimerHandle_t | [in] | xTimer | - Timer handle |
[out] | - | None |
This function will set the event flag bits based on the sensor sampling intervals. In the polling mode call the timer call-back function.
Returns
- NULL
sl_si91x_gpio_interrupt_config#
sl_status_t sl_si91x_gpio_interrupt_config (uint16_t gpio_pin, sl_gpio_intr_type_t intr_type, -)
Configuring the different types of NPSS GPIO interrupts in the Sensor HUB.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | [in] | gpio_pin | - NPSS gpio pin number |
sl_gpio_intr_type_t | [in] | intr_type | NPSS gpio interrupt type |
[out] | - | None |
This function configures the NPSS gpios and enables the interrupt mode for the gpios.
Returns
- If successful returns SL_STATUS_OK else returns error code
sl_si91x_gpio_interrupt_start#
void sl_si91x_gpio_interrupt_start (uint16_t gpio_pin, -)
Enable and set the priority of NPSS GPIO interrupt.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | [in] | gpio_pin | - NPSS gpio pin number |
[out] | - | None |
This function configures and sets the priority of the NPSS GPIO interrupt. GPIO interrupt priority is (configMAX_SYSCALL_INTERRUPT_PRIORITY - 1)
Returns
- NULL
sl_si91x_gpio_interrupt_stop#
void sl_si91x_gpio_interrupt_stop (uint16_t gpio_pin, -)
Mask and Disable the NPSS GPIO interrupt.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | [in] | gpio_pin | - NPSS gpio pin number |
[out] | - | None |
This function masks and disables the IRQ handler of the NPSS GPIO interrupt.
Returns
- NULL
sl_si91x_sensor_hub_start#
sl_status_t sl_si91x_sensor_hub_start (void , -)
Start the sensor hub Tasks.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None | |
[out] | - | None |
This Starts the sensor hub Tasks.
Returns
- If succesfull returns SL_STATUS_OK else returns error code
sli_si91x_set_alarm_intr_time#
void sli_si91x_set_alarm_intr_time (uint16_t interval, -)
set the alarm interrupt time.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | [in] | interval | - interval time |
[out] | - | None |
This function will set the alarm interrupt based on the periodic time.
Returns
- NULL
sli_si91x_init_m4alarm_config#
void sli_si91x_init_m4alarm_config (void , -)
initialize the Alarm block.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None | |
[out] | - | None |
This function will initialize the Alarm block.
Returns
- NULL
sli_si91x_config_wakeup_source#
void sli_si91x_config_wakeup_source (uint16_t sleep_time, -)
Configure the wake-up source for the system.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | [in] | sleep_time | - Sleep time for the sensor hub |
[out] | - | None |
This function will configure the wake-up source to the system.
Returns
- NULL
sli_si91x_sleep_wakeup#
void sli_si91x_sleep_wakeup (uint16_t sh_sleep_time, -)
Configures sleep/wakeup sources for the system.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | [in] | sh_sleep_time | - Sleep time for the sensor hub, in ADC PS-1 no parameters |
[out] | - | None |
This function will configure sleep/wakeup sources.
Returns
- NULL
sli_si91x_sensorhub_ps4tops2_state#
void sli_si91x_sensorhub_ps4tops2_state (void , -)
Change the system status from PS4 to PS2.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None | |
[out] | - | None |
This function will change the system status from PS4 to PS2.
Returns
- NULL
sli_si91x_sensorhub_ps2tops4_state#
void sli_si91x_sensorhub_ps2tops4_state (void , -)
Change the system status from PS2 to PS4.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None | |
[out] | - | None |
This function will change the system status from PS2 to PS4.
Returns
- NULL
sli_si91x_adc_init#
sl_status_t sli_si91x_adc_init (void )
Initialize ADC Interface based on configuration.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None |
This function will configure/Initialize ADC Interface based on configuration.
Returns
error code SL_STATUS_FAIL (0x0001)- Fail , SL_STATUS_OK (0X000)- Success
vPortSetupTimerInterrupt#
void vPortSetupTimerInterrupt (void , -)
Initialize and configure the systic timer for the RTOS.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] | None | |
[out] | - | None |
Set up the systic timer to generate the tick interrupts at the required frequency.
Returns
Initialize status to the application.
ARM_I2C_SignalEvent#
void ARM_I2C_SignalEvent (uint32_t event, -)
I2C event handler.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | event | - I2C transmit and receive events |
[out] | - | None |
Returns
None
sl_si91x_fetch_adc_bus_intf_info#
sl_adc_cfg_t * sl_si91x_fetch_adc_bus_intf_info (void )
Fetch ADC bus interface information.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This can be used by lower level layers Returns
Pointer to ADC configuration structure
sl_si91x_adc_callback#
void sl_si91x_adc_callback (uint8_t channel_no, uint8_t event)
ADC callback from RSI_ADC_InterruptHandler.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | channel_no | - respective channel number |
uint8_t | [in] | event | - callback event (ADC_STATIC_MODE_CALLBACK, ADC_THRSHOLD_CALLBACK, INTERNAL_DMA, FIFO_MODE_EVENT) |
sli_si91x_sdc_init#
uint8_t sli_si91x_sdc_init (void )
Initialize the sdc Interface based on the configuration.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | [in] |
Returns
status 0 if successful, else error code SL_STATUS_FAIL (0x0001)- Fail , SL_STATUS_OK (0X000)- Success,
sli_config_sdc_params#
void sli_config_sdc_params (sl_drv_sdc_config_t * sdc_config_st_p)
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_drv_sdc_config_t * | N/A | sdc_config_st_p |