Middleware to implement the FS1015 sensor interface. This module implements the FSXXXX Middleware Interface.
Overview
Features
The FS1015 sensor interface implementation has the following key features:
- Getting ADC data from the sensor
- Calculating flow value from ADC data
Limitations
Configuration
Build Time Configurations for rm_fs1015
The following build time configurations are defined in fsp_cfg/rm_fs1015_cfg.h:
Configuration | Options | Default | Description |
Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
Device Type | FS1015-1005 | FS1015-1005 | Select FS1015 device used. |
Configurations for Sensor > FS1015 Flow Sensor (rm_fs1015)
This module can be added to the Stacks tab via New Stack > Sensor > FS1015 Flow Sensor (rm_fs1015).
Configuration | Options | Default | Description |
Name | Name must be a valid C symbol | g_fs1015_sensor0 | Module name. |
Callback | Name must be a valid C symbol | fs1015_callback | A user callback function can be provided. |
Pin Configuration
This module use SDA and SCL pins of I2C Master and SCI I2C.
Usage Notes
FS1015 datasheet is here.
If ADC data is invalid, it is needed to read ADC data from FS1015 again. The module only supports FS1015-1005.
If an RTOS is used, blocking and bus lock is available.
- If blocking of an I2C bus is required, it is necessary to create a semaphore for blocking.
- If bus lock is required, it is necessary to create a mutex for bus lock. Bus lock is only available when a semaphore for blocking is used.
Bus Initialization
The FS1015 interface expects a bus instance to be opened before opening any FS1015 device. The interface will handle switching between devices on the bus but will not open or close the bus instance. The user should open the bus with the appropriate I2C Master Interface open call.
Examples
Basic Example
This is a basic example of minimal use of FS1015 sensor implementation in an application.
void rm_fs1015_basic_example (void)
{
uint8_t calculated_flag = 0;
rm_comms_i2c_bus_extended_cfg_t * p_extend =
(rm_comms_i2c_bus_extended_cfg_t *) g_fs1015_cfg.p_instance->p_cfg->p_extend;
p_driver_instance->
p_api->
open(p_driver_instance->p_ctrl, p_driver_instance->p_cfg);
#if BSP_CFG_RTOS
if (NULL != p_extend->p_blocking_semaphore)
{
#if BSP_CFG_RTOS == 1 // AzureOS
tx_semaphore_create(p_extend->p_blocking_semaphore->p_semaphore_handle,
p_extend->p_blocking_semaphore->p_semaphore_name,
(ULONG) 0);
#elif BSP_CFG_RTOS == 2 // FreeRTOS
*(p_extend->p_blocking_semaphore->p_semaphore_handle) =
xSemaphoreCreateCountingStatic((UBaseType_t) 1,
(UBaseType_t) 0,
p_extend->p_blocking_semaphore->p_semaphore_memory);
#endif
}
if (NULL != p_extend->p_bus_recursive_mutex)
{
#if BSP_CFG_RTOS == 1 // AzureOS
tx_mutex_create(p_extend->p_bus_recursive_mutex->p_mutex_handle,
p_extend->p_bus_recursive_mutex->p_mutex_name,
TX_INHERIT);
#elif BSP_CFG_RTOS == 2 // FreeRTOS
*(p_extend->p_bus_recursive_mutex->p_mutex_handle) =
xSemaphoreCreateRecursiveMutexStatic(p_extend->p_bus_recursive_mutex->p_mutex_memory);
#endif
}
#endif
handle_error(err);
while (true)
{
do
{
g_flag = 0;
while (0 == g_flag)
{
}
if (FSP_SUCCESS == err)
{
calculated_flag = 1;
}
{
calculated_flag = 0;
}
else
{
handle_error(err);
}
} while (0 == calculated_flag);
}
}
◆ rm_fs1015_instance_ctrl_t
struct rm_fs1015_instance_ctrl_t |
◆ RM_FS1015_Open()
Opens and configures the FS1015 Middle module. Implements rm_fsxxxx_api_t::open.
Example:
- Return values
-
FSP_SUCCESS | FS1015 successfully configured. |
FSP_ERR_ASSERTION | Null pointer, or one or more configuration options is invalid. |
FSP_ERR_ALREADY_OPEN | Module is already open. This module can only be opened once. |
◆ RM_FS1015_Close()
Disables specified FS1015 control block. Implements rm_fsxxxx_api_t::close.
- Return values
-
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_FS1015_Read()
Reads ADC data from FS1015. Implements rm_fsxxxx_api_t::read.
- Return values
-
FSP_SUCCESS | Successfully data decoded. |
FSP_ERR_ASSERTION | Null pointer, or one or more configuration options is invalid. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_FS1015_DataCalculate()
Calculates flow [m/sec] from ADC data. Implements rm_fsxxxx_api_t::dataCalculate.
- Return values
-
FSP_SUCCESS | Successfully data decoded. |
FSP_ERR_ASSERTION | Null pointer, or one or more configuration options is invalid. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_SENSOR_INVALID_DATA | Data is invalid. |