upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
Go to the source code of this file.
Data Structures | |
struct | max30100_context |
Functions | |
max30100_context * | max30100_init (int16_t i2c_bus) |
void | max30100_close (max30100_context *dev) |
upm_result_t | max30100_sample (max30100_context *dev, max30100_value *samp) |
upm_result_t | max30100_sample_continuous (max30100_context *dev, int gpio_pin, bool buffered, func_sample_ready_handler isr, void *arg) |
upm_result_t | max30100_sample_stop (max30100_context *dev) |
upm_result_t | max30100_read (const max30100_context *dev, MAX30100_REG reg, uint8_t *rd_data) |
upm_result_t | max30100_write (const max30100_context *dev, MAX30100_REG reg, uint8_t wr_data) |
upm_result_t | max30100_rd_mod_wr (const max30100_context *dev, MAX30100_REG reg, uint8_t value, uint8_t mask) |
upm_result_t | max30100_get_version (const max30100_context *dev, uint16_t *version) |
upm_result_t | max30100_get_temperature (const max30100_context *dev, float *temperature) |
upm_result_t | max30100_set_mode (const max30100_context *dev, MAX30100_MODE mode) |
upm_result_t | max30100_get_mode (const max30100_context *dev, MAX30100_MODE *mode) |
upm_result_t | max30100_set_high_res (const max30100_context *dev, bool high_res) |
upm_result_t | max30100_get_high_res (const max30100_context *dev, bool *high_res) |
upm_result_t | max30100_set_sample_rate (const max30100_context *dev, MAX30100_SR sample_rate) |
upm_result_t | max30100_get_sample_rate (const max30100_context *dev, MAX30100_SR *sample_rate) |
upm_result_t | max30100_set_pulse_width (const max30100_context *dev, MAX30100_LED_PW pulse_width) |
upm_result_t | max30100_get_pulse_width (const max30100_context *dev, MAX30100_LED_PW *pulse_width) |
upm_result_t | max30100_set_current (const max30100_context *dev, MAX30100_LED_CURRENT ir, MAX30100_LED_CURRENT r) |
upm_result_t | max30100_get_current (const max30100_context *dev, MAX30100_LED_CURRENT *ir, MAX30100_LED_CURRENT *r) |
upm_result_t | max30100_reset (const max30100_context *dev) |
upm_result_t | max30100_sleep (const max30100_context *dev, bool sleep) |
max30100_context* max30100_init | ( | int16_t | i2c_bus | ) |
Initialize sensor. Note, the MAX30100 I2C address is set to 0x57.
i2c_bus | Target I2C bus |
void max30100_close | ( | max30100_context * | dev | ) |
Sensor close method.
Cleans up any memory held by this device
dev | Sensor context pointer |
upm_result_t max30100_sample | ( | max30100_context * | dev, |
max30100_value * | samp | ||
) |
Sample a single set of infrared/red values
Note, all setup (sample rate, LED current, and pulse width must be done prior to calling this sample method.
dev | Sensor context pointer |
samp | IR/R values are returned in this structure |
upm_result_t max30100_sample_continuous | ( | max30100_context * | dev, |
int | gpio_pin, | ||
bool | buffered, | ||
func_sample_ready_handler | isr, | ||
void * | arg | ||
) |
Continuously sample Infrared/Red values.
This method requires a GPIO pin which is used to signal sample/samples ready. The INT * pin is open-drain and requires a pullup resistor. The interrupt pin is not designed to sink large currents, so the pull-up resistor value should be large, such as 4.7k ohm. The RCWL-0530 PCB which this library was designed with had the I2C lines and INT pin pulled up to 1.8v.
Note, all setup (sample rate, mode, LED current, and pulse width must be done prior to calling this sample method.
dev | Sensor context pointer |
gpio_pin | GPIO pin used for interrupt (input from sensor INT pin) |
buffered | Enable buffered sampling. In buffered sampling mode, the device reads 16 samples at a time. This can help with I2C read timing. buffered == true, enable buffered sampling buffered == false, single-sample mode |
isr | Function pointer which handles 1 IR/R sample and a void ptr arg |
arg | Void * passed back with ISR call |
upm_result_t max30100_sample_stop | ( | max30100_context * | dev | ) |
Stop continuous sampling. Disable interrupts.
dev | Sensor context pointer |
upm_result_t max30100_read | ( | const max30100_context * | dev, |
MAX30100_REG | reg, | ||
uint8_t * | rd_data | ||
) |
Read Oximeter and heart-rate sensor register
dev | Sensor context pointer |
reg | Target register |
rd_data | Data from sensor |
upm_result_t max30100_write | ( | const max30100_context * | dev, |
MAX30100_REG | reg, | ||
uint8_t | wr_data | ||
) |
Write Oximeter and heart-rate sensor register
dev | Sensor context pointer |
reg | Target register to write |
wr_data | Target data to write |
upm_result_t max30100_rd_mod_wr | ( | const max30100_context * | dev, |
MAX30100_REG | reg, | ||
uint8_t | value, | ||
uint8_t | mask | ||
) |
Read modify write Oximeter and heart-rate sensor register
dev | Sensor context pointer |
reg | Target register |
value | Target bits to set/clear |
mask | Specify the bits to set/clear If mask = 0xf0, read full byte, modify only the upper 4 bits If mask = 0xaa, read full byte, modify every other bit |
upm_result_t max30100_get_version | ( | const max30100_context * | dev, |
uint16_t * | version | ||
) |
Get sensor version Sensor version is a 2 byte value: upper byte = PART ID lower byte = REVISION ID
example: version() return 0x1105 0x11 = PART ID 0x05 = REVISION
dev | Sensor context pointer |
rd_data | Sensor version |
upm_result_t max30100_get_temperature | ( | const max30100_context * | dev, |
float * | temperature | ||
) |
Get temperature reading from device
dev | Sensor context pointer |
rd_data | Temperature in degrees Celsius |
upm_result_t max30100_set_mode | ( | const max30100_context * | dev, |
MAX30100_MODE | mode | ||
) |
Set the sampling mode (none vs red only vs SpO2)
dev | Sensor context pointer |
mode | Sensor mode value to write into the mode configuration register |
upm_result_t max30100_get_mode | ( | const max30100_context * | dev, |
MAX30100_MODE * | mode | ||
) |
Get the mode field from the mode configuration register
dev | Sensor context pointer |
mode | Sensor mode value read from mode configuration register |
upm_result_t max30100_set_high_res | ( | const max30100_context * | dev, |
bool | high_res | ||
) |
Set the high-res field in the SpO2 configuration register
dev | Sensor context pointer |
high_res | Sensor high-res value to write into the SpO2 configuration register |
upm_result_t max30100_get_high_res | ( | const max30100_context * | dev, |
bool * | high_res | ||
) |
Get the high-res field from the SpO2 configuration register
dev | Sensor context pointer |
high_res | Sensor high_res value read from the SpO2 configuration register |
upm_result_t max30100_set_sample_rate | ( | const max30100_context * | dev, |
MAX30100_SR | sample_rate | ||
) |
Set the sample rate field in the SpO2 configuration register
dev | Sensor context pointer |
sample_rate | Sensor sample rate value to write into the SpO2 configuration register |
upm_result_t max30100_get_sample_rate | ( | const max30100_context * | dev, |
MAX30100_SR * | sample_rate | ||
) |
Get the sample rate field from the SpO2 configuration register
dev | Sensor context pointer |
sample_rate | Sensor sample rate value read from the SpO2 configuration register |
upm_result_t max30100_set_pulse_width | ( | const max30100_context * | dev, |
MAX30100_LED_PW | pulse_width | ||
) |
Set the pulse width field in the SpO2 configuration register
dev | Sensor context pointer |
pulse_width | Sensor pulse width value to write into the SpO2 configuration register |
upm_result_t max30100_get_pulse_width | ( | const max30100_context * | dev, |
MAX30100_LED_PW * | pulse_width | ||
) |
Get the pulse width field from the SpO2 configuration register
dev | Sensor context pointer |
pulse_width | Sensor pulse width value read from the SpO2 configuration register |
upm_result_t max30100_set_current | ( | const max30100_context * | dev, |
MAX30100_LED_CURRENT | ir, | ||
MAX30100_LED_CURRENT | r | ||
) |
Set the LED current
dev | Sensor context pointer |
ir | Infrared LED current enum |
r | Red LED current enum |
upm_result_t max30100_get_current | ( | const max30100_context * | dev, |
MAX30100_LED_CURRENT * | ir, | ||
MAX30100_LED_CURRENT * | r | ||
) |
Get the LED current
dev | Sensor context pointer |
ir | Infrared LED current read from the LED configuration register |
r | Red LED current read from the LED configuration register |
upm_result_t max30100_reset | ( | const max30100_context * | dev | ) |
Reset sensor
When the RESET bit is set to one, all configuration, threshold, and data registers are reset to their power-on-state. The only exception is writing both RESET and TEMP_EN bits to one at the same time since temperature data registers 0x16 and 0x17 are not cleared. The RESET bit is cleared automatically back to zero after the reset sequence is completed.
dev | Sensor context pointer |
upm_result_t max30100_sleep | ( | const max30100_context * | dev, |
bool | sleep | ||
) |
Put device into power-save mode. While in power-save mode, all registers retain their values, and write/read operations function as normal. All interrupts are cleared to zero in this mode.
dev | Sensor context pointer |
sleep | Enter/exit power-save mode true = Enter power-save mode false = Exit power-save mode |