Unit testing and development for 9DOF sparkfun sensor stick
Dependencies: ADXL345 HMC5883L ITG3200 mbed
adxl345unit.h@2:d7e66940541d, 2012-11-01 (annotated)
- Committer:
- tylerjw
- Date:
- Thu Nov 01 18:46:58 2012 +0000
- Revision:
- 2:d7e66940541d
- Child:
- 3:5e21a352e236
ADXL345 unit test initial commit, built in self test (not tested)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tylerjw | 2:d7e66940541d | 1 | /* |
tylerjw | 2:d7e66940541d | 2 | * @file adxl345unit.h |
tylerjw | 2:d7e66940541d | 3 | * @author Tyler Weaver |
tylerjw | 2:d7e66940541d | 4 | * |
tylerjw | 2:d7e66940541d | 5 | * @section LICENSE |
tylerjw | 2:d7e66940541d | 6 | * |
tylerjw | 2:d7e66940541d | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
tylerjw | 2:d7e66940541d | 8 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
tylerjw | 2:d7e66940541d | 9 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
tylerjw | 2:d7e66940541d | 10 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
tylerjw | 2:d7e66940541d | 11 | * furnished to do so, subject to the following conditions: |
tylerjw | 2:d7e66940541d | 12 | * |
tylerjw | 2:d7e66940541d | 13 | * The above copyright notice and this permission notice shall be included in all copies or |
tylerjw | 2:d7e66940541d | 14 | * substantial portions of the Software. |
tylerjw | 2:d7e66940541d | 15 | * |
tylerjw | 2:d7e66940541d | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
tylerjw | 2:d7e66940541d | 17 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
tylerjw | 2:d7e66940541d | 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
tylerjw | 2:d7e66940541d | 19 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
tylerjw | 2:d7e66940541d | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
tylerjw | 2:d7e66940541d | 21 | * |
tylerjw | 2:d7e66940541d | 22 | * @section DESCRIPTION |
tylerjw | 2:d7e66940541d | 23 | * |
tylerjw | 2:d7e66940541d | 24 | * Unit test for the ADXL345 library. |
tylerjw | 2:d7e66940541d | 25 | * |
tylerjw | 2:d7e66940541d | 26 | * Reference: |
tylerjw | 2:d7e66940541d | 27 | */ |
tylerjw | 2:d7e66940541d | 28 | |
tylerjw | 2:d7e66940541d | 29 | #ifndef ADXL345UNIT_H |
tylerjw | 2:d7e66940541d | 30 | #define ADXL345UNIT_H |
tylerjw | 2:d7e66940541d | 31 | |
tylerjw | 2:d7e66940541d | 32 | #include "mbed.h" |
tylerjw | 2:d7e66940541d | 33 | #include "ADXL345.h" |
tylerjw | 2:d7e66940541d | 34 | |
tylerjw | 2:d7e66940541d | 35 | class ADXL345UNIT { |
tylerjw | 2:d7e66940541d | 36 | public: |
tylerjw | 2:d7e66940541d | 37 | /** |
tylerjw | 2:d7e66940541d | 38 | * Constructor |
tylerjw | 2:d7e66940541d | 39 | * runs init() |
tylerjw | 2:d7e66940541d | 40 | * |
tylerjw | 2:d7e66940541d | 41 | * @param i2c buss to use for adxl345 |
tylerjw | 2:d7e66940541d | 42 | */ |
tylerjw | 2:d7e66940541d | 43 | ADXL345UNIT(I2C &i2c); |
tylerjw | 2:d7e66940541d | 44 | |
tylerjw | 2:d7e66940541d | 45 | /** |
tylerjw | 2:d7e66940541d | 46 | * Initalize the device |
tylerjw | 2:d7e66940541d | 47 | */ |
tylerjw | 2:d7e66940541d | 48 | void init(); |
tylerjw | 2:d7e66940541d | 49 | |
tylerjw | 2:d7e66940541d | 50 | /** |
tylerjw | 2:d7e66940541d | 51 | * Perform built in self test and print results to ADXL_BIT.csv |
tylerjw | 2:d7e66940541d | 52 | * |
tylerjw | 2:d7e66940541d | 53 | * @returns true if passed, false if failed |
tylerjw | 2:d7e66940541d | 54 | */ |
tylerjw | 2:d7e66940541d | 55 | bool builtInSelfTest(); |
tylerjw | 2:d7e66940541d | 56 | private: |
tylerjw | 2:d7e66940541d | 57 | ADXL345 adxl345_; |
tylerjw | 2:d7e66940541d | 58 | Serial pc_; |
tylerjw | 2:d7e66940541d | 59 | LocalFileSystem local_; |
tylerjw | 2:d7e66940541d | 60 | DigitalOut open_file_; |
tylerjw | 2:d7e66940541d | 61 | |
tylerjw | 2:d7e66940541d | 62 | /** |
tylerjw | 2:d7e66940541d | 63 | * Averages an array of n length |
tylerjw | 2:d7e66940541d | 64 | * |
tylerjw | 2:d7e66940541d | 65 | * @param the array |
tylerjw | 2:d7e66940541d | 66 | * @param length |
tylerjw | 2:d7e66940541d | 67 | */ |
tylerjw | 2:d7e66940541d | 68 | int arr_avg(int*,int); |
tylerjw | 2:d7e66940541d | 69 | }; |
tylerjw | 2:d7e66940541d | 70 | |
tylerjw | 2:d7e66940541d | 71 | #endif |