Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of FXLS8471Q by
Diff: FXLS8471Q.cpp
- Revision:
- 2:6aae25fe9ab4
- Parent:
- 1:c80be04510fe
- Child:
- 4:b6e0c4ad3aee
--- a/FXLS8471Q.cpp Sat Apr 19 01:26:12 2014 +0000 +++ b/FXLS8471Q.cpp Mon Jun 02 17:14:15 2014 +0000 @@ -17,17 +17,16 @@ */ - #include "FXLS8471Q.h" - #define UINT14_MAX 16383 - -FXLS8471Q::FXLS8471Q(PinName mosi, PinName miso, PinName sck, PinName cs) : _spi(mosi, miso, sck), _spi_cs(cs) { +#include "FXLS8471Q.h" +#define UINT14_MAX 16383 + +FXLS8471Q::FXLS8471Q(PinName mosi, PinName miso, PinName sck, PinName cs) : _spi(mosi, miso, sck), _spi_cs(cs) +{ _spi_cs = 1; wait(0.1); begin(); } - - void FXLS8471Q::RegWrite( int reg, int *d, int len) { int ob[2]; @@ -40,7 +39,7 @@ while(c < len) _spi.write(d[c++]); _spi_cs = 1; } - + void FXLS8471Q::RegRead( int reg, int *d, int len) { int ob[2]; @@ -91,27 +90,27 @@ // [1]: f_read=0 for normal 16 bit reads // [0]: active=1 to take the part out of standby and enable sampling databyte = 0x15; - RegWrite(FXLS8471Q_CTRL_REG1, &databyte, 1); + RegWrite(FXLS8471Q_CTRL_REG1, &databyte, 1); } void FXLS8471Q::ReadXYZ(float * fdata) { -int raw[7]; -int16_t ix, iy, iz; -RegRead(FXLS8471Q_STATUS, raw, 7); + int raw[7]; + int16_t ix, iy, iz; + RegRead(FXLS8471Q_STATUS, raw, 7); -ix = ((raw[1] * 256) + raw[2]);// / 4; -iy = ((raw[3] * 256) + raw[4]);// / 4; -iz = ((raw[5] * 256) + raw[6]);// / 4; -fdata[0] = ((float) ix) / 16384.0; -fdata[1] = ((float) iy) / 16384.0; -fdata[2] = ((float) iz) / 16384.0; + ix = ((raw[1] * 256) + raw[2]);// / 4; + iy = ((raw[3] * 256) + raw[4]);// / 4; + iz = ((raw[5] * 256) + raw[6]);// / 4; + fdata[0] = ((float) ix) / 16384.0; + fdata[1] = ((float) iy) / 16384.0; + fdata[2] = ((float) iz) / 16384.0; } void FXLS8471Q::ReadXYZraw(int16_t * d) { -int res[6]; -int16_t acc; + int res[6]; + int16_t acc; RegRead(FXLS8471Q_OUT_X_MSB, res, 6); acc = (res[0] << 6) | (res[1] >> 2); @@ -127,5 +126,4 @@ acc -= UINT14_MAX; d[2] = acc; } - - \ No newline at end of file +