Pulse Oximeter Library  1.0.0
Pulse Oximeter Library for using the MAX32664 & MAX30101 SparkFun library
bio_sensor.h File Reference

bio_sensor.h More...

Go to the source code of this file.

Data Structures

struct  bioData
 Struct of algorithm output data. More...
 
struct  version
 Struct of version data. More...
 
struct  sensorAttr
 Struct of attributes for a sensor. More...
 

Enumerations

enum  READ_STATUS_BYTE_VALUE {
  ERR_UNAVAIL_CMD = 0x01 , ERR_UNAVAIL_FUNC , ERR_DATA_FORMAT , ERR_INPUT_VALUE ,
  ERR_INVALID_MODE = 0x05 , ERR_BTLDR_TRY_AGAIN = 0x05 , ERR_BTLDR_GENERAL = 0x80 , ERR_BTLDR_CHECKSUM ,
  ERR_BTLDR_AUTH , ERR_BTLDR_INVALID_APP , ERR_TRY_AGAIN = 0xFE , ERR_UNKNOWN = 0xFF
}
 
enum  FAMILY_REGISTER_BYTES {
  HUB_STATUS = 0x00 , SET_DEVICE_MODE , READ_DEVICE_MODE , OUTPUT_MODE = 0x10 ,
  READ_OUTPUT_MODE , READ_DATA_OUTPUT , READ_DATA_INPUT , WRITE_INPUT ,
  WRITE_REGISTER = 0x40 , READ_REGISTER , READ_ATTRIBUTES_AFE , DUMP_REGISTERS ,
  ENABLE_SENSOR , READ_SENSOR_MODE , CHANGE_ALGORITHM_CONFIG = 0x50 , READ_ALGORITHM_CONFIG ,
  ENABLE_ALGORITHM , BOOTLOADER_FLASH = 0x80 , BOOTLOADER_INFO , IDENTITY = 0xFF
}
 
enum  DEVICE_MODE_WRITE_BYTES { EXIT_BOOTLOADER = 0x00 , RESET = 0x02 , ENTER_BOOTLOADER = 0x08 }
 
enum  OUTPUT_MODE_WRITE_BYTE {
  PAUSE = 0x00 , SENSOR_DATA , ALGO_DATA , SENSOR_AND_ALGORITHM ,
  PAUSE_TWO , SENSOR_COUNTER_BYTE , ALGO_COUNTER_BYTE , SENSOR_ALGO_COUNTER
}
 
enum  FIFO_OUTPUT_INDEX_BYTE { NUM_SAMPLES , READ_DATA }
 
enum  FIFO_EXTERNAL_INDEX_BYTE {
  SAMPLE_SIZE , READ_INPUT_DATA , READ_SENSOR_DATA , READ_NUM_SAMPLES_INPUT ,
  READ_NUM_SAMPLES_SENSOR
}
 
enum  WRITE_REGISTER_INDEX_BYTE { WRITE_MAX30101 = 0x03 , WRITE_ACCELEROMETER }
 
enum  READ_REGISTER_INDEX_BYTE { READ_MAX30101 = 0x03 , READ_ACCELEROMETER }
 
enum  GET_AFE_INDEX_BYTE { RETRIEVE_AFE_MAX30101 = 0x03 , RETRIEVE_AFE_ACCELEROMETER }
 
enum  DUMP_REGISTER_INDEX_BYTE { DUMP_REGISTER_MAX30101 = 0x03 , DUMP_REGISTER_ACCELEROMETER }
 
enum  SENSOR_ENABLE_INDEX_BYTE { ENABLE_MAX30101 = 0x03 , ENABLE_ACCELEROMETER }
 
enum  READ_SENSOR_ENABLE_INDEX_BYTE { READ_ENABLE_MAX30101 = 0x03 , READ_ENABLE_ACCELEROMETER }
 
enum  ALGORITHM_CONFIG_INDEX_BYTE {
  SET_TARG_PERC = 0x00 , SET_STEP_SIZE = 0x00 , SET_SENSITIVITY = 0x00 , SET_AVG_SAMPLES = 0x00 ,
  SET_PULSE_OX_COEF = 0x02
}
 
enum  ALGO_AGC_WRITE_BYTE {
  AGC_GAIN_ID = 0x00 , AGC_STEP_SIZE_ID , AGC_SENSITIVITY_ID , AGC_NUM_SAMP_ID ,
  MAXIMFAST_COEF_ID = 0x0B
}
 
enum  READ_ALGORITHM_INDEX_BYTE {
  READ_AGC_PERCENTAGE = 0x00 , READ_AGC_STEP_SIZE = 0x00 , READ_AGC_SENSITIVITY = 0x00 , READ_AGC_NUM_SAMPLES = 0x00 ,
  READ_MAX_FAST_COEF = 0x02
}
 
enum  READ_AGC_ALGO_WRITE_BYTE {
  READ_AGC_PERC_ID = 0x00 , READ_AGC_STEP_SIZE_ID , READ_AGC_SENSITIVITY_ID , READ_AGC_NUM_SAMPLES_ID ,
  READ_MAX_FAST_COEF_ID = 0x0B
}
 
