mdot UDK & STMicro MEMS Shield Sensor packet example
Dependencies: libmDot-mbed5 DOGS102 ISL29011 MMA845x MPL3115A2 NCP5623B X_NUCLEO_IKS01A1 Senet_Packet
Fork of MTDOT-UDKDemo_Senet by
board/board.h@28:4fd8a894a403, 2017-08-25 (annotated)
- Committer:
- Shaun Nelson
- Date:
- Fri Aug 25 09:29:01 2017 -0400
- Branch:
- develop
- Revision:
- 28:4fd8a894a403
- Parent:
- 27:1753a44fa9ec
- Child:
- 39:022b327d6bf0
Create board api class and implement for EVB and UDK mDot boards.
UDK platform is working
Do not try EVB, not sure it even compiles
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Shaun Nelson |
27:1753a44fa9ec | 1 | /*** |
Shaun Nelson |
27:1753a44fa9ec | 2 | * _____ _ |
Shaun Nelson |
27:1753a44fa9ec | 3 | * / ____| | | |
Shaun Nelson |
27:1753a44fa9ec | 4 | * | (___ ___ _ __ ___ | |_ |
Shaun Nelson |
27:1753a44fa9ec | 5 | * \___ \ / _ \ | '_ \ / _ \ | __| |
Shaun Nelson |
27:1753a44fa9ec | 6 | * ____) | | __/ | | | | | __/ | |_ |
Shaun Nelson |
27:1753a44fa9ec | 7 | * |_____/ \___| |_| |_| \___| \__| |
Shaun Nelson |
27:1753a44fa9ec | 8 | * (C) Senet, Inc |
Shaun Nelson |
27:1753a44fa9ec | 9 | * |
Shaun Nelson |
27:1753a44fa9ec | 10 | */ |
Shaun Nelson |
27:1753a44fa9ec | 11 | #ifndef BOARD_BOARD_H_ |
Shaun Nelson |
27:1753a44fa9ec | 12 | #define BOARD_BOARD_H_ |
Shaun Nelson |
27:1753a44fa9ec | 13 | |
Shaun Nelson |
27:1753a44fa9ec | 14 | #include "mbed.h" |
Shaun Nelson |
28:4fd8a894a403 | 15 | #include "mDot.h" |
Shaun Nelson |
27:1753a44fa9ec | 16 | |
Shaun Nelson |
27:1753a44fa9ec | 17 | extern Serial debugUART; |
Shaun Nelson |
27:1753a44fa9ec | 18 | extern DigitalOut appLED; |
Shaun Nelson |
28:4fd8a894a403 | 19 | extern mDot *mDotPtr; |
Shaun Nelson |
27:1753a44fa9ec | 20 | |
Shaun Nelson |
27:1753a44fa9ec | 21 | enum EBoardState |
Shaun Nelson |
27:1753a44fa9ec | 22 | { |
Shaun Nelson |
27:1753a44fa9ec | 23 | Board_init, |
Shaun Nelson |
27:1753a44fa9ec | 24 | Board_start, |
Shaun Nelson |
27:1753a44fa9ec | 25 | Board_stop, |
Shaun Nelson |
27:1753a44fa9ec | 26 | }; |
Shaun Nelson |
27:1753a44fa9ec | 27 | |
Shaun Nelson |
27:1753a44fa9ec | 28 | struct BoardOrientation |
Shaun Nelson |
27:1753a44fa9ec | 29 | { |
Shaun Nelson |
28:4fd8a894a403 | 30 | bool vertical; |
Shaun Nelson |
27:1753a44fa9ec | 31 | bool up; |
Shaun Nelson |
27:1753a44fa9ec | 32 | bool down; |
Shaun Nelson |
27:1753a44fa9ec | 33 | bool right; |
Shaun Nelson |
27:1753a44fa9ec | 34 | bool left; |
Shaun Nelson |
27:1753a44fa9ec | 35 | |
Shaun Nelson |
27:1753a44fa9ec | 36 | void init() |
Shaun Nelson |
27:1753a44fa9ec | 37 | { |
Shaun Nelson |
28:4fd8a894a403 | 38 | vertical = false; |
Shaun Nelson |
28:4fd8a894a403 | 39 | up = false; |
Shaun Nelson |
28:4fd8a894a403 | 40 | down = false; |
Shaun Nelson |
28:4fd8a894a403 | 41 | right = false; |
Shaun Nelson |
28:4fd8a894a403 | 42 | left = false; |
Shaun Nelson |
27:1753a44fa9ec | 43 | } |
Shaun Nelson |
27:1753a44fa9ec | 44 | |
Shaun Nelson |
27:1753a44fa9ec | 45 | BoardOrientation() { init(); } |
Shaun Nelson |
27:1753a44fa9ec | 46 | }; |
Shaun Nelson |
27:1753a44fa9ec | 47 | |
Shaun Nelson |
27:1753a44fa9ec | 48 | /* |
Shaun Nelson |
27:1753a44fa9ec | 49 | * Board sensor data |
Shaun Nelson |
27:1753a44fa9ec | 50 | */ |
Shaun Nelson |
27:1753a44fa9ec | 51 | struct BoardSensorData |
Shaun Nelson |
27:1753a44fa9ec | 52 | { |
Shaun Nelson |
27:1753a44fa9ec | 53 | float temperature; |
Shaun Nelson |
27:1753a44fa9ec | 54 | float pressure; |
Shaun Nelson |
27:1753a44fa9ec | 55 | int32_t accel_x; |
Shaun Nelson |
27:1753a44fa9ec | 56 | int32_t accel_y; |
Shaun Nelson |
27:1753a44fa9ec | 57 | int32_t accel_z; |
Shaun Nelson |
27:1753a44fa9ec | 58 | BoardOrientation orientation; |
Shaun Nelson |
27:1753a44fa9ec | 59 | |
Shaun Nelson |
27:1753a44fa9ec | 60 | inline void init() |
Shaun Nelson |
27:1753a44fa9ec | 61 | { |
Shaun Nelson |
27:1753a44fa9ec | 62 | temperature= 0; |
Shaun Nelson |
27:1753a44fa9ec | 63 | pressure = 0; |
Shaun Nelson |
27:1753a44fa9ec | 64 | accel_x = 0; |
Shaun Nelson |
27:1753a44fa9ec | 65 | accel_y = 0; |
Shaun Nelson |
27:1753a44fa9ec | 66 | accel_z = 0; |
Shaun Nelson |
27:1753a44fa9ec | 67 | orientation.init(); |
Shaun Nelson |
27:1753a44fa9ec | 68 | } |
Shaun Nelson |
27:1753a44fa9ec | 69 | |
Shaun Nelson |
27:1753a44fa9ec | 70 | BoardSensorData() { init(); } |
Shaun Nelson |
27:1753a44fa9ec | 71 | }; |
Shaun Nelson |
27:1753a44fa9ec | 72 | |
Shaun Nelson |
28:4fd8a894a403 | 73 | enum EBoardStatus |
Shaun Nelson |
28:4fd8a894a403 | 74 | { |
Shaun Nelson |
28:4fd8a894a403 | 75 | Board_Ok, |
Shaun Nelson |
28:4fd8a894a403 | 76 | Board_Fail |
Shaun Nelson |
28:4fd8a894a403 | 77 | }; |
Shaun Nelson |
27:1753a44fa9ec | 78 | |
Shaun Nelson |
28:4fd8a894a403 | 79 | EBoardStatus BoardInit(); |
Shaun Nelson |
28:4fd8a894a403 | 80 | |
Shaun Nelson |
28:4fd8a894a403 | 81 | class CBoard |
Shaun Nelson |
28:4fd8a894a403 | 82 | { |
Shaun Nelson |
28:4fd8a894a403 | 83 | public: |
Shaun Nelson |
28:4fd8a894a403 | 84 | |
Shaun Nelson |
28:4fd8a894a403 | 85 | static EBoardStatus ReadSensors(BoardSensorData &data ) { return ( ( boardPtr != 0 ) ? boardPtr->readSensors( data ) : Board_Fail ); } |
Shaun Nelson |
28:4fd8a894a403 | 86 | static EBoardStatus Init() { return ( ( boardPtr != 0 ) ? boardPtr->init( ) : Board_Fail ); } |
Shaun Nelson |
28:4fd8a894a403 | 87 | static EBoardStatus Start() { return ( ( boardPtr != 0 ) ? boardPtr->start( ) : Board_Fail ); } |
Shaun Nelson |
27:1753a44fa9ec | 88 | |
Shaun Nelson |
28:4fd8a894a403 | 89 | protected: |
Shaun Nelson |
28:4fd8a894a403 | 90 | |
Shaun Nelson |
28:4fd8a894a403 | 91 | virtual EBoardStatus init(); |
Shaun Nelson |
28:4fd8a894a403 | 92 | |
Shaun Nelson |
28:4fd8a894a403 | 93 | virtual EBoardStatus readSensors ( BoardSensorData &data ) { return Board_Fail; } |
Shaun Nelson |
28:4fd8a894a403 | 94 | virtual EBoardStatus start() { return Board_Ok; } |
Shaun Nelson |
28:4fd8a894a403 | 95 | |
Shaun Nelson |
28:4fd8a894a403 | 96 | static CBoard *boardPtr; |
Shaun Nelson |
28:4fd8a894a403 | 97 | |
Shaun Nelson |
28:4fd8a894a403 | 98 | friend EBoardStatus BoardInit(); |
Shaun Nelson |
28:4fd8a894a403 | 99 | }; |
Shaun Nelson |
27:1753a44fa9ec | 100 | |
Shaun Nelson |
27:1753a44fa9ec | 101 | #endif /* BOARD_BOARD_H_ */ |