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
FXLS8471Q.h@3:b1fd3a2572e2, 2014-06-02 (annotated)
- Committer:
- screamer
- Date:
- Mon Jun 02 17:37:44 2014 +0000
- Revision:
- 3:b1fd3a2572e2
- Parent:
- 2:6aae25fe9ab4
- Child:
- 4:b6e0c4ad3aee
Documentation fixes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JimCarver | 1:c80be04510fe | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
JimCarver | 1:c80be04510fe | 2 | * |
JimCarver | 1:c80be04510fe | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
JimCarver | 1:c80be04510fe | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
JimCarver | 1:c80be04510fe | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
JimCarver | 1:c80be04510fe | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
JimCarver | 1:c80be04510fe | 7 | * Software is furnished to do so, subject to the following conditions: |
JimCarver | 1:c80be04510fe | 8 | * |
JimCarver | 1:c80be04510fe | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
JimCarver | 1:c80be04510fe | 10 | * substantial portions of the Software. |
JimCarver | 1:c80be04510fe | 11 | * |
JimCarver | 1:c80be04510fe | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
JimCarver | 1:c80be04510fe | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
JimCarver | 1:c80be04510fe | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
JimCarver | 1:c80be04510fe | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
JimCarver | 1:c80be04510fe | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
JimCarver | 1:c80be04510fe | 17 | */ |
JimCarver | 1:c80be04510fe | 18 | |
JimCarver | 1:c80be04510fe | 19 | |
JimCarver | 0:f89f2dc4b003 | 20 | #ifndef FXLS8471Q_H |
JimCarver | 0:f89f2dc4b003 | 21 | #define FXLS8471Q_H |
JimCarver | 0:f89f2dc4b003 | 22 | |
JimCarver | 0:f89f2dc4b003 | 23 | #include "mbed.h" |
JimCarver | 0:f89f2dc4b003 | 24 | |
JimCarver | 0:f89f2dc4b003 | 25 | // FXLS8471Q internal register addresses |
JimCarver | 0:f89f2dc4b003 | 26 | |
JimCarver | 0:f89f2dc4b003 | 27 | #define FXLS8471Q_STATUS 0x00 |
JimCarver | 1:c80be04510fe | 28 | #define FXLS8471Q_OUT_X_MSB 0x01 |
JimCarver | 0:f89f2dc4b003 | 29 | #define FXLS8471Q_WHOAMI 0x0D |
JimCarver | 0:f89f2dc4b003 | 30 | #define FXLS8471Q_XYZ_DATA_CFG 0x0E |
JimCarver | 0:f89f2dc4b003 | 31 | #define FXLS8471Q_CTRL_REG1 0x2A |
JimCarver | 0:f89f2dc4b003 | 32 | #define FXLS8471Q_WHOAMI_VAL 0x6A |
JimCarver | 0:f89f2dc4b003 | 33 | |
screamer | 2:6aae25fe9ab4 | 34 | /** |
screamer | 2:6aae25fe9ab4 | 35 | * FXLS8471Q Xtrinsic accelerometer on SPI |
screamer | 2:6aae25fe9ab4 | 36 | */ |
JimCarver | 0:f89f2dc4b003 | 37 | class FXLS8471Q |
JimCarver | 0:f89f2dc4b003 | 38 | { |
JimCarver | 0:f89f2dc4b003 | 39 | public: |
screamer | 2:6aae25fe9ab4 | 40 | /** |
screamer | 2:6aae25fe9ab4 | 41 | * FXLS8471Q constructor |
screamer | 2:6aae25fe9ab4 | 42 | * |
screamer | 2:6aae25fe9ab4 | 43 | * @param mosi MOSI pin |
screamer | 2:6aae25fe9ab4 | 44 | * @param miso MISO pin |
screamer | 2:6aae25fe9ab4 | 45 | * @param scl SCL pin |
screamer | 2:6aae25fe9ab4 | 46 | * @param cs Device Chip Select pin |
screamer | 2:6aae25fe9ab4 | 47 | */ |
screamer | 2:6aae25fe9ab4 | 48 | FXLS8471Q(PinName mosi, PinName miso, PinName scl, PinName cs); |
JimCarver | 0:f89f2dc4b003 | 49 | |
screamer | 2:6aae25fe9ab4 | 50 | /** |
screamer | 3:b1fd3a2572e2 | 51 | * Get XYZ axis acceleration in G's as floating point |
screamer | 2:6aae25fe9ab4 | 52 | * |
screamer | 2:6aae25fe9ab4 | 53 | * @param res array where acceleration data will be stored |
screamer | 2:6aae25fe9ab4 | 54 | */ |
screamer | 2:6aae25fe9ab4 | 55 | void ReadXYZ(float * a); |
JimCarver | 1:c80be04510fe | 56 | |
screamer | 2:6aae25fe9ab4 | 57 | /** |
screamer | 3:b1fd3a2572e2 | 58 | * Get XYZ axis acceleration as signed 16 bit values |
screamer | 2:6aae25fe9ab4 | 59 | * |
screamer | 2:6aae25fe9ab4 | 60 | * @param res array where acceleration data will be stored |
screamer | 2:6aae25fe9ab4 | 61 | */ |
screamer | 2:6aae25fe9ab4 | 62 | void ReadXYZraw(int16_t * d); |
screamer | 2:6aae25fe9ab4 | 63 | |
screamer | 2:6aae25fe9ab4 | 64 | /** |
screamer | 2:6aae25fe9ab4 | 65 | * Get the value of the WHO_AM_I register |
screamer | 2:6aae25fe9ab4 | 66 | * |
screamer | 2:6aae25fe9ab4 | 67 | * @returns WHO_AM_I value |
screamer | 2:6aae25fe9ab4 | 68 | */ |
screamer | 2:6aae25fe9ab4 | 69 | char getWhoAmI(void); |
screamer | 2:6aae25fe9ab4 | 70 | |
JimCarver | 0:f89f2dc4b003 | 71 | private: |
screamer | 3:b1fd3a2572e2 | 72 | SPI _spi; |
JimCarver | 0:f89f2dc4b003 | 73 | |
JimCarver | 0:f89f2dc4b003 | 74 | DigitalOut _spi_cs; |
JimCarver | 1:c80be04510fe | 75 | |
screamer | 3:b1fd3a2572e2 | 76 | /** |
screamer | 3:b1fd3a2572e2 | 77 | * Set the device in active mode |
screamer | 3:b1fd3a2572e2 | 78 | */ |
JimCarver | 0:f89f2dc4b003 | 79 | void begin( void); |
screamer | 3:b1fd3a2572e2 | 80 | |
screamer | 2:6aae25fe9ab4 | 81 | void RegWrite( int reg, int * d, int len); |
screamer | 3:b1fd3a2572e2 | 82 | |
JimCarver | 0:f89f2dc4b003 | 83 | void RegRead( int reg, int * d, int len); |
JimCarver | 0:f89f2dc4b003 | 84 | }; |
JimCarver | 0:f89f2dc4b003 | 85 | |
JimCarver | 0:f89f2dc4b003 | 86 | #endif |