![]() |
no-OS
|
Header file for MAXM86161 optical pulse oximeter driver. More...
#include <stdint.h>#include <stdbool.h>#include "no_os_i2c.h"#include "no_os_gpio.h"#include "no_os_irq.h"#include "no_os_util.h"Classes | |
| struct | maxm86161_int_handler |
| struct | maxm86161_dev |
| struct | maxm86161_init_param |
Typedefs | |
| typedef void(* | maxm86161_int_cb_t) (void *ctx) |
Functions | |
| int | maxm86161_init (struct maxm86161_dev **device, struct maxm86161_init_param *init_param) |
| Initialize the MAXM86161 device driver. | |
| int | maxm86161_remove (struct maxm86161_dev *dev) |
| Free resources allocated by maxm86161_init(). | |
| int | maxm86161_reset (struct maxm86161_dev *dev) |
| Perform a software reset of the MAXM86161. | |
| int | maxm86161_verify_id (struct maxm86161_dev *dev) |
| Verify the MAXM86161 part identity and cache revision info. | |
| int | maxm86161_reg_read (struct maxm86161_dev *dev, uint8_t reg_addr, uint8_t *reg_data) |
| Read a single register from the MAXM86161. | |
| int | maxm86161_reg_write (struct maxm86161_dev *dev, uint8_t reg_addr, uint8_t reg_data) |
| Write a single register on the MAXM86161. | |
| int | maxm86161_reg_update_bits (struct maxm86161_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data) |
| Read-modify-write the bits selected by a mask in a register. | |
| int | maxm86161_burst_reg_read (struct maxm86161_dev *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count) |
| Burst-read multiple bytes starting at a register address. | |
| int | maxm86161_burst_reg_write (struct maxm86161_dev *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count) |
| Burst-write multiple bytes starting at a register address. | |
| int | maxm86161_shutdown (struct maxm86161_dev *dev) |
| Put the MAXM86161 into shutdown (power-down) mode. | |
| int | maxm86161_set_shutdown (struct maxm86161_dev *dev, bool enable) |
| Enable or disable shutdown mode of the MAXM86161. | |
| int | maxm86161_set_low_power_mode (struct maxm86161_dev *dev, bool enable) |
| Enable or disable low-power mode of the MAXM86161. | |
| int | maxm86161_set_sample_rate (struct maxm86161_dev *dev, uint8_t ppg_sr) |
| Set the PPG sample rate. | |
| int | maxm86161_get_sample_rate (struct maxm86161_dev *dev, uint8_t *ppg_sr) |
| Get the currently configured PPG sample rate. | |
| int | maxm86161_set_integration_time (struct maxm86161_dev *dev, enum maxm86161_ppg_tint tint) |
| Set the PPG ADC integration time. | |
| int | maxm86161_get_integration_time (struct maxm86161_dev *dev, enum maxm86161_ppg_tint *tint) |
| Get the currently configured PPG ADC integration time. | |
| int | maxm86161_set_adc_range (struct maxm86161_dev *dev, enum maxm86161_adc_range range) |
| Set the PPG ADC full-scale range. | |
| int | maxm86161_get_adc_range (struct maxm86161_dev *dev, enum maxm86161_adc_range *range) |
| Get the currently configured PPG ADC full-scale range. | |
| int | maxm86161_set_sample_averaging (struct maxm86161_dev *dev, enum maxm86161_smp_ave avg) |
| Set the number of samples averaged per FIFO data point. | |
| int | maxm86161_get_sample_averaging (struct maxm86161_dev *dev, enum maxm86161_smp_ave *avg) |
| Get the currently configured sample averaging. | |
| int | maxm86161_set_alc_disable (struct maxm86161_dev *dev, bool disable) |
| Enable or disable the Ambient Light Cancellation (ALC) circuit. | |
| int | maxm86161_get_alc_disable (struct maxm86161_dev *dev, bool *disable) |
| Get the current Ambient Light Cancellation (ALC) disable state. | |
| int | maxm86161_set_add_offset (struct maxm86161_dev *dev, bool enable) |
| Enable or disable the ADC add-offset feature. | |
| int | maxm86161_get_add_offset (struct maxm86161_dev *dev, bool *enable) |
| Get the current ADC add-offset enable state. | |
| int | maxm86161_set_led_settling (struct maxm86161_dev *dev, enum maxm86161_led_settling settling) |
| Set the LED settling time. | |
| int | maxm86161_get_led_settling (struct maxm86161_dev *dev, enum maxm86161_led_settling *settling) |
| Get the currently configured LED settling time. | |
| int | maxm86161_set_digital_filter (struct maxm86161_dev *dev, enum maxm86161_dig_filt_sel filter) |
| Select the PPG digital filter (CDM or FDM). | |
| int | maxm86161_get_digital_filter (struct maxm86161_dev *dev, enum maxm86161_dig_filt_sel *filter) |
| Get the currently selected PPG digital filter. | |
| int | maxm86161_set_pd_bias (struct maxm86161_dev *dev, enum maxm86161_pd_bias bias) |
| Set the photodiode bias (based on PD capacitance). | |
| int | maxm86161_get_pd_bias (struct maxm86161_dev *dev, enum maxm86161_pd_bias *bias) |
| Get the currently configured photodiode bias. | |
| int | maxm86161_set_led_sequence (struct maxm86161_dev *dev, uint8_t slot, enum maxm86161_led_src src) |
| Set the LED/measurement source for a single sequence slot. | |
| int | maxm86161_get_led_sequence (struct maxm86161_dev *dev, uint8_t slot, enum maxm86161_led_src *src) |
| Get the LED/measurement source configured for a sequence slot. | |
| int | maxm86161_set_led_pulse_amplitude (struct maxm86161_dev *dev, enum maxm86161_led_num led_num, uint8_t amplitude) |
| Set the pulse amplitude (drive current) of an LED. | |
| int | maxm86161_get_led_pulse_amplitude (struct maxm86161_dev *dev, enum maxm86161_led_num led_num, uint8_t *amplitude) |
| Get the pulse amplitude (drive current) of an LED. | |
| int | maxm86161_set_led_range (struct maxm86161_dev *dev, enum maxm86161_led_num led_num, enum maxm86161_led_range range) |
| Set the full-scale current range of an LED driver. | |
| int | maxm86161_get_led_range (struct maxm86161_dev *dev, enum maxm86161_led_num led_num, enum maxm86161_led_range *range) |
| Get the full-scale current range of an LED driver. | |
| int | maxm86161_set_led_cfg (struct maxm86161_dev *dev, enum maxm86161_led_num led_num, enum maxm86161_led_range range, uint8_t led_seq_num, uint8_t amplitude) |
| Get the full-scale current range of an LED driver. | |
| int | maxm86161_set_hires_dac (struct maxm86161_dev *dev, uint8_t slot, bool override, uint8_t dac_val) |
| Configure the high-resolution DAC override for a sequence slot. | |
| int | maxm86161_get_hires_dac (struct maxm86161_dev *dev, uint8_t slot, bool *override, uint8_t *dac_val) |
| Read back the high-resolution DAC configuration for a slot. | |
| int | maxm86161_set_fifo_watermark (struct maxm86161_dev *dev, uint8_t watermark) |
| Set the FIFO almost-full watermark threshold. | |
| int | maxm86161_get_fifo_watermark (struct maxm86161_dev *dev, uint8_t *watermark) |
| Get the FIFO almost-full watermark threshold. | |
| int | maxm86161_fifo_flush (struct maxm86161_dev *dev) |
| Flush (clear) the FIFO contents. | |
| int | maxm86161_set_fifo_rollover (struct maxm86161_dev *dev, bool enable) |
| Enable or disable FIFO roll-over on full. | |
| int | maxm86161_get_fifo_rollover (struct maxm86161_dev *dev, bool *enable) |
| Get the FIFO roll-over enable state. | |
| int | maxm86161_set_fifo_a_full_type (struct maxm86161_dev *dev, bool type) |
| Set the FIFO almost-full interrupt assertion behavior. | |
| int | maxm86161_get_fifo_a_full_type (struct maxm86161_dev *dev, bool *type) |
| Get the FIFO almost-full interrupt assertion behavior. | |
| int | maxm86161_set_fifo_stat_clr (struct maxm86161_dev *dev, bool enable) |
| Configure whether reading FIFO data clears the status bit. | |
| int | maxm86161_get_fifo_count (struct maxm86161_dev *dev, uint8_t *count) |
| Get the number of samples currently stored in the FIFO. | |
| int | maxm86161_fifo_overflow_check (struct maxm86161_dev *dev, uint8_t *overflow_count) |
| Read the FIFO overflow counter. | |
| int | maxm86161_read_fifo_data (struct maxm86161_dev *dev, uint8_t *data, uint16_t num_samples) |
| Burst-read raw sample data from the FIFO. | |
| int | maxm86161_decode_fifo_sample (uint8_t *raw, uint8_t *tag, uint32_t *data) |
| Decode a raw 3-byte FIFO sample into its tag and data fields. | |
| int | maxm86161_get_interrupt_status (struct maxm86161_dev *dev, uint16_t *status) |
| Read the combined interrupt status of the MAXM86161. | |
| int | maxm86161_clear_interrupt_status (struct maxm86161_dev *dev) |
| Clear pending interrupt status flags. | |
| int | maxm86161_set_irq_handler (struct maxm86161_dev *dev, enum maxm86161_irq_sources int_source, bool enable, maxm86161_int_cb_t callback, void *cb_args) |
| Register a callback for an interrupt source and enable/disable it. | |
| void | maxm86161_irq_handler (void *ctx) |
| Top-level interrupt dispatcher for the MAXM86161. | |
| int | maxm86161_set_prox_threshold (struct maxm86161_dev *dev, uint8_t threshold) |
| Set the proximity mode entry threshold. | |
| int | maxm86161_get_prox_threshold (struct maxm86161_dev *dev, uint8_t *threshold) |
| Get the proximity mode entry threshold. | |
| int | maxm86161_set_pf_enable (struct maxm86161_dev *dev, bool enable) |
| Enable or disable the picket-fence detect-and-replace feature. | |
| int | maxm86161_get_pf_enable (struct maxm86161_dev *dev, bool *enable) |
| Get the picket-fence enable state. | |
| int | maxm86161_set_pf_order (struct maxm86161_dev *dev, bool order) |
| Set the picket-fence detect/replace ordering. | |
| int | maxm86161_get_pf_order (struct maxm86161_dev *dev, bool *order) |
| Get the picket-fence detect/replace ordering. | |
| int | maxm86161_set_pf_iir_tc (struct maxm86161_dev *dev, enum maxm86161_pf_iir_tc iir_tc) |
| Set the picket-fence IIR time constant. | |
| int | maxm86161_get_pf_iir_tc (struct maxm86161_dev *dev, enum maxm86161_pf_iir_tc *iir_tc) |
| Get the picket-fence IIR time constant. | |
| int | maxm86161_set_pf_iir_init (struct maxm86161_dev *dev, enum maxm86161_pf_iir_init iir_init_value) |
| Set the picket-fence IIR initialization value. | |
| int | maxm86161_get_pf_iir_init (struct maxm86161_dev *dev, enum maxm86161_pf_iir_init *iir_init_value) |
| Get the picket-fence IIR initialization value. | |
| int | maxm86161_set_pf_threshold_sigma (struct maxm86161_dev *dev, enum maxm86161_pf_threshold_sigma_mult threshold_sigma_mult) |
| Set the picket-fence threshold sigma multiplier. | |
| int | maxm86161_get_pf_threshold_sigma (struct maxm86161_dev *dev, enum maxm86161_pf_threshold_sigma_mult *threshold_sigma_mult) |
| Get the picket-fence threshold sigma multiplier. | |
| int | maxm86161_read_die_temperature (struct maxm86161_dev *dev, int32_t *temperature) |
| Read and convert the die temperature. | |
| int | maxm86161_start_calibration (struct maxm86161_dev *dev) |
| Start the DAC (offset) calibration procedure. | |
| int | maxm86161_get_calibration_status (struct maxm86161_dev *dev, bool *complete, bool *oor) |
| Query the DAC calibration status. | |
| int | maxm86161_set_burst_enable (struct maxm86161_dev *dev, bool enable) |
| Enable or disable burst sampling mode and set its rate. | |
| int | maxm86161_set_burst_rate (struct maxm86161_dev *dev, enum maxm86161_burst_rate rate) |
| Enable or disable burst sampling mode and set its rate. | |
| int | maxm86161_set_burst_mode (struct maxm86161_dev *dev, bool enable, enum maxm86161_burst_rate rate) |
| Enable or disable burst sampling mode and set its rate. | |
| int | maxm86161_set_timestamp_enable (struct maxm86161_dev *dev, bool enable) |
| Enable or disable timestamp tagging of PPG samples. | |
| int | maxm86161_set_dac_code_tag (struct maxm86161_dev *dev, bool enable) |
| Enable or disable DAC-code tagging of PPG samples. | |
| int | maxm86161_set_gpio_ctrl (struct maxm86161_dev *dev, enum maxm86161_gpio_ctrl ctrl) |
| Configure the behavior of the GPIO/sync pin. | |
| int | maxm86161_force_sync (struct maxm86161_dev *dev) |
| Issue a software-forced PPG synchronization event. | |
| int | maxm86161_sha_enable (struct maxm86161_dev *dev, bool enable) |
| Enable or disable the SHA-256 authentication engine. | |
| int | maxm86161_sha_start (struct maxm86161_dev *dev, uint8_t cmd) |
| Issue a SHA command and start the SHA-256 operation. | |
| int | maxm86161_sha_write_challenge (struct maxm86161_dev *dev, uint8_t *challenge, uint8_t len) |
| Write a SHA-256 challenge into the device memory. | |
| int | maxm86161_sha_read_response (struct maxm86161_dev *dev, uint8_t *response, uint8_t len) |
| Read the SHA-256 response from the device memory. | |
| int | maxm86161_memory_read (struct maxm86161_dev *dev, uint16_t addr, uint8_t *data) |
| Read a single byte from the device memory. | |
| int | maxm86161_memory_write (struct maxm86161_dev *dev, uint16_t addr, uint8_t data) |
| Write a single byte to the device memory. | |
Header file for MAXM86161 optical pulse oximeter driver.
Copyright 2026(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| #define MAXM86161_CAL_DAC1_OOR NO_OS_BIT(4) |
| #define MAXM86161_CAL_DAC_COMPLETE NO_OS_BIT(6) |
| #define MAXM86161_DIE_TEMP_FRAC_OFFSET 8 |
| #define MAXM86161_DIE_TEMP_FRAC_SCALE_UC 62500 |
| #define MAXM86161_DIE_TEMP_SCALE_UC 1000000 |
| #define MAXM86161_FIFO_A_FULL_MAX 127 |
| #define MAXM86161_FIFO_A_FULL_MSK NO_OS_GENMASK(6, 0) |
| #define MAXM86161_FIFO_BURST_RD_CAP (255U - (255U % MAXM86161_FIFO_SAMPLE_SIZE)) |
| #define MAXM86161_FIFO_CFG2_A_FULL_TYPE NO_OS_BIT(2) |
| #define MAXM86161_FIFO_CFG2_FIFO_RO NO_OS_BIT(1) |
| #define MAXM86161_FIFO_CFG2_FLUSH NO_OS_BIT(4) |
| #define MAXM86161_FIFO_CFG2_STAT_CLR NO_OS_BIT(3) |
| #define MAXM86161_FIFO_DATA_MSK NO_OS_GENMASK(18, 0) |
| #define MAXM86161_FIFO_DATA_SIZE 3 |
| #define MAXM86161_FIFO_DEPTH 128 |
| #define MAXM86161_FIFO_OVF_COUNTER_MSK NO_OS_GENMASK(6, 0) |
| #define MAXM86161_FIFO_PACK | ( | tag, | |
| data ) |
| #define MAXM86161_FIFO_SAMPLE_SIZE 3 |
| #define MAXM86161_FIFO_TAG_MSK NO_OS_GENMASK(23, 19) |
| #define MAXM86161_FIFO_TAG_SHIFT 19 |
| #define MAXM86161_HIRES_DAC_OVR NO_OS_BIT(7) |
| #define MAXM86161_HIRES_DAC_VAL_MSK NO_OS_GENMASK(5, 0) |
| #define MAXM86161_I2C_ADDR 0x62 |
| #define MAXM86161_INT1_A_FULL NO_OS_BIT(7) |
| #define MAXM86161_INT1_A_FULL_EN NO_OS_BIT(7) |
| #define MAXM86161_INT1_ALC_OVF NO_OS_BIT(5) |
| #define MAXM86161_INT1_ALC_OVF_EN NO_OS_BIT(5) |
| #define MAXM86161_INT1_DATA_RDY NO_OS_BIT(6) |
| #define MAXM86161_INT1_DATA_RDY_EN NO_OS_BIT(6) |
| #define MAXM86161_INT1_DIE_TEMP_RDY NO_OS_BIT(2) |
| #define MAXM86161_INT1_DIE_TEMP_RDY_EN NO_OS_BIT(2) |
| #define MAXM86161_INT1_LED_COMPB NO_OS_BIT(3) |
| #define MAXM86161_INT1_LED_COMPB_EN NO_OS_BIT(3) |
| #define MAXM86161_INT1_PROX_INT NO_OS_BIT(4) |
| #define MAXM86161_INT1_PROX_INT_EN NO_OS_BIT(4) |
| #define MAXM86161_INT1_PWR_RDY NO_OS_BIT(0) |
| #define MAXM86161_INT2_SHA_DONE NO_OS_BIT(0) |
| #define MAXM86161_INT2_SHA_DONE_EN NO_OS_BIT(0) |
| #define MAXM86161_LED1_RGE_MSK NO_OS_GENMASK(1, 0) |
| #define MAXM86161_LED2_RGE_MSK NO_OS_GENMASK(3, 2) |
| #define MAXM86161_LED3_RGE_MSK NO_OS_GENMASK(5, 4) |
| #define MAXM86161_LED_SEQ_EVEN_MSK NO_OS_GENMASK(7, 4) |
| #define MAXM86161_LED_SEQ_ODD_MSK NO_OS_GENMASK(3, 0) |
| #define MAXM86161_MEM_BANK_SEL NO_OS_BIT(0) |
| #define MAXM86161_MEM_IDX_BANK0_MSK 0xFF |
| #define MAXM86161_MEM_IDX_MAX 0x17F |
| #define MAXM86161_MEM_WR_EN NO_OS_BIT(1) |
| #define MAXM86161_NUM_LED_SEQ 6 |
| #define MAXM86161_NUM_LEDS 3 |
| #define MAXM86161_PART_ID_VAL 0x36 |
| #define MAXM86161_PD_BIAS_MSK NO_OS_GENMASK(2, 0) |
| #define MAXM86161_PF_ENABLE NO_OS_BIT(7) |
| #define MAXM86161_PF_IIR_INIT_MSK NO_OS_GENMASK(3, 2) |
| #define MAXM86161_PF_IIR_TC_MSK NO_OS_GENMASK(5, 4) |
| #define MAXM86161_PF_ORDER NO_OS_BIT(6) |
| #define MAXM86161_PF_THRESH_SIGMA_MSK NO_OS_GENMASK(1, 0) |
| #define MAXM86161_PPG_CFG1_ADC_RGE_MSK NO_OS_GENMASK(3, 2) |
| #define MAXM86161_PPG_CFG1_ADD_OFFSET NO_OS_BIT(6) |
| #define MAXM86161_PPG_CFG1_ALC_DISABLE NO_OS_BIT(7) |
| #define MAXM86161_PPG_CFG1_PPG_TINT_MSK NO_OS_GENMASK(1, 0) |
| #define MAXM86161_PPG_CFG2_PPG_SR_MSK NO_OS_GENMASK(7, 3) |
| #define MAXM86161_PPG_CFG2_SMP_AVE_MSK NO_OS_GENMASK(2, 0) |
| #define MAXM86161_PPG_CFG3_BURST_EN NO_OS_BIT(0) |
| #define MAXM86161_PPG_CFG3_BURST_RATE_MSK NO_OS_GENMASK(2, 1) |
| #define MAXM86161_PPG_CFG3_DIG_FILT_MSK NO_OS_BIT(5) |
| #define MAXM86161_PPG_CFG3_LED_SETLNG_MSK NO_OS_GENMASK(7, 6) |
| #define MAXM86161_PPG_SR_MAX 0x13 |
| #define MAXM86161_PPG_SYNC_DAC_CODE_TAG NO_OS_BIT(6) |
| #define MAXM86161_PPG_SYNC_GPIO_CTRL_MSK NO_OS_GENMASK(3, 0) |
| #define MAXM86161_PPG_SYNC_SW_FORCE NO_OS_BIT(4) |
| #define MAXM86161_PPG_SYNC_TIMESTAMP_EN NO_OS_BIT(7) |
| #define MAXM86161_REG_DAC_CAL_EN 0x50 |
| #define MAXM86161_REG_DIE_TEMP_CFG 0x40 |
| #define MAXM86161_REG_DIE_TEMP_FRAC 0x42 |
| #define MAXM86161_REG_DIE_TEMP_FRAC_MASK NO_OS_GENMASK(3, 0) |
| #define MAXM86161_REG_DIE_TEMP_INT 0x41 |
| #define MAXM86161_REG_DIE_TEMP_INT_MASK NO_OS_GENMASK(7, 0) /* Temp should be read in a burst */ |
| #define MAXM86161_REG_FIFO_CFG_1 0x09 |
| #define MAXM86161_REG_FIFO_CFG_2 0x0A |
| #define MAXM86161_REG_FIFO_DATA 0x08 |
| #define MAXM86161_REG_FIFO_DATA_COUNT 0x07 |
| #define MAXM86161_REG_FIFO_RD_PTR 0x05 |
| #define MAXM86161_REG_FIFO_WR_PTR 0x04 |
| #define MAXM86161_REG_INT_EN_1 0x02 |
| #define MAXM86161_REG_INT_EN_2 0x03 |
| #define MAXM86161_REG_INT_STATUS_1 0x00 |
| #define MAXM86161_REG_INT_STATUS_2 0x01 |
| #define MAXM86161_REG_LED1_PA 0x23 |
| #define MAXM86161_REG_LED2_PA 0x24 |
| #define MAXM86161_REG_LED3_PA 0x25 |
| #define MAXM86161_REG_LED_PILOT_PA 0x29 |
| #define MAXM86161_REG_LED_RANGE_1 0x2A |
| #define MAXM86161_REG_LED_SEQ_1 0x20 |
| #define MAXM86161_REG_LED_SEQ_2 0x21 |
| #define MAXM86161_REG_LED_SEQ_3 0x22 |
| #define MAXM86161_REG_MEM_CTRL 0xF2 |
| #define MAXM86161_REG_MEM_DATA 0xF4 |
| #define MAXM86161_REG_MEM_IDX 0xF3 |
| #define MAXM86161_REG_OVF_COUNTER 0x06 |
| #define MAXM86161_REG_PART_ID 0xFF |
| #define MAXM86161_REG_PD_BIAS 0x15 |
| #define MAXM86161_REG_PICKET_FENCE 0x16 |
| #define MAXM86161_REG_PPG_CFG_1 0x11 |
| #define MAXM86161_REG_PPG_CFG_2 0x12 |
| #define MAXM86161_REG_PPG_CFG_3 0x13 |
| #define MAXM86161_REG_PPG_SYNC_CTRL 0x10 |
| #define MAXM86161_REG_PROX_INT_THRESH 0x14 |
| #define MAXM86161_REG_REV_ID 0xFE |
| #define MAXM86161_REG_S1_HIRES_DAC 0x2C |
| #define MAXM86161_REG_S2_HIRES_DAC 0x2D |
| #define MAXM86161_REG_S3_HIRES_DAC 0x2E |
| #define MAXM86161_REG_S4_HIRES_DAC 0x2F |
| #define MAXM86161_REG_S5_HIRES_DAC 0x30 |
| #define MAXM86161_REG_S6_HIRES_DAC 0x31 |
| #define MAXM86161_REG_SHA_CFG 0xF1 |
| #define MAXM86161_REG_SHA_CMD 0xF0 |
| #define MAXM86161_REG_SYS_CTRL 0x0D |
| #define MAXM86161_RESET_DELAY_MS 10 |
| #define MAXM86161_SHA_CHALLENGE_LEN 20 |
| #define MAXM86161_SHA_CMD_MAC_W_ROM 0x35 |
| #define MAXM86161_SHA_CMD_MAC_WO_ROM 0x36 |
| #define MAXM86161_SHA_EN NO_OS_BIT(1) |
| #define MAXM86161_SHA_MEM_END 0x09 |
| #define MAXM86161_SHA_MEM_START 0x00 |
| #define MAXM86161_SHA_START NO_OS_BIT(0) |
| #define MAXM86161_START_CAL NO_OS_BIT(2) |
| #define MAXM86161_SYS_CTRL_LP_MODE NO_OS_BIT(2) |
| #define MAXM86161_SYS_CTRL_RESET NO_OS_BIT(0) |
| #define MAXM86161_SYS_CTRL_SHDN NO_OS_BIT(1) |
| #define MAXM86161_SYS_CTRL_SINGLE_PPG NO_OS_BIT(3) |
| #define MAXM86161_TEMP_EN NO_OS_BIT(0) |
| #define MAXM86161_TEMP_MEAS_DELAY_MS 10 |
| #define MAXM86161_TEMP_MEAS_WAIT_TRIES 10 |
| typedef void(* maxm86161_int_cb_t) (void *ctx) |
| enum maxm86161_adc_range |
| enum maxm86161_burst_rate |
| enum maxm86161_fifo_tag |
| enum maxm86161_gpio_ctrl |
| enum maxm86161_led_num |
| enum maxm86161_led_range |
| enum maxm86161_led_src |
| enum maxm86161_pd_bias |
| enum maxm86161_pf_iir_tc |
| enum maxm86161_ppg_tint |
| enum maxm86161_smp_ave |
| int maxm86161_burst_reg_read | ( | struct maxm86161_dev * | dev, |
| uint8_t | reg_addr, | ||
| uint8_t * | reg_data, | ||
| uint16_t | count ) |
Burst-read multiple bytes starting at a register address.
| dev | - Device descriptor. |
| reg_addr | - Starting register address for the burst read. |
| reg_data | - Buffer where the read bytes are stored. |
| count | - Number of bytes to read. |
| int maxm86161_burst_reg_write | ( | struct maxm86161_dev * | dev, |
| uint8_t | reg_addr, | ||
| uint8_t * | reg_data, | ||
| uint16_t | count ) |
Burst-write multiple bytes starting at a register address.
| dev | - Device descriptor. |
| reg_addr | - Starting register address for the burst write. |
| reg_data | - Buffer holding the bytes to write. |
| count | - Number of bytes to write. |
| int maxm86161_clear_interrupt_status | ( | struct maxm86161_dev * | dev | ) |
Clear pending interrupt status flags.
Reads INT_STATUS_1 and INT_STATUS_2 (which are cleared on read) to acknowledge and clear any pending interrupt flags.
| dev | - Device descriptor. |
| int maxm86161_decode_fifo_sample | ( | uint8_t * | raw, |
| uint8_t * | tag, | ||
| uint32_t * | data ) |
Decode a raw 3-byte FIFO sample into its tag and data fields.
Combines the three raw bytes (big-endian) into a 24-bit value and extracts the sample tag and the measurement data.
| raw | - Pointer to the 3 raw sample bytes. |
| tag | - Pointer where the decoded sample tag is stored. |
| data | - Pointer where the decoded measurement data is stored. |
| int maxm86161_fifo_flush | ( | struct maxm86161_dev * | dev | ) |
Flush (clear) the FIFO contents.
Sets the FLUSH bit in FIFO_CFG_2 to discard all currently buffered samples.
| dev | - Device descriptor. |
| int maxm86161_fifo_overflow_check | ( | struct maxm86161_dev * | dev, |
| uint8_t * | overflow_count ) |
Read the FIFO overflow counter.
Reads the OVF_COUNTER register and returns the number of samples lost due to FIFO overflow (lower 7 bits).
| dev | - Device descriptor. |
| overflow_count | - Pointer where the overflow sample count is stored. |
| int maxm86161_force_sync | ( | struct maxm86161_dev * | dev | ) |
Issue a software-forced PPG synchronization event.
Sets the SW_FORCE bit in the PPG sync control register to trigger a sync.
| dev | - Device descriptor. |
| int maxm86161_get_adc_range | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_adc_range * | range ) |
Get the currently configured PPG ADC full-scale range.
| dev | - Device descriptor. |
| range | - Pointer where the ADC range selection is stored. |
| int maxm86161_get_add_offset | ( | struct maxm86161_dev * | dev, |
| bool * | enable ) |
Get the current ADC add-offset enable state.
| dev | - Device descriptor. |
| enable | - Pointer set to true if the offset is enabled, false otherwise. |
| int maxm86161_get_alc_disable | ( | struct maxm86161_dev * | dev, |
| bool * | disable ) |
Get the current Ambient Light Cancellation (ALC) disable state.
| dev | - Device descriptor. |
| disable | - Pointer set to true if ALC is disabled, false otherwise. |
| int maxm86161_get_calibration_status | ( | struct maxm86161_dev * | dev, |
| bool * | complete, | ||
| bool * | oor ) |
Query the DAC calibration status.
Reads the DAC calibration register and reports whether calibration has completed and whether the result is out of range.
| dev | - Device descriptor. |
| complete | - Pointer set to true when calibration has completed. |
| oor | - Pointer set to true when the calibration result is out of range. |
| int maxm86161_get_digital_filter | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_dig_filt_sel * | filter ) |
Get the currently selected PPG digital filter.
| dev | - Device descriptor. |
| filter | - Pointer where the digital filter selection is stored. |
| int maxm86161_get_fifo_a_full_type | ( | struct maxm86161_dev * | dev, |
| bool * | type ) |
Get the FIFO almost-full interrupt assertion behavior.
| dev | - Device descriptor. |
| type | - Pointer where the almost-full interrupt type is stored. |
| int maxm86161_get_fifo_count | ( | struct maxm86161_dev * | dev, |
| uint8_t * | count ) |
Get the number of samples currently stored in the FIFO.
| dev | - Device descriptor. |
| count | - Pointer where the FIFO sample count is stored. |
| int maxm86161_get_fifo_rollover | ( | struct maxm86161_dev * | dev, |
| bool * | enable ) |
Get the FIFO roll-over enable state.
| dev | - Device descriptor. |
| enable | - Pointer set to true if roll-over is enabled, false otherwise. |
| int maxm86161_get_fifo_watermark | ( | struct maxm86161_dev * | dev, |
| uint8_t * | watermark ) |
Get the FIFO almost-full watermark threshold.
| dev | - Device descriptor. |
| watermark | - Pointer where the almost-full threshold is stored. |
| int maxm86161_get_hires_dac | ( | struct maxm86161_dev * | dev, |
| uint8_t | slot, | ||
| bool * | override, | ||
| uint8_t * | dac_val ) |
Read back the high-resolution DAC configuration for a slot.
| dev | - Device descriptor. |
| slot | - Sequence slot index (1 to MAXM86161_NUM_LED_SEQ). |
| override | - Pointer set to true if the DAC override is active. |
| dac_val | - Pointer where the 6-bit DAC value is stored. |
| int maxm86161_get_integration_time | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_ppg_tint * | tint ) |
Get the currently configured PPG ADC integration time.
| dev | - Device descriptor. |
| tint | - Pointer where the integration time selection is stored. |
| int maxm86161_get_interrupt_status | ( | struct maxm86161_dev * | dev, |
| uint16_t * | status ) |
Read the combined interrupt status of the MAXM86161.
Reads both INT_STATUS_1 and INT_STATUS_2 and packs them into a single 16-bit value (STATUS_2 in the high byte, STATUS_1 in the low byte).
| dev | - Device descriptor. |
| status | - Pointer where the packed interrupt status is stored. |
| int maxm86161_get_led_pulse_amplitude | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_led_num | led_num, | ||
| uint8_t * | amplitude ) |
Get the pulse amplitude (drive current) of an LED.
| dev | - Device descriptor. |
| led_num | - LED index (1 to MAXM86161_NUM_LEDS). |
| amplitude | - Pointer where the 8-bit pulse amplitude code is stored. |
| int maxm86161_get_led_range | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_led_num | led_num, | ||
| enum maxm86161_led_range * | range ) |
Get the full-scale current range of an LED driver.
| dev | - Device descriptor. |
| led_num | - LED index (1 to MAXM86161_NUM_LEDS). |
| range | - Pointer where the LED current range selection is stored. |
| int maxm86161_get_led_sequence | ( | struct maxm86161_dev * | dev, |
| uint8_t | slot, | ||
| enum maxm86161_led_src * | src ) |
Get the LED/measurement source configured for a sequence slot.
| dev | - Device descriptor. |
| slot | - Sequence slot index (0 to MAXM86161_NUM_LED_SEQ - 1). |
| src | - Pointer where the slot's source is stored. |
| int maxm86161_get_led_settling | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_led_settling * | settling ) |
Get the currently configured LED settling time.
| dev | - Device descriptor. |
| settling | - Pointer where the LED settling time selection is stored. |
| int maxm86161_get_pd_bias | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_pd_bias * | bias ) |
Get the currently configured photodiode bias.
| dev | - Device descriptor. |
| bias | - Pointer where the photodiode bias selection is stored. |
| int maxm86161_get_pf_enable | ( | struct maxm86161_dev * | dev, |
| bool * | enable ) |
Get the picket-fence enable state.
| dev | - Device descriptor. |
| enable | - Pointer set to true if picket-fence is enabled, false otherwise. |
| int maxm86161_get_pf_iir_init | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_pf_iir_init * | iir_init_value ) |
Get the picket-fence IIR initialization value.
| dev | - Device descriptor. |
| iir_init_value | - Pointer where the IIR initialization value is stored. |
| int maxm86161_get_pf_iir_tc | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_pf_iir_tc * | iir_tc ) |
Get the picket-fence IIR time constant.
| dev | - Device descriptor. |
| iir_tc | - Pointer where the IIR time constant selection is stored. |
| int maxm86161_get_pf_order | ( | struct maxm86161_dev * | dev, |
| bool * | order ) |
Get the picket-fence detect/replace ordering.
| dev | - Device descriptor. |
| order | - Pointer where the ordering selection is stored. |
| int maxm86161_get_pf_threshold_sigma | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_pf_threshold_sigma_mult * | threshold_sigma_mult ) |
Get the picket-fence threshold sigma multiplier.
| dev | - Device descriptor. |
| threshold_sigma_mult | - Pointer where the threshold sigma multiplier is stored. |
| int maxm86161_get_prox_threshold | ( | struct maxm86161_dev * | dev, |
| uint8_t * | threshold ) |
Get the proximity mode entry threshold.
| dev | - Device descriptor. |
| threshold | - Pointer where the proximity threshold value is stored. |
| int maxm86161_get_sample_averaging | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_smp_ave * | avg ) |
Get the currently configured sample averaging.
| dev | - Device descriptor. |
| avg | - Pointer where the sample averaging selection is stored. |
| int maxm86161_get_sample_rate | ( | struct maxm86161_dev * | dev, |
| uint8_t * | ppg_sr ) |
Get the currently configured PPG sample rate.
| dev | - Device descriptor. |
| ppg_sr | - Pointer where the sample rate selection code is stored. |
| int maxm86161_init | ( | struct maxm86161_dev ** | device, |
| struct maxm86161_init_param * | init_param ) |
Initialize the MAXM86161 device driver.
Allocates the device descriptor, initializes the I2C Bus, verifies the part ID, resets the device, places it into shutdown, clears the interrupt status and selects single-PPG mode. Optionally configures the INTB GPIO and registers a falling-edge interrupt callback when the corresponding init parameters are supplied. On any failure all acquired resources are released.
| device | - Pointer that receives the allocated device descriptor. |
| init_param | - Initialization parameters. |
| void maxm86161_irq_handler | ( | void * | ctx | ) |
Top-level interrupt dispatcher for the MAXM86161.
Intended to be registered as the GPIO/INTB interrupt callback. Reads the combined interrupt status and, for every asserted source, invokes the registered per-source callback (if any). Does nothing if the context is NULL or the status read fails.
| ctx | - Opaque context, expected to be a struct maxm86161_dev pointer. |
| int maxm86161_memory_read | ( | struct maxm86161_dev * | dev, |
| uint16_t | addr, | ||
| uint8_t * | data ) |
Read a single byte from the device memory.
Selects the memory bank based on the address (bank 1 for addresses above 0xFF), sets the memory index to the low byte of the address and reads the memory data register.
| dev | - Device descriptor. |
| addr | - Memory address to read (valid range 0x000 to 0x17F). |
| data | - Pointer where the read byte is stored. |
| int maxm86161_memory_write | ( | struct maxm86161_dev * | dev, |
| uint16_t | addr, | ||
| uint8_t | data ) |
Write a single byte to the device memory.
Enables memory writes and selects the memory bank based on the address (bank 1 for addresses above 0xFF), sets the memory index to the low byte of the address and writes the memory data register.
| dev | - Device descriptor. |
| addr | - Memory address to write (valid range 0x000 to 0x17F). |
| data | - Byte value to write. |
| int maxm86161_read_die_temperature | ( | struct maxm86161_dev * | dev, |
| int32_t * | temperature ) |
Read and convert the die temperature.
Reads the integer and fractional die-temperature registers and combines them into a signed temperature in degrees Celsius (fractional LSB = 0.0625 degC).
| dev | - Device descriptor. |
| temperature | - Pointer where the temperature in micro-degrees Celsius (1 degC = 1000000) is stored. |
| int maxm86161_read_fifo_data | ( | struct maxm86161_dev * | dev, |
| uint8_t * | data, | ||
| uint16_t | num_samples ) |
Burst-read raw sample data from the FIFO.
Reads num_samples samples from the FIFO_DATA register, each sample being MAXM86161_FIFO_DATA_SIZE bytes wide.
| dev | - Device descriptor. |
| data | - Buffer receiving the raw sample bytes; must hold at least num_samples * MAXM86161_FIFO_DATA_SIZE bytes. |
| num_samples | - Number of samples to read (must be non-zero). |
| int maxm86161_reg_read | ( | struct maxm86161_dev * | dev, |
| uint8_t | reg_addr, | ||
| uint8_t * | reg_data ) |
Read a single register from the MAXM86161.
| dev | - Device descriptor. |
| reg_addr | - Address of the register to read. |
| reg_data | - Pointer where the read register value is stored. |
| int maxm86161_reg_update_bits | ( | struct maxm86161_dev * | dev, |
| uint8_t | reg_addr, | ||
| uint8_t | mask, | ||
| uint8_t | data ) |
Read-modify-write the bits selected by a mask in a register.
Reads the register, clears the bits covered by mask and writes data into that bit field (aligned to the mask) before writing the register back.
| dev | - Device descriptor. |
| reg_addr | - Address of the register to update. |
| mask | - Bit mask selecting the field to modify. |
| data | - New value for the masked field (right-aligned). |
| int maxm86161_reg_write | ( | struct maxm86161_dev * | dev, |
| uint8_t | reg_addr, | ||
| uint8_t | reg_data ) |
Write a single register on the MAXM86161.
| dev | - Device descriptor. |
| reg_addr | - Address of the register to write. |
| reg_data | - Value to write into the register. |
| int maxm86161_remove | ( | struct maxm86161_dev * | dev | ) |
Free resources allocated by maxm86161_init().
Puts the device into shutdown, disables and unregisters the interrupt callback and removes the IRQ controller (if used), removes the INTB GPIO (if used), tears down the bus backend and frees the device descriptor. The first error encountered while releasing GPIO/bus resources is returned.
| dev | - Device descriptor. |
| int maxm86161_reset | ( | struct maxm86161_dev * | dev | ) |
Perform a software reset of the MAXM86161.
Sets the RESET bit in the system control register and waits for the reset settling delay before returning.
| dev | - Device descriptor. |
| int maxm86161_set_adc_range | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_adc_range | range ) |
Set the PPG ADC full-scale range.
Updates the ADC_RGE field of PPG_CFG_1 and caches the value in the device configuration.
| dev | - Device descriptor. |
| range | - ADC range selection. |
| int maxm86161_set_add_offset | ( | struct maxm86161_dev * | dev, |
| bool | enable ) |
Enable or disable the ADC add-offset feature.
Updates the ADD_OFFSET bit of PPG_CFG_1 and caches the value in the device configuration.
| dev | - Device descriptor. |
| enable | - true to enable the added offset, false to disable it. |
| int maxm86161_set_alc_disable | ( | struct maxm86161_dev * | dev, |
| bool | disable ) |
Enable or disable the Ambient Light Cancellation (ALC) circuit.
Updates the ALC_DISABLE bit of PPG_CFG_1 and caches the value in the device configuration.
| dev | - Device descriptor. |
| disable | - true to disable ALC, false to enable it. |
| int maxm86161_set_burst_enable | ( | struct maxm86161_dev * | dev, |
| bool | enable ) |
Enable or disable burst sampling mode and set its rate.
Updates the BURST_EN bit and, on success, the BURST_RATE field of PPG_CFG_3.
| dev | - Device descriptor. |
| enable | - true to enable burst mode, false to disable it. |
| int maxm86161_set_burst_mode | ( | struct maxm86161_dev * | dev, |
| bool | enable, | ||
| enum maxm86161_burst_rate | rate ) |
Enable or disable burst sampling mode and set its rate.
Updates the BURST_EN bit and, on success, the BURST_RATE field of PPG_CFG_3.
| dev | - Device descriptor. |
| enable | - true to enable burst mode, false to disable it. |
| rate | - Burst sampling rate selection. |
| int maxm86161_set_burst_rate | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_burst_rate | rate ) |
Enable or disable burst sampling mode and set its rate.
Updates the BURST_EN bit and, on success, the BURST_RATE field of PPG_CFG_3.
| dev | - Device descriptor. |
| rate | - Burst sampling rate selection. |
| int maxm86161_set_dac_code_tag | ( | struct maxm86161_dev * | dev, |
| bool | enable ) |
Enable or disable DAC-code tagging of PPG samples.
Updates the DAC_CODE_TAG bit of the PPG sync control register.
| dev | - Device descriptor. |
| enable | - true to enable DAC-code tagging, false to disable it. |
| int maxm86161_set_digital_filter | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_dig_filt_sel | filter ) |
Select the PPG digital filter (CDM or FDM).
Updates the DIG_FILT field of PPG_CFG_3 and caches the value in the device configuration.
| dev | - Device descriptor. |
| filter | - Digital filter selection. |
| int maxm86161_set_fifo_a_full_type | ( | struct maxm86161_dev * | dev, |
| bool | type ) |
Set the FIFO almost-full interrupt assertion behavior.
Updates the A_FULL_TYPE bit of FIFO_CFG_2 and caches the value in the device configuration, selecting whether the almost-full interrupt is repeated for each new sample or asserted only once.
| dev | - Device descriptor. |
| type | - Almost-full interrupt type selection. |
| int maxm86161_set_fifo_rollover | ( | struct maxm86161_dev * | dev, |
| bool | enable ) |
Enable or disable FIFO roll-over on full.
Updates the FIFO_RO bit of FIFO_CFG_2 and caches the value in the device configuration. When enabled, new samples overwrite the oldest once the FIFO is full.
| dev | - Device descriptor. |
| enable | - true to enable roll-over, false to disable it. |
| int maxm86161_set_fifo_stat_clr | ( | struct maxm86161_dev * | dev, |
| bool | enable ) |
Configure whether reading FIFO data clears the status bit.
Updates the STAT_CLR bit of FIFO_CFG_2 and caches the value in the device configuration.
| dev | - Device descriptor. |
| enable | - true to clear the FIFO status on data read, false otherwise. |
| int maxm86161_set_fifo_watermark | ( | struct maxm86161_dev * | dev, |
| uint8_t | watermark ) |
Set the FIFO almost-full watermark threshold.
Updates the A_FULL field of FIFO_CFG_1 and caches the value in the device configuration.
| dev | - Device descriptor. |
| watermark | - Almost-full threshold (valid range 0 to 127). |
| int maxm86161_set_gpio_ctrl | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_gpio_ctrl | ctrl ) |
Configure the behavior of the GPIO/sync pin.
Updates the GPIO_CTRL field of the PPG sync control register.
| dev | - Device descriptor. |
| ctrl | - GPIO control mode selection. |
| int maxm86161_set_hires_dac | ( | struct maxm86161_dev * | dev, |
| uint8_t | slot, | ||
| bool | override, | ||
| uint8_t | dac_val ) |
Configure the high-resolution DAC override for a sequence slot.
Writes the per-slot HIRES_DAC register, optionally setting the override bit together with the 6-bit DAC value.
| dev | - Device descriptor. |
| slot | - Sequence slot index (1 to MAXM86161_NUM_LED_SEQ). |
| override | - true to force the DAC value, false to use auto-calibration. |
| dac_val | - 6-bit DAC value (only the lower 6 bits are used). |
| int maxm86161_set_integration_time | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_ppg_tint | tint ) |
Set the PPG ADC integration time.
Updates the PPG_TINT field of PPG_CFG_1 and caches the value in the device configuration.
| dev | - Device descriptor. |
| tint | - Integration time selection. |
| int maxm86161_set_irq_handler | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_irq_sources | int_source, | ||
| bool | enable, | ||
| maxm86161_int_cb_t | callback, | ||
| void * | cb_args ) |
Register a callback for an interrupt source and enable/disable it.
Enables or disables the enable bit for the requested interrupt source in the appropriate INT_EN register and stores the callback and its argument in the device's handler table. The PWR_RDY source has no enable bit, so only the callback is registered for it.
| dev | - Device descriptor. |
| int_source | - Interrupt source to configure. |
| enable | - true to enable the interrupt, false to disable it. |
| callback | - Callback invoked when the interrupt fires. |
| cb_args | - Opaque argument passed to the callback. |
| int maxm86161_set_led_cfg | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_led_num | led_num, | ||
| enum maxm86161_led_range | range, | ||
| uint8_t | led_seq_num, | ||
| uint8_t | amplitude ) |
Get the full-scale current range of an LED driver.
| dev | - Device descriptor. |
| led_num | - LED index (1 to MAXM86161_NUM_LEDS). |
| range | - LED current range selection. |
| led_seq_num | - LED/measurement source assigned to the slot. |
| amplitude | - Pointer where the 8-bit pilot pulse amplitude is stored. |
| int maxm86161_set_led_pulse_amplitude | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_led_num | led_num, | ||
| uint8_t | amplitude ) |
Set the pulse amplitude (drive current) of an LED.
Writes the LEDn_PA register for the selected LED and caches the value in the device descriptor.
| dev | - Device descriptor. |
| led_num | - LED index (1 to MAXM86161_NUM_LEDS). |
| amplitude | - 8-bit pulse amplitude code. |
| int maxm86161_set_led_range | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_led_num | led_num, | ||
| enum maxm86161_led_range | range ) |
Set the full-scale current range of an LED driver.
Selects the appropriate mask in the LED_RANGE_1 register for the given LED, caches the range in the device descriptor and updates the field.
| dev | - Device descriptor. |
| led_num | - LED index (1 to MAXM86161_NUM_LEDS). |
| range | - LED current range selection. |
| int maxm86161_set_led_sequence | ( | struct maxm86161_dev * | dev, |
| uint8_t | slot, | ||
| enum maxm86161_led_src | src ) |
Set the LED/measurement source for a single sequence slot.
Selects the target LED_SEQ register and nibble (even/odd) based on the slot index, caches the source in the device descriptor and writes the field.
| dev | - Device descriptor. |
| slot | - Sequence slot index (0 to MAXM86161_NUM_LED_SEQ - 1). |
| src | - LED/measurement source assigned to the slot. |
| int maxm86161_set_led_settling | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_led_settling | settling ) |
Set the LED settling time.
Updates the LED_SETLNG field of PPG_CFG_3 and caches the value in the device configuration.
| dev | - Device descriptor. |
| settling | - LED settling time selection. |
| int maxm86161_set_low_power_mode | ( | struct maxm86161_dev * | dev, |
| bool | enable ) |
Enable or disable low-power mode of the MAXM86161.
| dev | - Device descriptor. |
| enable | - true to enable low-power mode, false to disable it. |
| int maxm86161_set_pd_bias | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_pd_bias | bias ) |
Set the photodiode bias (based on PD capacitance).
| dev | - Device descriptor. |
| bias | - Photodiode bias selection. |
| int maxm86161_set_pf_enable | ( | struct maxm86161_dev * | dev, |
| bool | enable ) |
Enable or disable the picket-fence detect-and-replace feature.
Updates the ENABLE bit of the PICKET_FENCE register.
| dev | - Device descriptor. |
| enable | - true to enable picket-fence, false to disable it. |
| int maxm86161_set_pf_iir_init | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_pf_iir_init | iir_init_value ) |
Set the picket-fence IIR initialization value.
Updates the IIR_INIT field of the PICKET_FENCE register.
| dev | - Device descriptor. |
| iir_init_value | - IIR initialization value selection. |
| int maxm86161_set_pf_iir_tc | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_pf_iir_tc | iir_tc ) |
Set the picket-fence IIR time constant.
Updates the IIR_TC field of the PICKET_FENCE register.
| dev | - Device descriptor. |
| iir_tc | - IIR time constant selection. |
| int maxm86161_set_pf_order | ( | struct maxm86161_dev * | dev, |
| bool | order ) |
Set the picket-fence detect/replace ordering.
Updates the ORDER bit of the PICKET_FENCE register.
| dev | - Device descriptor. |
| order | - Ordering selection (false or true). |
| int maxm86161_set_pf_threshold_sigma | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_pf_threshold_sigma_mult | threshold_sigma_mult ) |
Set the picket-fence threshold sigma multiplier.
Updates the THRESH_SIGMA field of the PICKET_FENCE register.
| dev | - Device descriptor. |
| threshold_sigma_mult | - Threshold sigma multiplier selection. |
| int maxm86161_set_prox_threshold | ( | struct maxm86161_dev * | dev, |
| uint8_t | threshold ) |
Set the proximity mode entry threshold.
Writes the PROX_INT_THRESH register that determines the ADC count at which the device transitions from proximity to normal PPG mode.
| dev | - Device descriptor. |
| threshold | - Proximity interrupt threshold value. |
| int maxm86161_set_sample_averaging | ( | struct maxm86161_dev * | dev, |
| enum maxm86161_smp_ave | avg ) |
Set the number of samples averaged per FIFO data point.
Updates the SMP_AVE field of PPG_CFG_2 and caches the value in the device configuration.
| dev | - Device descriptor. |
| avg | - Sample averaging selection. |
| int maxm86161_set_sample_rate | ( | struct maxm86161_dev * | dev, |
| uint8_t | ppg_sr ) |
Set the PPG sample rate.
Updates the PPG_SR field of PPG_CFG_2 and caches the value in the device configuration.
| dev | - Device descriptor. |
| ppg_sr | - Sample rate selection code (valid range 0x00 to 0x13). |
| int maxm86161_set_shutdown | ( | struct maxm86161_dev * | dev, |
| bool | enable ) |
Enable or disable shutdown mode of the MAXM86161.
| dev | - Device descriptor. |
| enable | - true to enter shutdown, false to resume normal operation. |
| int maxm86161_set_timestamp_enable | ( | struct maxm86161_dev * | dev, |
| bool | enable ) |
Enable or disable timestamp tagging of PPG samples.
Updates the TIMESTAMP_EN bit of the PPG sync control register.
| dev | - Device descriptor. |
| enable | - true to enable timestamps, false to disable them. |
| int maxm86161_sha_enable | ( | struct maxm86161_dev * | dev, |
| bool | enable ) |
Enable or disable the SHA-256 authentication engine.
Updates the SHA_EN bit of the SHA configuration register.
| dev | - Device descriptor. |
| enable | - true to enable the SHA engine, false to disable it. |
| int maxm86161_sha_read_response | ( | struct maxm86161_dev * | dev, |
| uint8_t * | response, | ||
| uint8_t | len ) |
Read the SHA-256 response from the device memory.
Sets the memory index to the SHA memory start and burst-reads the response from the memory data register.
| dev | - Device descriptor. |
| response | - Buffer receiving the response bytes. |
| len | - Number of bytes to read (must be non-zero). |
| int maxm86161_sha_start | ( | struct maxm86161_dev * | dev, |
| uint8_t | cmd ) |
Issue a SHA command and start the SHA-256 operation.
Writes the command to the SHA command register and then sets the SHA_START bit in the SHA configuration register to begin the operation.
| dev | - Device descriptor. |
| cmd | - SHA command code to execute. |
| int maxm86161_sha_write_challenge | ( | struct maxm86161_dev * | dev, |
| uint8_t * | challenge, | ||
| uint8_t | len ) |
Write a SHA-256 challenge into the device memory.
Enables memory writes, sets the memory index to the SHA memory start and burst-writes the challenge into the memory data register. The challenge must be exactly 20 bytes (a 160-bit value).
| dev | - Device descriptor. |
| challenge | - Buffer holding the challenge bytes. |
| len | - Length of the challenge in bytes (must be 20). |
| int maxm86161_shutdown | ( | struct maxm86161_dev * | dev | ) |
Put the MAXM86161 into shutdown (power-down) mode.
Convenience wrapper around maxm86161_set_shutdown() that always enables shutdown.
| dev | - Device descriptor. |
| int maxm86161_start_calibration | ( | struct maxm86161_dev * | dev | ) |
Start the DAC (offset) calibration procedure.
Sets the START_CAL bit in the DAC calibration enable register to begin calibration. Completion should be polled via maxm86161_get_calibration_status().
| dev | - Device descriptor. |
| int maxm86161_verify_id | ( | struct maxm86161_dev * | dev | ) |
Verify the MAXM86161 part identity and cache revision info.
Reads the part ID register and checks it against the expected value; on mismatch -ENODEV is returned. On success the part ID and revision ID are stored in the device descriptor.
| dev | - Device descriptor. |