ME11C Sample Code in Maxim Integrated Team

Dependencies:   BMI160 max32630hsp3 MemoryLCD USBDevice

Fork of Host_Software_MAX32664GWEC_SpO2_HR-_EXTE by Seyhmus Cacina

Committer:
seyhmuscacina
Date:
Mon Mar 25 07:56:34 2019 +0000
Revision:
2:3b5d2467e6c7
Parent:
0:b259fd1a88f5
Fork the repository

Who changed what in which revision?

UserRevisionLine numberNew contents of line
seyhmus.cacina 0:b259fd1a88f5 1 /*
seyhmus.cacina 0:b259fd1a88f5 2 * SHComm.h
seyhmus.cacina 0:b259fd1a88f5 3 *
seyhmus.cacina 0:b259fd1a88f5 4 * Created on: Nov 16, 2018
seyhmus.cacina 0:b259fd1a88f5 5 * Author: Yagmur.Gok
seyhmus.cacina 0:b259fd1a88f5 6 */
seyhmus.cacina 0:b259fd1a88f5 7
seyhmus.cacina 0:b259fd1a88f5 8 #ifndef SOURCE_SHCOMM_H_
seyhmus.cacina 0:b259fd1a88f5 9 #define SOURCE_SHCOMM_H_
seyhmus.cacina 0:b259fd1a88f5 10
seyhmus.cacina 0:b259fd1a88f5 11 /*
seyhmus.cacina 0:b259fd1a88f5 12 #ifdef __cplusplus
seyhmus.cacina 0:b259fd1a88f5 13 extern "C" {
seyhmus.cacina 0:b259fd1a88f5 14 #endif
seyhmus.cacina 0:b259fd1a88f5 15 */
seyhmus.cacina 0:b259fd1a88f5 16
seyhmus.cacina 0:b259fd1a88f5 17 // Sensor/Algo indicies
seyhmus.cacina 0:b259fd1a88f5 18 #define SH_SENSORIDX_MAX8614X 0x00
seyhmus.cacina 0:b259fd1a88f5 19 #define SH_SENSORIDX_MAX30205 0x01
seyhmus.cacina 0:b259fd1a88f5 20 #define SH_SENSORIDX_MAX30001 0x02
seyhmus.cacina 0:b259fd1a88f5 21 #define SH_SENSORIDX_MAX30101 0x03
seyhmus.cacina 0:b259fd1a88f5 22 #define SH_SENSORIDX_ACCEL 0x04
seyhmus.cacina 0:b259fd1a88f5 23 #define SH_NUM_CURRENT_SENSORS 5
seyhmus.cacina 0:b259fd1a88f5 24
seyhmus.cacina 0:b259fd1a88f5 25 #define SH_ALGOIDX_AGC 0x00
seyhmus.cacina 0:b259fd1a88f5 26 #define SH_ALGOIDX_AEC 0x01
seyhmus.cacina 0:b259fd1a88f5 27 #define SH_ALGOIDX_WHRM 0x02
seyhmus.cacina 0:b259fd1a88f5 28 #define SH_ALGOIDX_ECG 0x03
seyhmus.cacina 0:b259fd1a88f5 29 #define SH_ALGOIDX_BPT 0x04
seyhmus.cacina 0:b259fd1a88f5 30 #define SH_ALGOIDX_WSPO2 0x05
seyhmus.cacina 0:b259fd1a88f5 31 #define SH_NUM_CURRENT_ALGOS 6
seyhmus.cacina 0:b259fd1a88f5 32
seyhmus.cacina 0:b259fd1a88f5 33 #define PADDING_BYTE (0xEE)
seyhmus.cacina 0:b259fd1a88f5 34 #define DATA_BYTE (0xED)
seyhmus.cacina 0:b259fd1a88f5 35
seyhmus.cacina 0:b259fd1a88f5 36
seyhmus.cacina 0:b259fd1a88f5 37 #define SS_I2C_8BIT_SLAVE_ADDR 0xAA
seyhmus.cacina 0:b259fd1a88f5 38 #define SS_DEFAULT_CMD_SLEEP_MS 2
seyhmus.cacina 0:b259fd1a88f5 39 #define SS_DUMP_REG_SLEEP_MS 100
seyhmus.cacina 0:b259fd1a88f5 40 #define SS_ENABLE_SENSOR_SLEEP_MS 20
seyhmus.cacina 0:b259fd1a88f5 41 #define SS_BOOTLOADER_ERASE_DELAY 1000
seyhmus.cacina 0:b259fd1a88f5 42
seyhmus.cacina 0:b259fd1a88f5 43 #define SH_INPUT_DATA_DIRECT_SENSOR 0x00
seyhmus.cacina 0:b259fd1a88f5 44 #define SH_INPUT_DATA_FROM_HOST 0x01
seyhmus.cacina 0:b259fd1a88f5 45
seyhmus.cacina 0:b259fd1a88f5 46 #define SS_FAM_R_STATUS 0x00
seyhmus.cacina 0:b259fd1a88f5 47 #define SS_CMDIDX_STATUS 0x00
seyhmus.cacina 0:b259fd1a88f5 48 #define SS_SHIFT_STATUS_ERR 0
seyhmus.cacina 0:b259fd1a88f5 49 #define SS_MASK_STATUS_ERR (0x07 << SS_SHIFT_STATUS_ERR)
seyhmus.cacina 0:b259fd1a88f5 50 #define SS_SHIFT_STATUS_DATA_RDY 3
seyhmus.cacina 0:b259fd1a88f5 51 #define SS_MASK_STATUS_DATA_RDY (1 << SS_SHIFT_STATUS_DATA_RDY)
seyhmus.cacina 0:b259fd1a88f5 52 #define SS_SHIFT_STATUS_FIFO_OUT_OVR 4
seyhmus.cacina 0:b259fd1a88f5 53 #define SS_MASK_STATUS_FIFO_OUT_OVR (1 << SS_SHIFT_STATUS_FIFO_OUT_OVR)
seyhmus.cacina 0:b259fd1a88f5 54 #define SS_SHIFT_STATUS_FIFO_IN_OVR 5
seyhmus.cacina 0:b259fd1a88f5 55 #define SS_MASK_STATUS_FIFO_IN_OVR (1 << SS_SHIFT_STATUS_FIFO_IN_OVR)
seyhmus.cacina 0:b259fd1a88f5 56
seyhmus.cacina 0:b259fd1a88f5 57 #define SS_SHIFT_STATUS_LOG_OVR 6
seyhmus.cacina 0:b259fd1a88f5 58 #define SS_MASK_STATUS_LOG_OVR (1 << SS_SHIFT_STATUS_LOG_OVR)
seyhmus.cacina 0:b259fd1a88f5 59
seyhmus.cacina 0:b259fd1a88f5 60 #define SS_SHIFT_STATUS_LOG_RDY 7
seyhmus.cacina 0:b259fd1a88f5 61 #define SS_MASK_STATUS_LOG_RDY (1 << SS_SHIFT_STATUS_LOG_RDY)
seyhmus.cacina 0:b259fd1a88f5 62
seyhmus.cacina 0:b259fd1a88f5 63
seyhmus.cacina 0:b259fd1a88f5 64
seyhmus.cacina 0:b259fd1a88f5 65 #define SS_FAM_W_MODE 0x01
seyhmus.cacina 0:b259fd1a88f5 66 #define SS_FAM_R_MODE 0x02
seyhmus.cacina 0:b259fd1a88f5 67 #define SS_CMDIDX_MODE 0x00
seyhmus.cacina 0:b259fd1a88f5 68 #define SS_SHIFT_MODE_SHDN 0
seyhmus.cacina 0:b259fd1a88f5 69 #define SS_MASK_MODE_SHDN (1 << SS_SHIFT_MODE_SHDN)
seyhmus.cacina 0:b259fd1a88f5 70 #define SS_SHIFT_MODE_RESET 1
seyhmus.cacina 0:b259fd1a88f5 71 #define SS_MASK_MODE_RESET (1 << SS_SHIFT_MODE_RESET)
seyhmus.cacina 0:b259fd1a88f5 72 #define SS_SHIFT_MODE_FIFORESET 2
seyhmus.cacina 0:b259fd1a88f5 73 #define SS_MASK_MODE_FIFORESET (1 << SS_SHIFT_MODE_FIFORESET)
seyhmus.cacina 0:b259fd1a88f5 74 #define SS_SHIFT_MODE_BOOTLDR 3
seyhmus.cacina 0:b259fd1a88f5 75 #define SS_MASK_MODE_BOOTLDR (1 << SS_SHIFT_MODE_BOOTLDR)
seyhmus.cacina 0:b259fd1a88f5 76
seyhmus.cacina 0:b259fd1a88f5 77 /*MYG*/
seyhmus.cacina 0:b259fd1a88f5 78 #define SH_MODE_REQUEST_RET_BYTES (2)
seyhmus.cacina 0:b259fd1a88f5 79 #define SH_MODE_REQUEST_DELAY (2)
seyhmus.cacina 0:b259fd1a88f5 80 #define SH_STATUS_REQUEST_RET_BYTES (2)
seyhmus.cacina 0:b259fd1a88f5 81 #define SH_STATUS_REQUEST_DELAY (2)
seyhmus.cacina 0:b259fd1a88f5 82
seyhmus.cacina 0:b259fd1a88f5 83
seyhmus.cacina 0:b259fd1a88f5 84
seyhmus.cacina 0:b259fd1a88f5 85 #define SS_I2C_READ 0x03
seyhmus.cacina 0:b259fd1a88f5 86
seyhmus.cacina 0:b259fd1a88f5 87 #define SS_FAM_W_COMMCHAN 0x10
seyhmus.cacina 0:b259fd1a88f5 88 #define SS_FAM_R_COMMCHAN 0x11
seyhmus.cacina 0:b259fd1a88f5 89 #define SS_CMDIDX_OUTPUTMODE 0x00
seyhmus.cacina 0:b259fd1a88f5 90 #define SS_SHIFT_OUTPUTMODE_DATATYPE 0
seyhmus.cacina 0:b259fd1a88f5 91 #define SS_MASK_OUTPUTMODE_DATATYPE (0x03 << SS_SHIFT_OUTPUTMODE_DATATYPE)
seyhmus.cacina 0:b259fd1a88f5 92 #define SS_DATATYPE_PAUSE 0
seyhmus.cacina 0:b259fd1a88f5 93 #define SS_DATATYPE_RAW 1
seyhmus.cacina 0:b259fd1a88f5 94 #define SS_DATATYPE_ALGO 2
seyhmus.cacina 0:b259fd1a88f5 95 #define SS_DATATYPE_BOTH 3
seyhmus.cacina 0:b259fd1a88f5 96 #define SS_SHIFT_OUTPUTMODE_SC_EN 2
seyhmus.cacina 0:b259fd1a88f5 97 #define SS_MASK_OUTPUTMODE_SC_EN (1 << SS_SHIFT_OUTPUTMODE_SC_EN)
seyhmus.cacina 0:b259fd1a88f5 98 #define SS_CMDIDX_FIFOAFULL 0x01
seyhmus.cacina 0:b259fd1a88f5 99
seyhmus.cacina 0:b259fd1a88f5 100 #define SS_FAM_R_OUTPUTFIFO 0x12
seyhmus.cacina 0:b259fd1a88f5 101 #define SS_CMDIDX_OUT_NUMSAMPLES 0x00
seyhmus.cacina 0:b259fd1a88f5 102 #define SS_CMDIDX_READFIFO 0x01
seyhmus.cacina 0:b259fd1a88f5 103
seyhmus.cacina 0:b259fd1a88f5 104 #define SS_FAM_R_INPUTFIFO 0x13
seyhmus.cacina 0:b259fd1a88f5 105 #define SS_CMDIDX_SAMPLE_SIZE 0x00
seyhmus.cacina 0:b259fd1a88f5 106 #define SS_CMDIDX_INPUT_FIFO_SIZE 0x01
seyhmus.cacina 0:b259fd1a88f5 107 #define SS_CMDIDX_SENSOR_FIFO_SIZE 0x02
seyhmus.cacina 0:b259fd1a88f5 108 #define SS_CMDIDX_NUM_SAMPLES_SENSOR_FIFO 0x03
seyhmus.cacina 0:b259fd1a88f5 109 #define SS_CMDIDX_NUM_SAMPLES_INPUT_FIFO 0x04
seyhmus.cacina 0:b259fd1a88f5 110
seyhmus.cacina 0:b259fd1a88f5 111 #define SS_FAM_W_INPUTFIFO 0x14
seyhmus.cacina 0:b259fd1a88f5 112 #define SS_CMDIDN_WRITEFIFO 0x00
seyhmus.cacina 0:b259fd1a88f5 113 #define SS_CMDIDX_WRITE_FIFO 0x00
seyhmus.cacina 0:b259fd1a88f5 114
seyhmus.cacina 0:b259fd1a88f5 115 #define SS_FAM_W_WRITEREG 0x40
seyhmus.cacina 0:b259fd1a88f5 116 #define SS_FAM_R_READREG 0x41
seyhmus.cacina 0:b259fd1a88f5 117 #define SS_FAM_R_REGATTRIBS 0x42
seyhmus.cacina 0:b259fd1a88f5 118 #define SS_FAM_R_DUMPREG 0x43
seyhmus.cacina 0:b259fd1a88f5 119
seyhmus.cacina 0:b259fd1a88f5 120 #define SS_FAM_W_SENSORMODE 0x44
seyhmus.cacina 0:b259fd1a88f5 121 #define SS_FAM_R_SENSORMODE 0x45
seyhmus.cacina 0:b259fd1a88f5 122
seyhmus.cacina 0:b259fd1a88f5 123 //TODO: Fill in known configuration parameters
seyhmus.cacina 0:b259fd1a88f5 124 #define SS_FAM_W_ALGOCONFIG 0x50
seyhmus.cacina 0:b259fd1a88f5 125 #define SS_FAM_R_ALGOCONFIG 0x51
seyhmus.cacina 0:b259fd1a88f5 126 #define SS_CFGIDX_AGC_TARGET 0x00
seyhmus.cacina 0:b259fd1a88f5 127 #define SS_CFGIDX_AGC_CORR_COEFF 0x01
seyhmus.cacina 0:b259fd1a88f5 128 #define SS_CFGIDX_AGC_SENSITIVITY 0x02
seyhmus.cacina 0:b259fd1a88f5 129 #define SS_CFGIDX_AGC_SMP_AVG 0x03
seyhmus.cacina 0:b259fd1a88f5 130
seyhmus.cacina 0:b259fd1a88f5 131 #define SS_CFGIDX_WHRM_SR 0x00
seyhmus.cacina 0:b259fd1a88f5 132 #define SS_CFGIDX_WHRM_MAX_HEIGHT 0x01
seyhmus.cacina 0:b259fd1a88f5 133 #define SS_CFGIDX_WHRM_MAX_WEIGHT 0x02
seyhmus.cacina 0:b259fd1a88f5 134 #define SS_CFGIDX_WHRM_MAX_AGE 0x03
seyhmus.cacina 0:b259fd1a88f5 135 #define SS_CFGIDX_WHRM_MIN_HEIGHT 0x04
seyhmus.cacina 0:b259fd1a88f5 136 #define SS_CFGIDX_WHRM_MIN_WEIGHT 0x05
seyhmus.cacina 0:b259fd1a88f5 137 #define SS_CFGIDX_WHRM_MIN_AGE 0x06
seyhmus.cacina 0:b259fd1a88f5 138 #define SS_CFGIDX_WHRM_DEF_HEIGHT 0x07
seyhmus.cacina 0:b259fd1a88f5 139 #define SS_CFGIDX_WHRM_DEF_WEIGHT 0x08
seyhmus.cacina 0:b259fd1a88f5 140 #define SS_CFGIDX_WHRM_DEF_AGE 0x09
seyhmus.cacina 0:b259fd1a88f5 141 #define SS_CFGIDX_WHRM_INIT_HR 0x0A
seyhmus.cacina 0:b259fd1a88f5 142 // additional for WHRM_AEC_SCD
seyhmus.cacina 0:b259fd1a88f5 143 #define SS_CFGIDX_WHRM_AEC_ENABLE 0x0B
seyhmus.cacina 0:b259fd1a88f5 144 #define SS_CFGIDX_WHRM_SCD_ENABLE 0x0C
seyhmus.cacina 0:b259fd1a88f5 145 #define SS_CFGIDX_WHRM_ADJ_TARGET_PD_CURRENT_PERIOD 0x0D
seyhmus.cacina 0:b259fd1a88f5 146 #define SS_CFGIDX_WHRM_SCD_DEBOUNCE_WINDOW 0x0E
seyhmus.cacina 0:b259fd1a88f5 147 #define SS_CFGIDX_WHRM_MOTION_MAG_THRESHOLD 0x0F
seyhmus.cacina 0:b259fd1a88f5 148 #define SS_CFGIDX_WHRM_MIN_PD_CURRENT 0x10
seyhmus.cacina 0:b259fd1a88f5 149 #define SS_CFGIDX_WHRM_PD_CONFIG 0x11
seyhmus.cacina 0:b259fd1a88f5 150
seyhmus.cacina 0:b259fd1a88f5 151 // config for WSPO2
seyhmus.cacina 0:b259fd1a88f5 152 #define SS_CFGIDX_WSPO2_CAL 0x00
seyhmus.cacina 0:b259fd1a88f5 153 #define SS_CFGIDX_WSPO2_SR 0x01
seyhmus.cacina 0:b259fd1a88f5 154 #define SS_CFGIDX_WSPO2_ALGO_MODE 0x02
seyhmus.cacina 0:b259fd1a88f5 155 #define SS_CFGIDX_WSPO2_AGC_MODE 0x03
seyhmus.cacina 0:b259fd1a88f5 156 #define SS_CFGIDX_WSPO2_MOTION_DET 0x04
seyhmus.cacina 0:b259fd1a88f5 157 #define SS_CFGIDX_WSPO2_MOTION_PERIOD 0x05
seyhmus.cacina 0:b259fd1a88f5 158 #define SS_CFGIDX_WSPO2_MOTION_THRESHOLD 0x06
seyhmus.cacina 0:b259fd1a88f5 159 #define SS_CFGIDX_WSPO2_AGC_TIMEOUT 0x07
seyhmus.cacina 0:b259fd1a88f5 160 #define SS_CFGIDX_WSPO2_TIMEOUT 0x08
seyhmus.cacina 0:b259fd1a88f5 161 #define SS_CFGIDX_WSPO2_PD_CONFIG 0x09
seyhmus.cacina 0:b259fd1a88f5 162
seyhmus.cacina 0:b259fd1a88f5 163 #define SS_CFGIDX_BP_USE_MED 0x00
seyhmus.cacina 0:b259fd1a88f5 164 #define SS_CFGIDX_BP_SYS_BP_CAL 0x01
seyhmus.cacina 0:b259fd1a88f5 165 #define SS_CFGIDX_BP_DIA_BP_CAL 0x02
seyhmus.cacina 0:b259fd1a88f5 166 #define SS_CFGIDX_BP_CAL_DATA 0x03
seyhmus.cacina 0:b259fd1a88f5 167 #define SS_CFGIDX_BP_EST_DATE 0x04
seyhmus.cacina 0:b259fd1a88f5 168 #define SS_CFGIDX_BP_EST_NONREST 0x05
seyhmus.cacina 0:b259fd1a88f5 169
seyhmus.cacina 0:b259fd1a88f5 170 #define SS_FAM_W_ALGOMODE 0x52
seyhmus.cacina 0:b259fd1a88f5 171 #define SS_FAM_R_ALGOMODE 0x53
seyhmus.cacina 0:b259fd1a88f5 172
seyhmus.cacina 0:b259fd1a88f5 173 #define SS_FAM_W_EXTERNSENSORMODE 0x60
seyhmus.cacina 0:b259fd1a88f5 174 #define SS_FAM_R_EXTERNSENSORMODE 0x61
seyhmus.cacina 0:b259fd1a88f5 175
seyhmus.cacina 0:b259fd1a88f5 176 #define SS_FAM_R_SELFTEST 0x70
seyhmus.cacina 0:b259fd1a88f5 177
seyhmus.cacina 0:b259fd1a88f5 178 #define SS_FAM_W_BOOTLOADER 0x80
seyhmus.cacina 0:b259fd1a88f5 179 #define SS_CMDIDX_SETIV 0x00
seyhmus.cacina 0:b259fd1a88f5 180 #define SS_CMDIDX_SETAUTH 0x01
seyhmus.cacina 0:b259fd1a88f5 181 #define SS_CMDIDX_SETNUMPAGES 0x02
seyhmus.cacina 0:b259fd1a88f5 182 #define SS_CMDIDX_ERASE 0x03
seyhmus.cacina 0:b259fd1a88f5 183 #define SS_CMDIDX_SENDPAGE 0x04
seyhmus.cacina 0:b259fd1a88f5 184 #define SS_CMDIDX_ERASE_PAGE 0x05
seyhmus.cacina 0:b259fd1a88f5 185 #define SS_FAM_R_BOOTLOADER 0x81
seyhmus.cacina 0:b259fd1a88f5 186 #define SS_CMDIDX_BOOTFWVERSION 0x00
seyhmus.cacina 0:b259fd1a88f5 187 #define SS_CMDIDX_PAGESIZE 0x01
seyhmus.cacina 0:b259fd1a88f5 188
seyhmus.cacina 0:b259fd1a88f5 189 #define SS_FAM_W_BOOTLOADER_CFG 0x82
seyhmus.cacina 0:b259fd1a88f5 190 #define SS_FAM_R_BOOTLOADER_CFG 0x83
seyhmus.cacina 0:b259fd1a88f5 191 #define SS_CMDIDX_BL_SAVE 0x00
seyhmus.cacina 0:b259fd1a88f5 192 #define SS_CMDIDX_BL_ENTRY 0x01
seyhmus.cacina 0:b259fd1a88f5 193 #define SS_BL_CFG_ENTER_BL_MODE 0x00
seyhmus.cacina 0:b259fd1a88f5 194 #define SS_BL_CFG_EBL_PIN 0x01
seyhmus.cacina 0:b259fd1a88f5 195 #define SS_BL_CFG_EBL_POL 0x02
seyhmus.cacina 0:b259fd1a88f5 196 #define SS_CMDIDX_BL_EXIT 0x02
seyhmus.cacina 0:b259fd1a88f5 197 #define SS_BL_CFG_EXIT_BL_MODE 0x00
seyhmus.cacina 0:b259fd1a88f5 198 #define SS_BL_CFG_TIMEOUT 0x01
seyhmus.cacina 0:b259fd1a88f5 199
seyhmus.cacina 0:b259fd1a88f5 200 /* Enable logging/debugging */
seyhmus.cacina 0:b259fd1a88f5 201 #define SS_FAM_R_LOG 0x90
seyhmus.cacina 0:b259fd1a88f5 202 #define SS_CMDIDX_R_LOG_DATA 0x00
seyhmus.cacina 0:b259fd1a88f5 203 #define SS_CMDIDX_R_LOG_LEN 0x01
seyhmus.cacina 0:b259fd1a88f5 204
seyhmus.cacina 0:b259fd1a88f5 205 #define SS_CMDIDX_R_LOG_LEVEL 0x02
seyhmus.cacina 0:b259fd1a88f5 206 #define SS_LOG_DISABLE 0x00
seyhmus.cacina 0:b259fd1a88f5 207 #define SS_LOG_CRITICAL 0x01
seyhmus.cacina 0:b259fd1a88f5 208 #define SS_LOG_ERROR 0x02
seyhmus.cacina 0:b259fd1a88f5 209 #define SS_LOG_INFO 0x04
seyhmus.cacina 0:b259fd1a88f5 210 #define SS_LOG_DEBUG 0x08
seyhmus.cacina 0:b259fd1a88f5 211
seyhmus.cacina 0:b259fd1a88f5 212 #define SS_FAM_W_LOG_CFG 0x91
seyhmus.cacina 0:b259fd1a88f5 213 #define SS_CMDIDX_LOG_GET_LEVEL 0x00
seyhmus.cacina 0:b259fd1a88f5 214 #define SS_CMDIDX_LOG_SET_LEVEL 0x01
seyhmus.cacina 0:b259fd1a88f5 215
seyhmus.cacina 0:b259fd1a88f5 216 #define SS_FAM_R_IDENTITY 0xFF
seyhmus.cacina 0:b259fd1a88f5 217 #define SS_CMDIDX_PLATTYPE 0x00
seyhmus.cacina 0:b259fd1a88f5 218 #define SS_CMDIDX_PARTID 0x01
seyhmus.cacina 0:b259fd1a88f5 219 #define SS_CMDIDX_REVID 0x02
seyhmus.cacina 0:b259fd1a88f5 220 #define SS_CMDIDX_FWVERSION 0x03
seyhmus.cacina 0:b259fd1a88f5 221 #define SS_CMDIDX_AVAILSENSORS 0x04
seyhmus.cacina 0:b259fd1a88f5 222 #define SS_CMDIDX_DRIVERVER 0x05
seyhmus.cacina 0:b259fd1a88f5 223 #define SS_CMDIDX_AVAILALGOS 0x06
seyhmus.cacina 0:b259fd1a88f5 224 #define SS_CMDIDX_ALGOVER 0x07
seyhmus.cacina 0:b259fd1a88f5 225
seyhmus.cacina 0:b259fd1a88f5 226
seyhmus.cacina 0:b259fd1a88f5 227 /* Newly added ones; checko for collosion or repeats with the ones above */
seyhmus.cacina 0:b259fd1a88f5 228 #define SS_RESET_TIME 10
seyhmus.cacina 0:b259fd1a88f5 229 #define SS_STARTUP_TO_BTLDR_TIME 20
seyhmus.cacina 0:b259fd1a88f5 230 #define SS_STARTUP_TO_MAIN_APP_TIME 1000
seyhmus.cacina 0:b259fd1a88f5 231
seyhmus.cacina 0:b259fd1a88f5 232 #define SS_MAX_SUPPORTED_SENSOR_NUM 0xFE
seyhmus.cacina 0:b259fd1a88f5 233 #define SS_MAX_SUPPORTED_ALGO_NUM 0xFE
seyhmus.cacina 0:b259fd1a88f5 234
seyhmus.cacina 0:b259fd1a88f5 235 #define SS_APPPLICATION_MODE 0x00
seyhmus.cacina 0:b259fd1a88f5 236 #define SS_BOOTLOADER_MODE 0x08
seyhmus.cacina 0:b259fd1a88f5 237
seyhmus.cacina 0:b259fd1a88f5 238 typedef enum {
seyhmus.cacina 0:b259fd1a88f5 239 SS_SUCCESS =0x00,
seyhmus.cacina 0:b259fd1a88f5 240 SS_ERR_COMMAND =0x01,
seyhmus.cacina 0:b259fd1a88f5 241 SS_ERR_UNAVAILABLE =0x02,
seyhmus.cacina 0:b259fd1a88f5 242 SS_ERR_DATA_FORMAT =0x03,
seyhmus.cacina 0:b259fd1a88f5 243 SS_ERR_INPUT_VALUE =0x04,
seyhmus.cacina 0:b259fd1a88f5 244 SS_ERR_BTLDR_GENERAL =0x80,
seyhmus.cacina 0:b259fd1a88f5 245 SS_ERR_BTLDR_CHECKSUM =0x81,
seyhmus.cacina 0:b259fd1a88f5 246 SS_ERR_TRY_AGAIN =0xFE,
seyhmus.cacina 0:b259fd1a88f5 247 SS_ERR_UNKNOWN =0xFF,
seyhmus.cacina 0:b259fd1a88f5 248
seyhmus.cacina 0:b259fd1a88f5 249 } SS_STATUS;
seyhmus.cacina 0:b259fd1a88f5 250
seyhmus.cacina 0:b259fd1a88f5 251
seyhmus.cacina 0:b259fd1a88f5 252
seyhmus.cacina 0:b259fd1a88f5 253 /* ***************************************************************************************** *
seyhmus.cacina 0:b259fd1a88f5 254 * *
seyhmus.cacina 0:b259fd1a88f5 255 * SENSOR HUB COMMUNICATION INTERFACE ( Defined in MAX32664 User Guide ) API FUNCTIONS *
seyhmus.cacina 0:b259fd1a88f5 256 * *
seyhmus.cacina 0:b259fd1a88f5 257 * *
seyhmus.cacina 0:b259fd1a88f5 258 * ***************************************************************************************** */
seyhmus.cacina 0:b259fd1a88f5 259
seyhmus.cacina 0:b259fd1a88f5 260
seyhmus.cacina 0:b259fd1a88f5 261 /**
seyhmus.cacina 0:b259fd1a88f5 262 * @brief Func to write to sensor hub via sending generic command byte sequences
seyhmus.cacina 0:b259fd1a88f5 263 *
seyhmus.cacina 0:b259fd1a88f5 264 * @param[in] tx_buf - command byte sequence
seyhmus.cacina 0:b259fd1a88f5 265 * @param[in] tx_len - command byte sequence length in bytes
seyhmus.cacina 0:b259fd1a88f5 266 * @param[in] sleep_ms - time to wait for sensor hub to report statuss
seyhmus.cacina 0:b259fd1a88f5 267 *
seyhmus.cacina 0:b259fd1a88f5 268 * @return 1 byte status: 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 269 */
seyhmus.cacina 0:b259fd1a88f5 270 int sh_write_cmd( uint8_t *tx_buf,
seyhmus.cacina 0:b259fd1a88f5 271 int tx_len,
seyhmus.cacina 0:b259fd1a88f5 272 int sleep_ms );
seyhmus.cacina 0:b259fd1a88f5 273
seyhmus.cacina 0:b259fd1a88f5 274
seyhmus.cacina 0:b259fd1a88f5 275 /**
seyhmus.cacina 0:b259fd1a88f5 276 * @brief Func to write to sensor hub via sending generic command byte sequences and data bytes
seyhmus.cacina 0:b259fd1a88f5 277 *
seyhmus.cacina 0:b259fd1a88f5 278 * @param[in] cmd_bytes - command byte sequence
seyhmus.cacina 0:b259fd1a88f5 279 * @param[in] cmd_bytes_len - command byte sequence length in bytes
seyhmus.cacina 0:b259fd1a88f5 280 * @param[in] data - data byte array to be sent following cmd bytes
seyhmus.cacina 0:b259fd1a88f5 281 * @param[in] data_len - data array size in bytes
seyhmus.cacina 0:b259fd1a88f5 282 * @param[in] cmd_delay_ms - time to wait for sensor hub to report status
seyhmus.cacina 0:b259fd1a88f5 283 *
seyhmus.cacina 0:b259fd1a88f5 284 * @return 1 byte status: 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 285 */
seyhmus.cacina 0:b259fd1a88f5 286 int sh_write_cmd_with_data(uint8_t *cmd_bytes,
seyhmus.cacina 0:b259fd1a88f5 287 int cmd_bytes_len,
seyhmus.cacina 0:b259fd1a88f5 288 uint8_t *data,
seyhmus.cacina 0:b259fd1a88f5 289 int data_len,
seyhmus.cacina 0:b259fd1a88f5 290 int cmd_delay_ms);
seyhmus.cacina 0:b259fd1a88f5 291
seyhmus.cacina 0:b259fd1a88f5 292
seyhmus.cacina 0:b259fd1a88f5 293 /**
seyhmus.cacina 0:b259fd1a88f5 294 * @brief Func to read from sensor hub via sending generic command byte sequences
seyhmus.cacina 0:b259fd1a88f5 295 *
seyhmus.cacina 0:b259fd1a88f5 296 * @param[in] cmd_bytes - command byte sequence
seyhmus.cacina 0:b259fd1a88f5 297 * @param[in] cmd_bytes_len - command byte sequence length in bytes
seyhmus.cacina 0:b259fd1a88f5 298 * @param[in] data - data byte array to be sent following cmd bytes
seyhmus.cacina 0:b259fd1a88f5 299 * @param[in] data_len - data array size in bytes
seyhmus.cacina 0:b259fd1a88f5 300 * @param[out] rxbuf - byte buffer to store incoming data (including status byte)
seyhmus.cacina 0:b259fd1a88f5 301 * @param[in] rxbuf_sz - incoming data buffer size in bytes ( to prevent overflow)
seyhmus.cacina 0:b259fd1a88f5 302 * @param[in] cmd_delay_ms - time to wait for sensor hub to report status
seyhmus.cacina 0:b259fd1a88f5 303 *
seyhmus.cacina 0:b259fd1a88f5 304 * @return 1 byte status: 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 305 */
seyhmus.cacina 0:b259fd1a88f5 306 int sh_read_cmd( uint8_t *cmd_bytes,
seyhmus.cacina 0:b259fd1a88f5 307 int cmd_bytes_len,
seyhmus.cacina 0:b259fd1a88f5 308 uint8_t *data,
seyhmus.cacina 0:b259fd1a88f5 309 int data_len,
seyhmus.cacina 0:b259fd1a88f5 310 uint8_t *rxbuf,
seyhmus.cacina 0:b259fd1a88f5 311 int rxbuf_sz,
seyhmus.cacina 0:b259fd1a88f5 312 int sleep_ms );
seyhmus.cacina 0:b259fd1a88f5 313
seyhmus.cacina 0:b259fd1a88f5 314
seyhmus.cacina 0:b259fd1a88f5 315 /**
seyhmus.cacina 0:b259fd1a88f5 316 * @brief func to read sensor hub status
seyhmus.cacina 0:b259fd1a88f5 317 * @param[out] hubStatus - pointer to output byte sesnor hub status will be written
seyhmus.cacina 0:b259fd1a88f5 318 * @details ensor hub status byte: [2:0] -> 0 : no Err , 1: comm failure with sensor
seyhmus.cacina 0:b259fd1a88f5 319 * [3] -> 0 : FIFO below threshold; 1: FIFO filled to threshold or above.
seyhmus.cacina 0:b259fd1a88f5 320 * [4] -> 0 : No FIFO overflow; 1: Sensor Hub Output FIFO overflowed, data lost.
seyhmus.cacina 0:b259fd1a88f5 321 * [5] -> 0 : No FIFO overflow; 1: Sensor Hub Input FIFO overflowed, data lost.
seyhmus.cacina 0:b259fd1a88f5 322 * [6] -> 0 : Sensor Hub ready; 1: Sensor Hub is busy processing.
seyhmus.cacina 0:b259fd1a88f5 323 * [6] -> reserved.
seyhmus.cacina 0:b259fd1a88f5 324 *
seyhmus.cacina 0:b259fd1a88f5 325 * @return 1 byte status: 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 326 */
seyhmus.cacina 0:b259fd1a88f5 327 int sh_get_sensorhub_status(uint8_t *hubStatus);
seyhmus.cacina 0:b259fd1a88f5 328
seyhmus.cacina 0:b259fd1a88f5 329
seyhmus.cacina 0:b259fd1a88f5 330 /**
seyhmus.cacina 0:b259fd1a88f5 331 * @brief func to read sensor operating mode
seyhmus.cacina 0:b259fd1a88f5 332 *
seyhmus.cacina 0:b259fd1a88f5 333 * @param[in] hubMode - pointer to output byte mode will be written
seyhmus.cacina 0:b259fd1a88f5 334 * @details 0x00: application operating mode
seyhmus.cacina 0:b259fd1a88f5 335 * 0x08: bootloader operating mode
seyhmus.cacina 0:b259fd1a88f5 336 *
seyhmus.cacina 0:b259fd1a88f5 337 * @return 1 byte status: 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 338 */
seyhmus.cacina 0:b259fd1a88f5 339 int sh_get_sensorhub_operating_mode(uint8_t *hubMode);
seyhmus.cacina 0:b259fd1a88f5 340
seyhmus.cacina 0:b259fd1a88f5 341
seyhmus.cacina 0:b259fd1a88f5 342 /**
seyhmus.cacina 0:b259fd1a88f5 343 * @brief func to set sensor hub operating mode
seyhmus.cacina 0:b259fd1a88f5 344 *
seyhmus.cacina 0:b259fd1a88f5 345 * @param[out] hubMode - pointer to output byte mode will be written
seyhmus.cacina 0:b259fd1a88f5 346 * @details 0x00: application operating mode
seyhmus.cacina 0:b259fd1a88f5 347 * 0x02: soft reset
seyhmus.cacina 0:b259fd1a88f5 348 * 0x08: bootloader operating mode
seyhmus.cacina 0:b259fd1a88f5 349 *
seyhmus.cacina 0:b259fd1a88f5 350 * @return 1 byte status: 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 351 */
seyhmus.cacina 0:b259fd1a88f5 352 int sh_set_sensorhub_operating_mode(uint8_t hubMode);
seyhmus.cacina 0:b259fd1a88f5 353
seyhmus.cacina 0:b259fd1a88f5 354
seyhmus.cacina 0:b259fd1a88f5 355 /**
seyhmus.cacina 0:b259fd1a88f5 356 * @brief func to set sensorhub data output mode
seyhmus.cacina 0:b259fd1a88f5 357 *
seyhmus.cacina 0:b259fd1a88f5 358 * @param[in] data_type : 1 byte output format
seyhmus.cacina 0:b259fd1a88f5 359 * @details outpur format 0x00 : no data
seyhmus.cacina 0:b259fd1a88f5 360 * 0x01 : sensor data SS_DATATYPE_RAW
seyhmus.cacina 0:b259fd1a88f5 361 * 0x02 : algo data SS_DATATYPE_ALGO
seyhmus.cacina 0:b259fd1a88f5 362 * 0x03 : algo+sensor SS_DATATYPE_BOTH
seyhmus.cacina 0:b259fd1a88f5 363 *
seyhmus.cacina 0:b259fd1a88f5 364 * @return 1 byte status: 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 365 */
seyhmus.cacina 0:b259fd1a88f5 366 int sh_set_data_type(int data_type, bool sc_en);
seyhmus.cacina 0:b259fd1a88f5 367
seyhmus.cacina 0:b259fd1a88f5 368
seyhmus.cacina 0:b259fd1a88f5 369 /**
seyhmus.cacina 0:b259fd1a88f5 370 * @brief func to get sensorhub data output mode
seyhmus.cacina 0:b259fd1a88f5 371 *
seyhmus.cacina 0:b259fd1a88f5 372 * @param[out] data_type - pointer to byte, output format will be written to.
seyhmus.cacina 0:b259fd1a88f5 373 *
seyhmus.cacina 0:b259fd1a88f5 374 * @param[out] sc_en - pointer to boolean, sample count enable/disable status format will be written to.
seyhmus.cacina 0:b259fd1a88f5 375 * If true, SmartSensor is prepending data with 1 byte sample count.
seyhmus.cacina 0:b259fd1a88f5 376 *
seyhmus.cacina 0:b259fd1a88f5 377 * @details output format 0x00 : only algorithm data
seyhmus.cacina 0:b259fd1a88f5 378 * 0x01 : only raw sensor data
seyhmus.cacina 0:b259fd1a88f5 379 * 0x02 : algo + raw sensor data
seyhmus.cacina 0:b259fd1a88f5 380 * 0x03 : no data
seyhmus.cacina 0:b259fd1a88f5 381 *
seyhmus.cacina 0:b259fd1a88f5 382 * @return 1 byte status: 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 383 */
seyhmus.cacina 0:b259fd1a88f5 384 int sh_get_data_type(int *data_type, bool *sc_en);
seyhmus.cacina 0:b259fd1a88f5 385
seyhmus.cacina 0:b259fd1a88f5 386
seyhmus.cacina 0:b259fd1a88f5 387 /**
seyhmus.cacina 0:b259fd1a88f5 388 * @brief func to set the number of samples for the SmartSensor to collect
seyhmus.cacina 0:b259fd1a88f5 389 * before issuing an mfio event reporting interrupt
seyhmus.cacina 0:b259fd1a88f5 390 *
seyhmus.cacina 0:b259fd1a88f5 391 * @param[in] thresh - Number of samples (1-255) to collect before interrupt
seyhmus.cacina 0:b259fd1a88f5 392 *
seyhmus.cacina 0:b259fd1a88f5 393 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 394 */
seyhmus.cacina 0:b259fd1a88f5 395 int sh_set_fifo_thresh( int threshold );
seyhmus.cacina 0:b259fd1a88f5 396
seyhmus.cacina 0:b259fd1a88f5 397
seyhmus.cacina 0:b259fd1a88f5 398 /**
seyhmus.cacina 0:b259fd1a88f5 399 * @brief func to get the number of samples the SmartSensor will collect
seyhmus.cacina 0:b259fd1a88f5 400 * before issuing an mfio event reporting interrupt
seyhmus.cacina 0:b259fd1a88f5 401 *
seyhmus.cacina 0:b259fd1a88f5 402 * @param[out] thresh - Number of samples (1-255) collected before interrupt
seyhmus.cacina 0:b259fd1a88f5 403 *
seyhmus.cacina 0:b259fd1a88f5 404 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 405 */
seyhmus.cacina 0:b259fd1a88f5 406 int sh_get_fifo_thresh(int *thresh);
seyhmus.cacina 0:b259fd1a88f5 407
seyhmus.cacina 0:b259fd1a88f5 408
seyhmus.cacina 0:b259fd1a88f5 409 /**
seyhmus.cacina 0:b259fd1a88f5 410 * @brief func to check that the SmartSensor is connected
seyhmus.cacina 0:b259fd1a88f5 411 *
seyhmus.cacina 0:b259fd1a88f5 412 * @return 1 byte connection status 0x00: on connection
seyhmus.cacina 0:b259fd1a88f5 413 */
seyhmus.cacina 0:b259fd1a88f5 414 int sh_ss_comm_check(void);
seyhmus.cacina 0:b259fd1a88f5 415
seyhmus.cacina 0:b259fd1a88f5 416
seyhmus.cacina 0:b259fd1a88f5 417 /**
seyhmus.cacina 0:b259fd1a88f5 418 * @brief func to get the number of available samples in SmartSensor output FIFO
seyhmus.cacina 0:b259fd1a88f5 419 *
seyhmus.cacina 0:b259fd1a88f5 420 * @param[out] numSamples - number of data struct samples (1-255)
seyhmus.cacina 0:b259fd1a88f5 421 *
seyhmus.cacina 0:b259fd1a88f5 422 * @return 1 byte status: 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 423 */
seyhmus.cacina 0:b259fd1a88f5 424 int sh_num_avail_samples(int *numSamples);
seyhmus.cacina 0:b259fd1a88f5 425
seyhmus.cacina 0:b259fd1a88f5 426
seyhmus.cacina 0:b259fd1a88f5 427 /**
seyhmus.cacina 0:b259fd1a88f5 428 * @brief func to pull samples from SmartSensor output FIFO
seyhmus.cacina 0:b259fd1a88f5 429 *
seyhmus.cacina 0:b259fd1a88f5 430 * @param[in] numSamples - number of data struct samples to be pulled
seyhmus.cacina 0:b259fd1a88f5 431 * @param[in] sampleSize - size of cumulative data sample struct (based on enabled sesnors+algorithms) in bytes
seyhmus.cacina 0:b259fd1a88f5 432 * @param[out] databuf - buffer samples be written
seyhmus.cacina 0:b259fd1a88f5 433 * @param[in] databufSize - size of provided buffer size samples to be written
seyhmus.cacina 0:b259fd1a88f5 434 *
seyhmus.cacina 0:b259fd1a88f5 435 * @return 1 byte status: 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 436 */
seyhmus.cacina 0:b259fd1a88f5 437 int sh_read_fifo_data( int numSamples, int sampleSize, uint8_t* databuf, int databufSz);
seyhmus.cacina 0:b259fd1a88f5 438
seyhmus.cacina 0:b259fd1a88f5 439
seyhmus.cacina 0:b259fd1a88f5 440 /**
seyhmus.cacina 0:b259fd1a88f5 441 * @brief func to set register of a device onboard SmartSensor
seyhmus.cacina 0:b259fd1a88f5 442 *
seyhmus.cacina 0:b259fd1a88f5 443 * @param[in] idx - Index of device to read
seyhmus.cacina 0:b259fd1a88f5 444 * @param[in] addr - Register address
seyhmus.cacina 0:b259fd1a88f5 445 * @param[in] val - Register value
seyhmus.cacina 0:b259fd1a88f5 446 * @param[in] regSz - Size of sensor device register in bytes
seyhmus.cacina 0:b259fd1a88f5 447 *
seyhmus.cacina 0:b259fd1a88f5 448 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 449 */
seyhmus.cacina 0:b259fd1a88f5 450 int sh_set_reg(int idx, uint8_t addr, uint32_t val, int regSz);
seyhmus.cacina 0:b259fd1a88f5 451
seyhmus.cacina 0:b259fd1a88f5 452
seyhmus.cacina 0:b259fd1a88f5 453 /**
seyhmus.cacina 0:b259fd1a88f5 454 * @brief func to read register from a device onboard SmartSensor
seyhmus.cacina 0:b259fd1a88f5 455 *
seyhmus.cacina 0:b259fd1a88f5 456 * @param[in] idx - Index of device to read
seyhmus.cacina 0:b259fd1a88f5 457 * @param[in] addr - Register address
seyhmus.cacina 0:b259fd1a88f5 458 * @param[out] val - Register value
seyhmus.cacina 0:b259fd1a88f5 459 *
seyhmus.cacina 0:b259fd1a88f5 460 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 461 */
seyhmus.cacina 0:b259fd1a88f5 462 int sh_get_reg(int idx, uint8_t addr, uint32_t *val);
seyhmus.cacina 0:b259fd1a88f5 463
seyhmus.cacina 0:b259fd1a88f5 464
seyhmus.cacina 0:b259fd1a88f5 465 // depricated: int sh_sensor_enable( int idx , int sensorSampleSz);
seyhmus.cacina 0:b259fd1a88f5 466 /**
seyhmus.cacina 0:b259fd1a88f5 467 * @brief func to enable a sensor device onboard SmartSensor
seyhmus.cacina 0:b259fd1a88f5 468 *
seyhmus.cacina 0:b259fd1a88f5 469 * @param[in] idx - index of sensor device( i.e max8614x) to enable
seyhmus.cacina 0:b259fd1a88f5 470 * @param[in] sensorSampleSz - sample size of sensor device( i.e max8614x) to enable
seyhmus.cacina 0:b259fd1a88f5 471 * @param[in] ext_mode - enable extermal data input to Sensot Hub, ie accelerometer data for WHRM+WSPo2
seyhmus.cacina 0:b259fd1a88f5 472 *
seyhmus.cacina 0:b259fd1a88f5 473 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 474 */
seyhmus.cacina 0:b259fd1a88f5 475 int sh_sensor_enable( int idx , int sensorSampleSz , uint8_t ext_mode );
seyhmus.cacina 0:b259fd1a88f5 476
seyhmus.cacina 0:b259fd1a88f5 477
seyhmus.cacina 0:b259fd1a88f5 478 /**
seyhmus.cacina 0:b259fd1a88f5 479 * @brief func to disable a device on the SmartSensor
seyhmus.cacina 0:b259fd1a88f5 480 *
seyhmus.cacina 0:b259fd1a88f5 481 * @param[in] idx - Index of device
seyhmus.cacina 0:b259fd1a88f5 482 *
seyhmus.cacina 0:b259fd1a88f5 483 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 484 */
seyhmus.cacina 0:b259fd1a88f5 485 int sh_sensor_disable( int idx );
seyhmus.cacina 0:b259fd1a88f5 486
seyhmus.cacina 0:b259fd1a88f5 487
seyhmus.cacina 0:b259fd1a88f5 488 /**
seyhmus.cacina 0:b259fd1a88f5 489 * @brief func to get the total number of samples the input FIFO can hold
seyhmus.cacina 0:b259fd1a88f5 490 *
seyhmus.cacina 0:b259fd1a88f5 491 * @param[in] fifo_size - intger input FIFO capacity will be written to.
seyhmus.cacina 0:b259fd1a88f5 492 *
seyhmus.cacina 0:b259fd1a88f5 493 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 494 */
seyhmus.cacina 0:b259fd1a88f5 495 int sh_get_input_fifo_size(int *fifo_size);
seyhmus.cacina 0:b259fd1a88f5 496
seyhmus.cacina 0:b259fd1a88f5 497
seyhmus.cacina 0:b259fd1a88f5 498 /**
seyhmus.cacina 0:b259fd1a88f5 499 * @brief func to send ass external sensor data (accelerometer) to sensor hub's input FIFO
seyhmus.cacina 0:b259fd1a88f5 500 *
seyhmus.cacina 0:b259fd1a88f5 501 * @param[in] tx_buf - host sample data to be send to sensor hub input FIFO
seyhmus.cacina 0:b259fd1a88f5 502 * @param[in] tx_buf_sz - number of bytes of tx_buf
seyhmus.cacina 0:b259fd1a88f5 503 * @param[out] nb_written - number of samples succesfully written to sensor hub's input FIFO
seyhmus.cacina 0:b259fd1a88f5 504 *
seyhmus.cacina 0:b259fd1a88f5 505 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 506 */
seyhmus.cacina 0:b259fd1a88f5 507 int sh_feed_to_input_fifo(uint8_t *tx_buf, int tx_buf_sz, int *nb_written);
seyhmus.cacina 0:b259fd1a88f5 508
seyhmus.cacina 0:b259fd1a88f5 509
seyhmus.cacina 0:b259fd1a88f5 510 /**
seyhmus.cacina 0:b259fd1a88f5 511 * @brief func to get the total number of bytes in the sensor hub's input FIFO
seyhmus.cacina 0:b259fd1a88f5 512 *
seyhmus.cacina 0:b259fd1a88f5 513 * @param[in] fifo_size - total number of sample bytes available in input FIFO
seyhmus.cacina 0:b259fd1a88f5 514 *
seyhmus.cacina 0:b259fd1a88f5 515 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 516 */
seyhmus.cacina 0:b259fd1a88f5 517 int sh_get_num_bytes_in_input_fifo(int *fifo_size);
seyhmus.cacina 0:b259fd1a88f5 518
seyhmus.cacina 0:b259fd1a88f5 519
seyhmus.cacina 0:b259fd1a88f5 520 /**
seyhmus.cacina 0:b259fd1a88f5 521 * @brief func to enable an algorithm on SmartSensor
seyhmus.cacina 0:b259fd1a88f5 522 *
seyhmus.cacina 0:b259fd1a88f5 523 * @param[in] idx - index of algorithm to enable
seyhmus.cacina 0:b259fd1a88f5 524 * @param[in] sensorSampleSz - sample size of algorithm to enable
seyhmus.cacina 0:b259fd1a88f5 525 *
seyhmus.cacina 0:b259fd1a88f5 526 * @details idx - 0x00 : AGC
seyhmus.cacina 0:b259fd1a88f5 527 * 0x01 : AEC
seyhmus.cacina 0:b259fd1a88f5 528 * 0x02 : WHRM/Maximfast
seyhmus.cacina 0:b259fd1a88f5 529 * 0x03 : ECG
seyhmus.cacina 0:b259fd1a88f5 530 * 0x04 : BPT
seyhmus.cacina 0:b259fd1a88f5 531 * 0x05 : SPo2
seyhmus.cacina 0:b259fd1a88f5 532 * 0x06 : HRM/Maximfast finger
seyhmus.cacina 0:b259fd1a88f5 533 *
seyhmus.cacina 0:b259fd1a88f5 534 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 535 */
seyhmus.cacina 0:b259fd1a88f5 536 int sh_enable_algo(int idx , int algoSampleSz);
seyhmus.cacina 0:b259fd1a88f5 537
seyhmus.cacina 0:b259fd1a88f5 538 /* @sh_enable_algo + mode of the algorithm:
seyhmus.cacina 0:b259fd1a88f5 539 *
seyhmus.cacina 0:b259fd1a88f5 540 *
seyhmus.cacina 0:b259fd1a88f5 541 *
seyhmus.cacina 0:b259fd1a88f5 542 * */
seyhmus.cacina 0:b259fd1a88f5 543 int sh_enable_algo_withmode(int idx, int mode, int algoSampleSz);
seyhmus.cacina 0:b259fd1a88f5 544
seyhmus.cacina 0:b259fd1a88f5 545 /**
seyhmus.cacina 0:b259fd1a88f5 546 * @brief func to disable an algorithm on the SmartSensor
seyhmus.cacina 0:b259fd1a88f5 547 *
seyhmus.cacina 0:b259fd1a88f5 548 * @param[in] idx - index of algorithm to disable
seyhmus.cacina 0:b259fd1a88f5 549 *
seyhmus.cacina 0:b259fd1a88f5 550 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 551 */
seyhmus.cacina 0:b259fd1a88f5 552 int sh_disable_algo(int idx);
seyhmus.cacina 0:b259fd1a88f5 553
seyhmus.cacina 0:b259fd1a88f5 554
seyhmus.cacina 0:b259fd1a88f5 555 /**
seyhmus.cacina 0:b259fd1a88f5 556 * @brief func to set the value of an algorithm configuration parameter
seyhmus.cacina 0:b259fd1a88f5 557 *
seyhmus.cacina 0:b259fd1a88f5 558 * @param[in] algo_idx - index of algorithm
seyhmus.cacina 0:b259fd1a88f5 559 * @param[in] cfg_idx - index of configuration parameter
seyhmus.cacina 0:b259fd1a88f5 560 * @param[in] cfg Array - byte array of configuration
seyhmus.cacina 0:b259fd1a88f5 561 * @param[in] cfg_sz - size of cfg array
seyhmus.cacina 0:b259fd1a88f5 562 *
seyhmus.cacina 0:b259fd1a88f5 563 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 564 */
seyhmus.cacina 0:b259fd1a88f5 565 int sh_set_algo_cfg(int algo_idx, int cfg_idx, uint8_t *cfg, int cfg_sz);
seyhmus.cacina 0:b259fd1a88f5 566
seyhmus.cacina 0:b259fd1a88f5 567
seyhmus.cacina 0:b259fd1a88f5 568 /**
seyhmus.cacina 0:b259fd1a88f5 569 * @brief func to get the value of an algorithm configuration parameter
seyhmus.cacina 0:b259fd1a88f5 570 *
seyhmus.cacina 0:b259fd1a88f5 571 * @param[in] algo_idx - index of algorithm
seyhmus.cacina 0:b259fd1a88f5 572 * @param[in] cfg_idx - index of configuration parameter
seyhmus.cacina 0:b259fd1a88f5 573 * @param[out] cfg - array of configuration bytes to be filled in
seyhmus.cacina 0:b259fd1a88f5 574 * @param[in] cfg_sz - number of configuration parameter bytes to be read
seyhmus.cacina 0:b259fd1a88f5 575 *
seyhmus.cacina 0:b259fd1a88f5 576 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 577 */
seyhmus.cacina 0:b259fd1a88f5 578 int sh_get_algo_cfg(int algo_idx, int cfg_idx, uint8_t *cfg, int cfg_sz);
seyhmus.cacina 0:b259fd1a88f5 579
seyhmus.cacina 0:b259fd1a88f5 580 /**
seyhmus.cacina 0:b259fd1a88f5 581 * @brief func to pull sensor, algo data sample bytes from sensor hub. outpur buffer, Content of the buffer depends on
seyhmus.cacina 0:b259fd1a88f5 582 * enabled sensors, algorithms and their sample sizes.
seyhmus.cacina 0:b259fd1a88f5 583 *
seyhmus.cacina 0:b259fd1a88f5 584 * @param[out] databuf - byte buffer to hold pulled samples
seyhmus.cacina 0:b259fd1a88f5 585 * @param[in] databufLen - size of provided databuf in bytes
seyhmus.cacina 0:b259fd1a88f5 586 * @param[out] nSamplesRea - number of pulled samples in databuf
seyhmus.cacina 0:b259fd1a88f5 587 *
seyhmus.cacina 0:b259fd1a88f5 588 * @return N/A
seyhmus.cacina 0:b259fd1a88f5 589 */
seyhmus.cacina 0:b259fd1a88f5 590 //void sh_ss_execute_once( uint8_t *databuf , int databufLen , int *nSamplesRead);
seyhmus.cacina 0:b259fd1a88f5 591 int sh_ss_execute_once( uint8_t *databuf , int databufLen , int *nSamplesRead);
seyhmus.cacina 0:b259fd1a88f5 592
seyhmus.cacina 0:b259fd1a88f5 593
seyhmus.cacina 0:b259fd1a88f5 594
seyhmus.cacina 0:b259fd1a88f5 595
seyhmus.cacina 0:b259fd1a88f5 596
seyhmus.cacina 0:b259fd1a88f5 597
seyhmus.cacina 0:b259fd1a88f5 598 /* ***************************************************************************************** *
seyhmus.cacina 0:b259fd1a88f5 599 * *
seyhmus.cacina 0:b259fd1a88f5 600 * PHASE2 ADDITIONS *
seyhmus.cacina 0:b259fd1a88f5 601 * *
seyhmus.cacina 0:b259fd1a88f5 602 * ***************************************************************************************** */
seyhmus.cacina 0:b259fd1a88f5 603
seyhmus.cacina 0:b259fd1a88f5 604
seyhmus.cacina 0:b259fd1a88f5 605 /**
seyhmus.cacina 0:b259fd1a88f5 606 * @brief run the self test commands
seyhmus.cacina 0:b259fd1a88f5 607 * param[in] idx - the id of the sensor for the self test
seyhmus.cacina 0:b259fd1a88f5 608 * param[in] result - self-test response
seyhmus.cacina 0:b259fd1a88f5 609 * param[in] sleep_ms - duration of wait for read command
seyhmus.cacina 0:b259fd1a88f5 610 *
seyhmus.cacina 0:b259fd1a88f5 611 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 612 */
seyhmus.cacina 0:b259fd1a88f5 613 SS_STATUS self_test(int idx, uint8_t *result, int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
seyhmus.cacina 0:b259fd1a88f5 614 int sh_self_test(int idx, uint8_t *result, int sleep_ms);
seyhmus.cacina 0:b259fd1a88f5 615
seyhmus.cacina 0:b259fd1a88f5 616
seyhmus.cacina 0:b259fd1a88f5 617 /**
seyhmus.cacina 0:b259fd1a88f5 618 * @brief transition from bootloder mode to application mode
seyhmus.cacina 0:b259fd1a88f5 619 *
seyhmus.cacina 0:b259fd1a88f5 620 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 621 */
seyhmus.cacina 0:b259fd1a88f5 622 int sh_exit_from_bootloader(void);
seyhmus.cacina 0:b259fd1a88f5 623
seyhmus.cacina 0:b259fd1a88f5 624
seyhmus.cacina 0:b259fd1a88f5 625 /**
seyhmus.cacina 0:b259fd1a88f5 626 * @brief transition from application mode to bootloader mode
seyhmus.cacina 0:b259fd1a88f5 627 *
seyhmus.cacina 0:b259fd1a88f5 628 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 629 */
seyhmus.cacina 0:b259fd1a88f5 630 int sh_put_in_bootloader(void);
seyhmus.cacina 0:b259fd1a88f5 631
seyhmus.cacina 0:b259fd1a88f5 632 /**
seyhmus.cacina 0:b259fd1a88f5 633 * @brief Check if SmartSensor is in bootloader mode
seyhmus.cacina 0:b259fd1a88f5 634 *
seyhmus.cacina 0:b259fd1a88f5 635 * @return 1 byte mode info : 1 if in bootloader mode, 0 if in main app, -1 if comm error
seyhmus.cacina 0:b259fd1a88f5 636 */
seyhmus.cacina 0:b259fd1a88f5 637 int sh_checkif_bootldr_mode(void);
seyhmus.cacina 0:b259fd1a88f5 638
seyhmus.cacina 0:b259fd1a88f5 639 /**
seyhmus.cacina 0:b259fd1a88f5 640 * @brief Get a string representing the SmartSensor firmware version
seyhmus.cacina 0:b259fd1a88f5 641 * @details If in bootloader mode, returns bootloader version
seyhmus.cacina 0:b259fd1a88f5 642 *
seyhmus.cacina 0:b259fd1a88f5 643 * @return Pointer to firmware version string
seyhmus.cacina 0:b259fd1a88f5 644 */
seyhmus.cacina 0:b259fd1a88f5 645 const char* sh_get_hub_fw_version(void);
seyhmus.cacina 0:b259fd1a88f5 646
seyhmus.cacina 0:b259fd1a88f5 647 /**
seyhmus.cacina 0:b259fd1a88f5 648 * @brief Get a string representing the SmartSensor algo version
seyhmus.cacina 0:b259fd1a88f5 649 * @details If in bootloader mode, returns bootloader version
seyhmus.cacina 0:b259fd1a88f5 650 *
seyhmus.cacina 0:b259fd1a88f5 651 * @return Pointer to algo version string
seyhmus.cacina 0:b259fd1a88f5 652 */
seyhmus.cacina 0:b259fd1a88f5 653 const char* sh_get_hub_algo_version(void);
seyhmus.cacina 0:b259fd1a88f5 654
seyhmus.cacina 0:b259fd1a88f5 655
seyhmus.cacina 0:b259fd1a88f5 656 /**
seyhmus.cacina 0:b259fd1a88f5 657 * @brief send raw string to I2C
seyhmus.cacina 0:b259fd1a88f5 658 * @param[in] rawdata - Raw data string, after slave address
seyhmus.cacina 0:b259fd1a88f5 659 * @param[out] rawdata_sz - Raw data size
seyhmus.cacina 0:b259fd1a88f5 660 *
seyhmus.cacina 0:b259fd1a88f5 661 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 662 */
seyhmus.cacina 0:b259fd1a88f5 663 int sh_send_raw(uint8_t *rawdata, int rawdata_sz);
seyhmus.cacina 0:b259fd1a88f5 664
seyhmus.cacina 0:b259fd1a88f5 665 /**
seyhmus.cacina 0:b259fd1a88f5 666 * @brief get length of hub debug log data available
seyhmus.cacina 0:b259fd1a88f5 667 * @param[out] log_len - length of hub log data available
seyhmus.cacina 0:b259fd1a88f5 668 *
seyhmus.cacina 0:b259fd1a88f5 669 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 670 */
seyhmus.cacina 0:b259fd1a88f5 671 int sh_get_log_len(int *log_len);
seyhmus.cacina 0:b259fd1a88f5 672
seyhmus.cacina 0:b259fd1a88f5 673
seyhmus.cacina 0:b259fd1a88f5 674 /**
seyhmus.cacina 0:b259fd1a88f5 675 * @brief read hub debug log data available
seyhmus.cacina 0:b259fd1a88f5 676 * @details first call sh_get_log_len() to get available log data in bytes then
seyhmus.cacina 0:b259fd1a88f5 677 * call this function with parameter num_bytes with a value smaller then available log data in bytes
seyhmus.cacina 0:b259fd1a88f5 678 *
seyhmus.cacina 0:b259fd1a88f5 679 * @param[in] num_bytes - number of log data bytes to be read
seyhmus.cacina 0:b259fd1a88f5 680 * @param[in] log_buf_sz - byte size of buffer log data will be dumped to
seyhmus.cacina 0:b259fd1a88f5 681 * @param[out] log_buf - byte buffer log data will be dumped to
seyhmus.cacina 0:b259fd1a88f5 682 *
seyhmus.cacina 0:b259fd1a88f5 683 * @return 1 byte status (SS_STATUS) : 0x00 (SS_SUCCESS) on success
seyhmus.cacina 0:b259fd1a88f5 684 */
seyhmus.cacina 0:b259fd1a88f5 685 int sh_read_ss_log(int num_bytes, uint8_t *log_buf, int log_buf_sz);
seyhmus.cacina 0:b259fd1a88f5 686
seyhmus.cacina 0:b259fd1a88f5 687
seyhmus.cacina 0:b259fd1a88f5 688
seyhmus.cacina 0:b259fd1a88f5 689
seyhmus.cacina 0:b259fd1a88f5 690 /* ***************************************************************************************** *
seyhmus.cacina 0:b259fd1a88f5 691 * *
seyhmus.cacina 0:b259fd1a88f5 692 * BOOTLOADER ADDITIONS *
seyhmus.cacina 0:b259fd1a88f5 693 * *
seyhmus.cacina 0:b259fd1a88f5 694 * ***************************************************************************************** */
seyhmus.cacina 0:b259fd1a88f5 695 int sh_get_bootloader_pagesz(int *pagesz);
seyhmus.cacina 0:b259fd1a88f5 696 int sh_set_bootloader_numberofpages(const int pageCount);
seyhmus.cacina 0:b259fd1a88f5 697 int sh_set_bootloader_iv(const uint8_t *ivbytes);
seyhmus.cacina 0:b259fd1a88f5 698 int sh_set_bootloader_iv(uint8_t iv_bytes[]);
seyhmus.cacina 0:b259fd1a88f5 699 int sh_set_bootloader_auth(uint8_t auth_bytes[]);
seyhmus.cacina 0:b259fd1a88f5 700 int sh_set_bootloader_erase(void);
seyhmus.cacina 0:b259fd1a88f5 701 int sh_bootloader_flashpage(uint8_t *flashDataPreceedByCmdBytes , const int page_size);
seyhmus.cacina 0:b259fd1a88f5 702 int sh_set_bootloader_delayfactor(const int factor );
seyhmus.cacina 0:b259fd1a88f5 703 const int sh_get_bootloader_delayfactor(void);
seyhmus.cacina 0:b259fd1a88f5 704 int sh_set_ebl_mode(const uint8_t mode);
seyhmus.cacina 0:b259fd1a88f5 705 const int sh_get_ebl_mode(void);
seyhmus.cacina 0:b259fd1a88f5 706 int sh_reset_to_bootloader(void);
seyhmus.cacina 0:b259fd1a88f5 707 int sh_reset_to_main_app(void);
seyhmus.cacina 0:b259fd1a88f5 708
seyhmus.cacina 0:b259fd1a88f5 709 int sh_debug_reset_to_bootloader(void);
seyhmus.cacina 0:b259fd1a88f5 710
seyhmus.cacina 0:b259fd1a88f5 711 int exit_from_bootloader(void);
seyhmus.cacina 0:b259fd1a88f5 712
seyhmus.cacina 0:b259fd1a88f5 713
seyhmus.cacina 0:b259fd1a88f5 714 /* *************************************************************************************** *
seyhmus.cacina 0:b259fd1a88f5 715 * DEMO SPECIFIC DECLERATIONS, NOT RELATED TO SENSOR HUB INTERFACE API. *
seyhmus.cacina 0:b259fd1a88f5 716 * *
seyhmus.cacina 0:b259fd1a88f5 717 * * *
seyhmus.cacina 0:b259fd1a88f5 718 * *****************************************************************************************/
seyhmus.cacina 0:b259fd1a88f5 719
seyhmus.cacina 0:b259fd1a88f5 720 void sh_init_hwcomm_interface();
seyhmus.cacina 0:b259fd1a88f5 721 bool sh_has_mfio_event(void);
seyhmus.cacina 0:b259fd1a88f5 722 void sh_enable_irq_mfioevent(void);
seyhmus.cacina 0:b259fd1a88f5 723 void sh_disable_irq_mfioevent(void);
seyhmus.cacina 0:b259fd1a88f5 724 void sh_clear_mfio_event_flag(void);
seyhmus.cacina 0:b259fd1a88f5 725 int sh_hard_reset(int wakeupMode);
seyhmus.cacina 0:b259fd1a88f5 726
seyhmus.cacina 0:b259fd1a88f5 727 extern uint8_t sh_write_buf[];
seyhmus.cacina 0:b259fd1a88f5 728
seyhmus.cacina 0:b259fd1a88f5 729 /*
seyhmus.cacina 0:b259fd1a88f5 730 #ifdef __cplusplus
seyhmus.cacina 0:b259fd1a88f5 731 }
seyhmus.cacina 0:b259fd1a88f5 732 #endif
seyhmus.cacina 0:b259fd1a88f5 733 */
seyhmus.cacina 0:b259fd1a88f5 734
seyhmus.cacina 0:b259fd1a88f5 735
seyhmus.cacina 0:b259fd1a88f5 736
seyhmus.cacina 0:b259fd1a88f5 737 #endif /* _SENSOR_HUB_H */
seyhmus.cacina 0:b259fd1a88f5 738
seyhmus.cacina 0:b259fd1a88f5 739
seyhmus.cacina 0:b259fd1a88f5 740
seyhmus.cacina 0:b259fd1a88f5 741
seyhmus.cacina 0:b259fd1a88f5 742
seyhmus.cacina 0:b259fd1a88f5 743