initial commit, reads dev id
MAX8614X.h@4:6ec3bc44f055, 2018-08-16 (annotated)
- Committer:
- phonemacro
- Date:
- Thu Aug 16 19:53:01 2018 +0000
- Revision:
- 4:6ec3bc44f055
- Parent:
- 3:ad8f1059a0c5
- Child:
- 5:1f7b8cb07e26
updated to transform output
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
phonemacro | 0:77ee0ceb503a | 1 | /******************************************************************************* |
phonemacro | 0:77ee0ceb503a | 2 | * Author: Ihsan Mert Ozcelik, Ihsan.Ozcelik@maximintegrated.com |
phonemacro | 0:77ee0ceb503a | 3 | * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. |
phonemacro | 0:77ee0ceb503a | 4 | * |
phonemacro | 0:77ee0ceb503a | 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
phonemacro | 0:77ee0ceb503a | 6 | * copy of this software and associated documentation files (the "Software"), |
phonemacro | 0:77ee0ceb503a | 7 | * to deal in the Software without restriction, including without limitation |
phonemacro | 0:77ee0ceb503a | 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
phonemacro | 0:77ee0ceb503a | 9 | * and/or sell copies of the Software, and to permit persons to whom the |
phonemacro | 0:77ee0ceb503a | 10 | * Software is furnished to do so, subject to the following conditions: |
phonemacro | 0:77ee0ceb503a | 11 | * |
phonemacro | 0:77ee0ceb503a | 12 | * The above copyright notice and this permission notice shall be included |
phonemacro | 0:77ee0ceb503a | 13 | * in all copies or substantial portions of the Software. |
phonemacro | 0:77ee0ceb503a | 14 | * |
phonemacro | 0:77ee0ceb503a | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
phonemacro | 0:77ee0ceb503a | 16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
phonemacro | 0:77ee0ceb503a | 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
phonemacro | 0:77ee0ceb503a | 18 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
phonemacro | 0:77ee0ceb503a | 19 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
phonemacro | 0:77ee0ceb503a | 20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
phonemacro | 0:77ee0ceb503a | 21 | * OTHER DEALINGS IN THE SOFTWARE. |
phonemacro | 0:77ee0ceb503a | 22 | * |
phonemacro | 0:77ee0ceb503a | 23 | * Except as contained in this notice, the name of Maxim Integrated |
phonemacro | 0:77ee0ceb503a | 24 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
phonemacro | 0:77ee0ceb503a | 25 | * Products, Inc. Branding Policy. |
phonemacro | 0:77ee0ceb503a | 26 | * |
phonemacro | 0:77ee0ceb503a | 27 | * The mere transfer of this software does not imply any licenses |
phonemacro | 0:77ee0ceb503a | 28 | * of trade secrets, proprietary technology, copyrights, patents, |
phonemacro | 0:77ee0ceb503a | 29 | * trademarks, maskwork rights, or any other form of intellectual |
phonemacro | 0:77ee0ceb503a | 30 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
phonemacro | 0:77ee0ceb503a | 31 | * ownership rights. |
phonemacro | 0:77ee0ceb503a | 32 | ******************************************************************************* |
phonemacro | 0:77ee0ceb503a | 33 | */ |
phonemacro | 0:77ee0ceb503a | 34 | |
phonemacro | 0:77ee0ceb503a | 35 | #ifndef _MAX8614X_H_ |
phonemacro | 0:77ee0ceb503a | 36 | #define _MAX8614X_H_ |
phonemacro | 0:77ee0ceb503a | 37 | |
phonemacro | 0:77ee0ceb503a | 38 | #include "mbed.h" |
phonemacro | 0:77ee0ceb503a | 39 | //#include "queue.h" |
phonemacro | 0:77ee0ceb503a | 40 | //#include "MaximSensor.h" |
phonemacro | 0:77ee0ceb503a | 41 | |
phonemacro | 0:77ee0ceb503a | 42 | /** |
phonemacro | 0:77ee0ceb503a | 43 | @brief The MAX8614X |
phonemacro | 0:77ee0ceb503a | 44 | */ |
phonemacro | 0:77ee0ceb503a | 45 | |
phonemacro | 0:77ee0ceb503a | 46 | /** |
phonemacro | 0:77ee0ceb503a | 47 | @brief MAX8614X - supports MAX8614X object with SPI interface |
phonemacro | 0:77ee0ceb503a | 48 | */ |
phonemacro | 0:77ee0ceb503a | 49 | class MAX8614X |
phonemacro | 0:77ee0ceb503a | 50 | { |
phonemacro | 0:77ee0ceb503a | 51 | public: |
phonemacro | 0:77ee0ceb503a | 52 | /* PUBLIC CONST VARIABLES */ |
phonemacro | 0:77ee0ceb503a | 53 | |
phonemacro | 0:77ee0ceb503a | 54 | /* Return codes */ |
phonemacro | 0:77ee0ceb503a | 55 | static const int8_t RTN_NO_ERROR = 0; |
phonemacro | 0:77ee0ceb503a | 56 | static const int8_t RTN_ERR_UNSOPPORTED_PART = -1; |
phonemacro | 0:77ee0ceb503a | 57 | static const int8_t RTN_ERR_WRONG_DATA_TYPE = -2; |
phonemacro | 0:77ee0ceb503a | 58 | static const int8_t RTN_ERR_NOT_8614x = -3; |
phonemacro | 0:77ee0ceb503a | 59 | static const int8_t RTN_ERR_MEM_ALLOC_FAIL = -4; |
phonemacro | 0:77ee0ceb503a | 60 | static const int8_t RTN_ERR_QUEUE_INIT = -5; |
phonemacro | 0:77ee0ceb503a | 61 | static const int8_t RTN_ERR_QUEUE_EMPTY = -6; |
phonemacro | 0:77ee0ceb503a | 62 | |
phonemacro | 0:77ee0ceb503a | 63 | /* MAX8614X Registers */ |
phonemacro | 0:77ee0ceb503a | 64 | enum Registers |
phonemacro | 0:77ee0ceb503a | 65 | { |
phonemacro | 0:77ee0ceb503a | 66 | MAX8614X_INT_STATUS1_REG = 0x00, |
phonemacro | 0:77ee0ceb503a | 67 | MAX8614X_INT_STATUS2_REG, |
phonemacro | 0:77ee0ceb503a | 68 | MAX8614X_INT_ENABLE1_REG, |
phonemacro | 0:77ee0ceb503a | 69 | MAX8614X_INT_ENABLE2_REG, |
phonemacro | 0:77ee0ceb503a | 70 | MAX8614X_FIFO_WR_PTR_REG, |
phonemacro | 0:77ee0ceb503a | 71 | MAX8614X_FIFO_RD_PTR_REG, |
phonemacro | 0:77ee0ceb503a | 72 | MAX8614X_OVF_CNT_REG, |
phonemacro | 0:77ee0ceb503a | 73 | MAX8614X_FIFO_DATA_CNT_REG, |
phonemacro | 0:77ee0ceb503a | 74 | MAX8614X_FIFO_DATA_REG, |
phonemacro | 0:77ee0ceb503a | 75 | MAX8614X_FIFO_CFG1_REG, |
phonemacro | 0:77ee0ceb503a | 76 | MAX8614X_FIFO_CFG2_REG, //0x0A |
phonemacro | 0:77ee0ceb503a | 77 | MAX8614X_SYSTEM_CTRL_REG = 0x0D, |
phonemacro | 0:77ee0ceb503a | 78 | MAX8614X_PPG_SYNC_CTRL_REG = 0x10, |
phonemacro | 0:77ee0ceb503a | 79 | MAX8614X_PPG_CFG1_REG, |
phonemacro | 0:77ee0ceb503a | 80 | MAX8614X_PPG_CFG2_REG, |
phonemacro | 0:77ee0ceb503a | 81 | MAX8614X_PPG_CFG3_REG, |
phonemacro | 0:77ee0ceb503a | 82 | MAX8614X_PROX_INT_THRES_REG, |
phonemacro | 0:77ee0ceb503a | 83 | MAX8614X_PHOTO_DIODE_BIAS_REG, |
phonemacro | 0:77ee0ceb503a | 84 | MAX8614X_FICKET_FENCE_REG, //0x16 |
phonemacro | 0:77ee0ceb503a | 85 | MAX8614X_LED_SEQ1_REG = 0x20, |
phonemacro | 0:77ee0ceb503a | 86 | MAX8614X_LED_SEQ2_REG, |
phonemacro | 0:77ee0ceb503a | 87 | MAX8614X_LED_SEQ3_REG, |
phonemacro | 0:77ee0ceb503a | 88 | MAX8614X_LED1_PA_REG, |
phonemacro | 0:77ee0ceb503a | 89 | MAX8614X_LED2_PA_REG, |
phonemacro | 0:77ee0ceb503a | 90 | MAX8614X_LED3_PA_REG, |
phonemacro | 0:77ee0ceb503a | 91 | MAX8614X_LED4_PA_REG, |
phonemacro | 0:77ee0ceb503a | 92 | MAX8614X_LED5_PA_REG, |
phonemacro | 0:77ee0ceb503a | 93 | MAX8614X_LED6_PA_REG, |
phonemacro | 0:77ee0ceb503a | 94 | MAX8614X_LED_PILOT_PA_REG, |
phonemacro | 0:77ee0ceb503a | 95 | MAX8614X_LED_RANGE1_REG, |
phonemacro | 0:77ee0ceb503a | 96 | MAX8614X_LED_RANGE2_REG, //0x2B |
phonemacro | 0:77ee0ceb503a | 97 | MAX8614X_DIE_TEMP_CFG_REG = 0x40, |
phonemacro | 0:77ee0ceb503a | 98 | MAX8614X_DIE_TEMP_INT_REG, |
phonemacro | 0:77ee0ceb503a | 99 | MAX8614X_DIE_TEMP_FRAC_REG, |
phonemacro | 0:77ee0ceb503a | 100 | MAX8614X_SHA_CMD_REG = 0xF0, |
phonemacro | 0:77ee0ceb503a | 101 | MAX8614X_SHA_CFG_REG, |
phonemacro | 0:77ee0ceb503a | 102 | MAX8614X_MEMORY_CONTROL_REG, |
phonemacro | 0:77ee0ceb503a | 103 | MAX8614X_MEMORY_INDEX_REG, |
phonemacro | 0:77ee0ceb503a | 104 | MAX8614X_MEMORY_DATA_REG, |
phonemacro | 0:77ee0ceb503a | 105 | MAX8614X_REV_ID_REG = 0xFE, |
phonemacro | 0:77ee0ceb503a | 106 | MAX8614X_PART_ID_REG, |
phonemacro | 0:77ee0ceb503a | 107 | |
phonemacro | 0:77ee0ceb503a | 108 | }; |
phonemacro | 0:77ee0ceb503a | 109 | |
phonemacro | 0:77ee0ceb503a | 110 | /*System Control*/ |
phonemacro | 0:77ee0ceb503a | 111 | static const uint8_t MAX8614X_SYSTEM_RESET_MASK = (0x01 << 0); |
phonemacro | 0:77ee0ceb503a | 112 | static const uint8_t MAX8614X_SYSTEM_SHDN_MASK = (0x01 << 1); |
phonemacro | 0:77ee0ceb503a | 113 | static const uint8_t MAX8614X_SYSTEM_LP_BOOST = (0x01 << 2); |
phonemacro | 0:77ee0ceb503a | 114 | |
phonemacro | 0:77ee0ceb503a | 115 | /* Die Temperature */ |
phonemacro | 0:77ee0ceb503a | 116 | static const uint8_t MAX8614X_DIE_TEMP_EN = (0x1 << 0); |
phonemacro | 0:77ee0ceb503a | 117 | static const uint8_t MAX8614X_DIE_TEMP_FRAC_MASK = (0xF << 0); |
phonemacro | 0:77ee0ceb503a | 118 | |
phonemacro | 0:77ee0ceb503a | 119 | /* Sample rates */ |
phonemacro | 0:77ee0ceb503a | 120 | static const uint8_t MAX8614X_PPG_SR_25_SPS = (0x00 << 3); |
phonemacro | 0:77ee0ceb503a | 121 | static const uint8_t MAX8614X_PPG_SR_50_SPS = (0x01 << 3); |
phonemacro | 0:77ee0ceb503a | 122 | static const uint8_t MAX8614X_PPG_SR_84_SPS = (0x02 << 3); |
phonemacro | 0:77ee0ceb503a | 123 | static const uint8_t MAX8614X_PPG_SR_100_SPS = (0x03 << 3); |
phonemacro | 0:77ee0ceb503a | 124 | static const uint8_t MAX8614X_PPG_SR_200_SPS = (0x04 << 3); |
phonemacro | 0:77ee0ceb503a | 125 | static const uint8_t MAX8614X_PPG_SR_400_SPS = (0x05 << 3); |
phonemacro | 0:77ee0ceb503a | 126 | |
phonemacro | 0:77ee0ceb503a | 127 | /* LED Pulse Amplitude */ |
phonemacro | 0:77ee0ceb503a | 128 | static const uint8_t MAX8614X_LED1_RGE_MASK = (0x3 << 0); |
phonemacro | 0:77ee0ceb503a | 129 | static const uint8_t MAX8614X_LED2_RGE_MASK = (0x3 << 2); |
phonemacro | 0:77ee0ceb503a | 130 | static const uint8_t MAX8614X_LED3_RGE_MASK = (0x3 << 4); |
phonemacro | 0:77ee0ceb503a | 131 | |
phonemacro | 0:77ee0ceb503a | 132 | static const uint8_t MAX8614X_LED4_RGE_MASK = (0x3 << 0); |
phonemacro | 0:77ee0ceb503a | 133 | static const uint8_t MAX8614X_LED5_RGE_MASK = (0x3 << 2); |
phonemacro | 0:77ee0ceb503a | 134 | static const uint8_t MAX8614X_LED6_RGE_MASK = (0x3 << 4); |
phonemacro | 0:77ee0ceb503a | 135 | |
phonemacro | 0:77ee0ceb503a | 136 | static const uint8_t MAX8614X_LED1_RGE_25mA_MASK = (0x0 << 0); |
phonemacro | 0:77ee0ceb503a | 137 | static const uint8_t MAX8614X_LED1_RGE_50mA_MASK = (0x1 << 0); |
phonemacro | 0:77ee0ceb503a | 138 | static const uint8_t MAX8614X_LED1_RGE_75mA_MASK = (0x2 << 0); |
phonemacro | 0:77ee0ceb503a | 139 | static const uint8_t MAX8614X_LED1_RGE_100mA_MASK = (0x3 << 0); |
phonemacro | 0:77ee0ceb503a | 140 | |
phonemacro | 0:77ee0ceb503a | 141 | static const uint8_t MAX8614X_LED2_RGE_25mA_MASK = (0x0 << 2); |
phonemacro | 0:77ee0ceb503a | 142 | static const uint8_t MAX8614X_LED2_RGE_50mA_MASK = (0x1 << 2); |
phonemacro | 0:77ee0ceb503a | 143 | static const uint8_t MAX8614X_LED2_RGE_75mA_MASK = (0x2 << 2); |
phonemacro | 0:77ee0ceb503a | 144 | static const uint8_t MAX8614X_LED2_RGE_100mA_MASK = (0x3 << 2); |
phonemacro | 0:77ee0ceb503a | 145 | |
phonemacro | 0:77ee0ceb503a | 146 | static const uint8_t MAX8614X_LED3_RGE_25mA_MASK = (0x0 << 4); |
phonemacro | 0:77ee0ceb503a | 147 | static const uint8_t MAX8614X_LED3_RGE_50mA_MASK = (0x1 << 4); |
phonemacro | 0:77ee0ceb503a | 148 | static const uint8_t MAX8614X_LED3_RGE_75mA_MASK = (0x2 << 4); |
phonemacro | 0:77ee0ceb503a | 149 | static const uint8_t MAX8614X_LED3_RGE_100mA_MASK = (0x3 << 4); |
phonemacro | 0:77ee0ceb503a | 150 | |
phonemacro | 0:77ee0ceb503a | 151 | /* PPG PW */ |
phonemacro | 0:77ee0ceb503a | 152 | static const uint8_t MAX8614X_PPG_LED_PW_14_4_US_MASK = (0 << 0); |
phonemacro | 0:77ee0ceb503a | 153 | static const uint8_t MAX8614X_PPG_LED_PW_28_8_US_MASK = (1 << 0); |
phonemacro | 0:77ee0ceb503a | 154 | static const uint8_t MAX8614X_PPG_LED_PW_57_6_US_MASK = (2 << 0); |
phonemacro | 0:77ee0ceb503a | 155 | static const uint8_t MAX8614X_PPG_LED_PW_115_2_US_MASK = (3 << 0); |
phonemacro | 0:77ee0ceb503a | 156 | |
phonemacro | 0:77ee0ceb503a | 157 | /* PPG Range */ |
phonemacro | 0:77ee0ceb503a | 158 | static const uint8_t MAX8614X_PPG1_ADC_RGE_4096_MASK = (0 << 2); |
phonemacro | 0:77ee0ceb503a | 159 | static const uint8_t MAX8614X_PPG1_ADC_RGE_8192_MASK = (1 << 2); |
phonemacro | 0:77ee0ceb503a | 160 | static const uint8_t MAX8614X_PPG1_ADC_RGE_16384_MASK = (2 << 2); |
phonemacro | 0:77ee0ceb503a | 161 | static const uint8_t MAX8614X_PPG1_ADC_RGE_32768_MASK = (3 << 2); |
phonemacro | 0:77ee0ceb503a | 162 | |
phonemacro | 0:77ee0ceb503a | 163 | static const uint8_t MAX8614X_PPG2_ADC_RGE_4096_MASK = (0 << 4); |
phonemacro | 0:77ee0ceb503a | 164 | static const uint8_t MAX8614X_PPG2_ADC_RGE_8192_MASK = (1 << 4); |
phonemacro | 0:77ee0ceb503a | 165 | static const uint8_t MAX8614X_PPG2_ADC_RGE_16384_MASK = (2 << 4); |
phonemacro | 0:77ee0ceb503a | 166 | static const uint8_t MAX8614X_PPG2_ADC_RGE_32768_MASK = (3 << 4); |
phonemacro | 0:77ee0ceb503a | 167 | |
phonemacro | 0:77ee0ceb503a | 168 | /* FIFO */ |
phonemacro | 0:77ee0ceb503a | 169 | static const uint8_t MAX8614X_FIFO_WR_PTR_MASK = (0x7F << 0); |
phonemacro | 0:77ee0ceb503a | 170 | static const uint8_t MAX8614X_FIFO_RD_PTR_MASK = (0x7F << 0); |
phonemacro | 0:77ee0ceb503a | 171 | static const uint8_t MAX8614X_OVF_CNT_MASK = (0x7F << 0); |
phonemacro | 0:77ee0ceb503a | 172 | static const uint8_t MAX8614X_FIFO_A_FULL_MASK = (0x7F << 0); |
phonemacro | 0:77ee0ceb503a | 173 | static const uint8_t MAX8614X_FIFO_EN_MASK = (0x01 << 0); |
phonemacro | 0:77ee0ceb503a | 174 | static const uint8_t MAX8614X_FIFO_RO_MASK = (0x01 << 1); |
phonemacro | 0:77ee0ceb503a | 175 | static const uint8_t MAX8614X_A_FULL_TYPE_MASK = (0x01 << 2); |
phonemacro | 0:77ee0ceb503a | 176 | static const uint8_t MAX8614X_A_FULL_RPT = (0x00 << 2); |
phonemacro | 0:77ee0ceb503a | 177 | static const uint8_t MAX8614X_A_FULL_ONCE = (0x01 << 2); |
phonemacro | 0:77ee0ceb503a | 178 | static const uint8_t MAX8614X_FIFO_STAT_CLR_MASK = (0x01 << 3); |
phonemacro | 0:77ee0ceb503a | 179 | static const uint8_t MAX8614X_FLUSH_FIFO_MASK = (0x01 << 4); |
phonemacro | 0:77ee0ceb503a | 180 | |
phonemacro | 0:77ee0ceb503a | 181 | /* Status */ |
phonemacro | 0:77ee0ceb503a | 182 | static const uint8_t MAX8614X_INT1_EN_A_FULL_MASK = (0x1 << 7); |
phonemacro | 0:77ee0ceb503a | 183 | static const uint8_t MAX8614X_INT1_EN_DATA_RDY_MASK = (0x1 << 6); |
phonemacro | 0:77ee0ceb503a | 184 | static const uint8_t MAX8614X_INT1_EN_DIE_TEMP_MASK = (0x1 << 2); |
phonemacro | 0:77ee0ceb503a | 185 | static const uint8_t MAX8614X_INT1_EN_VDD_OOR_MASK = (0x1 << 1); |
phonemacro | 0:77ee0ceb503a | 186 | |
phonemacro | 2:11e0b5b86e1e | 187 | /*SHA256 Control*/ |
phonemacro | 2:11e0b5b86e1e | 188 | static const uint8_t MAX8614X_IE_SHA_DONE_EN = (0x01 << 0); |
phonemacro | 3:ad8f1059a0c5 | 189 | static const uint8_t MAX8614X_SHACFG_SHA_START = (0x01 << 0); |
phonemacro | 3:ad8f1059a0c5 | 190 | static const uint8_t MAX8614X_SHACFG_SHA_EN = (0x01 << 1); |
phonemacro | 2:11e0b5b86e1e | 191 | static const uint8_t MAX8614X_MEMCNTRL_BANK0_MASK = (0); |
phonemacro | 2:11e0b5b86e1e | 192 | static const uint8_t MAX8614X_MEMCNTRL_BANK1_MASK = (1); |
phonemacro | 2:11e0b5b86e1e | 193 | static const uint8_t MAX8614X_MEMCNTRL_WR_DIS_MASK = (0x01 << 0); |
phonemacro | 2:11e0b5b86e1e | 194 | static const uint8_t MAX8614X_MEMCNTRL_WR_EN_MASK = (0x01 << 1); |
phonemacro | 3:ad8f1059a0c5 | 195 | static const uint8_t MAX8614X_SHACMD_MAC_ROM_ID = (0x35); |
phonemacro | 3:ad8f1059a0c5 | 196 | static const uint8_t MAX8614X_SHACMD_MAC_NO_ROM_ID = (0x36); |
phonemacro | 0:77ee0ceb503a | 197 | /* PUBLIC TYPE DEFINITIONS */ |
phonemacro | 0:77ee0ceb503a | 198 | typedef struct RegisterMap { |
phonemacro | 0:77ee0ceb503a | 199 | uint8_t addr; |
phonemacro | 0:77ee0ceb503a | 200 | uint8_t val; |
phonemacro | 0:77ee0ceb503a | 201 | } RegisterMap_t; |
phonemacro | 1:7ae9b934ee55 | 202 | |
phonemacro | 1:7ae9b934ee55 | 203 | typedef union { |
phonemacro | 1:7ae9b934ee55 | 204 | struct { |
phonemacro | 1:7ae9b934ee55 | 205 | struct { |
phonemacro | 1:7ae9b934ee55 | 206 | unsigned char pwr_rdy:1; |
phonemacro | 1:7ae9b934ee55 | 207 | unsigned char vdd_oor:1; |
phonemacro | 1:7ae9b934ee55 | 208 | unsigned char die_temp_rdy:1; |
phonemacro | 1:7ae9b934ee55 | 209 | unsigned char led_compb:1; |
phonemacro | 1:7ae9b934ee55 | 210 | unsigned char prox_int:1; |
phonemacro | 1:7ae9b934ee55 | 211 | unsigned char alc_ovf:1; |
phonemacro | 1:7ae9b934ee55 | 212 | unsigned char data_rdy:1; |
phonemacro | 1:7ae9b934ee55 | 213 | unsigned char a_full:1; |
phonemacro | 1:7ae9b934ee55 | 214 | }; |
phonemacro | 1:7ae9b934ee55 | 215 | struct { |
phonemacro | 1:7ae9b934ee55 | 216 | unsigned char:7; |
phonemacro | 1:7ae9b934ee55 | 217 | unsigned char sha_done:1; |
phonemacro | 1:7ae9b934ee55 | 218 | }; |
phonemacro | 1:7ae9b934ee55 | 219 | }; |
phonemacro | 1:7ae9b934ee55 | 220 | uint8_t val[2]; |
phonemacro | 1:7ae9b934ee55 | 221 | } int_status_t; |
phonemacro | 1:7ae9b934ee55 | 222 | |
phonemacro | 0:77ee0ceb503a | 223 | |
phonemacro | 0:77ee0ceb503a | 224 | /* PUBLIC FUNCTION DECLARATIONS */ |
phonemacro | 0:77ee0ceb503a | 225 | |
phonemacro | 0:77ee0ceb503a | 226 | MAX8614X(SPI &spiBus, DigitalOut &cs, PinName intPin); |
phonemacro | 0:77ee0ceb503a | 227 | ~MAX8614X(); |
phonemacro | 4:6ec3bc44f055 | 228 | int init(); |
phonemacro | 0:77ee0ceb503a | 229 | |
phonemacro | 0:77ee0ceb503a | 230 | int readRegister(uint8_t reg, uint8_t *data, int len); |
phonemacro | 0:77ee0ceb503a | 231 | |
phonemacro | 0:77ee0ceb503a | 232 | int writeRegister(uint8_t reg, const uint8_t data); |
phonemacro | 0:77ee0ceb503a | 233 | |
phonemacro | 0:77ee0ceb503a | 234 | int writeBlock(const RegisterMap reg_block[], unsigned int size); |
phonemacro | 1:7ae9b934ee55 | 235 | void irq_handler(void); |
phonemacro | 2:11e0b5b86e1e | 236 | bool isShaComplete(void); |
phonemacro | 2:11e0b5b86e1e | 237 | void clearShaComplete(void); |
phonemacro | 1:7ae9b934ee55 | 238 | /* PUBLIC VARIABLES */ |
phonemacro | 1:7ae9b934ee55 | 239 | InterruptIn m_ir; |
phonemacro | 1:7ae9b934ee55 | 240 | |
phonemacro | 0:77ee0ceb503a | 241 | private: |
phonemacro | 0:77ee0ceb503a | 242 | |
phonemacro | 0:77ee0ceb503a | 243 | /* PRIVATE VARIABLES */ |
phonemacro | 0:77ee0ceb503a | 244 | SPI &m_spiBus; |
phonemacro | 0:77ee0ceb503a | 245 | DigitalOut &m_cs; |
phonemacro | 2:11e0b5b86e1e | 246 | bool shaComplete; |
phonemacro | 0:77ee0ceb503a | 247 | |
phonemacro | 0:77ee0ceb503a | 248 | /* PRIVATE FUNCTION DECLARATIONS */ |
phonemacro | 0:77ee0ceb503a | 249 | }; |
phonemacro | 0:77ee0ceb503a | 250 | |
phonemacro | 0:77ee0ceb503a | 251 | #endif /* _MAX8614X_H_ */ |