MPL3115A2 Fork
Fork of MPL3115A2 by
MPL3115A2.cpp@1:6fdcf150410e, 2017-05-18 (annotated)
- Committer:
- Rhyme
- Date:
- Thu May 18 06:30:44 2017 +0000
- Revision:
- 1:6fdcf150410e
- Parent:
- 0:752c9dbed2fa
- Child:
- 2:12223b4c88b1
getAlt. getPres. getTemp. now return double values, as m, hPa, and C
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 | 1:6fdcf150410e | 135 | wait_ms(sample_time) ; |
Rhyme | 0:752c9dbed2fa | 136 | readRegs(MPL_OUT_P_MSB, tmp, 3) ; |
Rhyme | 1:6fdcf150410e | 137 | data = ((tmp[0]<<16)|(tmp[1]<<8)|(tmp[2])) >> 6 ; |
Rhyme | 1:6fdcf150410e | 138 | return(((double)data) / 100.0 ) ; |
Rhyme | 0:752c9dbed2fa | 139 | } |
Rhyme | 0:752c9dbed2fa | 140 | |
Rhyme | 0:752c9dbed2fa | 141 | /* |
Rhyme | 0:752c9dbed2fa | 142 | * getTemperature returns the temperature in c-degree times 256 |
Rhyme | 0:752c9dbed2fa | 143 | */ |
Rhyme | 1:6fdcf150410e | 144 | double MPL3115A2::getTemperature(void) |
Rhyme | 0:752c9dbed2fa | 145 | { |
Rhyme | 0:752c9dbed2fa | 146 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 147 | uint16_t data ; |
Rhyme | 0:752c9dbed2fa | 148 | |
Rhyme | 0:752c9dbed2fa | 149 | readRegs(MPL_OUT_T_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 150 | data = (tmp[0]<<8)|(tmp[1]) ; |
Rhyme | 1:6fdcf150410e | 151 | return( ((double)data)/256.0 ) ; |
Rhyme | 0:752c9dbed2fa | 152 | } |
Rhyme | 0:752c9dbed2fa | 153 | |
Rhyme | 0:752c9dbed2fa | 154 | /* |
Rhyme | 0:752c9dbed2fa | 155 | * getAltDelta returns delta of alt in meters times 65536 |
Rhyme | 0:752c9dbed2fa | 156 | */ |
Rhyme | 0:752c9dbed2fa | 157 | int32_t MPL3115A2::getAltDelta(void) |
Rhyme | 0:752c9dbed2fa | 158 | { |
Rhyme | 0:752c9dbed2fa | 159 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 160 | int32_t data ; |
Rhyme | 0:752c9dbed2fa | 161 | |
Rhyme | 0:752c9dbed2fa | 162 | readRegs(MPL_OUT_P_DELTA_MSB, tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 163 | data = (tmp[0]<<24)|(tmp[1]<<16)|((tmp[2]&0xF0)<<8) ; |
Rhyme | 0:752c9dbed2fa | 164 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 165 | } |
Rhyme | 0:752c9dbed2fa | 166 | |
Rhyme | 0:752c9dbed2fa | 167 | /* |
Rhyme | 0:752c9dbed2fa | 168 | * getPrsDelta returns delta of pressure in Pascal times 16 |
Rhyme | 0:752c9dbed2fa | 169 | */ |
Rhyme | 0:752c9dbed2fa | 170 | int32_t MPL3115A2::getPrsDelta(void) |
Rhyme | 0:752c9dbed2fa | 171 | { |
Rhyme | 0:752c9dbed2fa | 172 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 173 | int32_t data ; |
Rhyme | 0:752c9dbed2fa | 174 | |
Rhyme | 0:752c9dbed2fa | 175 | readRegs(MPL_OUT_P_DELTA_MSB, tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 176 | data = (tmp[0]<<24)|(tmp[1]<<16)|((tmp[2]&0xF0)<<8) ; |
Rhyme | 0:752c9dbed2fa | 177 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 178 | } |
Rhyme | 0:752c9dbed2fa | 179 | |
Rhyme | 0:752c9dbed2fa | 180 | /* |
Rhyme | 0:752c9dbed2fa | 181 | * getTempDelta returns delta of temperature in c-degree times 16 |
Rhyme | 0:752c9dbed2fa | 182 | */ |
Rhyme | 0:752c9dbed2fa | 183 | int16_t MPL3115A2::getTempDelta(void) |
Rhyme | 0:752c9dbed2fa | 184 | { |
Rhyme | 0:752c9dbed2fa | 185 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 186 | int16_t data ; |
Rhyme | 0:752c9dbed2fa | 187 | |
Rhyme | 0:752c9dbed2fa | 188 | readRegs(MPL_OUT_T_DELTA_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 189 | data = (tmp[0]<<8) | (tmp[1]&0xF0) ; |
Rhyme | 0:752c9dbed2fa | 190 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 191 | } |
Rhyme | 0:752c9dbed2fa | 192 | |
Rhyme | 0:752c9dbed2fa | 193 | uint8_t MPL3115A2::getID(void) |
Rhyme | 0:752c9dbed2fa | 194 | { |
Rhyme | 0:752c9dbed2fa | 195 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 196 | readRegs(MPL_WHO_AM_I, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 197 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 198 | } |
Rhyme | 0:752c9dbed2fa | 199 | |
Rhyme | 0:752c9dbed2fa | 200 | uint8_t MPL3115A2::getFstatus(void) |
Rhyme | 0:752c9dbed2fa | 201 | { |
Rhyme | 0:752c9dbed2fa | 202 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 203 | readRegs(MPL_F_STATUS, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 204 | return(tmp[0]) ; |
Rhyme | 0:752c9dbed2fa | 205 | } |
Rhyme | 0:752c9dbed2fa | 206 | |
Rhyme | 0:752c9dbed2fa | 207 | uint8_t MPL3115A2::getFdata(void) |
Rhyme | 0:752c9dbed2fa | 208 | { |
Rhyme | 0:752c9dbed2fa | 209 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 210 | readRegs(MPL_F_DATA, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 211 | return(tmp[0]) ; |
Rhyme | 0:752c9dbed2fa | 212 | } |
Rhyme | 0:752c9dbed2fa | 213 | |
Rhyme | 0:752c9dbed2fa | 214 | uint8_t MPL3115A2::getFsetup(void) |
Rhyme | 0:752c9dbed2fa | 215 | { |
Rhyme | 0:752c9dbed2fa | 216 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 217 | readRegs(MPL_F_SETUP, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 218 | return(tmp[0]) ; |
Rhyme | 0:752c9dbed2fa | 219 | } |
Rhyme | 0:752c9dbed2fa | 220 | |
Rhyme | 0:752c9dbed2fa | 221 | void MPL3115A2::setFsetup(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 222 | { |
Rhyme | 0:752c9dbed2fa | 223 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 224 | tmp[0] = MPL_F_SETUP ; |
Rhyme | 0:752c9dbed2fa | 225 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 226 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 227 | } |
Rhyme | 0:752c9dbed2fa | 228 | |
Rhyme | 0:752c9dbed2fa | 229 | uint8_t MPL3115A2::getTimeDelay(void) |
Rhyme | 0:752c9dbed2fa | 230 | { |
Rhyme | 0:752c9dbed2fa | 231 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 232 | readRegs(MPL_TIME_DLY, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 233 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 234 | } |
Rhyme | 0:752c9dbed2fa | 235 | |
Rhyme | 0:752c9dbed2fa | 236 | uint8_t MPL3115A2::getSysMod(void) |
Rhyme | 0:752c9dbed2fa | 237 | { |
Rhyme | 0:752c9dbed2fa | 238 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 239 | readRegs(MPL_SYSMOD, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 240 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 241 | } |
Rhyme | 0:752c9dbed2fa | 242 | |
Rhyme | 0:752c9dbed2fa | 243 | uint8_t MPL3115A2::getIntSource(void) |
Rhyme | 0:752c9dbed2fa | 244 | { |
Rhyme | 0:752c9dbed2fa | 245 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 246 | readRegs(MPL_INT_SOURCE, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 247 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 248 | } |
Rhyme | 0:752c9dbed2fa | 249 | |
Rhyme | 0:752c9dbed2fa | 250 | uint8_t MPL3115A2::getPtDataConfig(void) |
Rhyme | 0:752c9dbed2fa | 251 | { |
Rhyme | 0:752c9dbed2fa | 252 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 253 | readRegs(MPL_PT_DATA_CFG, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 254 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 255 | } |
Rhyme | 0:752c9dbed2fa | 256 | |
Rhyme | 0:752c9dbed2fa | 257 | void MPL3115A2::setPtDataConfig(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 258 | { |
Rhyme | 0:752c9dbed2fa | 259 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 260 | tmp[0] = MPL_PT_DATA_CFG ; |
Rhyme | 0:752c9dbed2fa | 261 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 262 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 263 | } |
Rhyme | 0:752c9dbed2fa | 264 | |
Rhyme | 0:752c9dbed2fa | 265 | uint16_t MPL3115A2::getBarIn(void) |
Rhyme | 0:752c9dbed2fa | 266 | { |
Rhyme | 0:752c9dbed2fa | 267 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 268 | readRegs(MPL_BAR_IN_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 269 | return( (uint16_t)tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 270 | } |
Rhyme | 0:752c9dbed2fa | 271 | |
Rhyme | 0:752c9dbed2fa | 272 | void MPL3115A2::setBarIn(uint16_t data) |
Rhyme | 0:752c9dbed2fa | 273 | { |
Rhyme | 0:752c9dbed2fa | 274 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 275 | tmp[0] = MPL_BAR_IN_MSB ; |
Rhyme | 0:752c9dbed2fa | 276 | tmp[1] = (data >> 8)&0xFF ; |
Rhyme | 0:752c9dbed2fa | 277 | tmp[2] = data & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 278 | writeRegs(tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 279 | } |
Rhyme | 0:752c9dbed2fa | 280 | |
Rhyme | 0:752c9dbed2fa | 281 | int16_t MPL3115A2::getP_TGT(void) |
Rhyme | 0:752c9dbed2fa | 282 | { |
Rhyme | 0:752c9dbed2fa | 283 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 284 | int16_t data ; |
Rhyme | 0:752c9dbed2fa | 285 | readRegs(MPL_P_TGT_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 286 | data = (tmp[0] << 8) | tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 287 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 288 | } |
Rhyme | 0:752c9dbed2fa | 289 | |
Rhyme | 0:752c9dbed2fa | 290 | void MPL3115A2::setP_TGT(int16_t data) |
Rhyme | 0:752c9dbed2fa | 291 | { |
Rhyme | 0:752c9dbed2fa | 292 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 293 | tmp[0] = MPL_P_TGT_MSB ; |
Rhyme | 0:752c9dbed2fa | 294 | tmp[1] = (data >> 8) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 295 | tmp[2] = data & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 296 | writeRegs(tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 297 | } |
Rhyme | 0:752c9dbed2fa | 298 | |
Rhyme | 0:752c9dbed2fa | 299 | int8_t MPL3115A2::getT_TGT(void) |
Rhyme | 0:752c9dbed2fa | 300 | { |
Rhyme | 0:752c9dbed2fa | 301 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 302 | readRegs(MPL_T_TGT, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 303 | return( (int8_t)tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 304 | } |
Rhyme | 0:752c9dbed2fa | 305 | |
Rhyme | 0:752c9dbed2fa | 306 | void MPL3115A2::setT_TGT(int8_t data) |
Rhyme | 0:752c9dbed2fa | 307 | { |
Rhyme | 0:752c9dbed2fa | 308 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 309 | tmp[0] = MPL_PT_DATA_CFG ; |
Rhyme | 0:752c9dbed2fa | 310 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 311 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 312 | } |
Rhyme | 0:752c9dbed2fa | 313 | |
Rhyme | 0:752c9dbed2fa | 314 | uint16_t MPL3115A2::getP_WND(void) |
Rhyme | 0:752c9dbed2fa | 315 | { |
Rhyme | 0:752c9dbed2fa | 316 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 317 | uint16_t data ; |
Rhyme | 0:752c9dbed2fa | 318 | readRegs(MPL_P_WND_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 319 | data = (tmp[0]<<8) | tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 320 | return(data) ; |
Rhyme | 0:752c9dbed2fa | 321 | } |
Rhyme | 0:752c9dbed2fa | 322 | |
Rhyme | 0:752c9dbed2fa | 323 | void MPL3115A2::setP_WND(uint16_t data) |
Rhyme | 0:752c9dbed2fa | 324 | { |
Rhyme | 0:752c9dbed2fa | 325 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 326 | tmp[0] = MPL_P_WND_MSB ; |
Rhyme | 0:752c9dbed2fa | 327 | tmp[1] = (data >> 8)&0xFF ; |
Rhyme | 0:752c9dbed2fa | 328 | tmp[2] = data & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 329 | writeRegs(tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 330 | } |
Rhyme | 0:752c9dbed2fa | 331 | |
Rhyme | 0:752c9dbed2fa | 332 | uint8_t MPL3115A2::getT_WND(void) |
Rhyme | 0:752c9dbed2fa | 333 | { |
Rhyme | 0:752c9dbed2fa | 334 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 335 | readRegs(MPL_T_WND, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 336 | return(tmp[0]) ; |
Rhyme | 0:752c9dbed2fa | 337 | } |
Rhyme | 0:752c9dbed2fa | 338 | |
Rhyme | 0:752c9dbed2fa | 339 | void MPL3115A2::setT_WND(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 340 | { |
Rhyme | 0:752c9dbed2fa | 341 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 342 | tmp[0] = MPL_T_WND ; |
Rhyme | 0:752c9dbed2fa | 343 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 344 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 345 | } |
Rhyme | 0:752c9dbed2fa | 346 | |
Rhyme | 0:752c9dbed2fa | 347 | int32_t MPL3115A2::getP_MIN(void) |
Rhyme | 0:752c9dbed2fa | 348 | { |
Rhyme | 0:752c9dbed2fa | 349 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 350 | int32_t data ; |
Rhyme | 0:752c9dbed2fa | 351 | readRegs(MPL_P_MIN_MSB, tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 352 | data = (tmp[0]<<24)|(tmp[1]<<16)|((tmp[2]&0xF0)<<8) ; |
Rhyme | 0:752c9dbed2fa | 353 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 354 | } |
Rhyme | 0:752c9dbed2fa | 355 | |
Rhyme | 0:752c9dbed2fa | 356 | void MPL3115A2::setT_MIN(int32_t data) |
Rhyme | 0:752c9dbed2fa | 357 | { |
Rhyme | 0:752c9dbed2fa | 358 | uint8_t tmp[4] ; |
Rhyme | 0:752c9dbed2fa | 359 | tmp[0] = MPL_P_MIN_MSB ; |
Rhyme | 0:752c9dbed2fa | 360 | tmp[1] = (data >> 24) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 361 | tmp[2] = (data >> 16) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 362 | tmp[3] = (data >> 8) & 0xF0 ; |
Rhyme | 0:752c9dbed2fa | 363 | writeRegs(tmp, 4) ; |
Rhyme | 0:752c9dbed2fa | 364 | } |
Rhyme | 0:752c9dbed2fa | 365 | |
Rhyme | 0:752c9dbed2fa | 366 | int32_t MPL3115A2::getP_MAX(void) |
Rhyme | 0:752c9dbed2fa | 367 | { |
Rhyme | 0:752c9dbed2fa | 368 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 369 | int32_t data ; |
Rhyme | 0:752c9dbed2fa | 370 | readRegs(MPL_P_MAX_MSB, tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 371 | data = (tmp[0]<<24)|(tmp[1]<<16)|((tmp[2]&0xF0)<<8) ; |
Rhyme | 0:752c9dbed2fa | 372 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 373 | } |
Rhyme | 0:752c9dbed2fa | 374 | |
Rhyme | 0:752c9dbed2fa | 375 | void MPL3115A2::setP_MAX(int32_t data) |
Rhyme | 0:752c9dbed2fa | 376 | { |
Rhyme | 0:752c9dbed2fa | 377 | uint8_t tmp[4] ; |
Rhyme | 0:752c9dbed2fa | 378 | tmp[0] = MPL_P_MAX_MSB ; |
Rhyme | 0:752c9dbed2fa | 379 | tmp[1] = (data >> 24) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 380 | tmp[2] = (data >> 16) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 381 | tmp[3] = (data >> 8) & 0xF0 ; |
Rhyme | 0:752c9dbed2fa | 382 | writeRegs(tmp, 4) ; |
Rhyme | 0:752c9dbed2fa | 383 | } |
Rhyme | 0:752c9dbed2fa | 384 | |
Rhyme | 0:752c9dbed2fa | 385 | int16_t MPL3115A2::getT_MIN(void) |
Rhyme | 0:752c9dbed2fa | 386 | { |
Rhyme | 0:752c9dbed2fa | 387 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 388 | uint16_t data ; |
Rhyme | 0:752c9dbed2fa | 389 | readRegs(MPL_T_MIN_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 390 | data = (tmp[0]<<8) | tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 391 | return(data) ; |
Rhyme | 0:752c9dbed2fa | 392 | } |
Rhyme | 0:752c9dbed2fa | 393 | |
Rhyme | 0:752c9dbed2fa | 394 | void MPL3115A2::setT_MIN(int16_t data) |
Rhyme | 0:752c9dbed2fa | 395 | { |
Rhyme | 0:752c9dbed2fa | 396 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 397 | tmp[0] = MPL_T_MIN_MSB ; |
Rhyme | 0:752c9dbed2fa | 398 | tmp[1] = (data >> 8) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 399 | tmp[2] = data & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 400 | writeRegs(tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 401 | } |
Rhyme | 0:752c9dbed2fa | 402 | |
Rhyme | 0:752c9dbed2fa | 403 | int16_t MPL3115A2::getT_MAX(void) |
Rhyme | 0:752c9dbed2fa | 404 | { |
Rhyme | 0:752c9dbed2fa | 405 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 406 | uint16_t data ; |
Rhyme | 0:752c9dbed2fa | 407 | readRegs(MPL_T_MAX_MSB, tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 408 | data = (tmp[0]<<8) | tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 409 | return( data ) ; |
Rhyme | 0:752c9dbed2fa | 410 | } |
Rhyme | 0:752c9dbed2fa | 411 | |
Rhyme | 0:752c9dbed2fa | 412 | void MPL3115A2::setT_MAX(int16_t data) |
Rhyme | 0:752c9dbed2fa | 413 | { |
Rhyme | 0:752c9dbed2fa | 414 | uint8_t tmp[3] ; |
Rhyme | 0:752c9dbed2fa | 415 | tmp[0] = MPL_T_MAX_MSB ; |
Rhyme | 0:752c9dbed2fa | 416 | tmp[1] = (data >> 8) & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 417 | tmp[2] = data & 0xFF ; |
Rhyme | 0:752c9dbed2fa | 418 | writeRegs(tmp, 3) ; |
Rhyme | 0:752c9dbed2fa | 419 | } |
Rhyme | 0:752c9dbed2fa | 420 | |
Rhyme | 0:752c9dbed2fa | 421 | uint8_t MPL3115A2::getCTRL_REG1(void) |
Rhyme | 0:752c9dbed2fa | 422 | { |
Rhyme | 0:752c9dbed2fa | 423 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 424 | readRegs(MPL_CTRL_REG1, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 425 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 426 | } |
Rhyme | 0:752c9dbed2fa | 427 | |
Rhyme | 0:752c9dbed2fa | 428 | void MPL3115A2::setCTRL_REG1(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 429 | { |
Rhyme | 0:752c9dbed2fa | 430 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 431 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 432 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 433 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 434 | } |
Rhyme | 0:752c9dbed2fa | 435 | |
Rhyme | 0:752c9dbed2fa | 436 | uint8_t MPL3115A2::getCTRL_REG2(void) |
Rhyme | 0:752c9dbed2fa | 437 | { |
Rhyme | 0:752c9dbed2fa | 438 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 439 | readRegs(MPL_CTRL_REG2, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 440 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 441 | } |
Rhyme | 0:752c9dbed2fa | 442 | |
Rhyme | 0:752c9dbed2fa | 443 | void MPL3115A2::setCTRL_REG2(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 444 | { |
Rhyme | 0:752c9dbed2fa | 445 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 446 | tmp[0] = MPL_CTRL_REG2 ; |
Rhyme | 0:752c9dbed2fa | 447 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 448 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 449 | } |
Rhyme | 0:752c9dbed2fa | 450 | |
Rhyme | 0:752c9dbed2fa | 451 | uint8_t MPL3115A2::getCTRL_REG3(void) |
Rhyme | 0:752c9dbed2fa | 452 | { |
Rhyme | 0:752c9dbed2fa | 453 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 454 | readRegs(MPL_CTRL_REG3, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 455 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 456 | } |
Rhyme | 0:752c9dbed2fa | 457 | |
Rhyme | 0:752c9dbed2fa | 458 | void MPL3115A2::setCTRL_REG3(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 459 | { |
Rhyme | 0:752c9dbed2fa | 460 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 461 | tmp[0] = MPL_CTRL_REG3 ; |
Rhyme | 0:752c9dbed2fa | 462 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 463 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 464 | } |
Rhyme | 0:752c9dbed2fa | 465 | |
Rhyme | 0:752c9dbed2fa | 466 | uint8_t MPL3115A2::getCTRL_REG4(void) |
Rhyme | 0:752c9dbed2fa | 467 | { |
Rhyme | 0:752c9dbed2fa | 468 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 469 | readRegs(MPL_CTRL_REG4, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 470 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 471 | } |
Rhyme | 0:752c9dbed2fa | 472 | |
Rhyme | 0:752c9dbed2fa | 473 | void MPL3115A2::setCTRL_REG4(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 474 | { |
Rhyme | 0:752c9dbed2fa | 475 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 476 | tmp[0] = MPL_CTRL_REG4 ; |
Rhyme | 0:752c9dbed2fa | 477 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 478 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 479 | } |
Rhyme | 0:752c9dbed2fa | 480 | |
Rhyme | 0:752c9dbed2fa | 481 | uint8_t MPL3115A2::getCTRL_REG5(void) |
Rhyme | 0:752c9dbed2fa | 482 | { |
Rhyme | 0:752c9dbed2fa | 483 | uint8_t tmp[1] ; |
Rhyme | 0:752c9dbed2fa | 484 | readRegs(MPL_CTRL_REG5, tmp, 1) ; |
Rhyme | 0:752c9dbed2fa | 485 | return( tmp[0] ) ; |
Rhyme | 0:752c9dbed2fa | 486 | } |
Rhyme | 0:752c9dbed2fa | 487 | |
Rhyme | 0:752c9dbed2fa | 488 | void MPL3115A2::setCTRL_REG5(uint8_t data) |
Rhyme | 0:752c9dbed2fa | 489 | { |
Rhyme | 0:752c9dbed2fa | 490 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 491 | tmp[0] = MPL_CTRL_REG5 ; |
Rhyme | 0:752c9dbed2fa | 492 | tmp[1] = data ; |
Rhyme | 0:752c9dbed2fa | 493 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 494 | } |
Rhyme | 0:752c9dbed2fa | 495 | |
Rhyme | 1:6fdcf150410e | 496 | void MPL3115A2::oneShot(void) |
Rhyme | 1:6fdcf150410e | 497 | { |
Rhyme | 1:6fdcf150410e | 498 | uint8_t tmp[2] ; |
Rhyme | 1:6fdcf150410e | 499 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 1:6fdcf150410e | 500 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 1:6fdcf150410e | 501 | tmp[1] &= 0xFD ; /* clear OST */ |
Rhyme | 1:6fdcf150410e | 502 | writeRegs(tmp, 2) ; |
Rhyme | 1:6fdcf150410e | 503 | tmp[1] |= 0x02 ; /* set OST */ |
Rhyme | 1:6fdcf150410e | 504 | writeRegs(tmp, 2) ; |
Rhyme | 1:6fdcf150410e | 505 | } |
Rhyme | 1:6fdcf150410e | 506 | |
Rhyme | 1:6fdcf150410e | 507 | uint16_t MPL3115A2::getSampleTime(void) |
Rhyme | 0:752c9dbed2fa | 508 | { |
Rhyme | 0:752c9dbed2fa | 509 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 510 | uint16_t sample_time = 6 ; |
Rhyme | 0:752c9dbed2fa | 511 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 512 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 0:752c9dbed2fa | 513 | tmp[1] |= 0x02 ; |
Rhyme | 0:752c9dbed2fa | 514 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 515 | switch((tmp[1]>>3)&0x07) { |
Rhyme | 0:752c9dbed2fa | 516 | case 0: sample_time = 6 ; break ; |
Rhyme | 0:752c9dbed2fa | 517 | case 1: sample_time = 10 ; break ; |
Rhyme | 0:752c9dbed2fa | 518 | case 2: sample_time = 18 ; break ; |
Rhyme | 0:752c9dbed2fa | 519 | case 3: sample_time = 34 ; break ; |
Rhyme | 0:752c9dbed2fa | 520 | case 4: sample_time = 66 ; break ; |
Rhyme | 0:752c9dbed2fa | 521 | case 5: sample_time = 130 ; break ; |
Rhyme | 0:752c9dbed2fa | 522 | case 6: sample_time = 258 ; break ; |
Rhyme | 0:752c9dbed2fa | 523 | case 7: sample_time = 512 ; break ; |
Rhyme | 0:752c9dbed2fa | 524 | default: sample_time = 6 ; break ; |
Rhyme | 0:752c9dbed2fa | 525 | } |
Rhyme | 0:752c9dbed2fa | 526 | return( sample_time ) ; |
Rhyme | 0:752c9dbed2fa | 527 | } |
Rhyme | 0:752c9dbed2fa | 528 | |
Rhyme | 0:752c9dbed2fa | 529 | void MPL3115A2::standby(void) |
Rhyme | 0:752c9dbed2fa | 530 | { |
Rhyme | 0:752c9dbed2fa | 531 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 532 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 533 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 0:752c9dbed2fa | 534 | tmp[1] &= 0xFE ; |
Rhyme | 0:752c9dbed2fa | 535 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 536 | } |
Rhyme | 0:752c9dbed2fa | 537 | |
Rhyme | 0:752c9dbed2fa | 538 | void MPL3115A2::activate(void) |
Rhyme | 0:752c9dbed2fa | 539 | { |
Rhyme | 0:752c9dbed2fa | 540 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 541 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 542 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 0:752c9dbed2fa | 543 | tmp[1] |= 0x01 ; |
Rhyme | 0:752c9dbed2fa | 544 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 545 | } |
Rhyme | 0:752c9dbed2fa | 546 | |
Rhyme | 0:752c9dbed2fa | 547 | void MPL3115A2::modeAlt(void) |
Rhyme | 0:752c9dbed2fa | 548 | { |
Rhyme | 0:752c9dbed2fa | 549 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 550 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 551 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 0:752c9dbed2fa | 552 | tmp[1] |= 0x80 ; |
Rhyme | 0:752c9dbed2fa | 553 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 554 | } |
Rhyme | 0:752c9dbed2fa | 555 | |
Rhyme | 0:752c9dbed2fa | 556 | void MPL3115A2::modeBar(void) |
Rhyme | 0:752c9dbed2fa | 557 | { |
Rhyme | 0:752c9dbed2fa | 558 | uint8_t tmp[2] ; |
Rhyme | 0:752c9dbed2fa | 559 | tmp[0] = MPL_CTRL_REG1 ; |
Rhyme | 0:752c9dbed2fa | 560 | readRegs(tmp[0], &tmp[1], 1) ; |
Rhyme | 0:752c9dbed2fa | 561 | tmp[1] &= 0x7F ; |
Rhyme | 0:752c9dbed2fa | 562 | writeRegs(tmp, 2) ; |
Rhyme | 0:752c9dbed2fa | 563 | } |