test
Dependencies: BMI160 max32630hsp3 MemoryLCD USBDevice
SH_Max8614x_BareMetal.h
00001 /******************************************************************************* 00002 * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 ******************************************************************************* 00032 */ 00033 #ifndef SH_Max8614x_BareMetal_H_ 00034 #define SH_Max8614x_BareMetal_H_ 00035 00036 #include <stdint.h> 00037 #include <stdio.h> 00038 #include "demoDefinitions.h" 00039 00040 00041 #define COMM_SUCCESS 0 00042 #define COMM_GENERAL_ERROR -1 00043 #define COMM_INVALID_PARAM -254 00044 #define COMM_NOT_RECOGNIZED -255 00045 00046 enum enAlgoMode{ 00047 kAlgoModeHeartRate = 0, 00048 reinitHeartRate = 1, 00049 }; 00050 00051 /** 00052 * @brief Get the value of register at addr 00053 * 00054 * @param[in] addr - adress of the register 00055 * @param[out] val - value at the register 00056 00057 */ 00058 void SH_Max8614x_get_reg(uint8_t addr, uint32_t *val); 00059 00060 /** 00061 * @brief Write a value to the register at address addr 00062 * 00063 * @param[in] addr - adress of the register to write 00064 * @param[in] val - value of the register to write 00065 */ 00066 void SH_Max8614x_set_reg(uint8_t addr, uint32_t val); 00067 00068 /** 00069 * @brief Initialize Max86140 with default configuration 00070 * 00071 * @param[in] paramAlgoMode - the mode of the algorithm to initialize 00072 * 00073 * @return 0 on SUCCESS 00074 */ 00075 int SH_Max8614x_default_init(enum enAlgoMode paramAlgoMode); 00076 00077 /** 00078 * @brief Check the data stored in the Sensor Hub. Reads and prints 00079 * the data if available 00080 * 00081 */ 00082 int SH_Max8614x_data_report_execute(void); 00083 00084 /** 00085 * @brief Stops the active sensors and algorithms 00086 * 00087 */ 00088 void SH_Max8614x_stop(void); 00089 00090 00091 extern uint16_t HrmResult; 00092 extern uint8_t HrmConfidence; 00093 00094 00095 /* define to see debug messages*/ 00096 //#define DEBUG_INFO 00097 00098 /** 00099 * @brief gets the data format of reported whrm algo result sample , in form of struct fields with number of bits they are represented. 00100 * 00101 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00102 * 00103 * @return 0 00104 */ 00105 int SH_Max8614x_get_whrm_dataformat(const char *null_arg); 00106 00107 00108 /** 00109 * @brief sets the register value of ppg sensor (8614x is connected to ME11 SENSOR HUB for this demo but can be used for all sensors physically 00110 * connected to ME11 SENSOR HUB). 00111 * 00112 * @param[in] addr_value_args : byte string including command followed by register address in hex and register value in hex 00113 * "set_reg ppgsensor 0xAB 0xCD" or "set_reg ppgsensor AB CD" 00114 * 00115 * @return 0x00 on success and prints on command console 00116 */ 00117 int SH_Max8614x_set_ppgreg(const char *addr_value_args); 00118 00119 /** 00120 * @brief gets the register value of ppg sensor (8614x is connected to ME11 SENSOR HUB for this demo but can be used for all sensors physically 00121 * connected to ME11 SENSOR HUB). 00122 * 00123 * @param[in] addr_arg: byte string including command followed by register address in hex 00124 * "set_reg ppgsensor 0xAB" or "set_reg ppgsensor AB" 00125 * 00126 * @return 0x00 on success and prints register value on command console 00127 */ 00128 int SH_Max8614x_get_ppgreg(const char *addr_arg); 00129 00130 /** 00131 * @brief initalizes and starts whrm measurement from ME11 SENSOR HUB. 00132 * It default initilizes datatype(to BOTH) input fifo lenght(to 5 , this is FIFO used by accel data from host) 00133 * 00134 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00135 * 00136 ** @return 0x00 on success and prints status on command console 00137 */ 00138 int SH_Max8614x_measure_whrm(const char *null_arg); 00139 00140 00141 /** 00142 * @brief starts self test of ppg sensor 00143 * 00144 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00145 * 00146 ** @return 0x00 on success and prints status on command console 00147 */ 00148 int SH_Max8614x_self_test_ppg(const char *null_arg); 00149 00150 /** 00151 * @brief starts self test of accelerometer sensor physically connected to ME11 SENSOR HUB 00152 * NOTE:Not supported within this demo as Customer is assumed to feed accel data from HOST. 00153 * 00154 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00155 * 00156 ** @return 0x00 on success and prints status on command console 00157 */ 00158 int SH_Max8614x_self_test_acc(const char *null_arg); 00159 00160 /** 00161 * @brief sets the aec algo usage of SPO2 algorithm 00162 * 00163 * @param[in] onoff_arg : byte string including command followed by mode value in HEX uo to 1 hexadecimal digits. 00164 * "set_cfg whrm aecenable 0/1" 0:off 1: On 00165 * 00166 *@return status info, 0x00 on success 00167 * 00168 **/ 00169 int SH_Max8614x_set_whrm_aecusage(const char *onoff_arg); 00170 00171 /** 00172 * @brief gets the aec algo usage of SPO2 algorithm 00173 * prints aec algo usage usage on/off value commnad console. 0 : Off 1: On 00174 * 00175 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00176 * 00177 * @return status info, 0x00 on success. 00178 **/ 00179 int SH_Max8614x_get_whrm_aecusage(const char *null_arg); 00180 00181 /** 00182 * @brief sets the skin contact detection usage of SPO2 algorithm 00183 * 00184 * @param[in] onoff_arg : byte string including command followed by mode value in HEX uo to 1 hexadecimal digits. 00185 * "set_cfg whrm aecenable 0/1" 0:off 1: On 00186 * 00187 *@return status info, 0x00 on success 00188 * 00189 **/ 00190 int SH_Max8614x_set_whrm_scdusage(const char *onoff_arg); 00191 00192 /** 00193 * @brief gets the skin contact detection usage of SPO2 algorithm 00194 * prints skin contact detection usage on/off value commnad console. 0 : Off 1: On 00195 * 00196 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00197 * 00198 * @return status info, 0x00 on success. 00199 **/ 00200 int SH_Max8614x_get_whrm_scdusage(const char *null_arg); 00201 00202 /** 00203 * @brief sets the adjustment period parameter for skin contact detection for SPO2 algorithm. 00204 * 00205 * @param[in] period_arg : byte string including command followed by period value in HEX up to 4 hexadecimal digits. 00206 * "set_cfg whrm scdadjperiod 0xABCD" 00207 * 00208 * @return status info, 0x00 on success. 00209 **/ 00210 int SH_Max8614x_set_whrm_scdadjperiod(const char *period_arg); 00211 00212 /** 00213 * @brief Gets the adjustment period parameter for skin contact detection for SPO2 algorithm. 00214 * prints SPo2 period value on command console 00215 * 00216 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00217 * 00218 * @return status info, 0x00 on success. 00219 * 00220 **/ 00221 int SH_Max8614x_get_whrm_scdadjperiod(const char *null_arg); 00222 00223 /** 00224 * @brief sets the debounce window parameter for skin contact detection for SPO2 algorithm. 00225 * 00226 * @param[in] dwindow_arg : byte string including command followed by debounce window value in HEX up to 4 hexadecimal digits. 00227 * "set_cfg whrm scddebouncewin 0xABCD" 00228 * 00229 * @return status info, 0x00 on success. 00230 **/ 00231 int SH_Max8614x_set_whrm_scddebouncewin(const char *dwindow_arg); 00232 00233 /** 00234 * @brief gets the debounce window parameter for skin contact detection for SPO2 algorithm. 00235 * 00236 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00237 * 00238 * @return status info, 0x00 on success. 00239 **/ 00240 int SH_Max8614x_get_whrm_scddebouncewin(const char *null_arg); 00241 00242 00243 /** 00244 * @brief sets the motion threshold parameter for WHRM algorithm. 00245 * 00246 * @param[in] timeout_arg : byte string including command followed by motion threshold value in HEX up to 4 hexadecimal digits. 00247 * "set_cfg whrm motionthreshold 0xABCD" 00248 * 00249 * @return status info, 0x00 on success. 00250 * 00251 **/ 00252 int SH_Max8614x_set_whrm_motionthresh(const char *motion_arg); 00253 00254 /** 00255 * @brief Gets the motion threshold for WHRM algorithm. prints WHRM algorith motion threshold value on command console 00256 * 00257 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00258 * 00259 * @return status info, 0x00 on success. 00260 * 00261 **/ 00262 int SH_Max8614x_get_whrm_motionthresh(const char *null_arg); 00263 00264 /** 00265 * @brief sets the minimum photodiode current parameter for WHRM algorithm. 00266 * 00267 * @param[in] curr_arg : byte string including command followed by diode current value in HEX up to 4 hexadecimal digits. 00268 * "set_cfg whrm motionthreshold 0xABCD" 00269 * 00270 * @return status info, 0x00 on success. 00271 * 00272 **/ 00273 int SH_Max8614x_set_whrm_minpdiodecurr(const char *curr_arg); 00274 00275 /** 00276 * @brief Gets the minimum photodiode current parameter for WHRM algorithm. prints WHRM algorithm photodiode current parameter value on command console 00277 * 00278 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00279 * 00280 * @return status info, 0x00 on success. 00281 * 00282 **/ 00283 int SH_Max8614x_get_whrm_minpdiodecurr(const char *null_arg); 00284 00285 /** 00286 * @brief sets the sensor photodiode configuration for WHRM algorithm. 00287 * 00288 * @param[in] pdcfg_arg : byte string including command followed by photodiode configuration value in HEX up to 1 hexadecimal digits. 00289 "set_cfg whrm pdconfig 0xA" or "set_cfg whrm pdconfig A" 00290 * 00291 * @return status info, 0x00 on success. 00292 **/ 00293 int SH_Max8614x_set_whrm_pdiodeconfig(const char *cfg_arg); 00294 00295 /** 00296 * @brief Gets the sensor photodiode configuration for WHRM algorithm. prints WHRM algorithm photodiode configuration on command console 00297 * 00298 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00299 * 00300 * @return status info, 0x00 on success. 00301 * 00302 **/ 00303 int SH_Max8614x_get_whrm_pdiodeconfig(const char *null_arg); 00304 00305 /** 00306 * @brief Sends raw byte stream to ME11 SENSOR HUB. For debug purposes mainly. 00307 * 00308 * @param[in] raw_data : byte stream to be send 00309 * 00310 * @return status info, 0x00 on success. 00311 * 00312 **/ 00313 //int SH_Max8614x_send_raw(const char *raw_data); 00314 00315 00316 00317 /** 00318 * @brief Stops sensor+algorithm data acquisition and operation for all algorithms of ME11 sensor HUB . 00319 * Mainly for use in this demo code!! 00320 * 00321 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type 00322 * 00323 * @return status info, 0x00 on success. 00324 * 00325 **/ 00326 int SH_Max8614x_stop_acquisition(const char *null_arg); 00327 00328 00329 #if defined(RAW_DATA_ONLY) 00330 int SH_Max8614x_disable_whrm(const char *onoff_arg); 00331 int SH_Max8614x_enable_pureraw(const char *onoff_arg); 00332 #define NUMCMDS8614X (24) 00333 #else 00334 #define NUMCMDS8614X (22) 00335 #endif 00336 00337 /*Number of commands accosicated with 8614x sesnor command table*/ 00338 00339 #define CONSOLE_STR_BUF_SZ ((int)1024); 00340 00341 00342 typedef int (*cmdExecFunc)( const char*); // typedef void (*cmdExecFunc)( const void*); 00343 00344 typedef struct { 00345 char const* cmdStr; 00346 cmdExecFunc execute; 00347 char const *help; 00348 }cmd_interface_t; 00349 00350 00351 static int command_help(const char *str); 00352 00353 00354 const cmd_interface_t CMDTABLE8614x[] = { 00355 00356 { "get_format whrmdata" , SH_Max8614x_get_whrm_dataformat , "returns whrm algo sample format in terms of bit fileds" }, 00357 { "enable_measurement whrm" , SH_Max8614x_measure_whrm , "start whrm measurement with default settings" }, 00358 { "get_reg ppgsensor" , SH_Max8614x_get_ppgreg , "get register value of 8614x sensor, usage: get_reg ppgsensor rAddr(1byte)" }, 00359 { "set_reg ppgsensor" , SH_Max8614x_set_ppgreg , "set register value of 8614x sensor, usage : set_reg ppgsensor rAddr(1byte) rval(1byte)" }, 00360 { "self_test ppgsensor" , SH_Max8614x_self_test_ppg , "starts self test of onboard ppg sensor" }, 00361 { "self_test accel" , SH_Max8614x_self_test_acc , "starts self test of onboard accel sensor" }, 00362 { "set_cfg whrm aecenable" , SH_Max8614x_set_whrm_aecusage , "on/off whrm aec algo, usage: set_cfg whrm aec X , X: 0 off 1 on" }, 00363 { "get_cfg whrm aecenable" , SH_Max8614x_get_whrm_aecusage , "check if aec algo for whrm is on/off" }, 00364 { "set_cfg whrm scdenable" , SH_Max8614x_set_whrm_scdusage , "on/off whrm skin contact detection, usage: set_cfg whrm scd X , X: 0 off 1 on" }, 00365 { "get_cfg whrm scdenable" , SH_Max8614x_get_whrm_scdusage , "check if whrm skin contact detection is on/off" }, 00366 { "set_cfg whrm scdadjperiod" , SH_Max8614x_set_whrm_scdadjperiod , "sets photo diode adj peroiod for whrm scd algo, usage: set_cfg whrm scdadjperiod period(numeric)" }, 00367 { "get_cfg whrm scdadjperiod" , SH_Max8614x_get_whrm_scdadjperiod , "gets photo diode adj peroiod for whrm scd algo" }, 00368 { "set_cfg whrm scddebouncewin" , SH_Max8614x_set_whrm_scddebouncewin , "sets debounce window for whrm scd algo, usage: set_cfg whrm scddebouncewin window(numeric)" }, 00369 { "get_cfg whrm scddebouncewin" , SH_Max8614x_get_whrm_scddebouncewin , "gets debounce window for whrm scd algo" }, 00370 { "set_cfg whrm motionthreshold" , SH_Max8614x_set_whrm_motionthresh , "sets motion threshold for whrm, usage: set_cfg whrm motionthreshold threshold(numeric)" }, 00371 { "get_cfg whrm motionthreshold" , SH_Max8614x_get_whrm_motionthresh , "gets motion threshold for whrm" }, 00372 { "set_cfg whrm minpdcurrent" , SH_Max8614x_set_whrm_minpdiodecurr , "sets photodiode current range for whrm, usage: set_cfg whrm minpdcurrent current(numeric)" }, 00373 { "get_cfg whrm minpdcurrent" , SH_Max8614x_get_whrm_minpdiodecurr , "gets photodiode current rangefor whrm" }, 00374 { "set_cfg whrm pdconfig" , SH_Max8614x_set_whrm_pdiodeconfig , "sets photdiode config for whrm, usage: set_cfg whrmaecscd pdconfig configstring" }, 00375 { "get_cfg whrm pdconfig" , SH_Max8614x_get_whrm_pdiodeconfig , "gets photdiode config for whrm" }, 00376 { "stop" , SH_Max8614x_stop_acquisition , "stops raw&algorithm data acquisition within 8614x instance of hub" }, 00377 { "help" , command_help , "commnand info" }, 00378 #if defined(RAW_DATA_ONLY) 00379 { "disable_whrm" , SH_Max8614x_disable_whrm , "disable algorithms" }, 00380 { "enable_raw_only" , SH_Max8614x_enable_pureraw , "enable just raw ppg data" }, 00381 #endif 00382 // { "send_raw" , SH_Max8614x_send_raw , "sends raw data to sensor hub, usage: send_raw datastring" }, 00383 }; 00384 00385 00386 static int command_help(const char *str){ 00387 int cmdIdx = 0; 00388 00389 SERIALOUT("AVAILABLE COMMANDS: \r\n\r\n"); 00390 while( cmdIdx != NUMCMDS8614X){ 00391 SERIALOUT(" %s : \r\n %s \r\n\r\n", CMDTABLE8614x[cmdIdx].cmdStr , CMDTABLE8614x[cmdIdx].help ); 00392 cmdIdx++; 00393 }; 00394 00395 } 00396 00397 00398 #endif 00399 00400 00401
Generated on Fri Jul 15 2022 22:42:36 by
1.7.2