RA Flexible Software Package Documentation  Release v5.6.0

 
OB1203 Light/Proximity/PPG Sensor (rm_ob1203) [Deprecated]

Functions

fsp_err_t RM_OB1203_Open (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_cfg_t const *const p_cfg)
 Opens and configures the OB1203 Middle module. Implements rm_ob1203_api_t::open. More...
 
fsp_err_t RM_OB1203_Close (rm_ob1203_ctrl_t *const p_api_ctrl)
 Disables specified OB1203 control block. Implements rm_ob1203_api_t::close. More...
 
fsp_err_t RM_OB1203_MeasurementStart (rm_ob1203_ctrl_t *const p_api_ctrl)
 Start measurement. Implements rm_ob1203_api_t::measurementStart. More...
 
fsp_err_t RM_OB1203_MeasurementStop (rm_ob1203_ctrl_t *const p_api_ctrl)
 Stop measurement. If device interrupt is enabled, interrupt bits are cleared after measurement stop. If PPG mode, FIFO information is also reset after measurement stop. In RTOS and Light/Proximity/Light Proximity mode, if device interrupt is enabled, blocks 2 bytes on the I2C bus. In RTOS and PPG mode, if device interrupt is enabled, blocks 6 bytes on the I2C bus. If device interrupt is disabled, blocks 4 bytes on the I2C bus. Implements rm_ob1203_api_t::measurementStop. More...
 
fsp_err_t RM_OB1203_LightRead (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_raw_data_t *const p_raw_data, rm_ob1203_light_data_type_t type)
 Reads Light ADC data from OB1203 device. If device interrupt is enabled, interrupt bits are cleared after data read. In RTOS and Light mode, if device interrupt is enabled, blocks 2 bytes on the I2C bus. Implements rm_ob1203_api_t::lightRead. More...
 
fsp_err_t RM_OB1203_LightDataCalculate (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_raw_data_t *const p_raw_data, rm_ob1203_light_data_t *const p_ob1203_data)
 Calculate light data from raw data. Implements rm_ob1203_api_t::lightDataCalculate. More...
 
fsp_err_t RM_OB1203_ProxRead (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_raw_data_t *const p_raw_data)
 Reads Proximity ADC data from OB1203 device. If device interrupt is enabled, interrupt bits are cleared after data read. In RTOS and Proximity mode, if device interrupt is enabled, blocks 2 bytes on the I2C bus. Implements rm_ob1203_api_t::proxRead. More...
 
fsp_err_t RM_OB1203_ProxDataCalculate (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_raw_data_t *const p_raw_data, rm_ob1203_prox_data_t *const p_ob1203_data)
 Calculate proximity data from raw data. Implements rm_ob1203_api_t::proxDataCalculate. More...
 
fsp_err_t RM_OB1203_PpgRead (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_raw_data_t *const p_raw_data, uint8_t const number_of_samples)
 Reads PPG ADC data from OB1203 device. One sample requires three bytes. 0 cannot set to the number of samples. Implements rm_ob1203_api_t::ppgRead. More...
 
fsp_err_t RM_OB1203_PpgDataCalculate (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_raw_data_t *const p_raw_data, rm_ob1203_ppg_data_t *const p_ob1203_data)
 Calculate PPG data from raw data. Implements rm_ob1203_api_t::ppgDataCalculate. More...
 
fsp_err_t RM_OB1203_GainSet (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_gain_t const gain)
 Set gain. This function should be called after calling RM_OB1203_MeasurementStop(). In RTOS and Light Proximity mode, blocks 2 bytes on the I2C bus. Implements rm_ob1203_api_t::gainSet. More...
 
fsp_err_t RM_OB1203_LedCurrentSet (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_led_current_t const led_current)
 Set currents. This function should be called after calling RM_OB1203_MeasurementStop(). Implements rm_ob1203_api_t::ledCurrentSet. More...
 
fsp_err_t RM_OB1203_DeviceInterruptCfgSet (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_device_interrupt_cfg_t const interrupt_cfg)
 Set device interrupt configurations. This function should be called after calling RM_OB1203_MeasurementStop(). Implements rm_ob1203_api_t::deviceInterruptCfgSet. More...
 
fsp_err_t RM_OB1203_FifoInfoGet (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_fifo_info_t *const p_fifo_info)
 Get FIFO information from OB1203 device. Implements rm_ob1203_api_t::fifoInfoGet. More...
 
fsp_err_t RM_OB1203_DeviceStatusGet (rm_ob1203_ctrl_t *const p_api_ctrl, rm_ob1203_device_status_t *const p_status)
 Get device status from OB1203 device. Clear all interrupt bits. Implements rm_ob1203_api_t::deviceStatusGet. More...
 

Detailed Description

Middleware to implement the OB1203 sensor interface. This module implements the OB1203 Middleware Interface.

Overview

OB1203 is EOL.

This module provides APIs for configuring and controlling the OB1203 sensor operation modes. Supported OB1203 sensor operation modes are below.

Features

The OB1203 sensor interface implementation has the following key features:

Configuration

Build Time Configurations for rm_ob1203

The following build time configurations are defined in fsp_cfg/rm_ob1203_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.

Configurations for Sensor > OB1203 Light/Proximity/PPG Sensor (rm_ob1203) [Deprecated]

This module can be added to the Stacks tab via New Stack > Sensor > OB1203 Light/Proximity/PPG Sensor (rm_ob1203) [Deprecated].

ConfigurationOptionsDefaultDescription
NameName must be a valid C symbolg_ob1203_sensor0 Module name.
Semaphore Timeout (RTOS only)Value must be a non-negative integer0xFFFFFFFF Set timeout for blocking in using RTOS.
Comms I2C CallbackName must be a valid C symbolob1203_comms_i2c_callback A user COMMS I2C callback function can be provided.
IRQ CallbackName must be a valid C symbolob1203_irq_callback A user IRQ callback function can be provided.

