RZV Flexible Software Package Documentation
Release v3.0.0
|
|
Functions | |
fsp_err_t | RM_HS400X_Open (rm_hs400x_ctrl_t *const p_api_ctrl, rm_hs400x_cfg_t const *const p_cfg) |
Opens and configures the HS400X middleware module. Implements rm_hs400x_api_t::open. More... | |
fsp_err_t | RM_HS400X_Close (rm_hs400x_ctrl_t *const p_api_ctrl) |
Disables specified HS400X control block. Implements rm_hs400x_api_t::close. More... | |
fsp_err_t | RM_HS400X_MeasurementStart (rm_hs400x_ctrl_t *const p_api_ctrl) |
This function should be called when start one shot measurement. Sends the command of measurement to HS400X and start a measurement. This function supports No-Hold measurement and Periodic measurement only. If Hold measurement is enabled, please call RM_HS400X_Read() without calling this function. In Periodic measurement, if the periodic measurement has already run, RM_HS400X_EVENT_ERROR is received in callback because HS400x device replies with NACK. Implements rm_hs400x_api_t::measurementStart. More... | |
fsp_err_t | RM_HS400X_MeasurementStop (rm_hs400x_ctrl_t *const p_api_ctrl) |
Stop a periodic measurement. Sends the command of stopping periodic measurement to HS400X. This function supports periodic measurement only. If a periodic measurement is not running, RM_HS400X_EVENT_ERROR is received in callback because HS400x device replies with NACK. Implements rm_hs400x_api_t::measurementStop. More... | |
fsp_err_t | RM_HS400X_Read (rm_hs400x_ctrl_t *const p_api_ctrl, rm_hs400x_raw_data_t *const p_raw_data) |
Reads ADC data from HS400X. If Hold measurement is enabled, HS400X holds the SCL line low during the measurement and releases the SCL line when the measurement is complete. If No-Hold measurement is enabled and the measurement result is not ready, RM_HS400X_EVENT_MEASUREMENT_NOT_COMPLETE is received in callback. Implements rm_hs400x_api_t::read. More... | |
fsp_err_t | RM_HS400X_DataCalculate (rm_hs400x_ctrl_t *const p_api_ctrl, rm_hs400x_raw_data_t *const p_raw_data, rm_hs400x_data_t *const p_hs400x_data) |
Calculates temperature [Celsius] and humidity [RH] from ADC data. Implements rm_hs400x_api_t::dataCalculate. More... | |
Middleware to implement the HS400X sensor interface. This module implements the HS400X Middleware Interface.
The HS400X sensor interface implementation has the following key features:
Alert feature is not supported. It will be supported in the future.
The minimum frequency for the SCL clock in Hold measurement is 200kHz. Please configure I2C_MASTER_RATE_FAST or I2C_MASTER_RATE_FASTPLUS to "Rate" in I2C Master on RIIC (r_riic_master).
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Measurement Type |
| No-Hold Measurement | Select measurement type. Note: When select No-Hold Measurement, it is recommended to set the Drive Capacity of the pins for I2C function to Low on Pins tab. |
Data type |
| Both humidity and temperature | Select getting temperature only or both humidity and temperature. |
Configuration | Options | Default | Description |
---|---|---|---|
Name | Manual Entry | g_hs400x_sensor0 | Module name. |
Temperature Resolution |
| 14-bit | Set resolution of temperature. |
Humidity Resolution |
| 14-bit | Set resolution of humidity. |
Frequency for Periodic Measurement |
| 1Hz | Set frequency for periodic measurement. |
Comms I2C Callback | Name must be a valid C symbol | hs400x_comms_i2c_callback | A user COMMS I2C callback function can be provided. |
This module use SDA and SCL pins of I2C function.
HS400x datasheet is here.
This module supports three measurement type :
Hold and no-hold measurements also support measuring temperature data only. However, a periodic measurement only supports measuring both humidity and temperature data.
A hold measurement sequence consists of the following steps.
A no-hold measurement sequence consists of the following steps.
The HS400x sensors can also be configured to measure at regular intervals without user intervention. In this mode, the user can read the latest relative humidity / temperature data by issuing a data fetch sequence, which consists of sending the HS400x I2C address with a read bit. The sensor will then send the latest measurement result over the I2C bus.
When the periodic measurement mode is active, the only commands the chip will respond to are the data fetch command, and a command to stop the periodic measurements. The command to stop periodic measurements is issued by sending the I2C address with a write bit, followed by the command 0x30. Sequence to Stop Periodic Measurements. Once the periodic measurements have been stopped, the chip returns to sleep and is ready to accept all valid I2C commands.
The HS400X interface expects a I2C bus instance to be opened before opening any I2C 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.
If an RTOS is used, blocking and bus lock is available.
Initialize with RM_HS400X_Open().
After normal completion, start the each measurement.
In hold measurement, the HS400x series sensor holds the SCL line low during the measurement and releases the SCL line when the measurement is complete.
In no-hold measurement, the HS400x series sensor does not hold the SCL line low, and the master is free to initiate communication with other slaves while the chip is performing the measurement.
In periodic measurement, the HS400x sensors measure at regular intervals without user intervention. If a periodic measurement is running, the resolution and the frequency cannot be changed. please stop the periodic measurement with RM_HS400X_MeasurementStop().
This is a basic examples of minimal use of HS400X sensor implementation in an application.
Data Structures | |
struct | rm_hs400x_init_process_params_t |
struct | rm_hs400x_instance_ctrl_t |
struct rm_hs400x_init_process_params_t |
HS400X initialization process block
Data Fields | ||
---|---|---|
volatile bool | communication_finished | Communication flag for blocking. |
volatile rm_hs400x_event_t | event | Callback event. |
struct rm_hs400x_instance_ctrl_t |
HS400x Control Block
Data Fields | |
uint32_t | open |
Open flag. | |
rm_hs400x_cfg_t const * | p_cfg |
Pointer to HS400X Configuration. | |
rm_comms_instance_t const * | p_comms_i2c_instance |
Pointer of I2C Communications Middleware instance structure. | |
void const * | p_context |
Pointer to the user-provided context. | |
rm_hs400x_init_process_params_t | init_process_params |
For the initialization process. | |
uint8_t | resolution_register |
Register for temperature and humidity measurement resolution settings. | |
uint8_t | periodic_measurement_register [2] |
Register for periodic measurement settings. | |
volatile bool | periodic_measurement_stop |
Flag for stop of periodic measurement. | |
volatile bool | no_hold_measurement_read |
Flag for data read of No-Hold measurement. | |
uint8_t | write_buf [18] |
Buffer for data write. | |
void(* | p_comms_callback )(rm_hs400x_callback_args_t *p_args) |
I2C Communications callback. | |
fsp_err_t RM_HS400X_Open | ( | rm_hs400x_ctrl_t *const | p_api_ctrl, |
rm_hs400x_cfg_t const *const | p_cfg | ||
) |
Opens and configures the HS400X middleware module. Implements rm_hs400x_api_t::open.
Example:
FSP_SUCCESS | HS400X 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. |
FSP_ERR_TIMEOUT | communication is timeout. |
FSP_ERR_ABORTED | communication is aborted. |
fsp_err_t RM_HS400X_Close | ( | rm_hs400x_ctrl_t *const | p_api_ctrl | ) |
Disables specified HS400X control block. Implements rm_hs400x_api_t::close.
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_HS400X_MeasurementStart | ( | rm_hs400x_ctrl_t *const | p_api_ctrl | ) |
This function should be called when start one shot measurement. Sends the command of measurement to HS400X and start a measurement. This function supports No-Hold measurement and Periodic measurement only. If Hold measurement is enabled, please call RM_HS400X_Read() without calling this function. In Periodic measurement, if the periodic measurement has already run, RM_HS400X_EVENT_ERROR is received in callback because HS400x device replies with NACK. Implements rm_hs400x_api_t::measurementStart.
FSP_SUCCESS | Successfully started. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_TIMEOUT | communication is timeout. |
FSP_ERR_ABORTED | communication is aborted. |
FSP_ERR_UNSUPPORTED | Hold measurement is unsupported. |
fsp_err_t RM_HS400X_MeasurementStop | ( | rm_hs400x_ctrl_t *const | p_api_ctrl | ) |
Stop a periodic measurement. Sends the command of stopping periodic measurement to HS400X. This function supports periodic measurement only. If a periodic measurement is not running, RM_HS400X_EVENT_ERROR is received in callback because HS400x device replies with NACK. Implements rm_hs400x_api_t::measurementStop.
FSP_SUCCESS | Successfully started. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_TIMEOUT | communication is timeout. |
FSP_ERR_ABORTED | communication is aborted. |
FSP_ERR_UNSUPPORTED | Hold and No-Hold measurement are unsupported. |
fsp_err_t RM_HS400X_Read | ( | rm_hs400x_ctrl_t *const | p_api_ctrl, |
rm_hs400x_raw_data_t *const | p_raw_data | ||
) |
Reads ADC data from HS400X. If Hold measurement is enabled, HS400X holds the SCL line low during the measurement and releases the SCL line when the measurement is complete. If No-Hold measurement is enabled and the measurement result is not ready, RM_HS400X_EVENT_MEASUREMENT_NOT_COMPLETE is received in callback. Implements rm_hs400x_api_t::read.
FSP_SUCCESS | Successfully data decoded. |
FSP_ERR_ASSERTION | Null pointer, or one or more configuration options is invalid. |
FSP_ERR_TIMEOUT | communication is timeout. |
FSP_ERR_ABORTED | communication is aborted. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_HS400X_DataCalculate | ( | rm_hs400x_ctrl_t *const | p_api_ctrl, |
rm_hs400x_raw_data_t *const | p_raw_data, | ||
rm_hs400x_data_t *const | p_hs400x_data | ||
) |
Calculates temperature [Celsius] and humidity [RH] from ADC data. Implements rm_hs400x_api_t::dataCalculate.
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. |