Charge control
Dependencies: mbed PowerControl SDFileSystem
hepta_sat/HeptaAccel.cpp@0:0842f00470eb, 2016-12-09 (annotated)
- Committer:
- tomoya123
- Date:
- Fri Dec 09 05:04:37 2016 +0000
- Revision:
- 0:0842f00470eb
Charge control
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tomoya123 | 0:0842f00470eb | 1 | #include "HeptaAccel.h" |
tomoya123 | 0:0842f00470eb | 2 | #include "mbed.h" |
tomoya123 | 0:0842f00470eb | 3 | |
tomoya123 | 0:0842f00470eb | 4 | HeptaAccel::HeptaAccel(PinName sda, PinName scl, int aaddr ) : accel(sda,scl),addr(aaddr) |
tomoya123 | 0:0842f00470eb | 5 | { |
tomoya123 | 0:0842f00470eb | 6 | _cmd[0] = 0x2A;//CTL_REG |
tomoya123 | 0:0842f00470eb | 7 | _cmd[1] = 0x01;//ACTIVE |
tomoya123 | 0:0842f00470eb | 8 | accel.write(addr, _cmd, 2); |
tomoya123 | 0:0842f00470eb | 9 | accel.start(); |
tomoya123 | 0:0842f00470eb | 10 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 11 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 12 | } |
tomoya123 | 0:0842f00470eb | 13 | |
tomoya123 | 0:0842f00470eb | 14 | void HeptaAccel::setup() |
tomoya123 | 0:0842f00470eb | 15 | { |
tomoya123 | 0:0842f00470eb | 16 | _cmd[0] = 0x2A; |
tomoya123 | 0:0842f00470eb | 17 | _cmd[1] = 0x01; |
tomoya123 | 0:0842f00470eb | 18 | accel.frequency(100000); |
tomoya123 | 0:0842f00470eb | 19 | accel.write(addr, _cmd, 2); |
tomoya123 | 0:0842f00470eb | 20 | accel.start(); |
tomoya123 | 0:0842f00470eb | 21 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 22 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 23 | } |
tomoya123 | 0:0842f00470eb | 24 | |
tomoya123 | 0:0842f00470eb | 25 | void HeptaAccel::sensing(float *ax,float *ay,float *az) |
tomoya123 | 0:0842f00470eb | 26 | { |
tomoya123 | 0:0842f00470eb | 27 | int16_t acc; |
tomoya123 | 0:0842f00470eb | 28 | accel.start();//start |
tomoya123 | 0:0842f00470eb | 29 | accel.write(addr);//write address |
tomoya123 | 0:0842f00470eb | 30 | accel.write(0x01);//X-axis_MSB_REG |
tomoya123 | 0:0842f00470eb | 31 | accel.start();//restart, switch from write to read |
tomoya123 | 0:0842f00470eb | 32 | accel.write(addr|0x01);//read address |
tomoya123 | 0:0842f00470eb | 33 | _xmsb = accel.read(0);//read from selected register with NACK |
tomoya123 | 0:0842f00470eb | 34 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 35 | accel.start(); |
tomoya123 | 0:0842f00470eb | 36 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 37 | accel.write(0x02);//X-axis_LSB_REG |
tomoya123 | 0:0842f00470eb | 38 | accel.start(); |
tomoya123 | 0:0842f00470eb | 39 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 40 | _xlsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 41 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 42 | acc = (_xmsb << 6) | (_xlsb >> 2); |
tomoya123 | 0:0842f00470eb | 43 | if (acc > UINT14_MAX/2) |
tomoya123 | 0:0842f00470eb | 44 | { |
tomoya123 | 0:0842f00470eb | 45 | acc -= UINT14_MAX; |
tomoya123 | 0:0842f00470eb | 46 | } |
tomoya123 | 0:0842f00470eb | 47 | *ax = acc/4096.0*9.81; |
tomoya123 | 0:0842f00470eb | 48 | |
tomoya123 | 0:0842f00470eb | 49 | accel.start(); |
tomoya123 | 0:0842f00470eb | 50 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 51 | accel.write(0x03); |
tomoya123 | 0:0842f00470eb | 52 | accel.start(); |
tomoya123 | 0:0842f00470eb | 53 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 54 | _ymsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 55 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 56 | accel.start(); |
tomoya123 | 0:0842f00470eb | 57 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 58 | accel.write(0x04); |
tomoya123 | 0:0842f00470eb | 59 | accel.start(); |
tomoya123 | 0:0842f00470eb | 60 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 61 | _ylsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 62 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 63 | acc = (_ymsb << 6) | (_ylsb >> 2); |
tomoya123 | 0:0842f00470eb | 64 | if (acc > UINT14_MAX/2) |
tomoya123 | 0:0842f00470eb | 65 | { |
tomoya123 | 0:0842f00470eb | 66 | acc -= UINT14_MAX; |
tomoya123 | 0:0842f00470eb | 67 | } |
tomoya123 | 0:0842f00470eb | 68 | *ay = acc/4096.0*9.81; |
tomoya123 | 0:0842f00470eb | 69 | |
tomoya123 | 0:0842f00470eb | 70 | accel.start(); |
tomoya123 | 0:0842f00470eb | 71 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 72 | accel.write(0x05); |
tomoya123 | 0:0842f00470eb | 73 | accel.start(); |
tomoya123 | 0:0842f00470eb | 74 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 75 | _zmsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 76 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 77 | accel.start(); |
tomoya123 | 0:0842f00470eb | 78 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 79 | accel.write(0x06); |
tomoya123 | 0:0842f00470eb | 80 | accel.start(); |
tomoya123 | 0:0842f00470eb | 81 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 82 | _zlsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 83 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 84 | acc = (_zmsb << 6) | (_zlsb >> 2); |
tomoya123 | 0:0842f00470eb | 85 | if (acc > UINT14_MAX/2) |
tomoya123 | 0:0842f00470eb | 86 | { |
tomoya123 | 0:0842f00470eb | 87 | acc -= UINT14_MAX; |
tomoya123 | 0:0842f00470eb | 88 | } |
tomoya123 | 0:0842f00470eb | 89 | *az = acc/4096.0*9.81; |
tomoya123 | 0:0842f00470eb | 90 | } |
tomoya123 | 0:0842f00470eb | 91 | |
tomoya123 | 0:0842f00470eb | 92 | float HeptaAccel::x() |
tomoya123 | 0:0842f00470eb | 93 | { |
tomoya123 | 0:0842f00470eb | 94 | int16_t acc; |
tomoya123 | 0:0842f00470eb | 95 | float ax; |
tomoya123 | 0:0842f00470eb | 96 | accel.start(); |
tomoya123 | 0:0842f00470eb | 97 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 98 | accel.write(0x01); |
tomoya123 | 0:0842f00470eb | 99 | accel.start(); |
tomoya123 | 0:0842f00470eb | 100 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 101 | _xmsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 102 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 103 | accel.start(); |
tomoya123 | 0:0842f00470eb | 104 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 105 | accel.write(0x02); |
tomoya123 | 0:0842f00470eb | 106 | accel.start(); |
tomoya123 | 0:0842f00470eb | 107 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 108 | _xlsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 109 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 110 | acc = (_xmsb << 6) | (_xlsb >> 2); |
tomoya123 | 0:0842f00470eb | 111 | if (acc > UINT14_MAX/2) |
tomoya123 | 0:0842f00470eb | 112 | { |
tomoya123 | 0:0842f00470eb | 113 | acc -= UINT14_MAX; |
tomoya123 | 0:0842f00470eb | 114 | } |
tomoya123 | 0:0842f00470eb | 115 | ax = acc/4096.0*9.81; |
tomoya123 | 0:0842f00470eb | 116 | return(ax); |
tomoya123 | 0:0842f00470eb | 117 | } |
tomoya123 | 0:0842f00470eb | 118 | |
tomoya123 | 0:0842f00470eb | 119 | float HeptaAccel::y() |
tomoya123 | 0:0842f00470eb | 120 | { |
tomoya123 | 0:0842f00470eb | 121 | int16_t acc; |
tomoya123 | 0:0842f00470eb | 122 | float ay; |
tomoya123 | 0:0842f00470eb | 123 | accel.start(); |
tomoya123 | 0:0842f00470eb | 124 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 125 | accel.write(0x03); |
tomoya123 | 0:0842f00470eb | 126 | accel.start(); |
tomoya123 | 0:0842f00470eb | 127 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 128 | _ymsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 129 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 130 | accel.start(); |
tomoya123 | 0:0842f00470eb | 131 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 132 | accel.write(0x04); |
tomoya123 | 0:0842f00470eb | 133 | accel.start(); |
tomoya123 | 0:0842f00470eb | 134 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 135 | _ylsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 136 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 137 | acc = (_ymsb << 6) | (_ylsb >> 2); |
tomoya123 | 0:0842f00470eb | 138 | if (acc > UINT14_MAX/2) |
tomoya123 | 0:0842f00470eb | 139 | { |
tomoya123 | 0:0842f00470eb | 140 | acc -= UINT14_MAX; |
tomoya123 | 0:0842f00470eb | 141 | } |
tomoya123 | 0:0842f00470eb | 142 | ay = acc/4096.0*9.81; |
tomoya123 | 0:0842f00470eb | 143 | return(ay); |
tomoya123 | 0:0842f00470eb | 144 | } |
tomoya123 | 0:0842f00470eb | 145 | |
tomoya123 | 0:0842f00470eb | 146 | float HeptaAccel::z() |
tomoya123 | 0:0842f00470eb | 147 | { |
tomoya123 | 0:0842f00470eb | 148 | int16_t acc; |
tomoya123 | 0:0842f00470eb | 149 | float az; |
tomoya123 | 0:0842f00470eb | 150 | accel.start(); |
tomoya123 | 0:0842f00470eb | 151 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 152 | accel.write(0x2C); |
tomoya123 | 0:0842f00470eb | 153 | accel.start(); |
tomoya123 | 0:0842f00470eb | 154 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 155 | _zmsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 156 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 157 | accel.start(); |
tomoya123 | 0:0842f00470eb | 158 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 159 | accel.write(0x2D); |
tomoya123 | 0:0842f00470eb | 160 | accel.start(); |
tomoya123 | 0:0842f00470eb | 161 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 162 | _zlsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 163 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 164 | acc = (_zmsb << 6) | (_zlsb >> 2); |
tomoya123 | 0:0842f00470eb | 165 | if (acc > UINT14_MAX/2) |
tomoya123 | 0:0842f00470eb | 166 | { |
tomoya123 | 0:0842f00470eb | 167 | acc -= UINT14_MAX; |
tomoya123 | 0:0842f00470eb | 168 | } |
tomoya123 | 0:0842f00470eb | 169 | az = acc/4096.0*9.81; |
tomoya123 | 0:0842f00470eb | 170 | return(az); |
tomoya123 | 0:0842f00470eb | 171 | } |
tomoya123 | 0:0842f00470eb | 172 | |
tomoya123 | 0:0842f00470eb | 173 | void HeptaAccel::sensing_u16(char* ax_u16,char* ay_u16,char* az_u16, int *dsize) |
tomoya123 | 0:0842f00470eb | 174 | { |
tomoya123 | 0:0842f00470eb | 175 | char a1[8]={0x00},a2[8]={0x00}; |
tomoya123 | 0:0842f00470eb | 176 | accel.start(); |
tomoya123 | 0:0842f00470eb | 177 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 178 | accel.write(0x01); |
tomoya123 | 0:0842f00470eb | 179 | accel.start(); |
tomoya123 | 0:0842f00470eb | 180 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 181 | _xmsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 182 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 183 | accel.start(); |
tomoya123 | 0:0842f00470eb | 184 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 185 | accel.write(0x02); |
tomoya123 | 0:0842f00470eb | 186 | accel.start(); |
tomoya123 | 0:0842f00470eb | 187 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 188 | _xlsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 189 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 190 | sprintf( a1, "%02X", ((_xmsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 191 | sprintf( a2, "%02X", ((_xlsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 192 | ax_u16[0]=a1[0]; |
tomoya123 | 0:0842f00470eb | 193 | ax_u16[1]=a1[1]; |
tomoya123 | 0:0842f00470eb | 194 | ax_u16[2]=a2[0]; |
tomoya123 | 0:0842f00470eb | 195 | ax_u16[3]=a2[1]; |
tomoya123 | 0:0842f00470eb | 196 | |
tomoya123 | 0:0842f00470eb | 197 | accel.start(); |
tomoya123 | 0:0842f00470eb | 198 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 199 | accel.write(0x03); |
tomoya123 | 0:0842f00470eb | 200 | accel.start(); |
tomoya123 | 0:0842f00470eb | 201 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 202 | _ymsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 203 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 204 | accel.start(); |
tomoya123 | 0:0842f00470eb | 205 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 206 | accel.write(0x04); |
tomoya123 | 0:0842f00470eb | 207 | accel.start(); |
tomoya123 | 0:0842f00470eb | 208 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 209 | _ylsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 210 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 211 | sprintf( a1, "%02X", ((_ymsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 212 | sprintf( a2, "%02X", ((_ylsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 213 | ay_u16[0]=a1[0]; |
tomoya123 | 0:0842f00470eb | 214 | ay_u16[1]=a1[1]; |
tomoya123 | 0:0842f00470eb | 215 | ay_u16[2]=a2[0]; |
tomoya123 | 0:0842f00470eb | 216 | ay_u16[3]=a2[1]; |
tomoya123 | 0:0842f00470eb | 217 | |
tomoya123 | 0:0842f00470eb | 218 | accel.start(); |
tomoya123 | 0:0842f00470eb | 219 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 220 | accel.write(0x05); |
tomoya123 | 0:0842f00470eb | 221 | accel.start(); |
tomoya123 | 0:0842f00470eb | 222 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 223 | _zmsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 224 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 225 | accel.start(); |
tomoya123 | 0:0842f00470eb | 226 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 227 | accel.write(0x06); |
tomoya123 | 0:0842f00470eb | 228 | accel.start(); |
tomoya123 | 0:0842f00470eb | 229 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 230 | _zlsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 231 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 232 | sprintf( a1, "%02X", ((_zmsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 233 | sprintf( a2, "%02X", ((_zlsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 234 | az_u16[0]=a1[0]; |
tomoya123 | 0:0842f00470eb | 235 | az_u16[1]=a1[1]; |
tomoya123 | 0:0842f00470eb | 236 | az_u16[2]=a2[0]; |
tomoya123 | 0:0842f00470eb | 237 | az_u16[3]=a2[1]; |
tomoya123 | 0:0842f00470eb | 238 | *dsize = 4; |
tomoya123 | 0:0842f00470eb | 239 | } |
tomoya123 | 0:0842f00470eb | 240 | |
tomoya123 | 0:0842f00470eb | 241 | void HeptaAccel::x_u16(char* a_u16, int *dsize) |
tomoya123 | 0:0842f00470eb | 242 | { |
tomoya123 | 0:0842f00470eb | 243 | char a1[8]={0x00},a2[8]={0x00}; |
tomoya123 | 0:0842f00470eb | 244 | accel.start(); |
tomoya123 | 0:0842f00470eb | 245 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 246 | accel.write(0x01); |
tomoya123 | 0:0842f00470eb | 247 | accel.start(); |
tomoya123 | 0:0842f00470eb | 248 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 249 | _xmsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 250 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 251 | accel.start(); |
tomoya123 | 0:0842f00470eb | 252 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 253 | accel.write(0x02); |
tomoya123 | 0:0842f00470eb | 254 | accel.start(); |
tomoya123 | 0:0842f00470eb | 255 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 256 | _xlsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 257 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 258 | sprintf( a1, "%02X", ((_xmsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 259 | sprintf( a2, "%02X", ((_xlsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 260 | a_u16[0]=a1[0]; |
tomoya123 | 0:0842f00470eb | 261 | a_u16[1]=a1[1]; |
tomoya123 | 0:0842f00470eb | 262 | a_u16[2]=a2[0]; |
tomoya123 | 0:0842f00470eb | 263 | a_u16[3]=a2[1]; |
tomoya123 | 0:0842f00470eb | 264 | *dsize = 4; |
tomoya123 | 0:0842f00470eb | 265 | } |
tomoya123 | 0:0842f00470eb | 266 | |
tomoya123 | 0:0842f00470eb | 267 | void HeptaAccel::y_u16(char* a_u16, int *dsize) |
tomoya123 | 0:0842f00470eb | 268 | { |
tomoya123 | 0:0842f00470eb | 269 | char a1[8]={0x00},a2[8]={0x00}; |
tomoya123 | 0:0842f00470eb | 270 | accel.start(); |
tomoya123 | 0:0842f00470eb | 271 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 272 | accel.write(0x03); |
tomoya123 | 0:0842f00470eb | 273 | accel.start(); |
tomoya123 | 0:0842f00470eb | 274 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 275 | _ymsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 276 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 277 | accel.start(); |
tomoya123 | 0:0842f00470eb | 278 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 279 | accel.write(0x04); |
tomoya123 | 0:0842f00470eb | 280 | accel.start(); |
tomoya123 | 0:0842f00470eb | 281 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 282 | _ylsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 283 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 284 | sprintf( a1, "%02X", ((_ymsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 285 | sprintf( a2, "%02X", ((_ylsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 286 | a_u16[0]=a1[0]; |
tomoya123 | 0:0842f00470eb | 287 | a_u16[1]=a1[1]; |
tomoya123 | 0:0842f00470eb | 288 | a_u16[2]=a2[0]; |
tomoya123 | 0:0842f00470eb | 289 | a_u16[3]=a2[1]; |
tomoya123 | 0:0842f00470eb | 290 | *dsize = 4; |
tomoya123 | 0:0842f00470eb | 291 | } |
tomoya123 | 0:0842f00470eb | 292 | |
tomoya123 | 0:0842f00470eb | 293 | void HeptaAccel::z_u16(char* a_u16, int *dsize) |
tomoya123 | 0:0842f00470eb | 294 | { |
tomoya123 | 0:0842f00470eb | 295 | char a1[8]={0x00},a2[8]={0x00}; |
tomoya123 | 0:0842f00470eb | 296 | accel.start(); |
tomoya123 | 0:0842f00470eb | 297 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 298 | accel.write(0x05); |
tomoya123 | 0:0842f00470eb | 299 | accel.start(); |
tomoya123 | 0:0842f00470eb | 300 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 301 | _zmsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 302 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 303 | accel.start(); |
tomoya123 | 0:0842f00470eb | 304 | accel.write(addr); |
tomoya123 | 0:0842f00470eb | 305 | accel.write(0x06); |
tomoya123 | 0:0842f00470eb | 306 | accel.start(); |
tomoya123 | 0:0842f00470eb | 307 | accel.write(addr|0x01); |
tomoya123 | 0:0842f00470eb | 308 | _zlsb = accel.read(0); |
tomoya123 | 0:0842f00470eb | 309 | accel.stop(); |
tomoya123 | 0:0842f00470eb | 310 | sprintf( a1, "%02X", ((_zmsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 311 | sprintf( a2, "%02X", ((_zlsb)) & 0xFF); |
tomoya123 | 0:0842f00470eb | 312 | a_u16[0]=a1[0]; |
tomoya123 | 0:0842f00470eb | 313 | a_u16[1]=a1[1]; |
tomoya123 | 0:0842f00470eb | 314 | a_u16[2]=a2[0]; |
tomoya123 | 0:0842f00470eb | 315 | a_u16[3]=a2[1]; |
tomoya123 | 0:0842f00470eb | 316 | *dsize = 4; |
tomoya123 | 0:0842f00470eb | 317 | } |