Configurations for Sensor > OB1203 Light mode (rm_ob1203)

ConfigurationOptionsDefaultDescription
Operation Mode
  • LS mode
  • CS mode
LS mode Set operation mode.
Interrupt Type
  • Threshold
  • Variation
Threshold Set interrupt type.
Interrupt Source
  • Clear channel
  • Green channel
  • Red channel (CS mode only)
  • Blue channel (CS mode only)
Clear channel Set interrupt source.
The Number of Similar Consecutive Interrupt EventsValue must be a non-negative integer0x02 The number of similar consecutive Light mode interrupt events that must occur before the interrupt is asserted (4bits). Min = 0x0 and Max = 0xF
Sleep after Interrupt
  • Enabled
  • Disabled
Disabled Set sleep after interrupt.
Gain
  • 1
  • 3
  • 6
3 Set gain for detection range.
Resolution and Measurement PeriodRefer to the RA Configuration tool for available options.Resolution:18bit. Measurement Period:100ms Set resolution and measurement period.
Upper ThresholdValue must be a non-negative integer0x00CCC Set upper threshold value (20bits). Min = 0x00000 and Max = 0xFFFFF.
Lower ThresholdValue must be a non-negative integer0x00000 Set lower threshold value (20bits). Min = 0x00000 and Max = 0xFFFFF.
Variance Threshold
  • +/- 8 counts
  • +/- 16 counts
  • +/- 32 counts
  • +/- 64 counts
  • +/- 128 counts
  • +/- 256 counts
  • +/- 512 counts
  • +/- 1024 counts
+/- 128 counts Set variance threshold. New data varies by selected counts compared to previous result.

Configurations for Sensor > OB1203 Proximity mode (rm_ob1203)

ConfigurationOptionsDefaultDescription
Interrupt Type
  • Normal
  • Logic
Normal Set interrupt type.
The Number of Similar Consecutive Interrupt EventsValue must be a non-negative integer0x02 The number of similar consecutive Proximity mode interrupt events that must occur before the interrupt is asserted (4bits). Min = 0x0 and Max = 0xF
Sleep after Interrupt
  • Enabled
  • Disabled
Disabled Set sleep after interrupt.
Gain
  • 1
  • 1.5
  • 2
  • 4
1 Set gain of ADC output and noise.
LED CurrentValue must be a non-negative integer0x100 Set Current for LED (10bits). Min = 0x000 and Max = 0x3FF
LED Order
  • IR LED first, Red LED second
  • Red LED first, IR LED second
IR LED first, Red LED second Set LED order.
LED Analog Cancellation
  • Enabled (50% offset of the full-scale value)
  • Disabled
Disabled Set analog cancellation level.
LED Digital CancellationValue must be a non-negative integer0x100 Set digital cancellation level (16bits). Min = 0x0000 and Max = 0xFFFF
Number of LED pulses
  • 1 pulse
  • 2 pulses
  • 4 pulses
  • 8 pulses
  • 16 pulses
  • 32 pulses
8 pulses Set number of LED pulses.
Pulse Width and Measurement PeriodRefer to the RA Configuration tool for available options.Pulse width:42us. Measurement Period:100ms Set pulse width and measurement period.
Moving Average
  • Enabled
  • Disabled
Disabled Set moving average.
HysteresisValue must be a non-negative integer0x00 Set hysteresis level (7bits). Min = 0x00 and Max = 0x7F.
Upper ThresholdValue must be a non-negative integer0x0600 Set upper threshold value (16bits). Min = 0x0000 and Max = 0xFFFF.
Lower ThresholdValue must be a non-negative integer0x0000 Set lower threshold value (16bits). Min = 0x0000 and Max = 0xFFFF.

Configurations for Sensor > OB1203 PPG mode (rm_ob1203)

ConfigurationOptionsDefaultDescription
Operation Mode
  • PPG1 mode
  • PPG2 mode
PPG2 mode Set operation mode.
Interrupt Type
  • Data
  • FIFO Almost Full
Data Set interrupt type.
Gain
  • 1
  • 1.5
  • 2
  • 4
1 Set gain of ADC output and noise.
IR LED CurrentValue must be a non-negative integer0x366 Set Current for IR LED (10bits). Min = 0x000 and Max = 0x3FF
Red LED CurrentValue must be a non-negative integer0x1B3 Set Current for Red LED (9bits). Min = 0x000 and Max = 0x1FF
Power Save Mode
  • Enabled
  • Disabled
Disabled Set power save mode.
LED Order
  • IR LED first, Red LED second
  • Red LED first, IR LED second
IR LED first, Red LED second Set LED order.
IR LED Analog Cancellation
  • Enabled (50% offset of the full-scale value)
  • Disabled
Disabled Set analog cancellation level.
Red LED Analog Cancellation
  • Enabled (50% offset of the full-scale value)
  • Disabled
Disabled Set analog cancellation level.
Number of Averaged PPG Samples
  • 1 (No averaging)
  • 2 consecutives samples are averaged
  • 4 consecutives samples are averaged
  • 8 consecutives samples are averaged
  • 16 consecutives samples are averaged
  • 32 consecutives samples are averaged
8 consecutives samples are averaged Set number of averaged for PPG samples.
Pulse Width and Measurement PeriodRefer to the RA Configuration tool for available options.Pulse width:130us. Measurement Period:1.25ms Set pulse width and measurement period.
FIFO Rollover
  • Enabled
  • Disabled
Enabled Set FIFO rollover.
FIFO Almost Full ValueValue must be a non-negative integer0x0C Set the number of empty FIFO words when the FIFO almost full interrupt is issued (4bits). Min = 0x0 and Max = 0xF. In PPG2 Mode, only even values must be used.

Configurations for Sensor > OB1203 Light Proximity mode (rm_ob1203)

ConfigurationOptionsDefaultDescription
General
Device Interrupt
  • Light mode
  • Proximity mode
