Elevator Altimeter
Fork of MPL3115A2 by
MPL3115A2.cpp@2:12223b4c88b1, 2017-08-23 (annotated)
- Committer:
- Rhyme
- Date:
- Wed Aug 23 12:37:18 2017 +0000
- Revision:
- 2:12223b4c88b1
- Parent:
- 1:6fdcf150410e
in getPressure(void) activate() and oneShot() was missing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:752c9dbed2fa | 1 | /* |
Rhyme | 0:752c9dbed2fa | 2 | * File description here |
Rhyme | 0:752c9dbed2fa | 3 | */ |
Rhyme | 0:752c9dbed2fa | 4 | #include "MPL3115A2.h" |
Rhyme | 0:752c9dbed2fa | 5 | |
Rhyme | 0:752c9dbed2fa | 6 | /* some definitions here */ |
Rhyme | 0:752c9dbed2fa | 7 | #define MPL_STATUS 0x00 |
Rhyme | 0:752c9dbed2fa | 8 | #define MPL_OUT_P_MSB 0x01 |
Rhyme | 0:752c9dbed2fa | 9 | #define MPL_OUT_P_CSB 0x02 |
Rhyme | 0:752c9dbed2fa | 10 | #define MPL_OUT_P_LSB 0x03 |
Rhyme | 0:752c9dbed2fa | 11 | #define MPL_OUT_T_MSB 0x04 |
Rhyme | 0:752c9dbed2fa | 12 | #define MPL_OUT_T_LSB 0x05 |
Rhyme | 0:752c9dbed2fa | 13 | #define MPL_DR_STATUS 0x06 |
Rhyme | 0:752c9dbed2fa | 14 | #define MPL_OUT_P_DELTA_MSB 0x07 |
Rhyme | 0:752c9dbed2fa | 15 | #define MPL_OUT_P_DELTA_CSB 0x08 |
Rhyme | 0:752c9dbed2fa | 16 | #define MPL_OUT_P_DELTA_LSB 0x09 |
Rhyme | 0:752c9dbed2fa | 17 | #define MPL_OUT_T_DELTA_MSB 0x0A |
Rhyme | 0:752c9dbed2fa | 18 | #define MPL_OUT_T_DELTA_LSB 0x0B |
Rhyme | 0:752c9dbed2fa | 19 | #define MPL_WHO_AM_I 0x0C |
Rhyme | 0:752c9dbed2fa | 20 | #define MPL_F_STATUS 0x0D |
Rhyme | 0:752c9dbed2fa | 21 | #define MPL_F_DATA 0x0E |
Rhyme | 0:752c9dbed2fa | 22 | #define MPL_F_SETUP 0x0F |
Rhyme | 0:752c9dbed2fa | 23 | #define MPL_TIME_DLY 0x10 |
Rhyme | 0:752c9dbed2fa | 24 | #define MPL_SYSMOD 0x11 |
Rhyme | 0:752c9dbed2fa | 25 | #define MPL_INT_SOURCE 0x12 |
Rhyme | 0:752c9dbed2fa | 26 | #define MPL_PT_DATA_CFG 0x13 |
Rhyme | 0:752c9dbed2fa | 27 | #define MPL_BAR_IN_MSB 0x14 |
Rhyme | 0:752c9dbed2fa | 28 | #define MPL_BAR_IN_LSB 0x15 |
Rhyme | 0:752c9dbed2fa | 29 | #define MPL_P_TGT_MSB 0x16 |
Rhyme | 0:752c9dbed2fa | 30 | #define MPL_P_TGT_LSB 0x17 |
Rhyme | 0:752c9dbed2fa | 31 | #define MPL_T_TGT 0x18 |
Rhyme | 0:752c9dbed2fa | 32 | #define MPL_P_WND_MSB 0x19 |
Rhyme | 0:752c9dbed2fa | 33 | #define MPL_P_WND_LSB 0x1A |
Rhyme | 0:752c9dbed2fa | 34 | #define MPL_T_WND 0x1B |
Rhyme | 0:752c9dbed2fa | 35 | #define MPL_P_MIN_MSB 0x1C |
Rhyme | 0:752c9dbed2fa | 36 | #define MPL_P_MIN_CSB 0x1D |
Rhyme | 0:752c9dbed2fa | 37 | #define MPL_P_MIN_LSB 0x1E |
Rhyme | 0:752c9dbed2fa | 38 | #define MPL_T_MIN_MSB 0x1F |
Rhyme | 0:752c9dbed2fa | 39 | #define MPL_T_MIN_LSB 0x20 |
Rhyme | 0:752c9dbed2fa | 40 | #define MPL_P_MAX_MSB 0x21 |
Rhyme | 0:752c9dbed2fa | 41 | #define MPL_P_MAX_CSB 0x22 |
Rhyme | 0:752c9dbed2fa | 42 | #define MPL_P_MAX_LSB 0x23 |
Rhyme | 0:752c9dbed2fa | 43 | #define MPL_T_MAX_MSB 0x24 |
Rhyme | 0:752c9dbed2fa | 44 | #define MPL_T_MAX_LSB 0x25 |
Rhyme | 0:752c9dbed2fa | 45 | #define MPL_CTRL_REG1 0x26 |
Rhyme | 0:752c9dbed2fa | 46 | #define MPL_CTRL_REG2 0x27 |
Rhyme | 0:752c9dbed2fa | 47 | #define MPL_CTRL_REG3 0x28 |
Rhyme | 0:752c9dbed2fa | 48 | #define MPL_CTRL_REG4 0x29 |
Rhyme | 0:752c9dbed2fa | 49 | #define MPL_CTRL_REG5 0x2A |
Rhyme | 0:752c9dbed2fa | 50 | #define MPL_OFF_P 0x2B |
Rhyme | 0:752c9dbed2fa | 51 | #define MPL_OFF_T 0x2C |
Rhyme | 0:752c9dbed2fa | 52 | #define MPL_OFF_H 0x2D |
Rhyme | 0:752c9dbed2fa | 53 | /* |
Rhyme | 0:752c9dbed2fa | 54 | * If F_MODE = 0, FIFO is disabled |
Rhyme | 0:752c9dbed2fa | 55 | * |
Rhyme | 0:752c9dbed2fa | 56 | * 0x00/0x06 Sensor Status Register (DR_STATUS) |
Rhyme | 0:752c9dbed2fa | 57 | * 0x01 Pressure Data Out MSB (OUT_P_MSB) |
Rhyme | 0:752c9dbed2fa | 58 | * 0x02 Pressure Data Out CSB (OUT_P_CSB) |
Rhyme | 0:752c9dbed2fa | 59 | * 0x03 Pressure Data Out LSB (OUT_P_LSB) |
Rhyme | 0:752c9dbed2fa | 60 | * 0x04 Temperature Data Out MSB (OUT_T_MSB) |
Rhyme | 0:752c9dbed2fa | 61 | * 0x05 Temperature Data out LSB (OUT_T_LSB) |
Rhyme | 0:752c9dbed2fa | 62 | * |
Rhyme | 0:752c9dbed2fa | 63 | * If F_Mode > 0, FIFO is circular buffer or full stop mode |
Rhyme | 0:752c9dbed2fa | 64 | * |
Rhyme | 0:752c9dbed2fa | 65 | * 0x00/0x0D Sensor Status Register (F_STATUS) |
Rhyme | 0:752c9dbed2fa | 66 | * 0x01 FIFO 8-bit Data Access (F_DATA) |
Rhyme | 0:752c9dbed2fa | 67 | * 0x02 Read to Reserved Area returns 00 |
Rhyme | 0:752c9dbed2fa | 68 | * 0x03 Read to Reserved Area returns 00 |
Rhyme | 0:752c9dbed2fa | 69 | * 0x04 Read to Reserved Area returns 00 |
Rhyme | 0:752c9dbed2fa | 70 | * 0x05 Read to Reserved Area returns 00 |
Rhyme | 0:752c9dbed2fa | 71 | * |
Rhyme | 0:752c9dbed2fa | 72 | * F_MODE = 00, FIFO is disabled |
Rhyme | 0:752c9dbed2fa | 73 | * F_MODE = 01, FIFO is circulated buffer |
Rhyme | 0:752c9dbed2fa | 74 | * F_MODE = 10, FIFO is full stop mode |
Rhyme | 0:752c9dbed2fa | 75 | */ |
Rhyme | 0:752c9dbed2fa | 76 | |
Rhyme | 0:752c9dbed2fa | 77 | |
Rhyme | 0:752c9dbed2fa | 78 | MPL3115A2::MPL3115A2(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr<<1) { |
Rhyme | 0:752c9dbed2fa | 79 | // activate the peripheral |
Rhyme | 1:6fdcf150410e | 80 | standby() ; |
Rhyme | 1:6fdcf150410e | 81 | setCTRL_REG1( 0x38 ) ; /* oversample 32 */ |
Rhyme | 1:6fdcf150410e | 82 | activate() ; |
Rhyme | 0:752c9dbed2fa | 83 | } |
Rhyme | 0:752c9dbed2fa | 84 | |
Rhyme | 0:752c9dbed2fa | 85 | MPL3115A2::~MPL3115A2() { } |
Rhyme | 0:752c9dbed2fa | 86 | |
Rhyme | 0:752c9dbed2fa | 87 | void MPL3115A2::readRegs(int addr, uint8_t * data, int len) { |
Rhyme | 0:752c9dbed2fa | 88 | char t[1] = {addr} ; |
Rhyme | 0:752c9dbed2fa | 89 | m_i2c.write(m_addr, t, 1, true) ; |
Rhyme | 0:752c9dbed2fa | 90 | m_i2c.read(m_addr, (char*)data, len) ; |
Rhyme | 0:752c9dbed2fa | 91 | } |
Rhyme | 0:752c9dbed2fa | 92 | |
Rhyme | 0:752c9dbed2fa | 93 | void MPL3115A2::writeRegs(uint8_t * data, int len) { |
Rhyme | 0:752c9dbed2fa | 94 | m_i2c.write(m_addr, (char *)data, len) ; |
Rhyme | 0:752c9dbed2fa | 95 | } |
Rhyme | 0:752c9dbed2fa | 96 | |
Rhyme | 0:752c9dbed2fa | 97 | uint8_t MPL3115A2::getStatus(void) { |
Rhyme | 0:752c9dbed2fa | 98 | uint8_t data[1] ; |
Rhyme | 0:752c9dbed2fa | 99 | readRegs(MPL_DR_STATUS, data, 1) ; |
Rhyme | 0:752c9dbed2fa | 100 | return( data[0] ) ; |
Rhyme | 0:752c9dbed2fa | 101 | } |
Rhyme | 0:752c9dbed2fa | 102 | |
Rhyme | 0:752c9dbed2fa | 103 | /* |
Rhyme | 0:752c9dbed2fa | 104 | * getAltitude returns the altitude in meters times 65536 |
Rhyme | 0:752c9dbed2fa | 105 | */ |
Rhyme | 1:6fdcf150410e | 106 | double MPL3115A2::getAltitude(void) |
Rhyme | 0:752c9dbed2fa | 107 | { |
Rhyme | 0:752c9dbed2fa | 108 | uint8_t tmp[3] ; |
Rhyme | 1:6fdcf150410e | 109 | uint16_t sample_time ; |
Rhyme | 1:6fdcf150410e | 110 | int32_t data ; |
Rhyme | 1:6fdcf150410e | 111 | |
Rhyme | 1:6fdcf150410e | 112 | standby() ; |
Rhyme | 1:6fdcf150410e | 113 | modeAlt() ; |
Rhyme | 1:6fdcf150410e | 114 | sample_time = getSampleTime() ; |
Rhyme | 1:6fdcf150410e | 115 | activate() ; |
Rhyme | 1:6fdcf150410e | 116 | oneShot() ; |
Rhyme | 1:6fdcf150410e | 117 | wait_ms(sample_time) ; |
Rhyme | 0:752c9dbed2fa | 118 | readRegs(MPL_OUT_P_MSB, tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 119 | data = (tmp[0]<<24)|(tmp[1]<<16)|(tmp[2]<<8) ; |
Rhyme | 1:6fdcf150410e | 120 | return( ((double)data)/65536.0 ) ; |
Rhyme | 0:752c9dbed2fa | 121 | } |
Rhyme | 0:752c9dbed2fa | 122 | |
Rhyme | 0:752c9dbed2fa | 123 | /* |
Rhyme | 0:752c9dbed2fa | 124 | * getPressure returns the pressure in Pascals times 64 |
Rhyme | 0:752c9dbed2fa | 125 | */ |
Rhyme | 1:6fdcf150410e | 126 | double MPL3115A2::getPressure(void) |
Rhyme | 0:752c9dbed2fa | 127 | { |
Rhyme | 0:752c9dbed2fa | 128 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 129 | uint32_t data ; |
Rhyme | 1:6fdcf150410e | 130 | uint16_t sample_time ; |
Rhyme | 1:6fdcf150410e | 131 | |
Rhyme | 1:6fdcf150410e | 132 | standby() ; |
Rhyme | 1:6fdcf150410e | 133 | modeBar() ; |
Rhyme | 1:6fdcf150410e | 134 | sample_time = getSampleTime() ; |
Rhyme | 2:12223b4c88b1 | 135 | activate() ; |
Rhyme | 2:12223b4c88b1 | 136 | oneShot() ; |
Rhyme | 1:6fdcf150410e | 137 | wait_ms(sample_time) ; |
Rhyme | 0:752c9dbed2fa | 138 | readRegs(MPL_OUT_P_MSB, tmp, 3) ; |
Rhyme | 1:6fdcf150410e | 139 | data = ((tmp[0]<<16)|(tmp[1]<<8)|(tmp[2])) >> 6 ; |
Rhyme | 1:6fdcf150410e | 140 | return(((double)data) / 100.0 ) ; |
Rhyme | 0:752c9dbed2fa | 141 | } |
Rhyme | 0:752c9dbed2fa | 142 | |
Rhyme | 0:752c9dbed2fa | 143 | /* |
Rhyme | 0:752c9dbed2fa | 144 | * getTemperature returns the temperature in c-degree times 256 |
Rhyme | 0:752c9dbed2fa | 145 | */ |
Rhyme | 1:6fdcf150410e | 146 | double MPL3115A2::getTemperature(void) |
Rhyme | 0:752c9dbed2fa | 147 | { |
Rhyme | 0:752c9dbed2fa | 148 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 149 | uint16_t data ; |
Rhyme | 0:752c9dbed2fa | 150 | |
Rhyme | 0:752c9dbed2fa | 151 | readRegs(MPL_OUT_T_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 152 | data = (tmp[0]<<8)|(tmp[1]) ; |
Rhyme | 1:6fdcf150410e | 153 | return( ((double)data)/256.0 ) ; |
Rhyme | 0:752c9dbed2fa | 154 | } |
Rhyme | 0:752c9dbed2fa | 155 | |
Rhyme | 0:752c9dbed2fa | 156 | /* |
Rhyme | 0:752c9dbed2fa | 157 | * getAltDelta returns delta of alt in meters times 65536 |
Rhyme | 0:752c9dbed2fa | 158 | */ |
Rhyme | 0:752c9dbed2fa | 159 | int32_t MPL3115A2::getAltDelta(void) |
Rhyme | 0:752c9dbed2fa | 160 | { |
Rhyme | 0:752c9dbed2fa | 161 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 162 | int32_t data ; |
Rhyme | 0:752c9dbed2fa | 163 | |
Rhyme | 0:752c9dbed2fa | 164 | readRegs(MPL_OUT_P_DELTA_MSB, tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 165 | data = (tmp[0]<<24)|(tmp[1]<<16)|((tmp[2]&0xF0)<<8) ; |
Rhyme | 0:752c9dbed2fa | 166 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 167 | } |
Rhyme | 0:752c9dbed2fa | 168 | |
Rhyme | 0:752c9dbed2fa | 169 | /* |
Rhyme | 0:752c9dbed2fa | 170 | * getPrsDelta returns delta of pressure in Pascal times 16 |
Rhyme | 0:752c9dbed2fa | 171 | */ |
Rhyme | 0:752c9dbed2fa | 172 | int32_t MPL3115A2::getPrsDelta(void) |
Rhyme | 0:752c9dbed2fa | 173 | { |
Rhyme | 0:752c9dbed2fa | 174 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 175 | int32_t data ; |
Rhyme | 0:752c9dbed2fa | 176 | |
Rhyme | 0:752c9dbed2fa | 177 | readRegs(MPL_OUT_P_DELTA_MSB, tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 178 | data = (tmp[0]<<24)|(tmp[1]<<16)|((tmp[2]&0xF0)<<8) ; |
Rhyme | 0:752c9dbed2fa | 179 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 180 | } |
Rhyme | 0:752c9dbed2fa | 181 | |
Rhyme | 0:752c9dbed2fa | 182 | /* |
Rhyme | 0:752c9dbed2fa | 183 | * getTempDelta returns delta of temperature in c-degree times 16 |
Rhyme | 0:752c9dbed2fa | 184 | */ |
Rhyme | 0:752c9dbed2fa | 185 | int16_t MPL3115A2::getTempDelta(void) |
Rhyme | 0:752c9dbed2fa | 186 | { |
Rhyme | 0:752c9dbed2fa | 187 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 188 | int16_t data ; |
Rhyme | 0:752c9dbed2fa | 189 | |
Rhyme | 0:752c9dbed2fa | 190 | readRegs(MPL_OUT_T_DELTA_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 191 | data = (tmp[0]<<8) | (tmp[1]&0xF0) ; |
Rhyme | 0:752c9dbed2fa | 192 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 193 | } |
Rhyme | 0:752c9dbed2fa | 194 | |
Rhyme | 0:752c9dbed2fa | 195 | uint8_t MPL3115A2::getID(void) |
Rhyme | 0:752c9dbed2fa | 196 | { |
Rhyme | 0:752c9dbed2fa | 197 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 198 | readRegs(MPL_WHO_AM_I, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 199 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 200 | } |
Rhyme | 0:752c9dbed2fa | 201 | |
Rhyme | 0:752c9dbed2fa | 202 | uint8_t MPL3115A2::getFstatus(void) |
Rhyme | 0:752c9dbed2fa | 203 | { |
Rhyme | 0:752c9dbed2fa | 204 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 205 | readRegs(MPL_F_STATUS, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 206 | return(tmp[0]) ; |
Rhyme | 0:752c9dbed2fa | 207 | } |
Rhyme | 0:752c9dbed2fa | 208 | |
Rhyme | 0:752c9dbed2fa | 209 | uint8_t MPL3115A2::getFdata(void) |
Rhyme | 0:752c9dbed2fa | 210 | { |
Rhyme | 0:752c9dbed2fa | 211 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 212 | readRegs(MPL_F_DATA, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 213 | return(tmp[0]) ; |
Rhyme | 0:752c9dbed2fa | 214 | } |
Rhyme | 0:752c9dbed2fa | 215 | |
Rhyme | 0:752c9dbed2fa | 216 | uint8_t MPL3115A2::getFsetup(void) |
Rhyme | 0:752c9dbed2fa | 217 | { |
Rhyme | 0:752c9dbed2fa | 218 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 219 | readRegs(MPL_F_SETUP, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 220 | return(tmp[0]) ; |
Rhyme | 0:752c9dbed2fa | 221 | } |
Rhyme | 0:752c9dbed2fa | 222 | |
Rhyme | 0:752c9dbed2fa | 223 | void MPL3115A2::setFsetup(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 224 | { |
Rhyme | 0:752c9dbed2fa | 225 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 226 | tmp[0] = MPL_F_SETUP ; |
Rhyme | 0:752c9dbed2fa | 227 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 228 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 229 | } |
Rhyme | 0:752c9dbed2fa | 230 | |
Rhyme | 0:752c9dbed2fa | 231 | uint8_t MPL3115A2::getTimeDelay(void) |
Rhyme | 0:752c9dbed2fa | 232 | { |
Rhyme | 0:752c9dbed2fa | 233 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 234 | readRegs(MPL_TIME_DLY, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 235 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 236 | } |
Rhyme | 0:752c9dbed2fa | 237 | |
Rhyme | 0:752c9dbed2fa | 238 | uint8_t MPL3115A2::getSysMod(void) |
Rhyme | 0:752c9dbed2fa | 239 | { |
Rhyme | 0:752c9dbed2fa | 240 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 241 | readRegs(MPL_SYSMOD, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 242 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 243 | } |
Rhyme | 0:752c9dbed2fa | 244 | |
Rhyme | 0:752c9dbed2fa | 245 | uint8_t MPL3115A2::getIntSource(void) |
Rhyme | 0:752c9dbed2fa | 246 | { |
Rhyme | 0:752c9dbed2fa | 247 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 248 | readRegs(MPL_INT_SOURCE, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 249 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 250 | } |
Rhyme | 0:752c9dbed2fa | 251 | |
Rhyme | 0:752c9dbed2fa | 252 | uint8_t MPL3115A2::getPtDataConfig(void) |
Rhyme | 0:752c9dbed2fa | 253 | { |
Rhyme | 0:752c9dbed2fa | 254 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 255 | readRegs(MPL_PT_DATA_CFG, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 256 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 257 | } |
Rhyme | 0:752c9dbed2fa | 258 | |
Rhyme | 0:752c9dbed2fa | 259 | void MPL3115A2::setPtDataConfig(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 260 | { |
Rhyme | 0:752c9dbed2fa | 261 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 262 | tmp[0] = MPL_PT_DATA_CFG ; |
Rhyme | 0:752c9dbed2fa | 263 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 264 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 265 | } |
Rhyme | 0:752c9dbed2fa | 266 | |
Rhyme | 0:752c9dbed2fa | 267 | uint16_t MPL3115A2::getBarIn(void) |
Rhyme | 0:752c9dbed2fa | 268 | { |
Rhyme | 0:752c9dbed2fa | 269 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 270 | readRegs(MPL_BAR_IN_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 271 | return( (uint16_t)tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 272 | } |
Rhyme | 0:752c9dbed2fa | 273 | |
Rhyme | 0:752c9dbed2fa | 274 | void MPL3115A2::setBarIn(uint16_t data) |
Rhyme | 0:752c9dbed2fa | 275 | { |
Rhyme | 0:752c9dbed2fa | 276 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 277 | tmp[0] = MPL_BAR_IN_MSB ; |
Rhyme | 0:752c9dbed2fa | 278 | tmp[1] = (data >> 8)&0xFF ; |
Rhyme | 0:752c9dbed2fa | 279 | tmp[2] = data & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 280 | writeRegs(tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 281 | } |
Rhyme | 0:752c9dbed2fa | 282 | |
Rhyme | 0:752c9dbed2fa | 283 | int16_t MPL3115A2::getP_TGT(void) |
Rhyme | 0:752c9dbed2fa | 284 | { |
Rhyme | 0:752c9dbed2fa | 285 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 286 | int16_t data ; |
Rhyme | 0:752c9dbed2fa | 287 | readRegs(MPL_P_TGT_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 288 | data = (tmp[0] << 8) | tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 289 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 290 | } |
Rhyme | 0:752c9dbed2fa | 291 | |
Rhyme | 0:752c9dbed2fa | 292 | void MPL3115A2::setP_TGT(int16_t data) |
Rhyme | 0:752c9dbed2fa | 293 | { |
Rhyme | 0:752c9dbed2fa | 294 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 295 | tmp[0] = MPL_P_TGT_MSB ; |
Rhyme | 0:752c9dbed2fa | 296 | tmp[1] = (data >> 8) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 297 | tmp[2] = data & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 298 | writeRegs(tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 299 | } |
Rhyme | 0:752c9dbed2fa | 300 | |
Rhyme | 0:752c9dbed2fa | 301 | int8_t MPL3115A2::getT_TGT(void) |
Rhyme | 0:752c9dbed2fa | 302 | { |
Rhyme | 0:752c9dbed2fa | 303 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 304 | readRegs(MPL_T_TGT, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 305 | return( (int8_t)tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 306 | } |
Rhyme | 0:752c9dbed2fa | 307 | |
Rhyme | 0:752c9dbed2fa | 308 | void MPL3115A2::setT_TGT(int8_t data) |
Rhyme | 0:752c9dbed2fa | 309 | { |
Rhyme | 0:752c9dbed2fa | 310 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 311 | tmp[0] = MPL_PT_DATA_CFG ; |
Rhyme | 0:752c9dbed2fa | 312 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 313 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 314 | } |
Rhyme | 0:752c9dbed2fa | 315 | |
Rhyme | 0:752c9dbed2fa | 316 | uint16_t MPL3115A2::getP_WND(void) |
Rhyme | 0:752c9dbed2fa | 317 | { |
Rhyme | 0:752c9dbed2fa | 318 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 319 | uint16_t data ; |
Rhyme | 0:752c9dbed2fa | 320 | readRegs(MPL_P_WND_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 321 | data = (tmp[0]<<8) | tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 322 | return(data) ; |
Rhyme | 0:752c9dbed2fa | 323 | } |
Rhyme | 0:752c9dbed2fa | 324 | |
Rhyme | 0:752c9dbed2fa | 325 | void MPL3115A2::setP_WND(uint16_t data) |
Rhyme | 0:752c9dbed2fa | 326 | { |
Rhyme | 0:752c9dbed2fa | 327 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 328 | tmp[0] = MPL_P_WND_MSB ; |
Rhyme | 0:752c9dbed2fa | 329 | tmp[1] = (data >> 8)&0xFF ; |
Rhyme | 0:752c9dbed2fa | 330 | tmp[2] = data & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 331 | writeRegs(tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 332 | } |
Rhyme | 0:752c9dbed2fa | 333 | |
Rhyme | 0:752c9dbed2fa | 334 | uint8_t MPL3115A2::getT_WND(void) |
Rhyme | 0:752c9dbed2fa | 335 | { |
Rhyme | 0:752c9dbed2fa | 336 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 337 | readRegs(MPL_T_WND, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 338 | return(tmp[0]) ; |
Rhyme | 0:752c9dbed2fa | 339 | } |
Rhyme | 0:752c9dbed2fa | 340 | |
Rhyme | 0:752c9dbed2fa | 341 | void MPL3115A2::setT_WND(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 342 | { |
Rhyme | 0:752c9dbed2fa | 343 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 344 | tmp[0] = MPL_T_WND ; |
Rhyme | 0:752c9dbed2fa | 345 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 346 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 347 | } |
Rhyme | 0:752c9dbed2fa | 348 | |
Rhyme | 0:752c9dbed2fa | 349 | int32_t MPL3115A2::getP_MIN(void) |
Rhyme | 0:752c9dbed2fa | 350 | { |
Rhyme | 0:752c9dbed2fa | 351 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 352 | int32_t data ; |
Rhyme | 0:752c9dbed2fa | 353 | readRegs(MPL_P_MIN_MSB, tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 354 | data = (tmp[0]<<24)|(tmp[1]<<16)|((tmp[2]&0xF0)<<8) ; |
Rhyme | 0:752c9dbed2fa | 355 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 356 | } |
Rhyme | 0:752c9dbed2fa | 357 | |
Rhyme | 0:752c9dbed2fa | 358 | void MPL3115A2::setT_MIN(int32_t data) |
Rhyme | 0:752c9dbed2fa | 359 | { |
Rhyme | 0:752c9dbed2fa | 360 | uint8_t tmp[4] ; |
Rhyme | 0:752c9dbed2fa | 361 | tmp[0] = MPL_P_MIN_MSB ; |
Rhyme | 0:752c9dbed2fa | 362 | tmp[1] = (data >> 24) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 363 | tmp[2] = (data >> 16) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 364 | tmp[3] = (data >> 8) & 0xF0 ; |
Rhyme | 0:752c9dbed2fa | 365 | writeRegs(tmp, 4) ; |
Rhyme | 0:752c9dbed2fa | 366 | } |
Rhyme | 0:752c9dbed2fa | 367 | |
Rhyme | 0:752c9dbed2fa | 368 | int32_t MPL3115A2::getP_MAX(void) |
Rhyme | 0:752c9dbed2fa | 369 | { |
Rhyme | 0:752c9dbed2fa | 370 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 371 | int32_t data ; |
Rhyme | 0:752c9dbed2fa | 372 | readRegs(MPL_P_MAX_MSB, tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 373 | data = (tmp[0]<<24)|(tmp[1]<<16)|((tmp[2]&0xF0)<<8) ; |
Rhyme | 0:752c9dbed2fa | 374 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 375 | } |
Rhyme | 0:752c9dbed2fa | 376 | |
Rhyme | 0:752c9dbed2fa | 377 | void MPL3115A2::setP_MAX(int32_t data) |
Rhyme | 0:752c9dbed2fa | 378 | { |
Rhyme | 0:752c9dbed2fa | 379 | uint8_t tmp[4] ; |
Rhyme | 0:752c9dbed2fa | 380 | tmp[0] = MPL_P_MAX_MSB ; |
Rhyme | 0:752c9dbed2fa | 381 | tmp[1] = (data >> 24) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 382 | tmp[2] = (data >> 16) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 383 | tmp[3] = (data >> 8) & 0xF0 ; |
Rhyme | 0:752c9dbed2fa | 384 | writeRegs(tmp, 4) ; |
Rhyme | 0:752c9dbed2fa | 385 | } |
Rhyme | 0:752c9dbed2fa | 386 | |
Rhyme | 0:752c9dbed2fa | 387 | int16_t MPL3115A2::getT_MIN(void) |
Rhyme | 0:752c9dbed2fa | 388 | { |
Rhyme | 0:752c9dbed2fa | 389 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 390 | uint16_t data ; |
Rhyme | 0:752c9dbed2fa | 391 | readRegs(MPL_T_MIN_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 392 | data = (tmp[0]<<8) | tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 393 | return(data) ; |
Rhyme | 0:752c9dbed2fa | 394 | } |
Rhyme | 0:752c9dbed2fa | 395 | |
Rhyme | 0:752c9dbed2fa | 396 | void MPL3115A2::setT_MIN(int16_t data) |
Rhyme | 0:752c9dbed2fa | 397 | { |
Rhyme | 0:752c9dbed2fa | 398 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 399 | tmp[0] = MPL_T_MIN_MSB ; |
Rhyme | 0:752c9dbed2fa | 400 | tmp[1] = (data >> 8) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 401 | tmp[2] = data & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 402 | writeRegs(tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 403 | } |
Rhyme | 0:752c9dbed2fa | 404 | |
Rhyme | 0:752c9dbed2fa | 405 | int16_t MPL3115A2::getT_MAX(void) |
Rhyme | 0:752c9dbed2fa | 406 | { |
Rhyme | 0:752c9dbed2fa | 407 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 408 | uint16_t data ; |
Rhyme | 0:752c9dbed2fa | 409 | readRegs(MPL_T_MAX_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 410 | data = (tmp[0]<<8) | tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 411 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 412 | } |
Rhyme | 0:752c9dbed2fa | 413 | |
Rhyme | 0:752c9dbed2fa | 414 | void MPL3115A2::setT_MAX(int16_t data) |
Rhyme | 0:752c9dbed2fa | 415 | { |
Rhyme | 0:752c9dbed2fa | 416 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 417 | tmp[0] = MPL_T_MAX_MSB ; |
Rhyme | 0:752c9dbed2fa | 418 | tmp[1] = (data >> 8) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 419 | tmp[2] = data & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 420 | writeRegs(tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 421 | } |
Rhyme | 0:752c9dbed2fa | 422 | |
Rhyme | 0:752c9dbed2fa | 423 | uint8_t MPL3115A2::getCTRL_REG1(void) |
Rhyme | 0:752c9dbed2fa | 424 | { |
Rhyme | 0:752c9dbed2fa | 425 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 426 | readRegs(MPL_CTRL_REG1, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 427 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 428 | } |
Rhyme | 0:752c9dbed2fa | 429 | |
Rhyme | 0:752c9dbed2fa | 430 | void MPL3115A2::setCTRL_REG1(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 431 | { |
Rhyme | 0:752c9dbed2fa | 432 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 433 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 434 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 435 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 436 | } |
Rhyme | 0:752c9dbed2fa | 437 | |
Rhyme | 0:752c9dbed2fa | 438 | uint8_t MPL3115A2::getCTRL_REG2(void) |
Rhyme | 0:752c9dbed2fa | 439 | { |
Rhyme | 0:752c9dbed2fa | 440 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 441 | readRegs(MPL_CTRL_REG2, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 442 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 443 | } |
Rhyme | 0:752c9dbed2fa | 444 | |
Rhyme | 0:752c9dbed2fa | 445 | void MPL3115A2::setCTRL_REG2(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 446 | { |
Rhyme | 0:752c9dbed2fa | 447 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 448 | tmp[0] = MPL_CTRL_REG2 ; |
Rhyme | 0:752c9dbed2fa | 449 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 450 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 451 | } |
Rhyme | 0:752c9dbed2fa | 452 | |
Rhyme | 0:752c9dbed2fa | 453 | uint8_t MPL3115A2::getCTRL_REG3(void) |
Rhyme | 0:752c9dbed2fa | 454 | { |
Rhyme | 0:752c9dbed2fa | 455 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 456 | readRegs(MPL_CTRL_REG3, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 457 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 458 | } |
Rhyme | 0:752c9dbed2fa | 459 | |
Rhyme | 0:752c9dbed2fa | 460 | void MPL3115A2::setCTRL_REG3(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 461 | { |
Rhyme | 0:752c9dbed2fa | 462 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 463 | tmp[0] = MPL_CTRL_REG3 ; |
Rhyme | 0:752c9dbed2fa | 464 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 465 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 466 | } |
Rhyme | 0:752c9dbed2fa | 467 | |
Rhyme | 0:752c9dbed2fa | 468 | uint8_t MPL3115A2::getCTRL_REG4(void) |
Rhyme | 0:752c9dbed2fa | 469 | { |
Rhyme | 0:752c9dbed2fa | 470 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 471 | readRegs(MPL_CTRL_REG4, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 472 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 473 | } |
Rhyme | 0:752c9dbed2fa | 474 | |
Rhyme | 0:752c9dbed2fa | 475 | void MPL3115A2::setCTRL_REG4(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 476 | { |
Rhyme | 0:752c9dbed2fa | 477 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 478 | tmp[0] = MPL_CTRL_REG4 ; |
Rhyme | 0:752c9dbed2fa | 479 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 480 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 481 | } |
Rhyme | 0:752c9dbed2fa | 482 | |
Rhyme | 0:752c9dbed2fa | 483 | uint8_t MPL3115A2::getCTRL_REG5(void) |
Rhyme | 0:752c9dbed2fa | 484 | { |
Rhyme | 0:752c9dbed2fa | 485 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 486 | readRegs(MPL_CTRL_REG5, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 487 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 488 | } |
Rhyme | 0:752c9dbed2fa | 489 | |
Rhyme | 0:752c9dbed2fa | 490 | void MPL3115A2::setCTRL_REG5(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 491 | { |
Rhyme | 0:752c9dbed2fa | 492 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 493 | tmp[0] = MPL_CTRL_REG5 ; |
Rhyme | 0:752c9dbed2fa | 494 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 495 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 496 | } |
Rhyme | 0:752c9dbed2fa | 497 | |
Rhyme | 1:6fdcf150410e | 498 | void MPL3115A2::oneShot(void) |
Rhyme | 1:6fdcf150410e | 499 | { |
Rhyme | 1:6fdcf150410e | 500 | uint8_t tmp[2] ; |
Rhyme | 1:6fdcf150410e | 501 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 1:6fdcf150410e | 502 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 1:6fdcf150410e | 503 | tmp[1] &= 0xFD ; /* clear OST */ |
Rhyme | 1:6fdcf150410e | 504 | writeRegs(tmp, 2) ; |
Rhyme | 1:6fdcf150410e | 505 | tmp[1] |= 0x02 ; /* set OST */ |
Rhyme | 1:6fdcf150410e | 506 | writeRegs(tmp, 2) ; |
Rhyme | 1:6fdcf150410e | 507 | } |
Rhyme | 1:6fdcf150410e | 508 | |
Rhyme | 1:6fdcf150410e | 509 | uint16_t MPL3115A2::getSampleTime(void) |
Rhyme | 0:752c9dbed2fa | 510 | { |
Rhyme | 0:752c9dbed2fa | 511 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 512 | uint16_t sample_time = 6 ; |
Rhyme | 0:752c9dbed2fa | 513 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 514 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 0:752c9dbed2fa | 515 | tmp[1] |= 0x02 ; |
Rhyme | 0:752c9dbed2fa | 516 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 517 | switch((tmp[1]>>3)&0x07) { |
Rhyme | 0:752c9dbed2fa | 518 | case 0: sample_time = 6 ; break ; |
Rhyme | 0:752c9dbed2fa | 519 | case 1: sample_time = 10 ; break ; |
Rhyme | 0:752c9dbed2fa | 520 | case 2: sample_time = 18 ; break ; |
Rhyme | 0:752c9dbed2fa | 521 | case 3: sample_time = 34 ; break ; |
Rhyme | 0:752c9dbed2fa | 522 | case 4: sample_time = 66 ; break ; |
Rhyme | 0:752c9dbed2fa | 523 | case 5: sample_time = 130 ; break ; |
Rhyme | 0:752c9dbed2fa | 524 | case 6: sample_time = 258 ; break ; |
Rhyme | 0:752c9dbed2fa | 525 | case 7: sample_time = 512 ; break ; |
Rhyme | 0:752c9dbed2fa | 526 | default: sample_time = 6 ; break ; |
Rhyme | 0:752c9dbed2fa | 527 | } |
Rhyme | 0:752c9dbed2fa | 528 | return( sample_time ) ; |
Rhyme | 0:752c9dbed2fa | 529 | } |
Rhyme | 0:752c9dbed2fa | 530 | |
Rhyme | 0:752c9dbed2fa | 531 | void MPL3115A2::standby(void) |
Rhyme | 0:752c9dbed2fa | 532 | { |
Rhyme | 0:752c9dbed2fa | 533 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 534 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 535 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 0:752c9dbed2fa | 536 | tmp[1] &= 0xFE ; |
Rhyme | 0:752c9dbed2fa | 537 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 538 | } |
Rhyme | 0:752c9dbed2fa | 539 | |
Rhyme | 0:752c9dbed2fa | 540 | void MPL3115A2::activate(void) |
Rhyme | 0:752c9dbed2fa | 541 | { |
Rhyme | 0:752c9dbed2fa | 542 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 543 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 544 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 0:752c9dbed2fa | 545 | tmp[1] |= 0x01 ; |
Rhyme | 0:752c9dbed2fa | 546 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 547 | } |
Rhyme | 0:752c9dbed2fa | 548 | |
Rhyme | 0:752c9dbed2fa | 549 | void MPL3115A2::modeAlt(void) |
Rhyme | 0:752c9dbed2fa | 550 | { |
Rhyme | 0:752c9dbed2fa | 551 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 552 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 553 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 0:752c9dbed2fa | 554 | tmp[1] |= 0x80 ; |
Rhyme | 0:752c9dbed2fa | 555 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 556 | } |
Rhyme | 0:752c9dbed2fa | 557 | |
Rhyme | 0:752c9dbed2fa | 558 | void MPL3115A2::modeBar(void) |
Rhyme | 0:752c9dbed2fa | 559 | { |
Rhyme | 0:752c9dbed2fa | 560 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 561 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 562 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 0:752c9dbed2fa | 563 | tmp[1] &= 0x7F ; |
Rhyme | 0:752c9dbed2fa | 564 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 565 | } |