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@43:55e7bb4d9b60, 2017-08-30 (annotated)
- Committer:
- Shaun Nelson
- Date:
- Wed Aug 30 12:35:33 2017 -0400
- Revision:
- 43:55e7bb4d9b60
- Parent:
- 41:208af6be1869
Simplified orientation change detection
Implement button press events
EVB Button1(left) for backend enabled state status (2 sblink = disabled, 3 = enabled)
EVB Button2(right) toggle bacend enabled status
LED Behavior
- LED solid when backend out of sync
- LED blinks on downlink
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 |
28:4fd8a894a403 | 18 | extern mDot *mDotPtr; |
Shaun Nelson |
27:1753a44fa9ec | 19 | |
Shaun Nelson |
27:1753a44fa9ec | 20 | enum EBoardState |
Shaun Nelson |
27:1753a44fa9ec | 21 | { |
Shaun Nelson |
27:1753a44fa9ec | 22 | Board_init, |
Shaun Nelson |
27:1753a44fa9ec | 23 | Board_start, |
Shaun Nelson |
27:1753a44fa9ec | 24 | Board_stop, |
Shaun Nelson |
27:1753a44fa9ec | 25 | }; |
Shaun Nelson |
27:1753a44fa9ec | 26 | |
Shaun Nelson |
27:1753a44fa9ec | 27 | struct BoardOrientation |
Shaun Nelson |
27:1753a44fa9ec | 28 | { |
Shaun Nelson |
28:4fd8a894a403 | 29 | bool vertical; |
Shaun Nelson |
27:1753a44fa9ec | 30 | bool up; |
Shaun Nelson |
27:1753a44fa9ec | 31 | bool down; |
Shaun Nelson |
27:1753a44fa9ec | 32 | bool right; |
Shaun Nelson |
27:1753a44fa9ec | 33 | bool left; |
Shaun Nelson |
27:1753a44fa9ec | 34 | |
Shaun Nelson |
27:1753a44fa9ec | 35 | void init() |
Shaun Nelson |
27:1753a44fa9ec | 36 | { |
Shaun Nelson |
28:4fd8a894a403 | 37 | vertical = false; |
Shaun Nelson |
28:4fd8a894a403 | 38 | up = false; |
Shaun Nelson |
28:4fd8a894a403 | 39 | down = false; |
Shaun Nelson |
28:4fd8a894a403 | 40 | right = false; |
Shaun Nelson |
28:4fd8a894a403 | 41 | left = false; |
Shaun Nelson |
27:1753a44fa9ec | 42 | } |
Shaun Nelson |
27:1753a44fa9ec | 43 | |
Shaun Nelson |
27:1753a44fa9ec | 44 | BoardOrientation() { init(); } |
Shaun Nelson |
27:1753a44fa9ec | 45 | }; |
Shaun Nelson |
27:1753a44fa9ec | 46 | |
Shaun Nelson |
27:1753a44fa9ec | 47 | /* |
Shaun Nelson |
27:1753a44fa9ec | 48 | * Board sensor data |
Shaun Nelson |
27:1753a44fa9ec | 49 | */ |
Shaun Nelson |
27:1753a44fa9ec | 50 | struct BoardSensorData |
Shaun Nelson |
27:1753a44fa9ec | 51 | { |
Shaun Nelson |
27:1753a44fa9ec | 52 | float temperature; |
Shaun Nelson |
27:1753a44fa9ec | 53 | float pressure; |
Shaun Nelson |
27:1753a44fa9ec | 54 | int32_t accel_x; |
Shaun Nelson |
27:1753a44fa9ec | 55 | int32_t accel_y; |
Shaun Nelson |
27:1753a44fa9ec | 56 | int32_t accel_z; |
Shaun Nelson |
27:1753a44fa9ec | 57 | BoardOrientation orientation; |
Shaun Nelson |
27:1753a44fa9ec | 58 | |
Shaun Nelson |
27:1753a44fa9ec | 59 | inline void init() |
Shaun Nelson |
27:1753a44fa9ec | 60 | { |
Shaun Nelson |
27:1753a44fa9ec | 61 | temperature= 0; |
Shaun Nelson |
27:1753a44fa9ec | 62 | pressure = 0; |
Shaun Nelson |
27:1753a44fa9ec | 63 | accel_x = 0; |
Shaun Nelson |
27:1753a44fa9ec | 64 | accel_y = 0; |
Shaun Nelson |
27:1753a44fa9ec | 65 | accel_z = 0; |
Shaun Nelson |
27:1753a44fa9ec | 66 | orientation.init(); |
Shaun Nelson |
27:1753a44fa9ec | 67 | } |
Shaun Nelson |
27:1753a44fa9ec | 68 | |
Shaun Nelson |
27:1753a44fa9ec | 69 | BoardSensorData() { init(); } |
Shaun Nelson |
27:1753a44fa9ec | 70 | }; |
Shaun Nelson |
27:1753a44fa9ec | 71 | |
Shaun Nelson |
28:4fd8a894a403 | 72 | enum EBoardStatus |
Shaun Nelson |
28:4fd8a894a403 | 73 | { |
Shaun Nelson |
28:4fd8a894a403 | 74 | Board_Ok, |
Shaun Nelson |
39:022b327d6bf0 | 75 | Board_Fail, |
Shaun Nelson |
39:022b327d6bf0 | 76 | Board_Invalid |
Shaun Nelson |
28:4fd8a894a403 | 77 | }; |
Shaun Nelson |
27:1753a44fa9ec | 78 | |
Shaun Nelson |
41:208af6be1869 | 79 | typedef void (*PB_FUNC)(uint8_t button); |
Shaun Nelson |
39:022b327d6bf0 | 80 | |
Shaun Nelson |
28:4fd8a894a403 | 81 | EBoardStatus BoardInit(); |
Shaun Nelson |
28:4fd8a894a403 | 82 | |
Shaun Nelson |
28:4fd8a894a403 | 83 | class CBoard |
Shaun Nelson |
28:4fd8a894a403 | 84 | { |
Shaun Nelson |
28:4fd8a894a403 | 85 | public: |
Shaun Nelson |
28:4fd8a894a403 | 86 | |
Shaun Nelson |
28:4fd8a894a403 | 87 | static EBoardStatus ReadSensors(BoardSensorData &data ) { return ( ( boardPtr != 0 ) ? boardPtr->readSensors( data ) : Board_Fail ); } |
Shaun Nelson |
28:4fd8a894a403 | 88 | static EBoardStatus Init() { return ( ( boardPtr != 0 ) ? boardPtr->init( ) : Board_Fail ); } |
Shaun Nelson |
28:4fd8a894a403 | 89 | static EBoardStatus Start() { return ( ( boardPtr != 0 ) ? boardPtr->start( ) : Board_Fail ); } |
Shaun Nelson |
39:022b327d6bf0 | 90 | static EBoardStatus SetLED(uint8_t ledNum, bool on) { return ( ( boardPtr != 0 ) ? boardPtr->setLED(ledNum, on ) : Board_Fail ); } |
Shaun Nelson |
39:022b327d6bf0 | 91 | static EBoardStatus ToggleLED(uint8_t ledNum) { return ( ( boardPtr != 0 ) ? boardPtr->toggleLED(ledNum) : Board_Fail ); } |
Shaun Nelson |
41:208af6be1869 | 92 | static void SetButtonCallback(PB_FUNC func) { buttonCallback = func; } |
Shaun Nelson |
27:1753a44fa9ec | 93 | |
Shaun Nelson |
28:4fd8a894a403 | 94 | protected: |
Shaun Nelson |
28:4fd8a894a403 | 95 | |
Shaun Nelson |
28:4fd8a894a403 | 96 | virtual EBoardStatus init(); |
Shaun Nelson |
28:4fd8a894a403 | 97 | virtual EBoardStatus readSensors ( BoardSensorData &data ) { return Board_Fail; } |
Shaun Nelson |
28:4fd8a894a403 | 98 | virtual EBoardStatus start() { return Board_Ok; } |
Shaun Nelson |
39:022b327d6bf0 | 99 | virtual EBoardStatus setLED(uint8_t ledNum, bool on) { return Board_Fail; } |
Shaun Nelson |
39:022b327d6bf0 | 100 | virtual EBoardStatus toggleLED(uint8_t ledNum) { return Board_Fail; } |
Shaun Nelson |
28:4fd8a894a403 | 101 | |
Shaun Nelson |
41:208af6be1869 | 102 | static PB_FUNC buttonCallback; |
Shaun Nelson |
41:208af6be1869 | 103 | static CBoard *boardPtr; |
Shaun Nelson |
28:4fd8a894a403 | 104 | |
Shaun Nelson |
28:4fd8a894a403 | 105 | friend EBoardStatus BoardInit(); |
Shaun Nelson |
41:208af6be1869 | 106 | |
Shaun Nelson |
28:4fd8a894a403 | 107 | }; |
Shaun Nelson |
27:1753a44fa9ec | 108 | |
Shaun Nelson |
27:1753a44fa9ec | 109 | #endif /* BOARD_BOARD_H_ */ |