Light mode Select an operation mode using device interrupt.
Light mode
Operation Mode
  • LS mode
  • CS mode
LS mode Set operation mode.
Interrupt Type
  • Threshold
  • Variation
Threshold Set interrupt type.
Interrupt Source
  • Clear channel
  • Green channel
  • Red channel (CS mode only)
  • Blue channel (CS mode only)
Clear channel Set interrupt source.
The Number of Similar Consecutive Interrupt EventsValue must be a non-negative integer0x02 The number of similar consecutive Light mode interrupt events that must occur before the interrupt is asserted (4bits). Min = 0x0 and Max = 0xF
Sleep after Interrupt
  • Enabled
  • Disabled
Disabled Set sleep after interrupt.
Gain
  • 1
  • 3
  • 6
3 Set gain for detection range.
Resolution and Measurement PeriodRefer to the RA Configuration tool for available options.Resolution:18bit. Measurement Period:100ms Set resolution and measurement period.
Upper ThresholdValue must be a non-negative integer0x00CCC Set upper threshold value (20bits). Min = 0x00000 and Max = 0xFFFFF.
Lower ThresholdValue must be a non-negative integer0x00000 Set lower threshold value (20bits). Min = 0x00000 and Max = 0xFFFFF.
Variance Threshold
  • +/- 8 counts
  • +/- 16 counts
  • +/- 32 counts
  • +/- 64 counts
  • +/- 128 counts
  • +/- 256 counts
  • +/- 512 counts
  • +/- 1024 counts
+/- 128 counts Set variance threshold. New data varies by selected counts compared to previous result.
Proximity mode
Interrupt Type
  • Normal
  • Logic
Normal Set interrupt type.
The Number of Similar Consecutive Interrupt EventsValue must be a non-negative integer0x02 The number of similar consecutive Proximity mode interrupt events that must occur before the interrupt is asserted (4bits). Min = 0x0 and Max = 0xF
Sleep after Interrupt
  • Enabled
  • Disabled
Disabled Set sleep after interrupt.
Gain
  • 1
  • 1.5
  • 2
  • 4
1 Set gain of ADC output and noise.
LED CurrentValue must be a non-negative integer0x100 Set Current for LED (10bits). Min = 0x000 and Max = 0x3FF
LED Order
  • IR LED first, Red LED second
  • Red LED first, IR LED second
IR LED first, Red LED second Set LED order.
LED Analog Cancellation
  • Enabled (50% offset of the full-scale value)
  • Disabled
Disabled Set analog cancellation level.
LED Digital CancellationValue must be a non-negative integer0x100 Set digital cancellation level (16bits). Min = 0x0000 and Max = 0xFFFF
Number of LED pulses
  • 1 pulse
  • 2 pulses
  • 4 pulses
  • 8 pulses
  • 16 pulses
  • 32 pulses
8 pulses Set number of LED pulses.
Pulse Width and Measurement PeriodRefer to the RA Configuration tool for available options.Pulse width:42us. Measurement Period:100ms Set pulse width and measurement period.
Moving Average
  • Enabled
  • Disabled
Disabled Set moving average.
HysteresisValue must be a non-negative integer0x00 Set hysteresis level (7bits). Min = 0x00 and Max = 0x7F.
Upper ThresholdValue must be a non-negative integer0x0600 Set upper threshold value (16bits). Min = 0x0000 and Max = 0xFFFF.
Lower ThresholdValue must be a non-negative integer0x0000 Set lower threshold value (16bits). Min = 0x0000 and Max = 0xFFFF.

Pin Configuration

This module uses I2C Master, SCI I2C and IRQ drivers. Therefore, this module uses SDA and SCL pins of I2C Master and SCI I2C and an IRQ pin.

Usage Notes

OB1203 datasheet is here.
The OB1203 has four operation modes.

Light mode

Light mode has two operation modes.

Operation mode Red Green Blue Clear Comp *1
LS mode
CS mode

*1 : Temperature compensation data

Light mode features are below.

Proximity mode

Proximity mode features are below.

PPG mode

PPG mode has two operation modes.

Operation mode Discription
PPG1 mode Only one LED is used. This mode allows determination of parameters related to heart rate with an appropriate algorithm
PPG2 mode Two LED are used. Second LED is used as a transmitter. This mode supports further analysis, such as SpO2 and respiration rate determination.

PPG mode features are below.

Light Proximity mode

Light mode and Proximity mode can be used in parallel.

Bus Initialization

The OB1203 interface expects a bus instance to be opened before opening any OB1203 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 for I2C bus are available.

Initialization

Initialize with RM_OB1203_Open().

From measurement start to data acquisition

After normal completion, start the measurement with RM_OB1203_MeasurementStart().

Light mode

If IRQ is enabled

  1. Wait until RM_OB1203_EVENT_THRESHOLD_CROSSED is received via IRQ callback.
  2. Call RM_OB1203_LightRead(). This function will read the ADC data and clear the interrupt bits.
  3. Wait until RM_OB1203_EVENT_SUCCESS is received.
  4. Call RM_OB1203_LightDataCalculate(). This function will calculate light data from the ADC data.

If IRQ is disabled

  1. Wait for measurement period configured.
  2. Call RM_OB1203_LightRead(). This function will read the ADC data.
  3. Wait until RM_OB1203_EVENT_SUCCESS is received.
  4. Call RM_OB1203_LightDataCalculate(). This function will calculate light data from the ADC data.

Proximity mode

If IRQ is enabled

  1. Wait until RM_OB1203_EVENT_THRESHOLD_CROSSED or RM_OB1203_EVENT_OBJECT_NEAR is received via IRQ callback.
  2. Call RM_OB1203_ProxRead(). This function will read the ADC data and clear the interrupt bits.
  3. Wait until RM_OB1203_EVENT_SUCCESS is received.
  4. Call RM_OB1203_ProxDataCalculate(). This function will calculate proximity data from the ADC data.

