test

Dependencies:   BMI160 max32630hsp3 MemoryLCD USBDevice

Committer:
seyhmuscacina
Date:
Mon Mar 25 07:40:37 2019 +0000
Revision:
3:b8989dab0f88
Parent:
0:ac4dea3e2894
Fork the repository

Who changed what in which revision?

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