Maxim Integrated / Mbed OS MAXREFDES220_HR_SPO2_MONITOR

Dependencies:   max32630fthr USBDevice

Fork of MAXREFDES220_HEART_RATE_MONITOR by Maxim Integrated

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SSInterface.h Source File

SSInterface.h

00001 /***************************************************************************
00002 * Copyright (C) 2017 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 
00034 #ifndef _SSINTERFACE_H_
00035 #define _SSINTERFACE_H_
00036 
00037 #include "mbed.h"
00038 #include "MaximSensor.h"
00039 #include "EventStats.h"
00040 
00041 #define SS_PLATFORM_MAX3263X    "SmartSensor_MAX3263X"
00042 #define SS_PLATFORM_MAX32660    "SmartSensor_MAX32660"
00043 #define SS_BOOTLOADER_PLATFORM_MAX3263X    "Bootloader_MAX3263X"
00044 #define SS_BOOTLOADER_PLATFORM_MAX32660    "Bootloader_MAX32660"
00045 
00046 
00047 #define SS_I2C_8BIT_SLAVE_ADDR 0xAA
00048 #define SS_DEFAULT_CMD_SLEEP_MS 2
00049 #define SS_DUMP_REG_SLEEP_MS 100
00050 #define SS_ENABLE_SENSOR_SLEEP_MS 20
00051 
00052 #define SS_SENSORIDX_MAX86140   0x00
00053 #define SS_SENSORIDX_MAX30205   0x01
00054 #define SS_SENSORIDX_MAX30001   0x02
00055 #define SS_SENSORIDX_MAX30101   0x03
00056 #define SS_SENSORIDX_ACCEL  0x04
00057 
00058 #define SS_ALGOIDX_AGC  0x00
00059 #define SS_ALGOIDX_AEC  0x01
00060 #define SS_ALGOIDX_WHRM 0x02
00061 #define SS_ALGOIDX_ECG  0x03
00062 #define SS_ALGOIDX_BPT  0x04
00063 
00064 #define SS_FAM_R_STATUS     0x00
00065     #define SS_CMDIDX_STATUS    0x00
00066         #define SS_SHIFT_STATUS_ERR             0
00067         #define SS_MASK_STATUS_ERR              (0x07 << SS_SHIFT_STATUS_ERR)
00068         #define SS_SHIFT_STATUS_DATA_RDY        3
00069         #define SS_MASK_STATUS_DATA_RDY         (1 << SS_SHIFT_STATUS_DATA_RDY)
00070         #define SS_SHIFT_STATUS_FIFO_OUT_OVR    4
00071         #define SS_MASK_STATUS_FIFO_OUT_OVR     (1 << SS_SHIFT_STATUS_FIFO_OUT_OVR)
00072         #define SS_SHIFT_STATUS_FIFO_IN_OVR     5
00073         #define SS_MASK_STATUS_FIFO_IN_OVR      (1 << SS_SHIFT_STATUS_FIFO_IN_OVR)
00074 
00075 #define SS_FAM_W_MODE   0x01
00076 #define SS_FAM_R_MODE   0x02
00077     #define SS_CMDIDX_MODE  0x00
00078         #define SS_SHIFT_MODE_SHDN      0
00079         #define SS_MASK_MODE_SHDN       (1 << SS_SHIFT_MODE_SHDN)
00080         #define SS_SHIFT_MODE_RESET     1
00081         #define SS_MASK_MODE_RESET      (1 << SS_SHIFT_MODE_RESET)
00082         #define SS_SHIFT_MODE_FIFORESET 2
00083         #define SS_MASK_MODE_FIFORESET  (1 << SS_SHIFT_MODE_FIFORESET)
00084         #define SS_SHIFT_MODE_BOOTLDR   3
00085         #define SS_MASK_MODE_BOOTLDR    (1 << SS_SHIFT_MODE_BOOTLDR)
00086 
00087 #define SS_I2C_READ     0x03
00088 
00089 #define SS_FAM_W_COMMCHAN   0x10
00090 #define SS_FAM_R_COMMCHAN   0x11
00091     #define SS_CMDIDX_OUTPUTMODE    0x00
00092         #define SS_SHIFT_OUTPUTMODE_DATATYPE    0
00093         #define SS_MASK_OUTPUTMODE_DATATYPE     (0x03 << SS_SHIFT_OUTPUTMODE_DATATYPE)
00094             #define SS_DATATYPE_PAUSE               0
00095             #define SS_DATATYPE_RAW                 1
00096             #define SS_DATATYPE_ALGO                2
00097             #define SS_DATATYPE_BOTH                3
00098         #define SS_SHIFT_OUTPUTMODE_SC_EN       2
00099         #define SS_MASK_OUTPUTMODE_SC_EN        (1 << SS_SHIFT_OUTPUTMODE_SC_EN)
00100     #define SS_CMDIDX_FIFOAFULL     0x01
00101 
00102 #define SS_FAM_R_OUTPUTFIFO 0x12
00103     #define SS_CMDIDX_OUT_NUMSAMPLES    0x00
00104     #define SS_CMDIDX_READFIFO          0x01
00105 
00106 #define SS_FAM_R_INPUTFIFO  0x13
00107     #define SS_CMDIDX_SAMPLESIZE    0x00
00108     #define SS_CMDIDX_FIFOSIZE      0x01
00109     #define SS_CMDIDX_IN_NUMSAMPLES 0x02
00110 #define SS_FAM_W_INPUTFIFO  0x14
00111     #define SS_CMDIDN_WRITEFIFO     0x00
00112 
00113 #define SS_FAM_W_WRITEREG       0x40
00114 #define SS_FAM_R_READREG        0x41
00115 #define SS_FAM_R_REGATTRIBS     0x42
00116 #define SS_FAM_R_DUMPREG        0x43
00117 
00118 #define SS_FAM_W_SENSORMODE 0x44
00119 #define SS_FAM_R_SENSORMODE 0x45
00120 
00121 //TODO: Fill in known configuration parameters
00122 #define SS_FAM_W_ALGOCONFIG 0x50
00123 #define SS_FAM_R_ALGOCONFIG 0x51
00124     #define SS_CFGIDX_AGC_TARGET        0x00
00125     #define SS_CFGIDX_AGC_CORR_COEFF    0x01
00126     #define SS_CFGIDX_AGC_SENSITIVITY   0x02
00127     #define SS_CFGIDX_AGC_SMP_AVG       0x03
00128 
00129     #define SS_CFGIDX_WHRM_SR           0x00
00130     #define SS_CFGIDX_WHRM_MAX_HEIGHT   0x01
00131     #define SS_CFGIDX_WHRM_MAX_WEIGHT   0x02
00132     #define SS_CFGIDX_WHRM_MAX_AGE      0x03
00133     #define SS_CFGIDX_WHRM_MIN_HEIGHT   0x04
00134     #define SS_CFGIDX_WHRM_MIN_WEIGHT   0x05
00135     #define SS_CFGIDX_WHRM_MIN_AGE      0x06
00136     #define SS_CFGIDX_WHRM_DEF_HEIGHT   0x07
00137     #define SS_CFGIDX_WHRM_DEF_WEIGHT   0x08
00138     #define SS_CFGIDX_WHRM_DEF_AGE      0x09
00139     #define SS_CFGIDX_WHRM_INIT_HR      0x0A
00140 
00141     #define SS_CFGIDX_BP_USE_MED        0x00
00142     #define SS_CFGIDX_BP_SYS_BP_CAL     0x01
00143     #define SS_CFGIDX_BP_DIA_BP_CAL     0x02
00144     #define SS_CFGIDX_BP_CAL_DATA       0x03
00145     #define SS_CFGIDX_BP_EST_DATE       0x04
00146     #define SS_CFGIDX_BP_EST_NONREST    0x05
00147 
00148 #define SS_FAM_W_ALGOMODE   0x52
00149 #define SS_FAM_R_ALGOMODE   0x53
00150 
00151 #define SS_FAM_W_EXTERNSENSORMODE   0x60
00152 #define SS_FAM_R_EXTERNSENSORMODE   0x61
00153 
00154 #define SS_FAM_R_SELFTEST    0x70
00155 
00156 #define SS_FAM_W_BOOTLOADER 0x80
00157     #define SS_CMDIDX_SETIV         0x00
00158     #define SS_CMDIDX_SETAUTH       0x01
00159     #define SS_CMDIDX_SETNUMPAGES   0x02
00160     #define SS_CMDIDX_ERASE         0x03
00161     #define SS_CMDIDX_SENDPAGE      0x04
00162     #define SS_CMDIDX_ERASE_PAGE    0x05
00163 #define SS_FAM_R_BOOTLOADER 0x81
00164     #define SS_CMDIDX_BOOTFWVERSION 0x00
00165     #define SS_CMDIDX_PAGESIZE      0x01
00166 
00167 #define SS_FAM_W_BOOTLOADER_CFG 0x82
00168 #define SS_FAM_R_BOOTLOADER_CFG 0x83
00169     #define SS_CMDIDX_BL_SAVE       0x00
00170     #define SS_CMDIDX_BL_ENTRY      0x01
00171         #define SS_BL_CFG_ENTER_BL_MODE     0x00
00172         #define SS_BL_CFG_EBL_PIN           0x01
00173         #define SS_BL_CFG_EBL_POL           0x02
00174     #define SS_CMDIDX_BL_EXIT       0x02
00175         #define SS_BL_CFG_EXIT_BL_MODE      0x00
00176         #define SS_BL_CFG_TIMEOUT           0x01
00177 
00178 
00179 #define SS_FAM_R_IDENTITY   0xFF
00180     #define SS_CMDIDX_PLATTYPE      0x00
00181     #define SS_CMDIDX_PARTID        0x01
00182     #define SS_CMDIDX_REVID         0x02
00183     #define SS_CMDIDX_FWVERSION     0x03
00184     #define SS_CMDIDX_AVAILSENSORS  0x04
00185     #define SS_CMDIDX_DRIVERVER     0x05
00186     #define SS_CMDIDX_AVAILALGOS    0x06
00187     #define SS_CMDIDX_ALGOVER       0x07
00188 
00189 
00190 
00191 typedef enum {
00192     SS_SUCCESS=0x00,
00193 
00194     SS_ERR_COMMAND=0x01,
00195     SS_ERR_UNAVAILABLE=0x02,
00196     SS_ERR_DATA_FORMAT=0x03,
00197     SS_ERR_INPUT_VALUE=0x04,
00198 
00199     SS_ERR_BTLDR_GENERAL=0x80,
00200     SS_ERR_BTLDR_CHECKSUM=0x81,
00201 
00202     SS_ERR_TRY_AGAIN=0xFE,
00203     SS_ERR_UNKNOWN=0xFF,
00204 } SS_STATUS;
00205 
00206 typedef enum {
00207     SS_PLAT_MAX3263X=0,
00208     SS_PLAT_MAX32660=1,
00209 } SS_PLAT_TYPE;
00210 
00211 //self test result masks
00212 #define FAILURE_COMM        0x01
00213 #define FAILURE_INTERRUPT   0x02
00214 
00215 #define SS_SMALL_BUF_SIZE 32
00216 #define SS_MED_BUF_SIZE 512
00217 #define SS_LARGE_BUF_SIZE 8224
00218 
00219 #define SS_RESET_TIME   10
00220 #define SS_STARTUP_TO_BTLDR_TIME    50
00221 #define SS_STARTUP_TO_MAIN_APP_TIME 1000
00222 
00223 #define SS_MAX_SUPPORTED_SENSOR_NUM 0xFE
00224 #define SS_MAX_SUPPORTED_ALGO_NUM   0xFE
00225 #define SS_MAX_SUPPORTED_ALGO_CFG_NUM   0xFE
00226 #define SS_MAX_SUPPORTED_MODE_NUM   0xFF
00227 
00228 typedef struct {
00229     int data_size;
00230     Callback<void(uint8_t*)> callback;
00231 } ss_data_req;
00232 
00233 
00234 /**
00235  * @brief   SSInterface is Maxim's SmartSensor Interface class
00236  */
00237 class SSInterface
00238 {
00239 public:
00240 
00241     /* PUBLIC FUNCTION DECLARATIONS */
00242     /**
00243     * @brief    SSInterface constructor.
00244     *
00245     * @param[in]    i2cBus - reference to the I2C bus for the SmartSensor
00246     * @param[in]    ss_mfio - name of SmartSensor multi-function IO pin
00247     * @param[in]    ss_reset - name of SmartSensor Reset pin
00248     *
00249     */
00250     SSInterface(I2C &i2cBus, PinName ss_mfio, PinName ss_reset);
00251 
00252     /**
00253     * @brief    SSInterface constructor.
00254     *
00255     * @param[in]    spiBus - reference to the SPI bus for the SmartSensor
00256     * @param[in]    ss_mfio - name of SmartSensor multi-function IO pin
00257     * @param[in]    ss_reset - name of SmartSensor Reset pin
00258     *
00259     */
00260     SSInterface(SPI &spiBus, PinName ss_mfio, PinName ss_reset);
00261 
00262     /**
00263     * @brief    DSInterface destructor.
00264     *
00265     */
00266     ~SSInterface();
00267 
00268     /**
00269     * @brief    Write a command to the SmartSensor and get status response
00270     *
00271     * @param[in]    cmd_bytes - Pointer to the command's family and index bytes
00272     * @param[in]    cmd_idx_len - The number of bytes in the command
00273     * @param[in]    data - Pointer to the command's data bytes
00274     * @param[in]    data_len - The number data bytes
00275     *
00276     * @return SS_STATUS byte
00277     */
00278     SS_STATUS write_cmd(uint8_t *cmd_bytes, int cmd_bytes_len,
00279                         uint8_t *data, int data_len,
00280                         int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
00281 
00282 
00283     /**
00284     * @brief    Write a command to the SmartSensor and get status response
00285     *
00286     * @param[in]    tx_buf - Pointer to the command's family, index bytes and data bytes
00287     * @param[in]    tx_len - Total transaction lenght to send
00288     *
00289     * @return SS_STATUS byte
00290     */
00291     SS_STATUS write_cmd(uint8_t *tx_buf, int tx_len,
00292             int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
00293 
00294     /**
00295     * @brief    Write a command to the SmartSensor and get status response
00296     *
00297     * @param[in]    cmd_bytes - Pointer to the command's family and index bytes
00298     * @param[in]    cmd_idx_len - The number of bytes in the command
00299     * @param[in]    data - Pointer to the command's data bytes
00300     * @param[in]    data_len - The number data bytes
00301     * @param[in]    rxbuf - Buffer to fill in with read data (including status byte)
00302     * @param[in]    rxbuf_sz - Size of the rx buffer (to prevent overflow)
00303     *
00304     * @return SS_STATUS byte
00305     */
00306     SS_STATUS read_cmd( uint8_t *cmd_bytes, int cmd_bytes_len,
00307                         uint8_t *data, int data_len,
00308                         uint8_t *rxbuf, int rxbuf_sz,
00309                         int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
00310 
00311     /**
00312     * @brief    Get a string representing the SmartSensor firmware version
00313     * @details  If in bootloader mode, returns bootloader version
00314     *
00315     * @return   Pointer to firmware version string
00316     */
00317     const char* get_ss_fw_version();
00318 
00319     /**
00320     * @brief    Get a string representing the SmartSensor algo version
00321     * @details  If in bootloader mode, returns bootloader version
00322     *
00323     * @return   Pointer to algo version string
00324     */
00325     const char* get_ss_algo_version();
00326 
00327     /**
00328     * @brief    Get a string representing the SmartSensor platform type
00329     *
00330     * @return   Pointer to platform type string
00331     */
00332     const char* get_ss_platform_name();
00333 
00334     /**
00335      * @brief   Reset the SmartSensor and jump to main application
00336      *
00337      * @return  SS_STATUS code indicating success
00338      */ 
00339     SS_STATUS reset_to_main_app();
00340 
00341     /**
00342      * @brief   Reset the SmartSensor and jump to bootloader
00343      *
00344      * @return  SS_STATUS code indicating success
00345      */ 
00346     SS_STATUS reset_to_bootloader();
00347 
00348     /**
00349      * @brief   Reset the SmartSensor
00350      * @details If the SmartSensor was in bootloader, it will jump back into bootloader
00351      *          If the SmartSensor was in main app, it will jump back into main app
00352      *
00353      * @return  SS_STATUS code indicating success
00354      */ 
00355     SS_STATUS reset();
00356 
00357     /**
00358      * @brief       run the self test commands
00359      * param[in]    idx - the id of the sensor for the self test
00360      * param[in]    result - self-test response
00361      * param[in]    sleep_ms - duration of wait for read command
00362      * @return      SS_STATUS code indicating success
00363      */
00364     SS_STATUS self_test(int idx, uint8_t *result, int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
00365 
00366     /**
00367      * @brief   Check if SmartSensor is in bootloader mode
00368      *
00369      * @return  1 if in bootloader mode, 0 if in main app, -1 if comm error
00370      */
00371     int in_bootldr_mode();
00372 
00373 
00374     /**
00375      * @brief   Read register from a device onboard SmartSensor
00376      *
00377      * @param[in] idx - Index of device to read
00378      * @param[in] addr - Register address
00379      * @param[out] val - Register value
00380      *
00381      * @return  SS_SUCCESS on success
00382      */
00383     SS_STATUS get_reg(int idx, uint8_t addr, uint32_t *val);
00384 
00385     /**
00386      * @brief   Set register of a device onboard SmartSensor
00387      *
00388      * @param[in] idx - Index of device to read
00389      * @param[in] addr - Register address
00390      * @param[in] val - Register value
00391      * @param[in] byte_size - Size of IC register in bytes
00392      *
00393      * @return  SS_SUCCESS on success
00394      */
00395     SS_STATUS set_reg(int idx, uint8_t addr, uint32_t val, int byte_size);
00396 
00397     /**
00398      * @brief   Dump registers of a device onboard SmartSensor
00399      *
00400      * @param[in] idx - Index of device
00401      * @param[in] reg_vals - Array of addr_val_pairs
00402      * @param[in] reg_vals_sz - Number of items reg_vals can hold
00403      * @param[out] num_regs - Number of registers returned by command
00404      *
00405      * @return  SS_SUCCESS on success
00406      */
00407     SS_STATUS dump_reg(int idx, addr_val_pair* reg_vals, int reg_vals_sz, int* num_regs);
00408 
00409 
00410     /**
00411      * @brief   Enable a device on the SmartSensor
00412      *
00413      * @param[in] idx - Index of device
00414      * @param[in] mode - Mode to set the device to
00415      * @param[in] data_req - Data request
00416      *
00417      * @return  SS_SUCCESS on success
00418      */
00419     SS_STATUS enable_sensor(int idx, int mode, ss_data_req* data_req);
00420 
00421     /**
00422      * @brief   Disable a device on the SmartSensor
00423      *
00424      * @param[in] idx - Index of device
00425      *
00426      * @return  SS_SUCCESS on success
00427      */
00428     SS_STATUS disable_sensor(int idx);
00429 
00430     /**
00431      * @brief   Enable an algorithm on the SmartSensor
00432      *
00433      * @param[in] idx - Index of device
00434      * @param[in] mode - Mode to set the device to
00435      * @param[in] data_req - Data request
00436      *
00437      * @return  SS_SUCCESS on success
00438      */
00439     SS_STATUS enable_algo(int idx, int mode, ss_data_req* data_req);
00440 
00441     /**
00442      * @brief   Disable an algorithm on the SmartSensor
00443      *
00444      * @param[in] idx - Index of device
00445      *
00446      * @return  SS_SUCCESS on success
00447      */
00448     SS_STATUS disable_algo(int idx);
00449 
00450     /**
00451      * @brief   Set the value of an algorithm configuration parameter
00452      *
00453      * @param[in] algo_idx Index of algorithm
00454      * @param[in] cfg_idx Index of configuration parameter
00455      * @param[in] cfg Array of configuration bytes
00456      * @param[in] cfg_sz Size of cfg array
00457      *
00458      * @return SS_SUCCESS on success
00459      */
00460     SS_STATUS set_algo_cfg(int algo_idx, int cfg_idx, uint8_t *cfg, int cfg_sz);
00461 
00462     /**
00463      * @brief   Get the value of an algorithm configuration parameter
00464      *
00465      * @param[in] algo_idx Index of algorithm
00466      * @param[in] cfg_idx Index of configuration parameter
00467      * @param[in] cfg Array of configuration bytes to be filled in
00468      * @param[in] cfg_sz Number of bytes to be read
00469      *
00470      * @return SS_SUCCESS on success
00471      */
00472     SS_STATUS get_algo_cfg(int algo_idx, int cfg_idx, uint8_t *cfg, int cfg_sz);
00473 
00474     /**
00475      * @brief   Set the CommChannel Output Mode options
00476      *
00477      * @param[in] data_type - Set to 0 for only algorithm data
00478      *                          Set to 1 for only raw sensor data
00479      *                          Set to 2 for algo + raw sensor data
00480      *                          Set to 3 for no data
00481      * @param[in] sc_en - Set to true to receive 1 byte sample count from SmartSensor
00482      *
00483      * @return  SS_SUCCESS on success
00484      */
00485     SS_STATUS set_data_type(int data_type, bool sc_en);
00486 
00487     /**
00488      * @brief   Get the CommChannel Output Mode options
00489      *
00490      * @param[out] data_type - 0 for only algorithm data
00491      *                          1 for only raw sensor data
00492      *                          2 for algo + raw sensor data
00493      *                          3 for no data
00494      * @param[in] sc_en - If true, SmartSensor prepends data with 1 byte sample count
00495      *
00496      * @return  SS_SUCCESS on success
00497      */
00498     SS_STATUS get_data_type(int* data_type, bool *sc_en);
00499 
00500     /**
00501      * @brief   Set the number of samples for the SmartSensor to collect
00502      *          before issuing an interrupt
00503      *
00504      * @param[in]   thresh - Number of samples (1-255) to collect before interrupt
00505      *
00506      * @return SS_SUCCESS on success
00507      */
00508     SS_STATUS set_fifo_thresh(int thresh);
00509 
00510     /**
00511      * @brief   Get the number of samples the SmartSensor will collect
00512      *          before issuing an interrupt
00513      *
00514      * @param[out]  thresh - Number of samples (1-255) collected before interrupt
00515      *
00516      * @return SS_SUCCESS on success
00517      */
00518     SS_STATUS get_fifo_thresh(int *thresh);
00519 
00520     /**
00521      * @brief   Check that the SmartSensor is connected
00522      */
00523     SS_STATUS ss_comm_check();
00524 
00525     SS_STATUS stay_in_bootloader();
00526     SS_STATUS exit_from_bootloader();
00527 
00528     void enable_irq();
00529     void disable_irq();
00530 
00531     void mfio_selftest();
00532     bool reset_mfio_irq();
00533 
00534     void ss_execute_once();
00535     void ss_clear_interrupt_flag();
00536 
00537 private:
00538 
00539     /* PRIVATE VARIABLES */
00540     I2C *m_i2cBus;
00541     SPI *m_spiBus;
00542     DigitalInOut mfio_pin;
00543     DigitalInOut reset_pin;
00544     InterruptIn irq_pin;
00545 
00546     char fw_version[128];
00547     char algo_version[128];
00548     const char* plat_name;
00549 
00550     bool in_bootldr;
00551     bool sc_en;
00552     int data_type;
00553 
00554     int sensor_enabled_mode[SS_MAX_SUPPORTED_SENSOR_NUM];
00555     int algo_enabled_mode[SS_MAX_SUPPORTED_ALGO_NUM];
00556     ss_data_req* sensor_data_reqs[SS_MAX_SUPPORTED_SENSOR_NUM];
00557     ss_data_req* algo_data_reqs[SS_MAX_SUPPORTED_ALGO_NUM];
00558 
00559     /* PRIVATE METHODS */
00560     SS_STATUS write_cmd_small(uint8_t *cmd_bytes, int cmd_bytes_len,
00561                             uint8_t *data, int data_len,
00562                             int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
00563     SS_STATUS write_cmd_medium(uint8_t *cmd_bytes, int cmd_bytes_len,
00564                             uint8_t *data, int data_len,
00565                             int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
00566     SS_STATUS write_cmd_large(uint8_t *cmd_bytes, int cmd_bytes_len,
00567                             uint8_t *data, int data_len,
00568                             int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
00569     void cfg_mfio(PinDirection);
00570 
00571     void irq_handler();
00572     volatile bool m_irq_received_;
00573 
00574 
00575     void irq_handler_selftest();
00576     volatile bool mfio_int_happened;
00577 
00578     SS_STATUS read_fifo_data(int num_samples, int sample_size, uint8_t* databuf, int databuf_sz);
00579     SS_STATUS num_avail_samples(int* num_samples);
00580     void fifo_sample_size(int data_type, int* sample_size);
00581 
00582 /*  EventStats irq_evt; */
00583 };
00584 
00585 
00586 #endif