enum  ALGORITHM_MODE_ENABLE_INDEX_BYTE { ENABLE_AGC_ALGO = 0x00 , ENABLE_WHRM_ALGO = 0x02 }
 
enum  BOOTLOADER_FLASH_INDEX_BYTE {
  SET_INIT_VECTOR_BYTES = 0x00 , SET_AUTH_BYTES , SET_NUM_PAGES , ERASE_FLASH ,
  SEND_PAGE_VALUE
}
 
enum  BOOTLOADER_INFO_INDEX_BYTE { BOOTLOADER_VERS = 0x00 , PAGE_SIZE }
 
enum  IDENTITY_INDEX_BYTES { READ_MCU_TYPE = 0x00 , READ_SENSOR_HUB_VERS = 0x03 , READ_ALGO_VERS = 0x07 }
 

Functions

uint8_t beginI2C (I2C_Handle i2cHandle, uint8_t *statusByte)
 Takes the I2C handle object to read the current sensor hub mode. More...
 
uint8_t configMAX32664 (uint8_t outputFormat, uint8_t algoMode, uint8_t intThresh)
 Configures the MAX32664. More...
 
struct bioData readSensorData (uint8_t *statusByte)
 Read sensor data from MAX32664 output FIFO. More...
 
struct bioData readRawData (uint8_t *statusByte)
 Reads the raw sensor data, assuming only the raw sensor data is being output. More...
 
struct bioData readAlgoData (uint8_t *statusByte)
 Reads the algorithm data, assuming only the algorithm data is being output. More...
 
struct bioData readRawAndAlgoData (uint8_t *statusByte)
 Reads the raw+algorithm data if that this is the output format. More...
 
uint8_t softwareResetMAX32664 (void)
 Does a software reset of the device. More...
 
uint8_t softwareResetMAX30101 (void)
 Performs a reset of MAX30101 by setting the Reset Control bit to 1. More...
 
uint8_t setOutputMode (uint8_t outputType)
 Sets the data output mode: raw, algorithm, raw+algorithm, etc. More...
 