If IRQ is disabled

  1. Wait for measurement period configured.
  2. Call RM_OB1203_ProxRead(). This function will read the ADC data.
  3. Wait until RM_OB1203_EVENT_SUCCESS is received.
  4. Call RM_OB1203_ProxDataCalculate(). This function will calculate proximity data from the ADC data.

PPG mode

If IRQ is enabled

  1. Wait until RM_OB1203_EVENT_MEASUREMENT_COMPLETE is received via IRQ callback.
  2. Call RM_OB1203_PpgRead(). This function will read the ADC data and clear the interrupt bits. In PPG2 mode, the number of read FIFO samples must be even value because two samples is one pair.
  3. Wait until RM_OB1203_EVENT_SUCCESS is received.
  4. Call RM_OB1203_PpgDataCalculate(). This function will calculate PPG data from the ADC data.

If IRQ is disabled

  1. Wait for measurement period configured.
  2. Call RM_OB1203_PpgRead(). This function will read the ADC data. In PPG2 mode, the number of read FIFO samples must be even value because two samples is one pair.
  3. Wait until RM_OB1203_EVENT_SUCCESS is received.
  4. Call RM_OB1203_PpgDataCalculate(). This function will calculate PPG data from the ADC data.

Light Proximity mode

Combination of the above Light mode and Proximity mode.

Getting device status

Call RM_OB1203_DeviceStatusGet(). This function will get device status over I2C.

Clearing interrupt bits

If interrupt bits are needed to clear without calling RM_OB1203_LightRead(), RM_OB1203_ProxRead(), RM_OB1203_PpgRead() and RM_OB1203_MeasurementStop(), please call RM_OB1203_DeviceStatusGet(). Interrupt bits are reset by STATUS_0 and STATUS_1 registers read.

Sleep after interrupt

Sleep after interrupt is valid in Light mode and Proximity mode. If a sleep after interrupt bit are set, a measurement will be stopped after an interrupt occurs. After STATUS_0 and STATUS_1 registers are read, a measurement will be started. please call RM_OB1203_DeviceStatusGet().

PPG FIFO

PPG FIFO data is stored in 18-bit wide, 32-sample FIFO memory.
The FIFO almost full interrupt is triggered when a certain number of free FIFO registers are remaining.
If FIFO informations (write index, read index, overflow counter, unread_samples) are got, Call RM_OB1203_FifoInfoGet().

Reconfiguration

The interface supports the following APIs for reconfiguration.

API Discription
RM_OB1203_GainSet() Set gain
RM_OB1203_LedCurrentSet() Set LED currents.
Proximity mode and Light Proximity mode: LED Current is 10bits. Min = 0x000 and Max = 0x3FF
PPG mode: IR/Red LED currents are 10bits/9bits. Min = 0x000/0x000 and Max = 0x3FF/0x1FF
RM_OB1203_DeviceInterruptCfgSet() Set interrupt configurations.

Relationship between APIs and registers

The relationship between APIs and registers accessed by the API is below.

API Registers
RM_OB1203_MeasurementStart() MAIN_CTRL_0 and MAIN_CTRL_1
RM_OB1203_MeasurementStop() MAIN_CTRL_0, MAIN_CTRL_1 , STATUS_0, STATUS_1, FIFO_WR_PTR, FIFO_RD_PTR and FIFO_OVF_CNT
RM_OB1203_LightRead() LS_CLEAR_DATA, LS_GREEN_DATA, LS_BULE_DATA, LS_RED_DATA, COMP_DATA, STATUS_0 and STATUS_1
RM_OB1203_ProxRead() PS_DATA, STATUS_0 and STATUS_1
RM_OB1203_PpgRead() FIFO_DATA
RM_OB1203_DeviceStatusGet() STATUS_0 and STATUS_1
RM_OB1203_GainSet() LS_GAIN and PPG_PS_GAIN
RM_OB1203_LedCurrentSet() PS_LED_CURR, PPG_IRLED_CURR and PPG_RLED_CURR
RM_OB1203_DeviceInterruptCfgSet() INT_CFG_0, INT_CFG_1 and INT_PST
RM_OB1203_FifoInfoGet() FIFO_WR_PTR, FIFO_RD_PTR and FIFO_OVF_CNT

Notifications

The application note [R01AN6311] using this module has an algorithm for biometric data calculation. The algorithm has the constraint of sampling rate (default: 100 samples per second). Please refer to the application note [R36AN0001EU] and OB1203 sensor page (https://www.renesas.com/jp/en/products/sensor-products/biosensors/ob1203-heart-rate-blood-oxygen-concentration-pulse-oximetry-proximity-light-and-color-sensor)
R01AN6311 : https://www.renesas.com/document/apn/ob1203-sample-application-sample-code
R36AN0001EU : https://www.renesas.com/document/apn/ob1203-pulse-oximeter-algorithm-spo2-heart-rate-and-respiration-rate

If multiple operation modes is used with a single OB1203 sensor device, rm_ob1203 modules need to be used while switching between operation modes because modules cannot work in parallel. Threfore, a current rm_ob1203 module must be closed with RM_OB1203_Close() before another rm_ob1203 module is opened with RM_OB1203_Open().

Examples

Basic Example

These are basic examples of minimal use of OB1203 sensor implementation in an application.

Light mode

void rm_ob1203_light_mode_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
#if 0 == RM_OB1203_EXAMPLE_IRQ_ENABLE
#endif
/* Open the I2C bus if it is not already open. */
rm_comms_i2c_bus_extended_cfg_t * p_extend =
(rm_comms_i2c_bus_extended_cfg_t *) g_ob1203_cfg.p_comms_instance->p_cfg->p_extend;
i2c_master_instance_t * p_driver_instance = (i2c_master_instance_t *) p_extend->p_driver_instance;
p_driver_instance->p_api->open(p_driver_instance->p_ctrl, p_driver_instance->p_cfg);
#if BSP_CFG_RTOS
/* Create a semaphore for blocking if a semaphore is not NULL */
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
}
/* Create a recursive mutex for bus lock if a recursive mutex is not NULL */
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
err = RM_OB1203_Open(&g_ob1203_ctrl, &g_ob1203_cfg);
/* Handle any errors. This function should be defined by the user. */
handle_error(err);
g_i2c_flag = 0;
/* Start measurement */
RM_OB1203_MeasurementStart(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
while (true)
{
#if RM_OB1203_EXAMPLE_IRQ_ENABLE
/* Wait IRQ callback */
while (0 == g_irq_flag)
{
/* Wait callback */
}
g_irq_flag = 0;
#else
do
{
g_i2c_flag = 0;
/* Get device status */
RM_OB1203_DeviceStatusGet(&g_ob1203_ctrl, &device_status);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
} while (false == device_status.light_measurement_complete);
#endif
g_i2c_flag = 0;
/* Read ADC data */
while (0 == g_i2c_flag)
{
/* Wait callback */
}
/* Calculate light data */
RM_OB1203_LightDataCalculate(&g_ob1203_ctrl, &raw_data, &ob1203_data);
}
}

