AKM AK09970N 3D Magnetic Sensor with Programmable Switch
AK09970N.cpp@1:2b2ead3e4efc, 2017-12-28 (annotated)
- Committer:
- Rhyme
- Date:
- Thu Dec 28 07:24:03 2017 +0000
- Revision:
- 1:2b2ead3e4efc
first working version, no documents in place
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 1:2b2ead3e4efc | 1 | #include "mbed.h" |
Rhyme | 1:2b2ead3e4efc | 2 | #include "AK09970N.h" |
Rhyme | 1:2b2ead3e4efc | 3 | |
Rhyme | 1:2b2ead3e4efc | 4 | /* Read only Registers */ |
Rhyme | 1:2b2ead3e4efc | 5 | #define REG_ID 0x00 |
Rhyme | 1:2b2ead3e4efc | 6 | #define REG_STATUS 0x10 |
Rhyme | 1:2b2ead3e4efc | 7 | #define REG_ST_X 0x11 |
Rhyme | 1:2b2ead3e4efc | 8 | #define REG_ST_Y 0x12 |
Rhyme | 1:2b2ead3e4efc | 9 | #define REG_ST_X_Y 0x13 |
Rhyme | 1:2b2ead3e4efc | 10 | #define REG_ST_Z 0x14 |
Rhyme | 1:2b2ead3e4efc | 11 | #define REG_ST_X_Z 0x15 |
Rhyme | 1:2b2ead3e4efc | 12 | #define REG_ST_Y_Z 0x16 |
Rhyme | 1:2b2ead3e4efc | 13 | #define REG_ST_X_Y_Z 0x17 |
Rhyme | 1:2b2ead3e4efc | 14 | #define REG_ST_BX 0x19 |
Rhyme | 1:2b2ead3e4efc | 15 | #define REG_ST_BY 0x1A |
Rhyme | 1:2b2ead3e4efc | 16 | #define REG_ST_BX_BY 0x1B |
Rhyme | 1:2b2ead3e4efc | 17 | #define REG_ST_BZ 0x1C |
Rhyme | 1:2b2ead3e4efc | 18 | #define REG_ST_BX_BZ 0x1D |
Rhyme | 1:2b2ead3e4efc | 19 | #define REG_ST_BY_BZ 0x1E |
Rhyme | 1:2b2ead3e4efc | 20 | #define REG_ST_BX_BY_BZ 0x1F |
Rhyme | 1:2b2ead3e4efc | 21 | /* Read/Write Registers */ |
Rhyme | 1:2b2ead3e4efc | 22 | #define REG_INT 0x20 |
Rhyme | 1:2b2ead3e4efc | 23 | #define REG_CONFIG 0x21 |
Rhyme | 1:2b2ead3e4efc | 24 | #define REG_THS_X1 0x22 |
Rhyme | 1:2b2ead3e4efc | 25 | #define REG_THS_X2 0x23 |
Rhyme | 1:2b2ead3e4efc | 26 | #define REG_THS_Y1 0x24 |
Rhyme | 1:2b2ead3e4efc | 27 | #define REG_THS_Y2 0x25 |
Rhyme | 1:2b2ead3e4efc | 28 | #define REG_THS_Z1 0x26 |
Rhyme | 1:2b2ead3e4efc | 29 | #define REG_THS_Z2 0x27 |
Rhyme | 1:2b2ead3e4efc | 30 | /* Special function */ |
Rhyme | 1:2b2ead3e4efc | 31 | #define REG_RESET 0x30 |
Rhyme | 1:2b2ead3e4efc | 32 | #define REG_I2C_Disable 0x31 |
Rhyme | 1:2b2ead3e4efc | 33 | #define REG_TEST1 0x40 |
Rhyme | 1:2b2ead3e4efc | 34 | #define REG_TEST2 0x41 |
Rhyme | 1:2b2ead3e4efc | 35 | |
Rhyme | 1:2b2ead3e4efc | 36 | AK09970N::AK09970N(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr<<1) { |
Rhyme | 1:2b2ead3e4efc | 37 | uint8_t data[2] ; |
Rhyme | 1:2b2ead3e4efc | 38 | // activate the peripheral |
Rhyme | 1:2b2ead3e4efc | 39 | _mode = 0 ; /* power-down mode */ |
Rhyme | 1:2b2ead3e4efc | 40 | _sdr = 0 ; /* Sensor drive setting */ |
Rhyme | 1:2b2ead3e4efc | 41 | _smr = 0 ; /* 0: High sensitivity 1: Wide measurement range */ |
Rhyme | 1:2b2ead3e4efc | 42 | data[0] = REG_INT ; |
Rhyme | 1:2b2ead3e4efc | 43 | data[1] = 0x01 ; |
Rhyme | 1:2b2ead3e4efc | 44 | writeRegs(data, 2) ; |
Rhyme | 1:2b2ead3e4efc | 45 | } |
Rhyme | 1:2b2ead3e4efc | 46 | |
Rhyme | 1:2b2ead3e4efc | 47 | AK09970N::~AK09970N() { } |
Rhyme | 1:2b2ead3e4efc | 48 | |
Rhyme | 1:2b2ead3e4efc | 49 | int AK09970N::readRegs(int addr, uint8_t * data, int len) { |
Rhyme | 1:2b2ead3e4efc | 50 | int result ; |
Rhyme | 1:2b2ead3e4efc | 51 | char t[1] = {addr}; |
Rhyme | 1:2b2ead3e4efc | 52 | result = m_i2c.write(m_addr, t, 1, true); |
Rhyme | 1:2b2ead3e4efc | 53 | if (result == 0) { |
Rhyme | 1:2b2ead3e4efc | 54 | m_i2c.read(m_addr, (char *)data, len); |
Rhyme | 1:2b2ead3e4efc | 55 | } |
Rhyme | 1:2b2ead3e4efc | 56 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 57 | } |
Rhyme | 1:2b2ead3e4efc | 58 | |
Rhyme | 1:2b2ead3e4efc | 59 | int AK09970N::writeRegs(uint8_t * data, int len) { |
Rhyme | 1:2b2ead3e4efc | 60 | int result ; |
Rhyme | 1:2b2ead3e4efc | 61 | result = m_i2c.write(m_addr, (char *)data, len); |
Rhyme | 1:2b2ead3e4efc | 62 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 63 | } |
Rhyme | 1:2b2ead3e4efc | 64 | |
Rhyme | 1:2b2ead3e4efc | 65 | int AK09970N::software_reset(void) |
Rhyme | 1:2b2ead3e4efc | 66 | { |
Rhyme | 1:2b2ead3e4efc | 67 | int result ; |
Rhyme | 1:2b2ead3e4efc | 68 | uint8_t data[2] = { REG_RESET, 0x01 } ; |
Rhyme | 1:2b2ead3e4efc | 69 | result = writeRegs(data, 2) ; |
Rhyme | 1:2b2ead3e4efc | 70 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 71 | } |
Rhyme | 1:2b2ead3e4efc | 72 | |
Rhyme | 1:2b2ead3e4efc | 73 | int AK09970N::getID(uint16_t *CompanyID, uint16_t *DeviceID) |
Rhyme | 1:2b2ead3e4efc | 74 | { |
Rhyme | 1:2b2ead3e4efc | 75 | int result ; |
Rhyme | 1:2b2ead3e4efc | 76 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 77 | result = readRegs(REG_ID, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 78 | if (result == 0) { |
Rhyme | 1:2b2ead3e4efc | 79 | *CompanyID = data[0] ; |
Rhyme | 1:2b2ead3e4efc | 80 | *DeviceID = data[1] ; |
Rhyme | 1:2b2ead3e4efc | 81 | } |
Rhyme | 1:2b2ead3e4efc | 82 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 83 | } |
Rhyme | 1:2b2ead3e4efc | 84 | |
Rhyme | 1:2b2ead3e4efc | 85 | /** |
Rhyme | 1:2b2ead3e4efc | 86 | * REG_STATUS 0x10 |
Rhyme | 1:2b2ead3e4efc | 87 | * REG_STATUS[15:10] (reserved) |
Rhyme | 1:2b2ead3e4efc | 88 | * REG_STATUS[9] DOR : 0: Normal 1: Data overrun |
Rhyme | 1:2b2ead3e4efc | 89 | * REG_STATUS[8] ERRADC : 0: Normal 1: ADC overflow |
Rhyme | 1:2b2ead3e4efc | 90 | * REG_STATUS[7] ERRXY : 0: Normal 1: Magnetic sensor overflow (X and/or Y) |
Rhyme | 1:2b2ead3e4efc | 91 | * REG_STATUS[6] SWZ2 : exceed_THSeshold 2 |
Rhyme | 1:2b2ead3e4efc | 92 | * REG_STATUS[5] SWZ1 : exceed_THSeshold 1 |
Rhyme | 1:2b2ead3e4efc | 93 | * REG_STATUS[4] SWY2 : exceed_THSeshold 2 |
Rhyme | 1:2b2ead3e4efc | 94 | * REG_STATUS[3] SWY1 : exceed_THSeshold 1 |
Rhyme | 1:2b2ead3e4efc | 95 | * REG_STATUS[2] SWX2 : exceed THSeshold 2 |
Rhyme | 1:2b2ead3e4efc | 96 | * REG_STATUS[1] SWX1 : exceed THSeshold 1 |
Rhyme | 1:2b2ead3e4efc | 97 | * REG_STATUS[0] DRDY : 0: Normal 1: Data is ready |
Rhyme | 1:2b2ead3e4efc | 98 | */ |
Rhyme | 1:2b2ead3e4efc | 99 | uint16_t AK09970N::getStatus(void) |
Rhyme | 1:2b2ead3e4efc | 100 | { |
Rhyme | 1:2b2ead3e4efc | 101 | int result ; |
Rhyme | 1:2b2ead3e4efc | 102 | uint8_t data[2] ; |
Rhyme | 1:2b2ead3e4efc | 103 | uint16_t status = 0 ; |
Rhyme | 1:2b2ead3e4efc | 104 | result = readRegs(REG_STATUS, data, 2) ; |
Rhyme | 1:2b2ead3e4efc | 105 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 106 | status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 107 | } |
Rhyme | 1:2b2ead3e4efc | 108 | return( status ) ; |
Rhyme | 1:2b2ead3e4efc | 109 | } |
Rhyme | 1:2b2ead3e4efc | 110 | |
Rhyme | 1:2b2ead3e4efc | 111 | int AK09970N::setINT(uint16_t value) |
Rhyme | 1:2b2ead3e4efc | 112 | { |
Rhyme | 1:2b2ead3e4efc | 113 | int result ; |
Rhyme | 1:2b2ead3e4efc | 114 | uint8_t data[3] ; |
Rhyme | 1:2b2ead3e4efc | 115 | data[0] = REG_INT ; |
Rhyme | 1:2b2ead3e4efc | 116 | data[1] = (value >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 117 | data[2] = value & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 118 | result = writeRegs(data, 3) ; |
Rhyme | 1:2b2ead3e4efc | 119 | return(result) ; |
Rhyme | 1:2b2ead3e4efc | 120 | } |
Rhyme | 1:2b2ead3e4efc | 121 | |
Rhyme | 1:2b2ead3e4efc | 122 | uint16_t AK09970N::getINT(void) |
Rhyme | 1:2b2ead3e4efc | 123 | { |
Rhyme | 1:2b2ead3e4efc | 124 | int result ; |
Rhyme | 1:2b2ead3e4efc | 125 | uint8_t data[2] ; |
Rhyme | 1:2b2ead3e4efc | 126 | uint16_t value ; |
Rhyme | 1:2b2ead3e4efc | 127 | result = readRegs(REG_INT, data, 2) ; |
Rhyme | 1:2b2ead3e4efc | 128 | if (result == 0) { |
Rhyme | 1:2b2ead3e4efc | 129 | value = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 130 | } |
Rhyme | 1:2b2ead3e4efc | 131 | return(value) ; |
Rhyme | 1:2b2ead3e4efc | 132 | } |
Rhyme | 1:2b2ead3e4efc | 133 | |
Rhyme | 1:2b2ead3e4efc | 134 | int AK09970N::setConfig(uint8_t config) |
Rhyme | 1:2b2ead3e4efc | 135 | { |
Rhyme | 1:2b2ead3e4efc | 136 | int result ; |
Rhyme | 1:2b2ead3e4efc | 137 | uint8_t data[2] ; |
Rhyme | 1:2b2ead3e4efc | 138 | data[0] = REG_CONFIG ; |
Rhyme | 1:2b2ead3e4efc | 139 | data[1] = config ; |
Rhyme | 1:2b2ead3e4efc | 140 | result = writeRegs(data, 2) ; |
Rhyme | 1:2b2ead3e4efc | 141 | _mode = config & 0x0F ; /* operation mode 0: power down 1: single 2~: other */ |
Rhyme | 1:2b2ead3e4efc | 142 | _sdr = (config >> 4) & 0x01 ; /* Sensor drive setting */ |
Rhyme | 1:2b2ead3e4efc | 143 | _smr = (config >> 5) & 0x01 ; /* Measurement range and sensitivity */ |
Rhyme | 1:2b2ead3e4efc | 144 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 145 | } |
Rhyme | 1:2b2ead3e4efc | 146 | |
Rhyme | 1:2b2ead3e4efc | 147 | uint8_t AK09970N::getConfig(void) |
Rhyme | 1:2b2ead3e4efc | 148 | { |
Rhyme | 1:2b2ead3e4efc | 149 | int result ; |
Rhyme | 1:2b2ead3e4efc | 150 | uint8_t config = 0x00 ; |
Rhyme | 1:2b2ead3e4efc | 151 | result = readRegs(REG_CONFIG, &config, 1) ; |
Rhyme | 1:2b2ead3e4efc | 152 | if (result == 0) { /* read success, reflect each bits */ |
Rhyme | 1:2b2ead3e4efc | 153 | _mode = config & 0x0F ; |
Rhyme | 1:2b2ead3e4efc | 154 | _sdr = (config >> 4) & 0x01 ; |
Rhyme | 1:2b2ead3e4efc | 155 | _smr = (config >> 5) & 0x01 ; |
Rhyme | 1:2b2ead3e4efc | 156 | } |
Rhyme | 1:2b2ead3e4efc | 157 | return( config ) ; |
Rhyme | 1:2b2ead3e4efc | 158 | } |
Rhyme | 1:2b2ead3e4efc | 159 | |
Rhyme | 1:2b2ead3e4efc | 160 | int AK09970N::singleShot(void) |
Rhyme | 1:2b2ead3e4efc | 161 | { |
Rhyme | 1:2b2ead3e4efc | 162 | int result ; |
Rhyme | 1:2b2ead3e4efc | 163 | uint8_t config ; |
Rhyme | 1:2b2ead3e4efc | 164 | config = (_smr << 5)|(_sdr << 4)|0x01 ; |
Rhyme | 1:2b2ead3e4efc | 165 | result = setConfig(config) ; |
Rhyme | 1:2b2ead3e4efc | 166 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 167 | } |
Rhyme | 1:2b2ead3e4efc | 168 | |
Rhyme | 1:2b2ead3e4efc | 169 | float AK09970N::i2f(int16_t value) |
Rhyme | 1:2b2ead3e4efc | 170 | { |
Rhyme | 1:2b2ead3e4efc | 171 | float fvalue ; |
Rhyme | 1:2b2ead3e4efc | 172 | if (_smr) { |
Rhyme | 1:2b2ead3e4efc | 173 | fvalue = 0.0011 * ((float)value) ; |
Rhyme | 1:2b2ead3e4efc | 174 | } else { |
Rhyme | 1:2b2ead3e4efc | 175 | fvalue = 0.0031 * ((float)value) ; |
Rhyme | 1:2b2ead3e4efc | 176 | } |
Rhyme | 1:2b2ead3e4efc | 177 | return( fvalue ) ; |
Rhyme | 1:2b2ead3e4efc | 178 | } |
Rhyme | 1:2b2ead3e4efc | 179 | |
Rhyme | 1:2b2ead3e4efc | 180 | int AK09970N::getX(uint16_t *status, float *x) |
Rhyme | 1:2b2ead3e4efc | 181 | { |
Rhyme | 1:2b2ead3e4efc | 182 | int result ; |
Rhyme | 1:2b2ead3e4efc | 183 | int16_t hx ; |
Rhyme | 1:2b2ead3e4efc | 184 | result = getHX(status, &hx) ; |
Rhyme | 1:2b2ead3e4efc | 185 | if (result == 0) { |
Rhyme | 1:2b2ead3e4efc | 186 | *x = i2f(hx) ; |
Rhyme | 1:2b2ead3e4efc | 187 | } |
Rhyme | 1:2b2ead3e4efc | 188 | return(result) ; |
Rhyme | 1:2b2ead3e4efc | 189 | } |
Rhyme | 1:2b2ead3e4efc | 190 | |
Rhyme | 1:2b2ead3e4efc | 191 | int AK09970N::getY(uint16_t *status, float *y) |
Rhyme | 1:2b2ead3e4efc | 192 | { |
Rhyme | 1:2b2ead3e4efc | 193 | int result ; |
Rhyme | 1:2b2ead3e4efc | 194 | int16_t hy ; |
Rhyme | 1:2b2ead3e4efc | 195 | result = getHY(status, &hy) ; |
Rhyme | 1:2b2ead3e4efc | 196 | if (result == 0) { |
Rhyme | 1:2b2ead3e4efc | 197 | *y = i2f(hy) ; |
Rhyme | 1:2b2ead3e4efc | 198 | } |
Rhyme | 1:2b2ead3e4efc | 199 | return(result) ; |
Rhyme | 1:2b2ead3e4efc | 200 | } |
Rhyme | 1:2b2ead3e4efc | 201 | |
Rhyme | 1:2b2ead3e4efc | 202 | int AK09970N::getZ(uint16_t *status, float *z) |
Rhyme | 1:2b2ead3e4efc | 203 | { |
Rhyme | 1:2b2ead3e4efc | 204 | int result ; |
Rhyme | 1:2b2ead3e4efc | 205 | int16_t hz ; |
Rhyme | 1:2b2ead3e4efc | 206 | result = getHZ(status, &hz) ; |
Rhyme | 1:2b2ead3e4efc | 207 | if (result == 0) { |
Rhyme | 1:2b2ead3e4efc | 208 | *z = i2f(hz) ; |
Rhyme | 1:2b2ead3e4efc | 209 | } |
Rhyme | 1:2b2ead3e4efc | 210 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 211 | } |
Rhyme | 1:2b2ead3e4efc | 212 | int AK09970N::getX_Y(uint16_t *status, float *x, float *y) |
Rhyme | 1:2b2ead3e4efc | 213 | { |
Rhyme | 1:2b2ead3e4efc | 214 | int result ; |
Rhyme | 1:2b2ead3e4efc | 215 | int16_t hx, hy ; |
Rhyme | 1:2b2ead3e4efc | 216 | result = getHX_HY(status, &hx, &hy) ; |
Rhyme | 1:2b2ead3e4efc | 217 | if (result == 0) { |
Rhyme | 1:2b2ead3e4efc | 218 | *x = i2f(hx) ; |
Rhyme | 1:2b2ead3e4efc | 219 | *y = i2f(hy) ; |
Rhyme | 1:2b2ead3e4efc | 220 | } |
Rhyme | 1:2b2ead3e4efc | 221 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 222 | } |
Rhyme | 1:2b2ead3e4efc | 223 | |
Rhyme | 1:2b2ead3e4efc | 224 | int AK09970N::getX_Z(uint16_t *status, float *x, float *z) |
Rhyme | 1:2b2ead3e4efc | 225 | { |
Rhyme | 1:2b2ead3e4efc | 226 | int result ; |
Rhyme | 1:2b2ead3e4efc | 227 | int16_t hx, hz ; |
Rhyme | 1:2b2ead3e4efc | 228 | result = getHX_HZ(status, &hx, &hz) ; |
Rhyme | 1:2b2ead3e4efc | 229 | if (result == 0) { |
Rhyme | 1:2b2ead3e4efc | 230 | *x = i2f(hx) ; |
Rhyme | 1:2b2ead3e4efc | 231 | *z = i2f(hz) ; |
Rhyme | 1:2b2ead3e4efc | 232 | } |
Rhyme | 1:2b2ead3e4efc | 233 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 234 | } |
Rhyme | 1:2b2ead3e4efc | 235 | |
Rhyme | 1:2b2ead3e4efc | 236 | int AK09970N::getY_Z(uint16_t *status, float *y, float *z) |
Rhyme | 1:2b2ead3e4efc | 237 | { |
Rhyme | 1:2b2ead3e4efc | 238 | int result ; |
Rhyme | 1:2b2ead3e4efc | 239 | int16_t hy, hz ; |
Rhyme | 1:2b2ead3e4efc | 240 | result = getHY_HZ(status, &hy, &hz) ; |
Rhyme | 1:2b2ead3e4efc | 241 | if (result == 0) { |
Rhyme | 1:2b2ead3e4efc | 242 | *y = i2f(hy) ; |
Rhyme | 1:2b2ead3e4efc | 243 | *z = i2f(hz) ; |
Rhyme | 1:2b2ead3e4efc | 244 | } |
Rhyme | 1:2b2ead3e4efc | 245 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 246 | } |
Rhyme | 1:2b2ead3e4efc | 247 | |
Rhyme | 1:2b2ead3e4efc | 248 | int AK09970N::getX_Y_Z(uint16_t *status, float *x, float *y, float *z) |
Rhyme | 1:2b2ead3e4efc | 249 | { |
Rhyme | 1:2b2ead3e4efc | 250 | int result ; |
Rhyme | 1:2b2ead3e4efc | 251 | int16_t hx, hy, hz ; |
Rhyme | 1:2b2ead3e4efc | 252 | result = getHX_HY_HZ(status, &hx, &hy, &hz) ; |
Rhyme | 1:2b2ead3e4efc | 253 | if (result == 0) { |
Rhyme | 1:2b2ead3e4efc | 254 | *x = i2f(hx) ; |
Rhyme | 1:2b2ead3e4efc | 255 | *y = i2f(hy) ; |
Rhyme | 1:2b2ead3e4efc | 256 | *z = i2f(hz) ; |
Rhyme | 1:2b2ead3e4efc | 257 | } |
Rhyme | 1:2b2ead3e4efc | 258 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 259 | } |
Rhyme | 1:2b2ead3e4efc | 260 | |
Rhyme | 1:2b2ead3e4efc | 261 | int AK09970N::getHX(uint16_t *status, int16_t *x) |
Rhyme | 1:2b2ead3e4efc | 262 | { |
Rhyme | 1:2b2ead3e4efc | 263 | int result ; |
Rhyme | 1:2b2ead3e4efc | 264 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 265 | result = readRegs(REG_ST_X, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 266 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 267 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 268 | *x = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 269 | } |
Rhyme | 1:2b2ead3e4efc | 270 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 271 | } |
Rhyme | 1:2b2ead3e4efc | 272 | |
Rhyme | 1:2b2ead3e4efc | 273 | int AK09970N::getHY(uint16_t *status, int16_t *y) |
Rhyme | 1:2b2ead3e4efc | 274 | { |
Rhyme | 1:2b2ead3e4efc | 275 | int result ; |
Rhyme | 1:2b2ead3e4efc | 276 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 277 | result = readRegs(REG_ST_Y, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 278 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 279 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 280 | *y = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 281 | } |
Rhyme | 1:2b2ead3e4efc | 282 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 283 | } |
Rhyme | 1:2b2ead3e4efc | 284 | |
Rhyme | 1:2b2ead3e4efc | 285 | int AK09970N::getHZ(uint16_t *status, int16_t *z) |
Rhyme | 1:2b2ead3e4efc | 286 | { |
Rhyme | 1:2b2ead3e4efc | 287 | int result ; |
Rhyme | 1:2b2ead3e4efc | 288 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 289 | result = readRegs(REG_ST_Z, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 290 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 291 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 292 | *z = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 293 | } |
Rhyme | 1:2b2ead3e4efc | 294 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 295 | } |
Rhyme | 1:2b2ead3e4efc | 296 | |
Rhyme | 1:2b2ead3e4efc | 297 | int AK09970N::getHX_HY(uint16_t *status, int16_t *x, int16_t *y) |
Rhyme | 1:2b2ead3e4efc | 298 | { |
Rhyme | 1:2b2ead3e4efc | 299 | int result ; |
Rhyme | 1:2b2ead3e4efc | 300 | uint8_t data[6] ; |
Rhyme | 1:2b2ead3e4efc | 301 | result = readRegs(REG_ST_X_Y, data, 6) ; |
Rhyme | 1:2b2ead3e4efc | 302 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 303 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 304 | *y = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 305 | *x = (int16_t)((data[4] << 8) | data[5]) ; |
Rhyme | 1:2b2ead3e4efc | 306 | } |
Rhyme | 1:2b2ead3e4efc | 307 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 308 | } |
Rhyme | 1:2b2ead3e4efc | 309 | |
Rhyme | 1:2b2ead3e4efc | 310 | int AK09970N::getHX_HZ(uint16_t *status, int16_t *x, int16_t *z) |
Rhyme | 1:2b2ead3e4efc | 311 | { |
Rhyme | 1:2b2ead3e4efc | 312 | int result ; |
Rhyme | 1:2b2ead3e4efc | 313 | uint8_t data[6] ; |
Rhyme | 1:2b2ead3e4efc | 314 | result = readRegs(REG_ST_X_Z, data, 6) ; |
Rhyme | 1:2b2ead3e4efc | 315 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 316 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 317 | *z = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 318 | *x = (int16_t)((data[4] << 8) | data[5]) ; |
Rhyme | 1:2b2ead3e4efc | 319 | } |
Rhyme | 1:2b2ead3e4efc | 320 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 321 | } |
Rhyme | 1:2b2ead3e4efc | 322 | |
Rhyme | 1:2b2ead3e4efc | 323 | int AK09970N::getHY_HZ(uint16_t *status, int16_t *y, int16_t *z) |
Rhyme | 1:2b2ead3e4efc | 324 | { |
Rhyme | 1:2b2ead3e4efc | 325 | int result ; |
Rhyme | 1:2b2ead3e4efc | 326 | uint8_t data[6] ; |
Rhyme | 1:2b2ead3e4efc | 327 | result = readRegs(REG_ST_Y_Z, data, 6) ; |
Rhyme | 1:2b2ead3e4efc | 328 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 329 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 330 | *z = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 331 | *y = (int16_t)((data[4] << 8) | data[5]) ; |
Rhyme | 1:2b2ead3e4efc | 332 | } |
Rhyme | 1:2b2ead3e4efc | 333 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 334 | } |
Rhyme | 1:2b2ead3e4efc | 335 | |
Rhyme | 1:2b2ead3e4efc | 336 | int AK09970N::getHX_HY_HZ(uint16_t *status, int16_t *x, int16_t *y, int16_t *z) |
Rhyme | 1:2b2ead3e4efc | 337 | { |
Rhyme | 1:2b2ead3e4efc | 338 | int result ; |
Rhyme | 1:2b2ead3e4efc | 339 | uint8_t data[8] ; |
Rhyme | 1:2b2ead3e4efc | 340 | result = readRegs(REG_ST_X_Y_Z, data, 8) ; |
Rhyme | 1:2b2ead3e4efc | 341 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 342 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 343 | *z = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 344 | *y = (int16_t)((data[4] << 8) | data[5]) ; |
Rhyme | 1:2b2ead3e4efc | 345 | *x = (int16_t)((data[6] << 8) | data[7]) ; |
Rhyme | 1:2b2ead3e4efc | 346 | } |
Rhyme | 1:2b2ead3e4efc | 347 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 348 | } |
Rhyme | 1:2b2ead3e4efc | 349 | |
Rhyme | 1:2b2ead3e4efc | 350 | /* get measured data 8bit versions */ |
Rhyme | 1:2b2ead3e4efc | 351 | int AK09970N::getBX(uint16_t *status, int8_t *x) |
Rhyme | 1:2b2ead3e4efc | 352 | { |
Rhyme | 1:2b2ead3e4efc | 353 | int result ; |
Rhyme | 1:2b2ead3e4efc | 354 | uint8_t data[3] ; |
Rhyme | 1:2b2ead3e4efc | 355 | result = readRegs(REG_ST_BX, data, 3) ; |
Rhyme | 1:2b2ead3e4efc | 356 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 357 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 358 | *x = (int8_t)data[2] ; |
Rhyme | 1:2b2ead3e4efc | 359 | } |
Rhyme | 1:2b2ead3e4efc | 360 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 361 | } |
Rhyme | 1:2b2ead3e4efc | 362 | |
Rhyme | 1:2b2ead3e4efc | 363 | int AK09970N::getBY(uint16_t *status, int8_t *y) |
Rhyme | 1:2b2ead3e4efc | 364 | { |
Rhyme | 1:2b2ead3e4efc | 365 | int result ; |
Rhyme | 1:2b2ead3e4efc | 366 | uint8_t data[3] ; |
Rhyme | 1:2b2ead3e4efc | 367 | result = readRegs(REG_ST_BY, data, 3) ; |
Rhyme | 1:2b2ead3e4efc | 368 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 369 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 370 | *y = (int8_t)data[2] ; |
Rhyme | 1:2b2ead3e4efc | 371 | } |
Rhyme | 1:2b2ead3e4efc | 372 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 373 | } |
Rhyme | 1:2b2ead3e4efc | 374 | |
Rhyme | 1:2b2ead3e4efc | 375 | int AK09970N::getBZ(uint16_t *status, int8_t *z) |
Rhyme | 1:2b2ead3e4efc | 376 | { |
Rhyme | 1:2b2ead3e4efc | 377 | int result ; |
Rhyme | 1:2b2ead3e4efc | 378 | uint8_t data[3] ; |
Rhyme | 1:2b2ead3e4efc | 379 | result = readRegs(REG_ST_BZ, data, 3) ; |
Rhyme | 1:2b2ead3e4efc | 380 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 381 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 382 | *z = (int8_t)data[2] ; |
Rhyme | 1:2b2ead3e4efc | 383 | } |
Rhyme | 1:2b2ead3e4efc | 384 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 385 | } |
Rhyme | 1:2b2ead3e4efc | 386 | |
Rhyme | 1:2b2ead3e4efc | 387 | int AK09970N::getBX_BY(uint16_t *status, int8_t *x, int8_t *y) |
Rhyme | 1:2b2ead3e4efc | 388 | { |
Rhyme | 1:2b2ead3e4efc | 389 | int result ; |
Rhyme | 1:2b2ead3e4efc | 390 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 391 | result = readRegs(REG_ST_BX_BY, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 392 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 393 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 394 | *y = (int8_t)data[2] ; |
Rhyme | 1:2b2ead3e4efc | 395 | *x = (int8_t)data[3] ; |
Rhyme | 1:2b2ead3e4efc | 396 | } |
Rhyme | 1:2b2ead3e4efc | 397 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 398 | } |
Rhyme | 1:2b2ead3e4efc | 399 | |
Rhyme | 1:2b2ead3e4efc | 400 | int AK09970N::getBX_BZ(uint16_t *status, int8_t *x, int8_t *z) |
Rhyme | 1:2b2ead3e4efc | 401 | { |
Rhyme | 1:2b2ead3e4efc | 402 | int result ; |
Rhyme | 1:2b2ead3e4efc | 403 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 404 | result = readRegs(REG_ST_BX_BZ, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 405 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 406 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 407 | *z = (int8_t)data[2] ; |
Rhyme | 1:2b2ead3e4efc | 408 | *x = (int8_t)data[3] ; |
Rhyme | 1:2b2ead3e4efc | 409 | } |
Rhyme | 1:2b2ead3e4efc | 410 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 411 | } |
Rhyme | 1:2b2ead3e4efc | 412 | |
Rhyme | 1:2b2ead3e4efc | 413 | int AK09970N::getBY_BZ(uint16_t *status, int8_t *y, int8_t *z) |
Rhyme | 1:2b2ead3e4efc | 414 | { |
Rhyme | 1:2b2ead3e4efc | 415 | int result ; |
Rhyme | 1:2b2ead3e4efc | 416 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 417 | result = readRegs(REG_ST_BY_BZ, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 418 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 419 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 420 | *z = (int8_t)data[2] ; |
Rhyme | 1:2b2ead3e4efc | 421 | *y = (int8_t)data[3] ; |
Rhyme | 1:2b2ead3e4efc | 422 | } |
Rhyme | 1:2b2ead3e4efc | 423 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 424 | } |
Rhyme | 1:2b2ead3e4efc | 425 | |
Rhyme | 1:2b2ead3e4efc | 426 | int AK09970N::getBX_BY_BZ(uint16_t *status, int8_t *x, int8_t *y, int8_t *z) |
Rhyme | 1:2b2ead3e4efc | 427 | { |
Rhyme | 1:2b2ead3e4efc | 428 | int result ; |
Rhyme | 1:2b2ead3e4efc | 429 | uint8_t data[5] ; |
Rhyme | 1:2b2ead3e4efc | 430 | result = readRegs(REG_ST_BX_BY_BZ, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 431 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 432 | *status = (data[0] << 8) | data[1] ; |
Rhyme | 1:2b2ead3e4efc | 433 | *z = (int8_t)data[2] ; |
Rhyme | 1:2b2ead3e4efc | 434 | *y = (int8_t)data[3] ; |
Rhyme | 1:2b2ead3e4efc | 435 | *x = (int8_t)data[4] ; |
Rhyme | 1:2b2ead3e4efc | 436 | } |
Rhyme | 1:2b2ead3e4efc | 437 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 438 | } |
Rhyme | 1:2b2ead3e4efc | 439 | |
Rhyme | 1:2b2ead3e4efc | 440 | int AK09970N::getTHS_X1(int16_t *bop, int16_t *brp) |
Rhyme | 1:2b2ead3e4efc | 441 | { |
Rhyme | 1:2b2ead3e4efc | 442 | int result ; |
Rhyme | 1:2b2ead3e4efc | 443 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 444 | result = readRegs(REG_THS_X1, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 445 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 446 | *bop = (int16_t)((data[0] << 8) | data[1]) ; |
Rhyme | 1:2b2ead3e4efc | 447 | *brp = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 448 | } |
Rhyme | 1:2b2ead3e4efc | 449 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 450 | } |
Rhyme | 1:2b2ead3e4efc | 451 | |
Rhyme | 1:2b2ead3e4efc | 452 | int AK09970N::getTHS_X2(int16_t *bop, int16_t *brp) |
Rhyme | 1:2b2ead3e4efc | 453 | { |
Rhyme | 1:2b2ead3e4efc | 454 | int result ; |
Rhyme | 1:2b2ead3e4efc | 455 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 456 | result = readRegs(REG_THS_X2, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 457 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 458 | *bop = (int16_t)((data[0] << 8) | data[1]) ; |
Rhyme | 1:2b2ead3e4efc | 459 | *brp = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 460 | } |
Rhyme | 1:2b2ead3e4efc | 461 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 462 | } |
Rhyme | 1:2b2ead3e4efc | 463 | |
Rhyme | 1:2b2ead3e4efc | 464 | int AK09970N::getTHS_Y1(int16_t *bop, int16_t *brp) |
Rhyme | 1:2b2ead3e4efc | 465 | { |
Rhyme | 1:2b2ead3e4efc | 466 | int result ; |
Rhyme | 1:2b2ead3e4efc | 467 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 468 | result = readRegs(REG_THS_Y1, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 469 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 470 | *bop = (int16_t)((data[0] << 8) | data[1]) ; |
Rhyme | 1:2b2ead3e4efc | 471 | *brp = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 472 | } |
Rhyme | 1:2b2ead3e4efc | 473 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 474 | } |
Rhyme | 1:2b2ead3e4efc | 475 | |
Rhyme | 1:2b2ead3e4efc | 476 | int AK09970N::getTHS_Y2(int16_t *bop, int16_t *brp) |
Rhyme | 1:2b2ead3e4efc | 477 | { |
Rhyme | 1:2b2ead3e4efc | 478 | int result ; |
Rhyme | 1:2b2ead3e4efc | 479 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 480 | result = readRegs(REG_THS_Y2, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 481 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 482 | *bop = (int16_t)((data[0] << 8) | data[1]) ; |
Rhyme | 1:2b2ead3e4efc | 483 | *brp = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 484 | } |
Rhyme | 1:2b2ead3e4efc | 485 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 486 | } |
Rhyme | 1:2b2ead3e4efc | 487 | |
Rhyme | 1:2b2ead3e4efc | 488 | int AK09970N::getTHS_Z1(int16_t *bop, int16_t *brp) |
Rhyme | 1:2b2ead3e4efc | 489 | { |
Rhyme | 1:2b2ead3e4efc | 490 | int result ; |
Rhyme | 1:2b2ead3e4efc | 491 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 492 | result = readRegs(REG_THS_Z1, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 493 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 494 | *bop = (int16_t)((data[0] << 8) | data[1]) ; |
Rhyme | 1:2b2ead3e4efc | 495 | *brp = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 496 | } |
Rhyme | 1:2b2ead3e4efc | 497 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 498 | } |
Rhyme | 1:2b2ead3e4efc | 499 | |
Rhyme | 1:2b2ead3e4efc | 500 | int AK09970N::getTHS_Z2(int16_t *bop, int16_t *brp) |
Rhyme | 1:2b2ead3e4efc | 501 | { |
Rhyme | 1:2b2ead3e4efc | 502 | int result ; |
Rhyme | 1:2b2ead3e4efc | 503 | uint8_t data[4] ; |
Rhyme | 1:2b2ead3e4efc | 504 | result = readRegs(REG_THS_Z2, data, 4) ; |
Rhyme | 1:2b2ead3e4efc | 505 | if (result == 0) { /* success */ |
Rhyme | 1:2b2ead3e4efc | 506 | *bop = (int16_t)((data[0] << 8) | data[1]) ; |
Rhyme | 1:2b2ead3e4efc | 507 | *brp = (int16_t)((data[2] << 8) | data[3]) ; |
Rhyme | 1:2b2ead3e4efc | 508 | } |
Rhyme | 1:2b2ead3e4efc | 509 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 510 | } |
Rhyme | 1:2b2ead3e4efc | 511 | |
Rhyme | 1:2b2ead3e4efc | 512 | int AK09970N::setTHS_X1(int16_t bop, int16_t brp) |
Rhyme | 1:2b2ead3e4efc | 513 | { |
Rhyme | 1:2b2ead3e4efc | 514 | int result ; |
Rhyme | 1:2b2ead3e4efc | 515 | uint8_t data[5] ; |
Rhyme | 1:2b2ead3e4efc | 516 | data[0] = REG_THS_X1 ; |
Rhyme | 1:2b2ead3e4efc | 517 | data[1] = (bop >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 518 | data[2] = bop & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 519 | data[3] = (brp >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 520 | data[4] = brp & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 521 | result = writeRegs(data, 5) ; |
Rhyme | 1:2b2ead3e4efc | 522 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 523 | } |
Rhyme | 1:2b2ead3e4efc | 524 | |
Rhyme | 1:2b2ead3e4efc | 525 | int AK09970N::setTHS_X2(int16_t bop, int16_t brp) |
Rhyme | 1:2b2ead3e4efc | 526 | { |
Rhyme | 1:2b2ead3e4efc | 527 | int result ; |
Rhyme | 1:2b2ead3e4efc | 528 | uint8_t data[5] ; |
Rhyme | 1:2b2ead3e4efc | 529 | data[0] = REG_THS_X2 ; |
Rhyme | 1:2b2ead3e4efc | 530 | data[1] = (bop >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 531 | data[2] = bop & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 532 | data[3] = (brp >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 533 | data[4] = brp & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 534 | result = writeRegs(data, 5) ; |
Rhyme | 1:2b2ead3e4efc | 535 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 536 | } |
Rhyme | 1:2b2ead3e4efc | 537 | |
Rhyme | 1:2b2ead3e4efc | 538 | int AK09970N::setTHS_Y1(int16_t bop, int16_t brp) |
Rhyme | 1:2b2ead3e4efc | 539 | { |
Rhyme | 1:2b2ead3e4efc | 540 | int result ; |
Rhyme | 1:2b2ead3e4efc | 541 | uint8_t data[5] ; |
Rhyme | 1:2b2ead3e4efc | 542 | data[0] = REG_THS_Y1 ; |
Rhyme | 1:2b2ead3e4efc | 543 | data[1] = (bop >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 544 | data[2] = bop & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 545 | data[3] = (brp >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 546 | data[4] = brp & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 547 | result = writeRegs(data, 5) ; |
Rhyme | 1:2b2ead3e4efc | 548 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 549 | } |
Rhyme | 1:2b2ead3e4efc | 550 | |
Rhyme | 1:2b2ead3e4efc | 551 | int AK09970N::setTHS_Y2(int16_t bop, int16_t brp) |
Rhyme | 1:2b2ead3e4efc | 552 | { |
Rhyme | 1:2b2ead3e4efc | 553 | int result ; |
Rhyme | 1:2b2ead3e4efc | 554 | uint8_t data[5] ; |
Rhyme | 1:2b2ead3e4efc | 555 | data[0] = REG_THS_Y2 ; |
Rhyme | 1:2b2ead3e4efc | 556 | data[1] = (bop >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 557 | data[2] = bop & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 558 | data[3] = (brp >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 559 | data[4] = brp & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 560 | result = writeRegs(data, 5) ; |
Rhyme | 1:2b2ead3e4efc | 561 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 562 | } |
Rhyme | 1:2b2ead3e4efc | 563 | |
Rhyme | 1:2b2ead3e4efc | 564 | int AK09970N::setTHS_Z1(int16_t bop, int16_t brp) |
Rhyme | 1:2b2ead3e4efc | 565 | { |
Rhyme | 1:2b2ead3e4efc | 566 | int result ; |
Rhyme | 1:2b2ead3e4efc | 567 | uint8_t data[5] ; |
Rhyme | 1:2b2ead3e4efc | 568 | data[0] = REG_THS_Z1 ; |
Rhyme | 1:2b2ead3e4efc | 569 | data[1] = (bop >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 570 | data[2] = bop & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 571 | data[3] = (brp >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 572 | data[4] = brp & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 573 | result = writeRegs(data, 5) ; |
Rhyme | 1:2b2ead3e4efc | 574 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 575 | } |
Rhyme | 1:2b2ead3e4efc | 576 | |
Rhyme | 1:2b2ead3e4efc | 577 | int AK09970N::setTHS_Z2(int16_t bop, int16_t brp) |
Rhyme | 1:2b2ead3e4efc | 578 | { |
Rhyme | 1:2b2ead3e4efc | 579 | int result ; |
Rhyme | 1:2b2ead3e4efc | 580 | uint8_t data[5] ; |
Rhyme | 1:2b2ead3e4efc | 581 | data[0] = REG_THS_Z2 ; |
Rhyme | 1:2b2ead3e4efc | 582 | data[1] = (bop >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 583 | data[2] = bop & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 584 | data[3] = (brp >> 8) & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 585 | data[4] = brp & 0xFF ; |
Rhyme | 1:2b2ead3e4efc | 586 | result = writeRegs(data, 5) ; |
Rhyme | 1:2b2ead3e4efc | 587 | return( result ) ; |
Rhyme | 1:2b2ead3e4efc | 588 | } |