Unit testing and development for 9DOF sparkfun sensor stick

Dependencies:   ADXL345 HMC5883L ITG3200 mbed

Committer:
tylerjw
Date:
Fri Nov 09 18:33:29 2012 +0000
Revision:
5:63b115f85aa7
Parent:
4:8a77e21d08f1
ITG3200 curve fit test

Who changed what in which revision?

UserRevisionLine numberNew 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 3:5e21a352e236 43 ADXL345UNIT(I2C &i2c, Timer &t);
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 3:5e21a352e236 51 * Perform built in self test and print results to BIST.csv
tylerjw 3:5e21a352e236 52 * Raw data is printed to BIST_RAW.csv
tylerjw 3:5e21a352e236 53 *
tylerjw 4:8a77e21d08f1 54 * Working
tylerjw 3:5e21a352e236 55 *
tylerjw 3:5e21a352e236 56 * @param store_raw true to store raw data
tylerjw 3:5e21a352e236 57 * @returns test result: true if passed, false if failed
tylerjw 3:5e21a352e236 58 */
tylerjw 3:5e21a352e236 59 bool builtInSelfTest(bool);
tylerjw 3:5e21a352e236 60
tylerjw 3:5e21a352e236 61 /**
tylerjw 3:5e21a352e236 62 * Performs the offset callibration test and prints to OFF_CAL.csv
tylerjw 3:5e21a352e236 63 *
tylerjw 4:8a77e21d08f1 64 * Working
tylerjw 2:d7e66940541d 65 *
tylerjw 4:8a77e21d08f1 66 * Implemented in ADXL345 class
tylerjw 3:5e21a352e236 67 *
tylerjw 3:5e21a352e236 68 * @param store_raw true to store raw data
tylerjw 2:d7e66940541d 69 */
tylerjw 3:5e21a352e236 70 void offsetCalibration(bool);
tylerjw 3:5e21a352e236 71
tylerjw 2:d7e66940541d 72 private:
tylerjw 2:d7e66940541d 73 ADXL345 adxl345_;
tylerjw 2:d7e66940541d 74 Serial pc_;
tylerjw 2:d7e66940541d 75 DigitalOut open_file_;
tylerjw 3:5e21a352e236 76 Timer t_;
tylerjw 2:d7e66940541d 77
tylerjw 2:d7e66940541d 78 /**
tylerjw 2:d7e66940541d 79 * Averages an array of n length
tylerjw 2:d7e66940541d 80 *
tylerjw 2:d7e66940541d 81 * @param the array
tylerjw 2:d7e66940541d 82 * @param length
tylerjw 2:d7e66940541d 83 */
tylerjw 3:5e21a352e236 84 int16_t arr_avg(int16_t*,int16_t);
tylerjw 3:5e21a352e236 85
tylerjw 3:5e21a352e236 86 /**
tylerjw 3:5e21a352e236 87 * Sample 100 times and average
tylerjw 3:5e21a352e236 88 *
tylerjw 3:5e21a352e236 89 * @param period of sample rate
tylerjw 3:5e21a352e236 90 * @param array to hold raw data, should be int16_t[100][3] (sample,axis)
tylerjw 3:5e21a352e236 91 * @param array to hold averages, should be 3 in length
tylerjw 3:5e21a352e236 92 * @param pointer to timer object (should already be started)
tylerjw 3:5e21a352e236 93 */
tylerjw 3:5e21a352e236 94 void sample100avg(float, int16_t[][3], int16_t*, Timer*);
tylerjw 2:d7e66940541d 95 };
tylerjw 2:d7e66940541d 96
tylerjw 2:d7e66940541d 97 #endif