Proximity mode

void rm_ob1203_prox_mode_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
rm_ob1203_prox_data_t ob1203_data;
#if 0 == RM_OB1203_EXAMPLE_IRQ_ENABLE
#endif
/* Open the I2C bus if it is not already open. */
rm_comms_i2c_bus_extended_cfg_t * p_extend =
(rm_comms_i2c_bus_extended_cfg_t *) g_ob1203_cfg.p_comms_instance->p_cfg->p_extend;
i2c_master_instance_t * p_driver_instance = (i2c_master_instance_t *) p_extend->p_driver_instance;
p_driver_instance->p_api->open(p_driver_instance->p_ctrl, p_driver_instance->p_cfg);
#if BSP_CFG_RTOS
/* Create a semaphore for blocking if a semaphore is not NULL */
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
}
/* Create a recursive mutex for bus lock if a recursive mutex is not NULL */
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
err = RM_OB1203_Open(&g_ob1203_ctrl, &g_ob1203_cfg);
/* Handle any errors. This function should be defined by the user. */
handle_error(err);
g_i2c_flag = 0;
/* Start measurement */
RM_OB1203_MeasurementStart(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
while (true)
{
#if RM_OB1203_EXAMPLE_IRQ_ENABLE
/* Wait IRQ callback */
while (0 == g_irq_flag)
{
/* Wait callback */
}
g_irq_flag = 0;
#else
do
{
g_i2c_flag = 0;
/* Get device status */
RM_OB1203_DeviceStatusGet(&g_ob1203_ctrl, &device_status);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
} while (false == device_status.prox_measurement_complete);
#endif
g_i2c_flag = 0;
/* Read ADC data */
RM_OB1203_ProxRead(&g_ob1203_ctrl, &raw_data);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
/* Calculate proximity data */
RM_OB1203_ProxDataCalculate(&g_ob1203_ctrl, &raw_data, &ob1203_data);
}
}

Light Proximity mode

void rm_ob1203_light_prox_mode_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
rm_ob1203_light_data_t ob1203_light_data;
rm_ob1203_prox_data_t ob1203_prox_data;
#if 0 == RM_OB1203_EXAMPLE_IRQ_ENABLE
#endif
/* Open the I2C bus if it is not already open. */
rm_comms_i2c_bus_extended_cfg_t * p_extend =
(rm_comms_i2c_bus_extended_cfg_t *) g_ob1203_cfg.p_comms_instance->p_cfg->p_extend;
i2c_master_instance_t * p_driver_instance = (i2c_master_instance_t *) p_extend->p_driver_instance;
p_driver_instance->p_api->open(p_driver_instance->p_ctrl, p_driver_instance->p_cfg);
#if BSP_CFG_RTOS
/* Create a semaphore for blocking if a semaphore is not NULL */
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
}
/* Create a recursive mutex for bus lock if a recursive mutex is not NULL */
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
err = RM_OB1203_Open(&g_ob1203_ctrl, &g_ob1203_cfg);
/* Handle any errors. This function should be defined by the user. */
handle_error(err);
g_i2c_flag = 0;
/* Start measurement in both Light and Proximity modes */
RM_OB1203_MeasurementStart(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
/*
* Example :
* Device interrupt : Proximity mode
* Measurement peroid(Light mode) : 50ms
* Measurement peroid(Proximity mode) : 100ms
*/
while (true)
{
/* Delay 50ms for Light mode */
R_BSP_SoftwareDelay(RM_OB1203_EXAMPLE_DELAY_50MS, BSP_DELAY_UNITS_MILLISECONDS);
g_i2c_flag = 0;
/* Read Light ADC data */
while (0 == g_i2c_flag)
{
/* Wait callback */
}
/* Calculate Light data */
RM_OB1203_LightDataCalculate(&g_ob1203_ctrl, &raw_data, &ob1203_light_data);
#if RM_OB1203_EXAMPLE_IRQ_ENABLE
/* Wait IRQ callback */
while (0 == g_irq_flag)
{
/* Wait callback */
}
g_irq_flag = 0;
#else
do
{
g_i2c_flag = 0;
/* Get device status */
RM_OB1203_DeviceStatusGet(&g_ob1203_ctrl, &device_status);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
} while (false == device_status.prox_measurement_complete);
#endif
g_i2c_flag = 0;
/* Read Proximity ADC data */
RM_OB1203_ProxRead(&g_ob1203_ctrl, &raw_data);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
/* Calculate proximity data */
RM_OB1203_ProxDataCalculate(&g_ob1203_ctrl, &raw_data, &ob1203_prox_data);
}
}

PPG mode

