This API provides high-level access to the RRH46410 sensor.
More...
|
| int | RRH46410_Init (RRH46410_t *sensor, Interface_t *hal) |
| | Initialize sensor object. More...
|
| |
| int | RRH46410_GetSensorInfo (RRH46410_t *sensor, RRH46410_SensorInfo_t *info) |
| | Read additional sensor information. More...
|
| |
| int | RRH46410_ReadOperatingMode (RRH46410_t *sensor) |
| | Read the current operating mode. More...
|
| |
| int | RRH46410_SetOperatingMode (RRH46410_t *sensor, RRH46410_OperatingMode_t mode) |
| | Set the current operating mode. More...
|
| |
| int | RRH46410_SetHumidity (RRH46410_t *sensor, float humidity) |
| | Set humidity value to be used in gas algorithm computations. More...
|
| |
| int | RRH46410_ReadResults (RRH46410_t *sensor, void *result) |
| | Read latest sensor results. More...
|
| |
| int | RRH46410_ReadDebug (RRH46410_t *sensor, void *result) |
| | Read debug output. More...
|
| |
| int | RRH46410_PerformCleaning (RRH46410_t *sensor) |
| | Perform sensor cleaning. More...
|
| |
| int | RRH46410_Reset (RRH46410_t *sensor) |
| | Reset the sensor. More...
|
| |
| int | RRH46410_SoftReset (RRH46410_t *sensor) |
| | Perform a software reset. More...
|
| |
| int | RRH46410_ConfigureGPIO (RRH46410_t *sensor, uint8_t outputMask) |
| | Configure GPIO1 and GPIO2 direction. More...
|
| |
| int | RRH46410_WriteGPIO (RRH46410_t *sensor, uint8_t mask, uint8_t state) |
| | Write one or multiple GPIO pins. More...
|
| |
| int | RRH46410_ReadGPIO (RRH46410_t *sensor, uint8_t *state) |
| | Read the state of all GPIO pins. More...
|
| |
|
| enum | RRH46410_OperatingMode_t {
omSuspend = 0x00,
omIAQ2 = 0x01,
omIAQ2_ULP = 0x02,
omPBAQ = 0x05,
omCleaning = 0x80,
omUnknown = 0xff
} |
| | Operating mode types. More...
|
| |
| enum | RRH46410_Commands_t {
cmdGetSensorInfo = 0x00,
cmdGetTrackingNumber = 0x01,
cmdGetOperatingMode = 0x10,
cmdSetOperatingMode = 0x11,
cmdSetHumidity = 0x12,
cmdGetResults = 0x18,
cmdSetGPIOConfig = 0x20,
cmdGetGPIOState = 0x21,
cmdSetOutputHigh = 0x22,
cmdSetOutputLow = 0x23,
cmdGetDebugData = 0x31,
cmdSoftwareReset = 0x8f
} |
| | Define names for RRH46410 commands. More...
|
| |
| enum | RRH46410_ErrorCodes_t {
ecWarmup = 0x01,
ecCleaningCountExceeded = 0x08,
ecPOR = 0x09,
ecDamage = 0x0a,
ecDataNotReady = 0x10,
ecInternalComm = 0x20,
ecHostToSensorCheckusm = 0x40,
ecInvalidCommand = 0x80,
ecSampleNotNew = 0x100,
ecSensorToHostChecksum = 0x101,
ecCleaningTimeout = 0x102,
ecGPIOConfigInvalid = 0x103
} |
| | Definition of error codes for RRH46410 sensors. More...
|
| |
This API provides high-level access to the RRH46410 sensor.
The RRH46410 is a sensor module that combines a gas sensor with an embedded microcontroller, removing the need for doing algorithmic computations in the application processor. In addition the embedded MCU maintains the correct timing required to get reliable results from the sensor.
The RRH46410 API is the most convenient way of accessing the sensor. The example code provided with this firmware package may be used as basis for custom applications. All that needs to be done to port this example to the customer hardware is modifying the HAL template, provided in directory src/hal/custom/template.c. Refer to the template.c documentation for further details.
HAL API Requirements
HAL API ports to a customer specific hardware require the following function pointers of the
Interface_t HAL data structure to be initialized and working as documented:
◆ RRH46410_Common_Results_t
| struct RRH46410_Common_Results_t |
This struct helps accessing sample ID independent from operating mode.
◆ sampleID
Sample counter (wrapping at 255)
◆ RRH46410_IAQ2_Results_t
| struct RRH46410_IAQ2_Results_t |
Results returned from sensor in IAQ2 and IAQ2 ULP mode.
◆ eco2
◆ etoh
EtOH concentration * 100 (ppm)
◆ iaq
◆ rel_IAQ
◆ sampleID
Sample counter (wrapping at 255)
◆ tvoc
TVOC concentration * 100 (mg/m^3)
◆ RRH46410_PBAQ_Results_t
| struct RRH46410_PBAQ_Results_t |
Raw result returned from sensor in PBAQ mode.
◆ etoh
EtOH concentration * 100 (ppm)
◆ sampleID
Sample counter (wrapping at 255)
◆ tvoc
TVOC concentration * 100 (mg/m^3)
◆ RRH46410_Results_t
Generic result data structure, joining the results of the different operating modes.
◆ common
Common part of all result data structures
◆ iaq2
Result data structure used in IAQ2 and IAQ2_ULP operating mode
◆ pbaq
Result data structure used in PBAQ operating mode
◆ RRH46410_Debug_t
Debug output data structure.
◆ raw
◆ sampleID
Sample counter (wrapping at 255)
◆ RRH46410_t
Data structure holding information required for RRH46410 API operation.
◆ debugLength
Length of the debug results in current operating mode
◆ hal
Pointer to the hal object for physical communication
◆ i2cAddress
I2C slave address of the RRH46410
◆ measurementInterval
| uint32_t measurementInterval |
Measurement interval of the current operating mode
◆ operatingMode
Current operating mode of the RRH46410
◆ recentsampleID
Id of last sample read from sensor
◆ remainingWarmup
Remaining number of samples required for sensor stabilization
◆ resultsLength
Length of the sensor results in current operating mode
◆ RRH46410_SensorInfo_t
| struct RRH46410_SensorInfo_t |
Sensor information data structure.
◆ fwVersion
RRH46410 internal firmware version
◆ productId
◆ trackingNumber
| uint8_t trackingNumber[6] |
◆ RRH46410_Commands_t
Define names for RRH46410 commands.
| Enumerator |
|---|
| cmdGetSensorInfo | Read sensor product id and firmware version
|
| cmdGetTrackingNumber | Read sensor tracking number (unique ID)
|
| cmdGetOperatingMode | Read the operating mode of the sensor
|
| cmdSetOperatingMode | Change the operating mode of the sensor
|
| cmdSetHumidity | Set the ambient humidity value
|
| cmdGetResults | Read sensor results
|
| cmdSetGPIOConfig | Set GPIOs as input or output
|
| cmdGetGPIOState | Read the state of GPIO pins
|
| cmdSetOutputHigh | Set output pin to high level
|
| cmdSetOutputLow | Set output pin to low level
|
| cmdGetDebugData | Read debug data
|
| cmdSoftwareReset | Reset the sensor
|
◆ RRH46410_ErrorCodes_t
Definition of error codes for RRH46410 sensors.
| Enumerator |
|---|
| ecWarmup | Sensor is in stabilization phase, results may be inaccurate
|
| ecCleaningCountExceeded | Cleaning has been completed before.
|
| ecPOR | Power-on reset event. Check power supply and reset pin.
|
| ecDamage | Gas sensor may be damaged. Refer to datasheet for details.
|
| ecDataNotReady | Data requested before data is available.
|
| ecInternalComm | Internal communication error in RRH46410 module.
|
| ecHostToSensorCheckusm | Checksum received by sensor does not match data.
|
| ecInvalidCommand | Command is unknown to the sensor. Check datasheet for available commands.
|
| ecSampleNotNew | Sensor has not taken a new sample after reading the previous one. Wait until new sample is available
|
| ecSensorToHostChecksum | The checksum received does not match the preceded data.
|
| ecCleaningTimeout | Sensor cleaning took longer than specified.
|
| ecGPIOConfigInvalid | The GPIO configuration provided is invalid.
|
◆ RRH46410_OperatingMode_t
Operating mode types.
| Enumerator |
|---|
| omSuspend | Sensor is not taking measurements
|
| omIAQ2 | IAQ 2nd Gen mode
|
| omIAQ2_ULP | IAQ 2nd Gen Ultra Low Power mode
|
| omPBAQ | Public Building Air Quality mode
|
| omCleaning | Execute cleaning cycle
|
| omUnknown | Used by application before initialization
|
◆ RRH46410_ConfigureGPIO()
| int RRH46410_ConfigureGPIO |
( |
RRH46410_t * |
sensor, |
|
|
uint8_t |
outputMask |
|
) |
| |
Configure GPIO1 and GPIO2 direction.
Bits 0 and 1 determine the direction of GPIO1 and GPIO2, respectively. Setting the corresponding bit to 1 configures the pin as output. Otherwise the pin is configured as input.
- Parameters
-
| sensor | pointer to RRH46410_t object |
| outputMask | bit field defining GPIO direction |
- Returns
- int error code
- Return values
-
◆ RRH46410_GetSensorInfo()
Read additional sensor information.
- Parameters
-
- Returns
- int error code
- Return values
-
◆ RRH46410_Init()
Initialize sensor object.
This function tries calling RRH46410_ReadOperatingMode() with using hal as hardware interface. As the sensor is not accessible immediately after power on, this operation is repeated up to 50 times, ever 20 ms.
On success the interface property of the sensor object is set to hal. Otherwise the interface property will be set to NULL.
- Note
- The RRH46410 API requires that the HAL interface object has the Interface_t::i2cRead and Interface_t::msSleep members defined. If Interface_t::reset is defined, the RRH46410_Reset function will use hardware reset, otherwise software reset is used.
- Parameters
-
| sensor | pointer to RRH46410_t object |
| hal | pointer to object providing physical communication |
- Returns
- int error code
- Return values
-
◆ RRH46410_PerformCleaning()
| int RRH46410_PerformCleaning |
( |
RRH46410_t * |
sensor | ) |
|
Perform sensor cleaning.
The RRH46410 cleaning procedure shall be executed once after production to remove residual materials that would impair the measurement accuracy. The whole procedure requires 1 minute to complete. Do not interrupt the cleaning!
- Note
- No measurements can be taken while clening is running.
-
Cleaning can only be executed once per sensor.
- Parameters
-
- Returns
- int error code
- Return values
-
| 0 | Success |
| ecCleaningCountExceeded | Cleaning has already been performed |
| other | Error |
◆ RRH46410_ReadDebug()
| int RRH46410_ReadDebug |
( |
RRH46410_t * |
sensor, |
|
|
void * |
result |
|
) |
| |
Read debug output.
If algorithm support is required, Renesas may ask to provide the output delivered by this function.
- Note
- : This function should be called shortly after RRH46410_ReadResults()
- Parameters
-
| sensor | pointer to RRH46410_t object |
| result | pointer to debug data object (raw byte array) |
- Note
- : The caller must ensure the buffer pointed to by result is big enough to store the debug data. The debug data size for the present operating mode is accessible through the RRH46410_t::debugLength
- Returns
- int error code
- Return values
-
◆ RRH46410_ReadGPIO()
| int RRH46410_ReadGPIO |
( |
RRH46410_t * |
sensor, |
|
|
uint8_t * |
state |
|
) |
| |
Read the state of all GPIO pins.
The read operation works on inputs and outputs, and reports the value that is actually observed on the GPIO pin.
- Parameters
-
| sensor | pointer to RRH46410_t object |
| state | pointer to byte where result is written to |
- Returns
- int error code
- Return values
-
◆ RRH46410_ReadOperatingMode()
| int RRH46410_ReadOperatingMode |
( |
RRH46410_t * |
sensor | ) |
|
Read the current operating mode.
Call this function to determine the current operating mode of the sensor. On success, the object pointed to by sensor will be updated with the appropriate values.
- Note
- : This function is called internally by RRH46410_Init.
- Parameters
-
- Returns
- int error code
- Return values
-
◆ RRH46410_ReadResults()
| int RRH46410_ReadResults |
( |
RRH46410_t * |
sensor, |
|
|
void * |
result |
|
) |
| |
Read latest sensor results.
The data returned depends on the operating mode
- Parameters
-
| sensor | pointer to RRH46410_t object |
| result | pointer to results object |
- Returns
- int error code
- Return values
-
| 0 | Success |
| ecSampleNotNew | result has not been updated since the last readout |
| other | Error |
◆ RRH46410_Reset()
Reset the sensor.
This is a convenience function that toggles the reset pin if supported by the interface object. Otherwise it sends a soft reset command through I2C.
- Note
- The sensor requires some time to be accessible after reset. Please refer to the data sheet for further details.
- Parameters
-
- Returns
- int error code
- Return values
-
◆ RRH46410_SetHumidity()
| int RRH46410_SetHumidity |
( |
RRH46410_t * |
sensor, |
|
|
float |
humidity |
|
) |
| |
Set humidity value to be used in gas algorithm computations.
The gas sensing hardware is sensitive to humidity changes. In order to get accurate gas measurement results, the actual humidity value should be provided.
- Parameters
-
| sensor | pointer to RRH46410_t object |
| humidity | Humidity value to be use in gas algorithm computations |
- Returns
- int error code
- Return values
-
◆ RRH46410_SetOperatingMode()
Set the current operating mode.
On success, the sensor data structure will be updated.
- Note
- : A change of the operating mode results in a reset of the sample ID
- Parameters
-
| sensor | pointer to RRH46410_t object |
| mode | new operating mode |
- Returns
- int error code
- Return values
-
◆ RRH46410_SoftReset()
Perform a software reset.
This function issues a Reset command through the I2C interface.
- Note
- The sensor requires some time to be accessible after reset. Please refer to the data sheet for further details.
- Parameters
-
- Returns
- int error code
- Return values
-
◆ RRH46410_WriteGPIO()
| int RRH46410_WriteGPIO |
( |
RRH46410_t * |
sensor, |
|
|
uint8_t |
mask, |
|
|
uint8_t |
state |
|
) |
| |
Write one or multiple GPIO pins.
GPIO1 and GPIO2 can be configured as output. Only pins for which the mask bitfield contains a 1 are written. The state file contains the actual value.
- Note
- If multiple pins are changed, there may be a significant delay between the actual change of the output values of these pins. This especially applies if the pins are set to different states.
- Parameters
-
| sensor | pointer to RRH46410_t object |
| mask | bit field defining GPIOs that shall be affected |
| state | bit field defining the logic output value of pins |
- Returns
- int error code
- Return values
-