uint8_t setFifoThreshold (uint8_t intThresh)
 Sets output FIFO threshold (# data samples extracted before MRIO output interrupt generated) More...
 
uint8_t numSamplesOutFifo (uint8_t *statusByte)
 Reads number of samples available in the output FIFO. More...
 
uint8_t agcAlgoControl (uint8_t enable)
 Controls the AGC algorithm, enables or disables it. More...
 
uint8_t max30101Control (uint8_t senSwitch)
 Controls the MAX30101 pulse oximeter, enables or disables it. More...
 
uint8_t readMAX30101State (uint8_t *statusByte)
 Reads the MAX30101 pulse oximeter state. More...
 
uint8_t maximFastAlgoControl (uint8_t mode)
 Controls the WHRM/Maxim Algorithm, disables it or sets the mode (mode 1 or mode 2) More...
 
uint8_t readDeviceMode (uint8_t *statusByte)
 Reads the current MAX32664 operating mode. More...
 
uint8_t setDeviceMode (uint8_t operatingMode, uint8_t *statusByte)
 Sets the operating mode for the MAX32664. More...
 
uint8_t readSensorHubStatus (uint8_t *statusByte)
 Reads the current sensor hub status. More...
 
uint8_t readAlgoSamples (uint8_t *statusByte)
 Reads the number of samples available in the output FIFO. More...
 
uint8_t readAlgoRange (uint8_t *statusByte)
 Reads the percent of full scale ADC range that the AGC algorithm is using. More...
 
uint8_t readAlgoStepSize (uint8_t *statusByte)
 Reads the step size towards the target for the AGC algorithm. More...
 
uint8_t readAlgoSensitivity (uint8_t *statusByte)
 Reads the sensitivity of the AGC algorithm. More...
 
uint16_t readAlgoSampleRate (uint8_t *statusByte)
 Reads the WHRM algorithm sample rate. More...
 
uint8_t readMaximFastCoef (int32_t *coefArray)
 Reads the 3 Maxim Fast algorithm coefficients, which are 32-bit signed values * 100,000. More...
 
struct version readSensorHubVersion (uint8_t *statusByte)
 Reads the current version of the sensor hub. More...
 
struct version readAlgorithmVersion (uint8_t *statusByte)
 Reads the current version of the algorithm. More...
 
struct version readBootloaderVersion (uint8_t *statusByte)
 Reads the current version of the bootloader. More...
 
uint8_t getMcuType (uint8_t *statusByte)
 Reads the MCU type of biometric sensor hub (expect MAX32660/MAX32664) More...
 
uint16_t readADCSampleRate (uint8_t *statusByte)
 Reads the ADC sample rate of the MAX30101 internal ADC. More...
 
uint16_t readADCRange (uint8_t *statusByte)
 Reads the internal ADC range of the MAX30101. More...
 
uint16_t readPulseWidth (uint8_t *statusByte)
 Reads the LED pulse width of the LEDs in the MAX30101. More...
 
uint8_t readPulseAmp (uint8_t *ledArray, uint8_t *statusByte)
 Reads the LED pulse amplitude of the LEDs in the MAX30101. More...
 
uint8_t readMAX30101Mode (uint8_t *statusByte)
 Reads the operating mode of the MAX30101 PO sensor. More...
 
struct sensorAttr getAfeAttributesMAX30101 (uint8_t *statusByte)
 Gets the attributes for the MAX30101 sensor. More...
 
struct sensorAttr getAfeAttributesAccelerometer (uint8_t *statusByte)
 Gets the attributes for the accelerometer. More...
 
uint8_t getExtAccelMode (uint8_t *statusByte)
 Gets the current mode of the external accelerometer. More...
 
uint8_t readRegisterMAX30101 (uint8_t regAddr, uint8_t *statusByte)
 Reads the value in specific register in the MAX30101. More...
 
uint8_t writeRegisterMAX30101 (uint8_t regAddr, uint8_t regVal)
 Writes the given value to the given register address in the MAX30101. More...
 
uint8_t I2CReadByte (uint8_t familyByte, uint8_t indexByte, uint8_t *statusByte)
 Does an I2C read transaction with the MAX32664 that will read a single byte. More...
 
uint8_t I2CReadBytewithWriteByte (uint8_t familyByte, uint8_t indexByte, uint8_t dataByte, uint8_t *statusByte)
 Does an I2C read transaction with the MAX32664 that requires a single write byte, that will read a single byte. More...
 
uint8_t I2CReadFillArray (uint8_t familyByte, uint8_t indexByte, uint8_t arraySize, uint8_t *arraytoFill)
 Does an I2C read transaction with the MAX32664 that will read an array of data back,. More...
 
uint16_t I2CReadInt (uint8_t familyByte, uint8_t indexByte, uint8_t *statusByte)
 Performs a read transaction with no write bytes. More...
 
uint16_t I2CReadIntWithWriteByte (uint8_t familyByte, uint8_t indexByte, uint8_t writeByte, uint8_t *statusByte)
 Performs a read transaction with a single write byte. More...
 
int32_t I2CRead32BitValue (uint8_t familyByte, uint8_t indexByte, uint8_t dataByte, uint8_t *statusByte)
 Does an I2C read transaction with the MAX32664 that reads a single 32-bit variable. More...
 
uint8_t I2CReadMultiple32BitValues (uint8_t familyByte, uint8_t indexByte, uint8_t dataByte, uint8_t numReads, int32_t *numArray)
 Does an I2C read transaction with the MAX32664 that reads multiple 32-bit variables. More...
 
uint8_t I2CWriteByte (uint8_t familyByte, uint8_t indexByte, uint8_t dataByte)
 Does an I2C write transaction with the MAX32664 that will write a single byte. More...
 
uint8_t I2CWrite2Bytes (uint8_t familyByte, uint8_t indexByte, uint8_t dataByte0, uint8_t dataByte1)
 Does an I2C write transaction with the MAX32664 that will write two bytes. More...
 
uint8_t I2CenableWriteByte (uint8_t familyByte, uint8_t indexByte, uint8_t dataByte)
 Does an I2C write transaction with the MAX32664 that will write a single byte, with a longer delay between write and read. More...
 

Detailed Description

bio_sensor.h

Created on: Nov 12, 2020 Author: AveryW

This library is based heavily on the SparkFun Bio Sensor Hub Library: https://github.com/sparkfun/SparkFun_Bio_Sensor_Hub_Library which is an open source library produced by SparkFun Electronics. We would like to thank SparkFun and Elias Santistevan (main author) for writing this library and making it available to the public. Below is the short shpeel given at the beginning of the SparkFun Library

Below is the header from the SparkFun Bio Sensor Hub Library files, which gives a description of the library ours was based on:

"This is an Arduino Library written for the MAXIM 32664 Biometric Sensor Hub The MAX32664 Biometric Sensor Hub is in actuality a small Cortex M4 microcontroller with pre-loaded firmware and algorithms used to interact with the a number of MAXIM sensors; specifically the MAX30101 Pulse Oximter and Heart Rate Monitor and the KX122 Accelerometer. With that in mind, this library is built to communicate with a middle-person and so has a unique method of communication (family, index, and write bytes) that is more simplistic than writing and reading to registers, but includes a larger set of definable values.

SparkFun Electronics Date: June, 2019 Author: Elias Santistevan kk License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

Feel like supporting our work? Buy a board from SparkFun!"

Function Documentation

◆ agcAlgoControl()

uint8_t agcAlgoControl ( uint8_t  enable)

Controls the AGC algorithm, enables or disables it.

familyByte - ENABLE_ALGORITHM (0x52)

indexByte - ENABLE_AGC_ALGO (0x00)

writeByte0 - enable

writeByteN - none

Parameters
enableAlgorithm enable (0x01)/disable (0x00) parameter
Returns
agcStatusByte - Status byte of I2C transaction

◆ beginI2C()

uint8_t beginI2C ( I2C_Handle  i2cHandle,
uint8_t *  statusByte 
)

Takes the I2C handle object to read the current sensor hub mode.

familyByte N/A - multiple I2C transactions internally

indexByte N/A - multiple I2C transactions internally

writeByte0 N/A - multiple I2C transactions internally

writeByteN N/A - multiple I2C transactions internally

Parameters
i2cHandleI2C_Handle Object
*statusBytePointer to status byte
Returns
mode - Current device operating mode, ERR_UNKNOWN on I2C transaction issues (check status byte!)

◆ configMAX32664()

uint8_t configMAX32664 ( uint8_t  outputFormat,
uint8_t  algoMode,
uint8_t  intThresh 
)

Configures the MAX32664.

Configures the output format of the data, set the algorithm mode, sets FIFO threshold, enables the Automatic Gain Control (AGC) algorithm, enables the MAX30101 pulse oximeter, enables the Wearable Heart Rate Monitor (WHRM)/MaximFast algorithm to the specified mode, reads number of samples averaged by the AGC algorithm.

familyByte N/A - multiple I2C transactions internally

indexByte N/A - multiple I2C transactions internally

writeByte0 N/A - multiple I2C transactions internally

writeByteN N/A - multiple I2C transactions internally

Precondition
beginI2C() to pass I2C handle object
Parameters
outputFormatFormat of the output data (raw MAX30101 ADC reading, algorithm data, OR raw reading + algorithm data)
algoModeMode you want to set the MaximFast Algorithm to (mode 1 OR mode 2)
intTreshNumber of samples taken before interrupt is generate
Returns
statusChauf - Status of I2C transactions

◆ getAfeAttributesAccelerometer()

struct sensorAttr getAfeAttributesAccelerometer ( uint8_t *  statusByte)

Gets the attributes for the accelerometer.

Includes how many bytes to a word and number of registers

familyByte - READ_ATTRIBUTES_AFE (0x42)

indexByte - RETRIEVE_AFE_ACCELEROMETER (0x04)

writeByte0 - none

writeByteN - none

See also
sensorAttr
Parameters
*statusBytePointer to status byte
Returns
accelAttr - Struct of sensor attributes, 0 on a failure

◆ getAfeAttributesMAX30101()

struct sensorAttr getAfeAttributesMAX30101 ( uint8_t *  statusByte)

Gets the attributes for the MAX30101 sensor.

Includes how many bytes to a word and number of registers

familyByte - READ_ATTRIBUTES_AFE (0x42)

indexByte - RETRIEVE_AFE_MAX30101 (0x03)

writeByte0 - none

writeByteN - none

See also
sensorAttr
Parameters
*statusBytePointer to status byte
Returns
maxAttr - Struct of sensor attributes

◆ getExtAccelMode()

uint8_t getExtAccelMode ( uint8_t *  statusByte)

Gets the current mode of the external accelerometer.

Tells info about sensor hub accelerometer or host accelerometer

familyByte - READ_SENSOR_MODE (0x45)

indexByte - READ_ENABLE_ACCELEROMETER (0x04)

writeByte0 - none

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
accelMode - Mode of the accelerometer. 0: sensor hub accel disabled, 1: external host accel disabled, 2: sensor hub accel enabled, 3: external host accel enabled, 255 (0xFF) on an invalid value

◆ getMcuType()

uint8_t getMcuType ( uint8_t *  statusByte)

Reads the MCU type of biometric sensor hub (expect MAX32660/MAX32664)

familyByte - IDENTITY (0xFF)

indexByte - READ_MCU_TYPE (0x00)

writeByte0 - none

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
mcuType - Type of MCU

◆ I2CenableWriteByte()

uint8_t I2CenableWriteByte ( uint8_t  familyByte,
uint8_t  indexByte,
uint8_t  dataByte 
)

Does an I2C write transaction with the MAX32664 that will write a single byte, with a longer delay between write and read.

familyByte - familyByte

indexByte - indexByte

writeByte0 - dataByte

writeByteN - none

Parameters
familyByteDesired family byte for I2C transaction
indexByteDesired index byte for I2C transaction
dataByteWrite data byte for I2C transaction
Returns
localRxBuffer[0] - Status byte of I2C transaction

◆ I2CRead32BitValue()

int32_t I2CRead32BitValue ( uint8_t  familyByte,
uint8_t  indexByte,
uint8_t  dataByte,
uint8_t *  statusByte 
)

Does an I2C read transaction with the MAX32664 that reads a single 32-bit variable.

familyByte - familyByte

indexByte - indexByte

writeByte0 - writeBtye0

writeByteN - none

Parameters
familyByteDesired family byte for I2C transaction
indexByteDesired index byte for I2C transaction
dataByteDesired write byte 0 for I2C transaction
*statusBytePointer to status byte
Returns
value - 32-bit signed value

◆ I2CReadByte()

uint8_t I2CReadByte ( uint8_t  familyByte,
uint8_t  indexByte,
uint8_t *  statusByte 
)

Does an I2C read transaction with the MAX32664 that will read a single byte.

familyByte - familyByte

indexByte - indexByte

writeByte0 - none

writeByteN - none

Parameters
familyByteDesired family byte for I2C transaction
indexByteDesired index byte for I2C transaction
*statusBytePointer to status byte of transaction
Returns
localRxBuffer[1] - Read data byte

◆ I2CReadBytewithWriteByte()

uint8_t I2CReadBytewithWriteByte ( uint8_t  familyByte,
uint8_t  indexByte,
uint8_t  dataByte,
uint8_t *  statusByte 
)

Does an I2C read transaction with the MAX32664 that requires a single write byte, that will read a single byte.

familyByte - familyByte

indexByte - indexByte

writeByte0 - dataByte

writeByteN - none

Parameters
familyByteDesired family byte for I2C transaction
indexByteDesired index byte for I2C transaction
dataByteWrite data byte for I2C transaction
*statusBytePointer to the status byte
Returns
localRxBuffer[1] - Read data byte

◆ I2CReadFillArray()

uint8_t I2CReadFillArray ( uint8_t  familyByte,
uint8_t  indexByte,
uint8_t  arraySize,
uint8_t *  arraytoFill 
)

Does an I2C read transaction with the MAX32664 that will read an array of data back,.

familyByte - familyByte

indexByte - indexByte

writeByte0 - none

writeByteN - none

Parameters
familyByteDesired family byte for I2C transaction
indexByteDesired index byte for I2C transaction
arraySizeSize of expected read array
*arraytoFillPointer to array to fill
Returns
localRxBuffer[0] - Status byte of I2C transaction

◆ I2CReadInt()

uint16_t I2CReadInt ( uint8_t  familyByte,
uint8_t  indexByte,
uint8_t *  statusByte 
)

Performs a read transaction with no write bytes.

Will perform an I2C transaction and translate result into a 16 bit value

familyByte - familyByte

indexByte - indexByte

writeByte0 - none

writeByteN - none

Parameters
familyByteDesired family byte for I2C transaction
indexByteDesired index byte for I2C transaction
*statusBytePointer to status byte
Returns
returnInt - 16-bit unsigned read data, 0 on a failure

◆ I2CReadIntWithWriteByte()

uint16_t I2CReadIntWithWriteByte ( uint8_t  familyByte,
uint8_t  indexByte,
uint8_t  writeByte,
uint8_t *  statusByte 
)

Performs a read transaction with a single write byte.

Will perform an I2C transaction and translate result into a 16 bit value

familyByte - familyByte

indexByte - indexByte

writeByte0 - writeByte

writeByteN - none

Parameters
familyByteDesired family byte for I2C transaction
indexByteDesired index byte for I2C transaction
writeByteDesired write byte for I2C transaction
*statusBytePointer to status byte
Returns
returnInt - 16-bit read data, 0 on a failure

◆ I2CReadMultiple32BitValues()

uint8_t I2CReadMultiple32BitValues ( uint8_t  familyByte,
uint8_t  indexByte,
uint8_t  dataByte,
uint8_t  numReads,
int32_t *  numArray 
)

Does an I2C read transaction with the MAX32664 that reads multiple 32-bit variables.

familyByte - familyByte

indexByte - indexByte

writeByte0 - dataByte

writeByteN - none

Parameters
familyByteDesired family byte for I2C transaction
indexByteDesired index byte for I2C transaction
dataByteDesired write byte 0 for I2C transaction
numReadsNumber of 32-bit signed values you want to read
*numArrayPointer to array to be filled. Must be a 32-bit array and be the same size as numReads
Returns
localRxBuffer[0] - Status byte of I2C transaction

◆ I2CWrite2Bytes()

uint8_t I2CWrite2Bytes ( uint8_t  familyByte,
uint8_t  indexByte,
uint8_t  dataByte0,
uint8_t  dataByte1 
)

Does an I2C write transaction with the MAX32664 that will write two bytes.

familyByte - familyByte

indexByte - indexByte

writeByte0 - dataByte0

writeByteN - dataByte1

Parameters
familyByteDesired family byte for I2C transaction
indexByteDesired index byte for I2C transaction
dataByte0Write data byte 0 for I2C transaction
dataByte1Write data byte 1 for I2C transaction
Returns
localRxBuffer[0] - Status byte of I2C transaction

◆ I2CWriteByte()

uint8_t I2CWriteByte ( uint8_t  familyByte,
uint8_t  indexByte,
uint8_t  dataByte 
)

Does an I2C write transaction with the MAX32664 that will write a single byte.

familyByte - familyByte

indexByte - indexByte

writeByte0 - dataByte

writeByteN - none

Parameters
familyByteDesired family byte for I2C transaction
indexByteDesired index byte for I2C transaction
dataByteWrite data byte for I2C transaction
Returns
localRxBuffer[0] - Status byte of I2C transaction

◆ max30101Control()

uint8_t max30101Control ( uint8_t  senSwitch)

Controls the MAX30101 pulse oximeter, enables or disables it.

familyByte - ENABLE_SENSOR (0x44)

indexByte - ENABLE_MAX30101 (0x03)

writeByte0 - senSwitch

writeByteN - none

Parameters
senSwitchMAX30101 enable (0x01)/disable(0x00) parameter
Returns
maxStatusByte - Returns SUCCESS if everything goes well, return status byte if issue with I2C transaction

◆ maximFastAlgoControl()

uint8_t maximFastAlgoControl ( uint8_t  mode)

Controls the WHRM/Maxim Algorithm, disables it or sets the mode (mode 1 or mode 2)

familyByte - ENABLE_ALGORITHM (0x52)

indexByte - ENABLE_WHRM_ALGO (0x02)

writeByte0 - mode

writeByteN - none

Parameters
modeDisables (0x00) or sets algorithm mode to mode 1 (0x01) or mode 2 (0x02)
Returns
maximAlgoStatusByte - Returns SUCCESS if everything goes well, return status byte if issue with I2C transaction

◆ numSamplesOutFifo()

uint8_t numSamplesOutFifo ( uint8_t *  statusByte)

Reads number of samples available in the output FIFO.

familyByte - READ_DATA_OUTPUT (0x12)

indexByte - NUM_SAMPLES (0x00)

writeByte0 - none

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
sampAvail - Number of samples available in the output FIFO, 0 on failure

◆ readADCRange()

uint16_t readADCRange ( uint8_t *  statusByte)

Reads the internal ADC range of the MAX30101.

MAX30101 Register - CONFIGURATION_REGISTER (0x0A)

Parameters
*statusBytePointer to status byte
Returns
ADC full scale range of MAX30101, ERR_UNKNOWN if invalid number

◆ readADCSampleRate()

uint16_t readADCSampleRate ( uint8_t *  statusByte)

Reads the ADC sample rate of the MAX30101 internal ADC.

MAX30101 Register - CONFIGURATION_REGISTER (0x0A)

Parameters
*statusBytePointer to status byte
Returns
Sample rate of MAX30101 internal ADC in Hertz, ERR_UNKNOWN on a issue reading register or invalid number read

◆ readAlgoData()

struct bioData readAlgoData ( uint8_t *  statusByte)

Reads the algorithm data, assuming only the algorithm data is being output.

familyByte - READ_DATA_OUTPUT (0x12)

indexByte - READ_DATA (0x01)

writeByte0 - none

writeByteN - none

Precondition
configMAX32664() function, set to output only algorithm data
Parameters
*statusBytePointer to status byte
Returns
libAlgoData - Struct of algorithm data, all 0s on an error

◆ readAlgoRange()

uint8_t readAlgoRange ( uint8_t *  statusByte)

Reads the percent of full scale ADC range that the AGC algorithm is using.

familyByte - READ_ALGORITHM_CONFIG (0x51)

indexByte - READ_AGC_PERCENTAGE (0x00)

writeByte0 - READ_AGC_PERC_ID (0x00)

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
range - Percent of the full scale ADC range that the AGC algorithm is using, 0 on an error

◆ readAlgorithmVersion()

struct version readAlgorithmVersion ( uint8_t *  statusByte)

Reads the current version of the algorithm.

Format of version is major.minor.revision

familyByte - IDENTITY (0xFF)

indexByte - READ_ALGO_VERS (0x07)

writeByte0 - none

writeByteN - none

See also
version
Parameters
*statusBytePointer to status byte
Returns
algoVers - Struct of version info, all 0s on failure

◆ readAlgoSampleRate()

uint16_t readAlgoSampleRate ( uint8_t *  statusByte)

Reads the WHRM algorithm sample rate.

familyByte - READ_ALGORITHM_CONFIG (0x51)

indexByte - READ_MAX_FAST_RATE (0x02)

writeByte0 - READ_MAX_FAST_RATE_ID (0x00)

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
algoSampleRate - Sample rate of WHRM algorithm, 0s on a failure

◆ readAlgoSamples()

uint8_t readAlgoSamples ( uint8_t *  statusByte)

Reads the number of samples available in the output FIFO.

familyByte - READ_ALGORITHM_CONFIG (0x51)

indexByte - READ_AGC_NUM_SAMPLES (0x00)

writeByte0 - READ_AGC_NUM_SAMPLES_ID (0x03)

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
samples - Number of samples available in output FIFO, 0 on a failure

◆ readAlgoSensitivity()

uint8_t readAlgoSensitivity ( uint8_t *  statusByte)

Reads the sensitivity of the AGC algorithm.

familyByte - READ_ALGORITHM_CONFIG (0x51)

indexByte - READ_AGC_SENSITIVITY (0x00)

writeByte0 - READ_AGC_SENSITIVITY_ID (0x02)

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
algoSens - Sensitivity of AGC algorithm, 0 on a failure

◆ readAlgoStepSize()

uint8_t readAlgoStepSize ( uint8_t *  statusByte)

Reads the step size towards the target for the AGC algorithm.

familyByte - READ_ALGORITHM_CONFIG (0x51)

indexByte - READ_AGC_STEP_SIZE (0x00)

writeByte0 - READ_AGC_STEP_SIZE_ID (0x01)

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
stepSize - step size towards the target for the AGC algorithm, 0 on a failure

◆ readBootloaderVersion()

struct version readBootloaderVersion ( uint8_t *  statusByte)

Reads the current version of the bootloader.

Format of version is major.minor.revision

familyByte - BOOTLOADER_INFO (0x81)

indexByte - BOOTLOADER_VERS (0x00)

writeByte0 - none

writeByteN - none

See also
version
Parameters
*statusBytepointer to status byte
Returns
bootVers - Struct of version info, 0s on a failure

◆ readDeviceMode()

uint8_t readDeviceMode ( uint8_t *  statusByte)

Reads the current MAX32664 operating mode.

     0x00: Application operating mode

     0x02: Reset

     0x08: Bootloader operating mode

familyByte - READ_DEVICE_MODE (0x02)

indexByte - 0x00

writeByte0 - none

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
deviceMode - Operating mode of the MAX32664, 0 on a failure (check status byte flag!)

◆ readMAX30101Mode()

uint8_t readMAX30101Mode ( uint8_t *  statusByte)

Reads the operating mode of the MAX30101 PO sensor.

Results indicate which LEDs are being used

MAX30101 Register - MODE_REGISTER (0x09)

Parameters
*statusBytePointer to status byte
Returns
Operating mode of the MAX30101 (which LEDs are being used), ERR_UNKNOWN on invalid return value or I2C transaciton issue

◆ readMAX30101State()

uint8_t readMAX30101State ( uint8_t *  statusByte)

Reads the MAX30101 pulse oximeter state.

familyByte - READ_SENSOR_MODE (0x45)

indexByte - READ_ENABLE_MAX30101 (0x03)

writeByte0 - none

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
maxState - Read MAX30101 state (0x00 == disabled / 0x01 == enabled), 0 on a failure (check status byte!)

◆ readMaximFastCoef()

uint8_t readMaximFastCoef ( int32_t *  coefArray)

Reads the 3 Maxim Fast algorithm coefficients, which are 32-bit signed values * 100,000.

familyByte - READ_ALGORITHM_CONFIG (0x51)

indexByte - READ_MAX_FAST_COEF (0x02)

writeByte0 - READ_MAX_FAST_COEF_ID (0x0B)

Parameters
*coefArrayPointer to array to fill with the 3 coefficients. Needs to be 32-bit
Returns
statusByte - Status of I2C transaction

◆ readPulseAmp()

uint8_t readPulseAmp ( uint8_t *  ledArray,
uint8_t *  statusByte 
)

Reads the LED pulse amplitude of the LEDs in the MAX30101.

MAX30101 Register - LEDX_REGISTER (0x0C <-> 0x0F)

Parameters
*ledArrayArray that the LED data is put into
*statusBytePointer to status byte
Returns
SUCCESS on successful sequence of I2C transactions, ERR_UNKNOWN when there's an issue (refer to status byte!)

◆ readPulseWidth()

uint16_t readPulseWidth ( uint8_t *  statusByte)

Reads the LED pulse width of the LEDs in the MAX30101.

MAX30101 Register - CONFIGURATION_REGISTER (0x0A)

Parameters
*statusBytePointer to status byte
Returns
LED pulse width of MAX30101 in us, ERR_UNKNOWN for invalid read value or I2C transaction (check status byte!)

◆ readRawAndAlgoData()

struct bioData readRawAndAlgoData ( uint8_t *  statusByte)

Reads the raw+algorithm data if that this is the output format.

familyByte - READ_DATA_OUTPUT (0x12)

indexByte - READ_DATA (0x01)

writeByte0 - none

writeByteN - none

Precondition
configMAX32664() function, set to output raw+algorithm data
Parameters
*statusBytePointer to status byte
Returns
libRawAlgoData - Struct of raw+algorithm data, all 0s on I2C failure (check status byte!)

◆ readRawData()

struct bioData readRawData ( uint8_t *  statusByte)

Reads the raw sensor data, assuming only the raw sensor data is being output.

familyByte - READ_DATA_OUTPUT (0x12)

indexByte - READ_DATA (0x01)

writeByte0 - none

writeByteN - none

Precondition
configMAX32664() function, set to output only raw data
Parameters
*statusBytePointer to status byte
Returns
libRawData - Struct of raw sensor data, 0s on I2C failure or incorrect setting (check status byte!)

◆ readRegisterMAX30101()

uint8_t readRegisterMAX30101 ( uint8_t  regAddr,
uint8_t *  statusByte 
)

Reads the value in specific register in the MAX30101.

Passed parameter selects the specific register

familyByte - READ_REGISTER (0x41)

indexByte - READ_MAX30101 (0x03)

writeByte0 - regAddr

writeByteN - none

Parameters
regAddrRegister address in the MAX30101
*statusBytePointer to statusByte
Returns
regCont - Register value, 0 on failure (check status byte!)

◆ readSensorData()

struct bioData readSensorData ( uint8_t *  statusByte)

Read sensor data from MAX32664 output FIFO.

Data contents/format depend on previous settings (typically set by configMAX32664)

familyByte N/A - multiple I2C transactions internally

indexByte N/A - multiple I2C transactions internally

writeByte0 N/A - multiple I2C transactions internally

writeByteN N/A - multiple I2C transactions internally

Precondition
configMAX32664() or other function(s) that configures the data output format, algorithm mode, interrupt threshold, enable the algorithms, and enable the MAX30101
Parameters
*statusBytePointer to status byte
Returns
libData - Struct containing body data (IR and Red LED ADC count, heart rate, confidence, SpO2, algorithm state, etc.) Contents and formats depend on previous settings (typically set by configBPM). 0s when not used or I2C transaction errors (check status byte!)

◆ readSensorHubStatus()

uint8_t readSensorHubStatus ( uint8_t *  statusByte)

Reads the current sensor hub status.

Includes sensor communication status, current FIFO threshold, FIFO input overflow, FIFO output overflow, and host accelerometer underflow info

familyByte - HUB_STATUS (0x00)

indexByte - 0x00

writeByte0 - none

writeByteN - none

Parameters
*statusBytePointer to status byte
Returns
status - sensor hub status (see Table 7 in MAX32664 User's Guide for bitfield details (https://pdfserv.maximintegrated.com/en/an/user-guide-6806-max32664.pdf), 0 on I2C failure (check status byte!)

◆ readSensorHubVersion()

struct version readSensorHubVersion ( uint8_t *  statusByte)

Reads the current version of the sensor hub.

Format of version is major.minor.revision

familyByte - IDENTITY (0xFF)

indexByte - READ_SENSOR_HUB_VERS (0x03)

writeByte0 - none

writeByteN - none

See also
version
Parameters
*statusBytePointer to status byte
Returns
sensorHubVer - Struct of version info, all 0s on a failure (check status byte!)

◆ setDeviceMode()

uint8_t setDeviceMode ( uint8_t  operatingMode,
uint8_t *  statusByte 
)

Sets the operating mode for the MAX32664.

Alternative method to setting operating mode (to external pin method)

familyByte - SET_DEVICE_MODE (0x01)

indexByte - 0x00

writeByte0 - none

writeByteN - none

Parameters
operatingModeDesired operating mode to be written out. 0x00: exit bootloader, enter application mode, 0x02: reset, 0x08: enter bootloader
*statusBytePointer to the status byte
Returns
deviceMode - The current operating mode, should be equal to what it was set to. ERR_UNKNOWN on transaction issue or not equal to what it's set to (check status byte!)

◆ setFifoThreshold()

uint8_t setFifoThreshold ( uint8_t  intThresh)

Sets output FIFO threshold (# data samples extracted before MRIO output interrupt generated)

familyByte - OUTPUT_MODE (0x10)

indexByte - WRITE_SET_THRESHOLD (0x01)

writeByte0 - intThresh (0x01 to 0xff)

writeByteN - none

Parameters
intThreshFIFO interrupt threshold (0x01 to 0xff)
Returns
fifoThreshStatus - SUCCESS when no I2C transaction issues, status byte when there was an i2C transaction issue

◆ setOutputMode()

uint8_t setOutputMode ( uint8_t  outputType)

Sets the data output mode: raw, algorithm, raw+algorithm, etc.

familyByte - OUTPUT_MODE (0x10)

indexByte - SET_FORMAT (0x00)

writeByte0 - outputType (0x00 to 0x07)

writeByteN - none

Parameters
outputTypeOutput type of the data. See OUTPUT_MODE_WRITE_BYTE for valid options
Returns
outputModeStatus - returns SUCCESS if everything goes well, return status byte if issue with I2C transaction

◆ softwareResetMAX30101()

uint8_t softwareResetMAX30101 ( void  )

Performs a reset of MAX30101 by setting the Reset Control bit to 1.

MAX30101 Register - MODE_REGISTER (0x09)

Postcondition
configMAX32664() to configure the MAX30101 appropriately
Parameters
none
Returns
statusByte - Status byte of I2C transaction

◆ softwareResetMAX32664()

uint8_t softwareResetMAX32664 ( void  )

Does a software reset of the device.

Sets the device mode of the MAX32664 to reset mode, then to application mode. Finally waits 1s before turning to ensure that initialization is complete

familyByte N/A - multiple I2C transactions internally

indexByte N/A - multiple I2C transactions internally

writeByte0 N/A - multiple I2C transactions internally

writeByteN N/A - multiple I2C transactions internally

Postcondition
configMAX32664() to reconfigure the MAX32664
Parameters
none
Returns
statusByte - Status byte of I2C transaction or ERR_UNKNOWN if we don't return to application mode

◆ writeRegisterMAX30101()

uint8_t writeRegisterMAX30101 ( uint8_t  regAddr,
uint8_t  regVal 
)

Writes the given value to the given register address in the MAX30101.

Returns status of I2C transaction

familyByte - WRITE_REGISTER (0x40)

indexByte - WRITE_MAX30101 (0x03)

writeByte0 - regAddr

writeByteN - regVal

Parameters
regAddrAddress of the register we want to write to in the MAX30101
regValValue you want to write into that register
Returns
status - Status byte of I2C transaction