void rm_ob1203_ppg_mode_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
rm_ob1203_ppg_data_t ob1203_data;
#if 0 == RM_OB1203_EXAMPLE_IRQ_ENABLE
#endif
/* Open the I2C bus if it is not already open. */
rm_comms_i2c_bus_extended_cfg_t * p_extend =
(rm_comms_i2c_bus_extended_cfg_t *) g_ob1203_cfg.p_comms_instance->p_cfg->p_extend;
i2c_master_instance_t * p_driver_instance = (i2c_master_instance_t *) p_extend->p_driver_instance;
p_driver_instance->p_api->open(p_driver_instance->p_ctrl, p_driver_instance->p_cfg);
#if BSP_CFG_RTOS
/* Create a semaphore for blocking if a semaphore is not NULL */
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
}
/* Create a recursive mutex for bus lock if a recursive mutex is not NULL */
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
err = RM_OB1203_Open(&g_ob1203_ctrl, &g_ob1203_cfg);
/* Handle any errors. This function should be defined by the user. */
handle_error(err);
g_i2c_flag = 0;
/* Start measurement */
RM_OB1203_MeasurementStart(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
while (true)
{
#if RM_OB1203_EXAMPLE_IRQ_ENABLE
/* Wait IRQ callback */
while (0 == g_irq_flag)
{
/* Wait callback */
}
g_irq_flag = 0;
#else
do
{
g_i2c_flag = 0;
/* Get device status */
RM_OB1203_DeviceStatusGet(&g_ob1203_ctrl, &device_status);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
} while (false == device_status.ppg_measurement_complete);
#endif
g_i2c_flag = 0;
/* Read ADC data */
RM_OB1203_PpgRead(&g_ob1203_ctrl, &raw_data, 2);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
/* Calculate ppg data */
RM_OB1203_PpgDataCalculate(&g_ob1203_ctrl, &raw_data, &ob1203_data);
}
}

Light mode reconfiguration at runtime

