Pulse Oximeter Library  1.0.0
Pulse Oximeter Library for using the MAX32664 & MAX30101 SparkFun library
bio_sensor.h
Go to the documentation of this file.
1 
33 #ifndef BIO_SENSOR_H_
34 #define BIO_SENSOR_H_
35 
36 #include <stdint.h>
37 #include <stddef.h>
38 #include <unistd.h>
39 #include <ti/drivers/GPIO.h>
40 #include <ti/drivers/I2C.h>
41 /* Driver configuration */
42 #include "ti_drivers_config.h"
43 
44 
45 
47 /* The following defines and enums within the large lines of ///
48  are taken (almost) directly from the SparkFun Bio Sensor Hub Library. Small modifications were made to allow for easier documentation/reference
49  It was easier to copy their macros than re-write our own.
50  We would like to thank SparkFun and Elias Santistevan (main author)
51  for writing this library and making it available to the public.
52  Below is the introduction/background section taken from the
53  "SparkFun_Bio_Sensor_Hub_Library.cpp" file from the library:
54 
55 
56 
57  This is an Arduino Library written for the MAXIM 32664 Biometric Sensor Hub
58  The MAX32664 Biometric Sensor Hub is in actuality a small Cortex M4 microcontroller
59  with pre-loaded firmware and algorithms used to interact with the a number of MAXIM
60  sensors; specifically the MAX30101 Pulse Oximter and Heart Rate Monitor and
61  the KX122 Accelerometer. With that in mind, this library is built to
62  communicate with a middle-person and so has a unique method of communication
63  (family, index, and write bytes) that is more simplistic than writing and reading to
64  registers, but includes a larger set of definable values.
65 
66  SparkFun Electronics
67  Date: June, 2019
68  Author: Elias Santistevan
69 kk
70  License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
71 
72  Feel like supporting our work? Buy a board from SparkFun!
73 */
74 
75 #define WRITE_FIFO_INPUT_BYTE 0x04
76 #define DISABLE 0x00
77 #define ENABLE 0x01
78 #define MODE_ONE 0x01
79 #define MODE_TWO 0x02
80 #define APP_MODE 0x00
81 #define BOOTLOADER_MODE 0x08
82 #define NO_WRITE 0x00
83 #define INCORR_PARAM 0xEE
84 
85 #define CONFIGURATION_REGISTER 0x0A
86 #define PULSE_MASK 0xFC
87 #define READ_PULSE_MASK 0x03
88 #define SAMP_MASK 0xE3
89 #define READ_SAMP_MASK 0x1C
90 #define ADC_MASK 0x9F
91 #define READ_ADC_MASK 0x60
92 
93 #define ENABLE_CMD_DELAY 50 // Milliseconds
94 #define CMD_DELAY 6 // Milliseconds
95 #define MAXFAST_ARRAY_SIZE 6 // Number of bytes....
96 #define MAXFAST_EXTENDED_DATA 5
97 #define MAX30101_LED_ARRAY 12 // 4 values of 24 bit (3 byte) LED values
98 
99 #define SET_FORMAT 0x00
100 #define READ_FORMAT 0x01 // Index Byte under Family Byte: READ_OUTPUT_MODE (0x11)
101 #define WRITE_SET_THRESHOLD 0x01 //Index Byte for WRITE_INPUT(0x14)
102 #define WRITE_EXTERNAL_TO_FIFO 0x00
103 
104 #define BIO_ADDRESS 0x55;
105 #define SUCCESS 0x00
106 
107 
112 struct bioData {
113 
114  uint32_t irLed;
115  uint32_t redLed;
116  uint16_t heartRate;
117  uint8_t confidence;
118  uint16_t oxygen;
119  uint8_t status;
120  float rValue;
121  int8_t extStatus;
122  uint8_t reserveOne; // --
123  uint8_t resserveTwo; // -- Algorithm Mode 2 ^^
124 
125 };
126 
130 struct version {
131  // 3 bytes total
132  uint8_t major;
133  uint8_t minor;
134  uint8_t revision;
135 
136 };
137 
138 
142 struct sensorAttr {
143 
144  uint8_t byteWord;
145  uint8_t availRegisters;
146 
147 };
148 
149 // Status Bytes are communicated back after every I-squared-C transmission and
150 // are indicators of success or failure of the previous transmission.
151 enum READ_STATUS_BYTE_VALUE {
152 
153 // SUCCESS = 0x00, //comment out when this is already declared in another file
154  ERR_UNAVAIL_CMD = 0x01, //Illegal Family Byte and/or Index Byte was used. Verify that the Family Byte, Index Byte are valid for the host command sent. Verify that the latest .msbl is flashed.
155  ERR_UNAVAIL_FUNC, //This function is not implemented. Verify that the Index Byte and Write Byte(s) are valid for the host command sent. Verify that the latest .msbl is flashed.
156  ERR_DATA_FORMAT, //Incorrect number of bytes sent for the requested Family Byte. Verify that the correct number of bytes are sent for the host command. Verify that the latest .msbl is flashed.
157  ERR_INPUT_VALUE, //Illegal configuration value was attempted to be set. Verify that the Index Byte is correct for Family Byte 0x44. Verify that the report period is not 0 for host command 0x10 0x02. Verify that the Write byte for host command 0x10 0x03 is in the valid range specified. Verify that the latest .msbl is flashed.
158  ERR_INVALID_MODE = 0x05, //Application mode: Not used in application mode.
159  ERR_BTLDR_TRY_AGAIN = 0x05, //Bootloader mode: Device is busy. Insert delay and resend the host command.
160  ERR_BTLDR_GENERAL = 0x80, //General error while receiving/flashing a page during the bootloader sequence. Not used
161  ERR_BTLDR_CHECKSUM, //Bootloader checksum error while decrypting/checking page data. Verify that the keyed .msbl file is compatible with MAX32664A/B/C/D.
162  ERR_BTLDR_AUTH, //Bootloader authorization error. Verify that the keyed .msbl file is compatible with MAX32664A/B/C/D.
163  ERR_BTLDR_INVALID_APP, //Bootloader detected that the application is not valid
164  ERR_TRY_AGAIN = 0xFE, //Device is busy, try again. Increase the delay before the command and increase the CMD_DELAY.
165  ERR_UNKNOWN = 0xFF //Unknown Error. Verify that the communications to the AFE/KX-122 are correct by reading the PART_ID/WHO_AM_I register. For MAX32664B/C, the MAX32664 is in deep sleep unless the host sets the MFIO pin low 250us before and during the I2C communications.
166 
167 };
168 
169 // The family register bytes are the larger umbrella for all the Index and
170 // Write Bytes listed below. You can not reference a nestled byte without first
171 // referencing it's larger category: Family Register Byte.
172 enum FAMILY_REGISTER_BYTES {
173 
174  HUB_STATUS = 0x00,
175  SET_DEVICE_MODE,
176  READ_DEVICE_MODE,
177  OUTPUT_MODE = 0x10,
178  READ_OUTPUT_MODE,
179  READ_DATA_OUTPUT,
180  READ_DATA_INPUT,
181  WRITE_INPUT,
182  WRITE_REGISTER = 0x40,
183  READ_REGISTER,
184  READ_ATTRIBUTES_AFE,
185  DUMP_REGISTERS,
186  ENABLE_SENSOR,
187  READ_SENSOR_MODE,
188  CHANGE_ALGORITHM_CONFIG = 0x50,
189  READ_ALGORITHM_CONFIG,
190  ENABLE_ALGORITHM,
191  BOOTLOADER_FLASH = 0x80,
192  BOOTLOADER_INFO,
193  IDENTITY = 0xFF
194 
195 };
196 
197 // All the defines below are: 1. Index Bytes nestled in the larger category of the
198 // family registry bytes listed above and 2. The Write Bytes nestled even
199 // farther under their Index Bytes.
200 
201 // Write Bytes under Family Byte: SET_DEVICE_MODE (0x01) and Index
202 // Byte: 0x00.
203 enum DEVICE_MODE_WRITE_BYTES {
204 
205  EXIT_BOOTLOADER = 0x00,
206  RESET = 0x02,
207  ENTER_BOOTLOADER = 0x08
208 
209 };
210 
211 // Write Bytes under Family Byte: OUTPUT_MODE (0x10) and Index byte: SET_FORMAT
212 // (0x00)
213 enum OUTPUT_MODE_WRITE_BYTE {
214 
215  PAUSE = 0x00,
216  SENSOR_DATA,
217  ALGO_DATA,
218  SENSOR_AND_ALGORITHM,
219  PAUSE_TWO,
220  SENSOR_COUNTER_BYTE,
221  ALGO_COUNTER_BYTE,
222  SENSOR_ALGO_COUNTER
223 
224 };
225 
226 // Index Byte under the Family Byte: READ_DATA_OUTPUT (0x12)
227 enum FIFO_OUTPUT_INDEX_BYTE {
228 
229  NUM_SAMPLES,
230  READ_DATA
231 
232 };
233 
234 // Index Byte under the Family Byte: READ_DATA_INPUT (0x13)
235 enum FIFO_EXTERNAL_INDEX_BYTE {
236 
237  SAMPLE_SIZE,
238  READ_INPUT_DATA,
239  READ_SENSOR_DATA, // For external accelerometer
240  READ_NUM_SAMPLES_INPUT, // For external accelerometer
241  READ_NUM_SAMPLES_SENSOR
242 
243 };
244 
245 // Index Byte under the Family Registry Byte: WRITE_REGISTER (0x40)
246 enum WRITE_REGISTER_INDEX_BYTE {
247 
248  WRITE_MAX30101 = 0x03,
249  WRITE_ACCELEROMETER
250 
251 };
252 
253 // Index Byte under the Family Registry Byte: READ_REGISTER (0x41)
254 enum READ_REGISTER_INDEX_BYTE {
255 
256  READ_MAX30101 = 0x03,
257  READ_ACCELEROMETER
258 
259 };
260 
261 // Index Byte under the Family Registry Byte: READ_ATTRIBUTES_AFE (0x42)
262 enum GET_AFE_INDEX_BYTE {
263 
264  RETRIEVE_AFE_MAX30101 = 0x03,
265  RETRIEVE_AFE_ACCELEROMETER
266 
267 };
268 
269 // Index Byte under the Family Byte: DUMP_REGISTERS (0x43)
270 enum DUMP_REGISTER_INDEX_BYTE {
271 
272  DUMP_REGISTER_MAX30101 = 0x03,
273  DUMP_REGISTER_ACCELEROMETER
274 
275 };
276 
277 // Index Byte under the Family Byte: ENABLE_SENSOR (0x44)
278 enum SENSOR_ENABLE_INDEX_BYTE {
279 
280  ENABLE_MAX30101 = 0x03,
281  ENABLE_ACCELEROMETER
282 
283 };
284 
285 // Index Byte for the Family Byte: READ_SENSOR_MODE (0x45)
286 enum READ_SENSOR_ENABLE_INDEX_BYTE {
287 
288  READ_ENABLE_MAX30101 = 0x03,
289  READ_ENABLE_ACCELEROMETER
290 
291 };
292 
293 // Index Byte under the Family Byte: CHANGE_ALGORITHM_CONFIG (0x50)
294 enum ALGORITHM_CONFIG_INDEX_BYTE {
295 
296  SET_TARG_PERC = 0x00,
297  SET_STEP_SIZE = 0x00,
298  SET_SENSITIVITY = 0x00,
299  SET_AVG_SAMPLES = 0x00,
300  SET_PULSE_OX_COEF = 0x02,
301 
302 };
303 
304 // Write Bytes under the Family Byte: CHANGE_ALGORITHM_CONFIG (0x50) and the
305 // Index Byte: ALGORITHM_CONFIG_INDEX_BYTE - SET_TARG_PERC
306 enum ALGO_AGC_WRITE_BYTE {
307 
308  AGC_GAIN_ID = 0x00,
309  AGC_STEP_SIZE_ID,
310  AGC_SENSITIVITY_ID,
311  AGC_NUM_SAMP_ID,
312  MAXIMFAST_COEF_ID = 0x0B
313 
314 };
315 
316 // Index Bytes under the Family Byte: READ_ALGORITHM_CONFIG (0x51)
317 enum READ_ALGORITHM_INDEX_BYTE {
318 
319  READ_AGC_PERCENTAGE = 0x00,
320  READ_AGC_STEP_SIZE = 0x00,
321  READ_AGC_SENSITIVITY = 0x00,
322  READ_AGC_NUM_SAMPLES = 0x00,
323  READ_MAX_FAST_COEF = 0x02
324 
325 };
326 
327 // Write Bytes under the Family Byte: READ_ALGORITHM_CONFIG (0x51) and Index Byte:
328 // READ_ALGORITHM_INDEX_BYTE - AGC
329 enum READ_AGC_ALGO_WRITE_BYTE {
330 
331  READ_AGC_PERC_ID = 0x00,
332  READ_AGC_STEP_SIZE_ID,
333  READ_AGC_SENSITIVITY_ID,
334  READ_AGC_NUM_SAMPLES_ID,
335  READ_MAX_FAST_COEF_ID = 0x0B
336 
337 };
338 
339 // Index Byte under the Family Byte: ENABLE_ALGORITHM (0x52).
340 enum ALGORITHM_MODE_ENABLE_INDEX_BYTE {
341 
342  ENABLE_AGC_ALGO = 0x00,
343  ENABLE_WHRM_ALGO = 0x02
344 
345 };
346 
347 // Index Byte under the Family Byte: BOOTLOADER_FLASH (0x80).
348 enum BOOTLOADER_FLASH_INDEX_BYTE {
349 
350  SET_INIT_VECTOR_BYTES = 0x00,
351  SET_AUTH_BYTES,
352  SET_NUM_PAGES,
353  ERASE_FLASH,
354  SEND_PAGE_VALUE
355 
356 };
357 
358 // Index Byte under the Family Byte: BOOTLOADER_INFO (0x81).
359 enum BOOTLOADER_INFO_INDEX_BYTE {
360 
361  BOOTLOADER_VERS = 0x00,
362  PAGE_SIZE
363 
364 };
365 
366 // Index Byte under the Family Byte: IDENTITY (0xFF).
367 enum IDENTITY_INDEX_BYTES {
368 
369  READ_MCU_TYPE = 0x00,
370  READ_SENSOR_HUB_VERS = 0x03,
371  READ_ALGO_VERS = 0x07
372 
373 };
374 
375 //End of section taken from SparkFun Bio Sensor Hub Library
377 
378 
379 
380 
382 //Section of new variables we created to add certain functionality to our system
383 
384 #define I2_READ_STATUS_BYTE_COUNT 0x01
385 
386 #define MODE_REGISTER 0x09 //Mode Configuration register of MAX30101
387 #define MODE_MASK 0xF8 //mask for modifying the mode bits while keeping other bits in register
388 #define READ_MODE_MASK 0x07 //mask for reading just the mode bits [2:0]
389 #define RESET_MASK 0xBF //mask for modifying the reset bit while keeping other bits in register
390 #define READ_RESET_MASK 0x40 //mask for reading just the reset bit [6]
391 #define SET_RESET_BIT 0x40 //mask for setting the reset bit to 1
392 #define SHDN_MASK 0x7F //mask for modifying the shutdown bit while keeping other bits in register
393 #define READ_SHDN_MASK 0x80 //mask for reading just the shutdown bit [7]
394 
395 #define LEDOFFSET_REGISTER 0x0B //reserved register, just using as an offset
396 #define LED1_REGISTER 0x0C //LED1 Pulse Amplitude register
397 #define LED2_REGISTER 0x0D //LED2 Pulse Amplitude register
398 #define LED3_REGISTER 0x0E //LED3 Pulse Amplitude register
399 #define LED4_REGISTER 0x0F //LED4 Pulse Amplitude register
400 
401 #define READ_MAX_FAST_RATE 0x02 //Maxim Fast sampling rate
402 #define READ_MAX_FAST_RATE_ID 0x00 //Maxim Fast sampling rate ID
403 
404 #define NUM_MAXIM_FAST_COEF 0x03 //number of Maxim Fast algorithm coefficients
406 
407 
424 uint8_t beginI2C(I2C_Handle i2cHandle, uint8_t *statusByte);
425 
426 
449 uint8_t configMAX32664(uint8_t outputFormat, uint8_t algoMode, uint8_t intThresh);
450 
451 
472 struct bioData readSensorData(uint8_t *statusByte);
473 
474 
492 struct bioData readRawData(uint8_t *statusByte);
493 
494 
512 struct bioData readAlgoData(uint8_t *statusByte);
513 
514 
532 struct bioData readRawAndAlgoData(uint8_t *statusByte);
533 
534 
553 uint8_t softwareResetMAX32664(void);
554 
555 
567 uint8_t softwareResetMAX30101(void);
568 
569 
585 uint8_t setOutputMode(uint8_t outputType);
586 
587 
603 uint8_t setFifoThreshold(uint8_t intThresh);
604 
605 
621 uint8_t numSamplesOutFifo(uint8_t *statusByte);
622 
623 
639 uint8_t agcAlgoControl(uint8_t enable);
640 
641 
657 uint8_t max30101Control(uint8_t senSwitch);
658 
659 
675 uint8_t readMAX30101State(uint8_t *statusByte);
676 
677 
693 uint8_t maximFastAlgoControl(uint8_t mode);
694 
695 
717 uint8_t readDeviceMode(uint8_t *statusByte);
718 
719 
736 uint8_t setDeviceMode(uint8_t operatingMode, uint8_t *statusByte);
737 
738 
755 uint8_t readSensorHubStatus(uint8_t *statusByte);
756 
757 
773 uint8_t readAlgoSamples(uint8_t *statusByte);
774 
775 
791 uint8_t readAlgoRange(uint8_t *statusByte);
792 
793 
809 uint8_t readAlgoStepSize(uint8_t *statusByte);
810 
811 
827 uint8_t readAlgoSensitivity(uint8_t *statusByte);
828 
829 
845 uint16_t readAlgoSampleRate(uint8_t *statusByte);
846 
847 
861 uint8_t readMaximFastCoef(int32_t *coefArray);
862 
881 struct version readSensorHubVersion(uint8_t *statusByte);
882 
883 
902 struct version readAlgorithmVersion(uint8_t *statusByte);
903 
904 
923 struct version readBootloaderVersion(uint8_t *statusByte);
924 
925 
941 uint8_t getMcuType(uint8_t *statusByte);
942 
943 
953 uint16_t readADCSampleRate(uint8_t *statusByte);
954 
955 
965 uint16_t readADCRange(uint8_t *statusByte);
966 
967 
977 uint16_t readPulseWidth(uint8_t *statusByte);
978 
979 
990 uint8_t readPulseAmp(uint8_t *ledArray, uint8_t *statusByte);
991 
992 
1002 uint8_t readMAX30101Mode(uint8_t *statusByte);
1003 
1004 
1022 struct sensorAttr getAfeAttributesMAX30101(uint8_t *statusByte);
1023 
1024 
1042 struct sensorAttr getAfeAttributesAccelerometer(uint8_t *statusByte);
1043 
1044 
1060 uint8_t getExtAccelMode(uint8_t *statusByte);
1061 
1062 
1079 uint8_t readRegisterMAX30101(uint8_t regAddr, uint8_t *statusByte);
1080 
1081 
1098 uint8_t writeRegisterMAX30101(uint8_t regAddr, uint8_t regVal);
1099 
1100 
1101 
1102 
1103 
1105 
1106 /*
1107  * Low level I2C transaction functions, called by all higher lever functions
1108  * Overall I2C transaction requires a write AND read I2C transaction with a small delay between
1109  */
1110 
1111 
1112 
1113 
1131 uint8_t I2CReadByte(uint8_t familyByte, uint8_t indexByte, uint8_t *statusByte);
1132 
1133 
1152 uint8_t I2CReadBytewithWriteByte(uint8_t familyByte, uint8_t indexByte, uint8_t dataByte, uint8_t *statusByte);
1153 
1154 
1173 uint8_t I2CReadFillArray(uint8_t familyByte, uint8_t indexByte, uint8_t arraySize, uint8_t *arraytoFill);
1174 
1175 
1193 uint16_t I2CReadInt(uint8_t familyByte, uint8_t indexByte, uint8_t *statusByte);
1194 
1195 
1214 uint16_t I2CReadIntWithWriteByte(uint8_t familyByte, uint8_t indexByte, uint8_t writeByte, uint8_t *statusByte);
1215 
1216 
1235 int32_t I2CRead32BitValue(uint8_t familyByte, uint8_t indexByte, uint8_t dataByte, uint8_t *statusByte);
1236 
1237 
1257 uint8_t I2CReadMultiple32BitValues(uint8_t familyByte, uint8_t indexByte, uint8_t dataByte, uint8_t numReads, int32_t *numArray);
1258 
1259 
1277 uint8_t I2CWriteByte(uint8_t familyByte, uint8_t indexByte, uint8_t dataByte);
1278 
1279 
1297 uint8_t I2CWrite2Bytes(uint8_t familyByte, uint8_t indexByte, uint8_t dataByte0, uint8_t dataByte1);
1298 
1299 
1318 uint8_t I2CenableWriteByte(uint8_t familyByte, uint8_t indexByte, uint8_t dataByte);
1319 
1320 
1321 
1322 
1323 
1325 //older versions of the lower level I2C transaction functions
1326 
1327 //char I2CWriteByte(I2C_Transaction *i2cTrans, I2C_Handle *i2cHandle, uint8_t familyByte, uint8_t indexByte, uint8_t dataByte);
1328 
1329 //char I2CReadByte(I2C_Transaction *i2cTrans, I2C_Handle *i2cHandle, uint8_t familyByte, uint8_t indexByte);
1330 
1331 //char I2CReadBytewithWriteByte(I2C_Transaction *i2cTrans, I2C_Handle *i2cHandle, uint8_t familyByte, uint8_t indexByte, uint8_t dataByte);
1332 
1333 //char I2CenableWrite(I2C_Transaction *i2cTrans, I2C_Handle *i2cHandle, uint8_t familyByte, uint8_t indexByte, uint8_t dataByte);
1334 
1335 //char I2CReadFillArray(I2C_Transaction *i2cTrans, I2C_Handle *i2cHandle, uint8_t familyByte, uint8_t indexByte, uint8_t arraySize, uint8_t *arraytoFill);
1337 
1338 
1339 #endif /* BIO_SENSOR_H_ */
uint16_t I2CReadIntWithWriteByte(uint8_t familyByte, uint8_t indexByte, uint8_t writeByte, uint8_t *statusByte)
Performs a read transaction with a single write byte.
Definition: bio_sensor.c:1981
uint8_t numSamplesOutFifo(uint8_t *statusByte)
Reads number of samples available in the output FIFO.
Definition: bio_sensor.c:853
uint8_t readAlgoRange(uint8_t *statusByte)
Reads the percent of full scale ADC range that the AGC algorithm is using.
Definition: bio_sensor.c:1116
struct version readSensorHubVersion(uint8_t *statusByte)
Reads the current version of the sensor hub.
Definition: bio_sensor.c:1236
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.
Definition: bio_sensor.c:2183
uint8_t readRegisterMAX30101(uint8_t regAddr, uint8_t *statusByte)
Reads the value in specific register in the MAX30101.
Definition: bio_sensor.c:1673
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 be...
Definition: bio_sensor.c:2285
uint8_t agcAlgoControl(uint8_t enable)
Controls the AGC algorithm, enables or disables it.
Definition: bio_sensor.c:876
uint8_t setFifoThreshold(uint8_t intThresh)
Sets output FIFO threshold (# data samples extracted before MRIO output interrupt generated)
Definition: bio_sensor.c:825
uint16_t readPulseWidth(uint8_t *statusByte)
Reads the LED pulse width of the LEDs in the MAX30101.
Definition: bio_sensor.c:1438
uint8_t readPulseAmp(uint8_t *ledArray, uint8_t *statusByte)
Reads the LED pulse amplitude of the LEDs in the MAX30101.
Definition: bio_sensor.c:1467
uint8_t softwareResetMAX30101(void)
Performs a reset of MAX30101 by setting the Reset Control bit to 1.
Definition: bio_sensor.c:754
struct bioData readSensorData(uint8_t *statusByte)
Read sensor data from MAX32664 output FIFO.
Definition: bio_sensor.c:195
uint8_t readAlgoStepSize(uint8_t *statusByte)
Reads the step size towards the target for the AGC algorithm.
Definition: bio_sensor.c:1139
uint16_t I2CReadInt(uint8_t familyByte, uint8_t indexByte, uint8_t *statusByte)
Performs a read transaction with no write bytes.
Definition: bio_sensor.c:1917
struct sensorAttr getAfeAttributesAccelerometer(uint8_t *statusByte)
Gets the attributes for the accelerometer.
Definition: bio_sensor.c:1609
uint8_t setDeviceMode(uint8_t operatingMode, uint8_t *statusByte)
Sets the operating mode for the MAX32664.
Definition: bio_sensor.c:1028
uint8_t maximFastAlgoControl(uint8_t mode)
Controls the WHRM/Maxim Algorithm, disables it or sets the mode (mode 1 or mode 2)
Definition: bio_sensor.c:965
uint8_t getMcuType(uint8_t *statusByte)
Reads the MCU type of biometric sensor hub (expect MAX32660/MAX32664)
Definition: bio_sensor.c:1353
uint16_t readADCRange(uint8_t *statusByte)
Reads the internal ADC range of the MAX30101.
Definition: bio_sensor.c:1408
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.
Definition: bio_sensor.c:1731
uint8_t softwareResetMAX32664(void)
Does a software reset of the device.
Definition: bio_sensor.c:715
uint8_t readAlgoSamples(uint8_t *statusByte)
Reads the number of samples available in the output FIFO.
Definition: bio_sensor.c:1093
struct sensorAttr getAfeAttributesMAX30101(uint8_t *statusByte)
Gets the attributes for the MAX30101 sensor.
Definition: bio_sensor.c:1570
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.
Definition: bio_sensor.c:2233
uint8_t readDeviceMode(uint8_t *statusByte)
Reads the current MAX32664 operating mode.
Definition: bio_sensor.c:1004
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 si...
Definition: bio_sensor.c:1790
uint8_t readMAX30101State(uint8_t *statusByte)
Reads the MAX30101 pulse oximeter state.
Definition: bio_sensor.c:942
struct bioData readRawAndAlgoData(uint8_t *statusByte)
Reads the raw+algorithm data if that this is the output format.
Definition: bio_sensor.c:555
uint16_t readADCSampleRate(uint8_t *statusByte)
Reads the ADC sample rate of the MAX30101 internal ADC.
Definition: bio_sensor.c:1374
uint8_t max30101Control(uint8_t senSwitch)
Controls the MAX30101 pulse oximeter, enables or disables it.
Definition: bio_sensor.c:909
struct version readBootloaderVersion(uint8_t *statusByte)
Reads the current version of the bootloader.
Definition: bio_sensor.c:1316
struct version readAlgorithmVersion(uint8_t *statusByte)
Reads the current version of the algorithm.
Definition: bio_sensor.c:1276
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.
Definition: bio_sensor.c:2111
struct bioData readRawData(uint8_t *statusByte)
Reads the raw sensor data, assuming only the raw sensor data is being output.
Definition: bio_sensor.c:337
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,...
Definition: bio_sensor.c:1850
uint8_t readSensorHubStatus(uint8_t *statusByte)
Reads the current sensor hub status.
Definition: bio_sensor.c:1070
uint8_t beginI2C(I2C_Handle i2cHandle, uint8_t *statusByte)
Takes the I2C handle object to read the current sensor hub mode.
Definition: bio_sensor.c:63
uint8_t setOutputMode(uint8_t outputType)
Sets the data output mode: raw, algorithm, raw+algorithm, etc.
Definition: bio_sensor.c:793
uint8_t configMAX32664(uint8_t outputFormat, uint8_t algoMode, uint8_t intThresh)
Configures the MAX32664.
Definition: bio_sensor.c:108
uint8_t readMAX30101Mode(uint8_t *statusByte)
Reads the operating mode of the MAX30101 PO sensor.
Definition: bio_sensor.c:1534
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.
Definition: bio_sensor.c:2045
struct bioData readAlgoData(uint8_t *statusByte)
Reads the algorithm data, assuming only the algorithm data is being output.
Definition: bio_sensor.c:414
uint8_t getExtAccelMode(uint8_t *statusByte)
Gets the current mode of the external accelerometer.
Definition: bio_sensor.c:1643
uint8_t writeRegisterMAX30101(uint8_t regAddr, uint8_t regVal)
Writes the given value to the given register address in the MAX30101.
Definition: bio_sensor.c:1697
uint16_t readAlgoSampleRate(uint8_t *statusByte)
Reads the WHRM algorithm sample rate.
Definition: bio_sensor.c:1185
uint8_t readAlgoSensitivity(uint8_t *statusByte)
Reads the sensitivity of the AGC algorithm.
Definition: bio_sensor.c:1162
uint8_t readMaximFastCoef(int32_t *coefArray)
Reads the 3 Maxim Fast algorithm coefficients, which are 32-bit signed values * 100,...
Definition: bio_sensor.c:1209
Struct of algorithm output data.
Definition: bio_sensor.h:112
int8_t extStatus
– Algorithm status. 0: Success, 1: Not Ready, -1: Something is on sensor, -2: Device excessive motion...
Definition: bio_sensor.h:121
uint16_t heartRate
Calculated WHRM algorithm heart rate. LSB = 0.1bpm.
Definition: bio_sensor.h:116
uint16_t oxygen
Calculated WHRM algorithm SpO2 level. 0-100% LSB = 1%.
Definition: bio_sensor.h:118
uint32_t irLed
IR LED ADC Count.
Definition: bio_sensor.h:114
float rValue
– Algorithm Mode 2 vv calculated R value
Definition: bio_sensor.h:120
uint8_t status
Algorithm current state. 0: No object detected, 1: Something on sensor, 2: Another object detected,...
Definition: bio_sensor.h:119
uint8_t confidence
Calculated WHRM algorithm confidence in heart rate. 0-100% LSB = 1%.
Definition: bio_sensor.h:117
uint32_t redLed
RED LED ADC Count.
Definition: bio_sensor.h:115
Struct of attributes for a sensor.
Definition: bio_sensor.h:142
uint8_t availRegisters
Number of registers available.
Definition: bio_sensor.h:145
uint8_t byteWord
Number of bytes in a word for this sensor.
Definition: bio_sensor.h:144
Struct of version data.
Definition: bio_sensor.h:130
uint8_t major
major part of version information
Definition: bio_sensor.h:132
uint8_t revision
revision part of version information
Definition: bio_sensor.h:134
uint8_t minor
minor part of version information
Definition: bio_sensor.h:133