void rm_ob1203_light_reconfiguration_basic_example (void)
{
g_i2c_flag = 0;
/* Stop a measurement */
RM_OB1203_MeasurementStop(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
/* Set Light mode gain.
* Example : Gain mode is 1.
*/
{
};
RM_OB1203_GainSet(&g_ob1203_ctrl, gain);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
#if RM_OB1203_EXAMPLE_IRQ_ENABLE
/* Set interrupt configurations for Light mode.
* Example :
* Source : Green channel
* Type : threshold interrupt
* Persist : 0x02
*/
{
.persist = 0x02,
};
RM_OB1203_DeviceInterruptCfgSet(&g_ob1203_ctrl, interrupt_cfg);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
#endif
/* Restart a measurement */
RM_OB1203_MeasurementStart(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
}

Proximity mode reconfiguration at runtime

void rm_ob1203_prox_reconfiguration_basic_example (void)
{
g_i2c_flag = 0;
/* Stop a measurement */
RM_OB1203_MeasurementStop(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
/* Set Proximity mode gain.
* Example : Gain mode is 2.
*/
{
};
RM_OB1203_GainSet(&g_ob1203_ctrl, gain);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
/* Set LED current.
* Example :
* LED : IR LED
* Current : 0x366 (10bits).
*/
{
.ir_led = RM_OB1203_EXAMPLE_IR_CURRENT_0X366,
};
RM_OB1203_LedCurrentSet(&g_ob1203_ctrl, led_current);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
#if RM_OB1203_EXAMPLE_IRQ_ENABLE
/* Set interrupt configurations for Proximity mode.
* Example :
* Type : normal interrupt
* Persist : 0x02
*/
{
.persist = 0x02,
};
RM_OB1203_DeviceInterruptCfgSet(&g_ob1203_ctrl, interrupt_cfg);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
#endif
/* Restart a measurement */
RM_OB1203_MeasurementStart(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
}

Light Proximity mode reconfiguration at runtime

void rm_ob1203_light_prox_reconfiguration_basic_example (void)
{
g_i2c_flag = 0;
/* Stop a measurement */
RM_OB1203_MeasurementStop(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
/* Set Proximity mode gain.
* Example :
* Light mode : 1
* Proximity mode : 2
*/
{
};
RM_OB1203_GainSet(&g_ob1203_ctrl, gain);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
/* Set LED current.
* Example :
* LED : IR LED
* Current : 0x366 (10bits).
*/
{
.ir_led = RM_OB1203_EXAMPLE_IR_CURRENT_0X366,
};
RM_OB1203_LedCurrentSet(&g_ob1203_ctrl, led_current);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
#if RM_OB1203_EXAMPLE_IRQ_ENABLE
/* Set interrupt configurations for Light Proximity mode.
* Example :
* device interrupt : Proximity mode
* Type : normal interrupt
* Persist : 0x02
*/
{
.persist = 0x02,
};
RM_OB1203_DeviceInterruptCfgSet(&g_ob1203_ctrl, interrupt_cfg);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
#endif
/* Restart a measurement */
RM_OB1203_MeasurementStart(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
}

PPG mode reconfiguration at runtime

void rm_ob1203_ppg_reconfiguration_basic_example (void)
{
g_i2c_flag = 0;
/* Stop a measurement */
RM_OB1203_MeasurementStop(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
/* Set PPG mode gain.
* Example : Gain mode is 2.
*/
{
};
RM_OB1203_GainSet(&g_ob1203_ctrl, gain);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
/* Set LED current.
* Example :
* IR LED : 0x366 (10bits).
* Red LED : 0x1B3 (9bits).
*/
{
.ir_led = RM_OB1203_EXAMPLE_IR_CURRENT_0X366,
.red_led = RM_OB1203_EXAMPLE_RED_CURRENT_0X1B3,
};
RM_OB1203_LedCurrentSet(&g_ob1203_ctrl, led_current);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
#if RM_OB1203_EXAMPLE_IRQ_ENABLE
/* Set interrupt configurations for PPG mode.
* Example :
* Type : data interrupt
*/
{
};
RM_OB1203_DeviceInterruptCfgSet(&g_ob1203_ctrl, interrupt_cfg);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
g_i2c_flag = 0;
#endif
/* Restart a measurement */
RM_OB1203_MeasurementStart(&g_ob1203_ctrl);
while (0 == g_i2c_flag)
{
/* Wait callback */
}
}

Data Structures

struct  rm_ob1203_init_process_params_t
 
struct  rm_ob1203_mode_extended_cfg_t
 
struct  rm_ob1203_instance_ctrl_t
 

Data Structure Documentation

◆ rm_ob1203_init_process_params_t

struct rm_ob1203_init_process_params_t

OB1203 initialization process block

Data Fields
volatile bool communication_finished Communication flag for blocking.
volatile rm_ob1203_event_t event Callback event.

◆ rm_ob1203_mode_extended_cfg_t

struct rm_ob1203_mode_extended_cfg_t

OB1203 mode extended configuration

Data Fields
rm_ob1203_api_t const * p_api Pointer to APIs.
rm_ob1203_operation_mode_t mode_irq Operation mode using IRQ.
rm_ob1203_ppg_prox_gain_t ppg_prox_gain Proximity gain range.
rm_ob1203_led_order_t led_order LED order.
rm_ob1203_light_sensor_mode_t light_sensor_mode LS or CS sensor mode.
rm_ob1203_light_interrupt_type_t light_interrupt_type Light mode interrupt type.
rm_ob1203_light_interrupt_source_t light_interrupt_source Light mode interrupt source.
uint8_t light_interrupt_persist The number of similar consecutive Light mode interrupt events that must occur before the interrupt is asserted (4bits).
rm_ob1203_sleep_after_interrupt_t light_sleep Sleep after an interrupt.
rm_ob1203_light_gain_t light_gain Light gain range.
uint32_t light_upper_threshold Upper threshold for interrupt.
uint32_t light_lower_threshold Lower threshold for interrupt.
rm_ob1203_variance_threshold_t light_variance_threshold variance threshold for interrupt.
rm_ob1203_light_resolution_meas_period_t light_resolution_period Resolution and measurement period.
rm_ob1203_light_data_type_t light_data_type Light data type.
rm_ob1203_sleep_after_interrupt_t prox_sleep Sleep after an interrupt.
rm_ob1203_prox_interrupt_type_t prox_interrupt_type Proximity mode interrupt type.
uint8_t prox_interrupt_persist The number of similar consecutive Proximity mode interrupt events that must occur before the interrupt is asserted (4bits).
uint16_t prox_led_current Proximity LED current.
rm_ob1203_analog_cancellation_t prox_ana_can Analog cancellation.
uint16_t prox_dig_can Digital cancellation.
rm_ob1203_number_led_pulses_t prox_num_led_pulses Number of LED pulses.
uint16_t prox_upper_threshold Upper threshold for interrupt.
uint16_t prox_lower_threshold Lower threshold for interrupt.
rm_ob1203_prox_pulse_width_meas_period_t prox_width_period Proximity pulse width and measurement period.
rm_ob1203_moving_average_t prox_moving_average Moving average.
uint8_t prox_hysteresis Proximity hysteresis threshold (7bits).
rm_ob1203_ppg_sensor_mode_t ppg_sensor_mode PPG1 or PPG2 sensor mode.
rm_ob1203_ppg_interrupt_type_t ppg_interrupt_type PPG mode interrupt type.
uint16_t ppg_ir_led_current PPG IR LED current.
uint16_t ppg_red_led_current PPG Red LED current.
rm_ob1203_power_save_mode_t ppg_power_save_mode PPG power save mode.
rm_ob1203_analog_cancellation_t ppg_ir_led_ana_can IR LED analog cancellations.
rm_ob1203_analog_cancellation_t ppg_red_led_ana_can Red LED analog cancellations.
rm_ob1203_number_averaged_samples_t ppg_num_averaged_samples Number of averaged PPG samples.
rm_ob1203_ppg_pulse_width_meas_period_t ppg_width_period PPG pulse width and measurement period.
rm_ob1203_fifo_rollover_t ppg_fifo_rollover FIFO rollover enable.
uint8_t ppg_fifo_empty_num the number of empty FIFO words when the FIFO almost full interrupt is issued. In PPG2 Mode only even values should be used. (4 bits)
uint8_t ppg_number_of_samples Number of PPG samples.

◆ rm_ob1203_instance_ctrl_t

struct rm_ob1203_instance_ctrl_t

OB1203 Control Block

Data Fields

rm_ob1203_semaphore_t const * p_semaphore
 The semaphore to wait for callback. This is used for another data read/write after a communication.
 
uint32_t open
 Open flag.
 
rm_ob1203_cfg_t const * p_cfg
 Pointer to OB1203 Configuration.
 
uint8_t buf [8]
 Buffer for I2C communications.
 
rm_ob1203_init_process_params_t init_process_params
 For the initialization process.
 
uint8_t register_address
 Register address to access.
 
volatile rm_ob1203_device_status_tp_device_status
 Pointer to device status.
 
volatile rm_ob1203_fifo_info_tp_fifo_info
 Pointer to FIFO information structure.
 
volatile bool fifo_reset
 Flag for FIFO reset for PPG mode.
 
volatile bool prox_gain_update
 Flag for gain update for Proximity mode.
 
volatile bool interrupt_bits_clear
 Flag for clearing interrupt bits.
 
rm_comms_instance_t const * p_comms_i2c_instance
 Pointer of I2C Communications Middleware instance structure.
 
rm_ob1203_mode_extended_cfg_tp_mode
 Pointer of OB1203 operation mode extended configuration.
 
void const * p_irq_instance
 Pointer to IRQ instance.
 
void const * p_context
 Pointer to the user-provided context.
 
void(* p_comms_callback )(rm_ob1203_callback_args_t *p_args)
 I2C Communications callback.
 
void(* p_irq_callback )(rm_ob1203_callback_args_t *p_args)
 IRQ callback.
 

Function Documentation

◆ RM_OB1203_Open()

fsp_err_t RM_OB1203_Open ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_cfg_t const *const  p_cfg 
)

Opens and configures the OB1203 Middle module. Implements rm_ob1203_api_t::open.

Example:

err = RM_OB1203_Open(&g_ob1203_ctrl, &g_ob1203_cfg);
Return values
FSP_SUCCESSOB1203 successfully configured.
FSP_ERR_ASSERTIONNull pointer, or one or more configuration options is invalid.
FSP_ERR_ALREADY_OPENModule is already open. This module can only be opened once.
FSP_ERR_TIMEOUTCommunication is timeout.
FSP_ERR_ABORTEDCommunication is aborted.

◆ RM_OB1203_Close()

fsp_err_t RM_OB1203_Close ( rm_ob1203_ctrl_t *const  p_api_ctrl)

Disables specified OB1203 control block. Implements rm_ob1203_api_t::close.

Return values
FSP_SUCCESSSuccessfully closed.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_OB1203_MeasurementStart()

fsp_err_t RM_OB1203_MeasurementStart ( rm_ob1203_ctrl_t *const  p_api_ctrl)

Start measurement. Implements rm_ob1203_api_t::measurementStart.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_MeasurementStop()

fsp_err_t RM_OB1203_MeasurementStop ( rm_ob1203_ctrl_t *const  p_api_ctrl)

Stop measurement. If device interrupt is enabled, interrupt bits are cleared after measurement stop. If PPG mode, FIFO information is also reset after measurement stop. In RTOS and Light/Proximity/Light Proximity mode, if device interrupt is enabled, blocks 2 bytes on the I2C bus. In RTOS and PPG mode, if device interrupt is enabled, blocks 6 bytes on the I2C bus. If device interrupt is disabled, blocks 4 bytes on the I2C bus. Implements rm_ob1203_api_t::measurementStop.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_LightRead()

fsp_err_t RM_OB1203_LightRead ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_raw_data_t *const  p_raw_data,
rm_ob1203_light_data_type_t  type 
)

Reads Light ADC data from OB1203 device. If device interrupt is enabled, interrupt bits are cleared after data read. In RTOS and Light mode, if device interrupt is enabled, blocks 2 bytes on the I2C bus. Implements rm_ob1203_api_t::lightRead.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_LightDataCalculate()

fsp_err_t RM_OB1203_LightDataCalculate ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_raw_data_t *const  p_raw_data,
rm_ob1203_light_data_t *const  p_ob1203_data 
)

Calculate light data from raw data. Implements rm_ob1203_api_t::lightDataCalculate.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_ProxRead()

fsp_err_t RM_OB1203_ProxRead ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_raw_data_t *const  p_raw_data 
)

Reads Proximity ADC data from OB1203 device. If device interrupt is enabled, interrupt bits are cleared after data read. In RTOS and Proximity mode, if device interrupt is enabled, blocks 2 bytes on the I2C bus. Implements rm_ob1203_api_t::proxRead.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_ProxDataCalculate()

fsp_err_t RM_OB1203_ProxDataCalculate ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_raw_data_t *const  p_raw_data,
rm_ob1203_prox_data_t *const  p_ob1203_data 
)

Calculate proximity data from raw data. Implements rm_ob1203_api_t::proxDataCalculate.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_PpgRead()

fsp_err_t RM_OB1203_PpgRead ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_raw_data_t *const  p_raw_data,
uint8_t const  number_of_samples 
)

Reads PPG ADC data from OB1203 device. One sample requires three bytes. 0 cannot set to the number of samples. Implements rm_ob1203_api_t::ppgRead.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_PpgDataCalculate()

fsp_err_t RM_OB1203_PpgDataCalculate ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_raw_data_t *const  p_raw_data,
rm_ob1203_ppg_data_t *const  p_ob1203_data 
)

Calculate PPG data from raw data. Implements rm_ob1203_api_t::ppgDataCalculate.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_GainSet()

fsp_err_t RM_OB1203_GainSet ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_gain_t const  gain 
)

Set gain. This function should be called after calling RM_OB1203_MeasurementStop(). In RTOS and Light Proximity mode, blocks 2 bytes on the I2C bus. Implements rm_ob1203_api_t::gainSet.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_LedCurrentSet()

fsp_err_t RM_OB1203_LedCurrentSet ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_led_current_t const  led_current 
)

Set currents. This function should be called after calling RM_OB1203_MeasurementStop(). Implements rm_ob1203_api_t::ledCurrentSet.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_DeviceInterruptCfgSet()

fsp_err_t RM_OB1203_DeviceInterruptCfgSet ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_device_interrupt_cfg_t const  interrupt_cfg 
)

Set device interrupt configurations. This function should be called after calling RM_OB1203_MeasurementStop(). Implements rm_ob1203_api_t::deviceInterruptCfgSet.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_FifoInfoGet()

fsp_err_t RM_OB1203_FifoInfoGet ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_fifo_info_t *const  p_fifo_info 
)

Get FIFO information from OB1203 device. Implements rm_ob1203_api_t::fifoInfoGet.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.

◆ RM_OB1203_DeviceStatusGet()

fsp_err_t RM_OB1203_DeviceStatusGet ( rm_ob1203_ctrl_t *const  p_api_ctrl,
rm_ob1203_device_status_t *const  p_status 
)

Get device status from OB1203 device. Clear all interrupt bits. Implements rm_ob1203_api_t::deviceStatusGet.

Return values
FSP_SUCCESSSuccessfully results are read.
FSP_ERR_ASSERTIONNull pointer passed as a parameter.
FSP_ERR_NOT_OPENModule is not opened configured.
FSP_ERR_TIMEOUTCommunication is timeout.
FSP_ERR_ABORTEDCommunication is aborted.