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 canuck lehead

board/board.h

Committer:
Shaun Nelson
Date:
2017-08-25
Branch:
develop
Revision:
28:4fd8a894a403
Parent:
27:1753a44fa9ec
Child:
39:022b327d6bf0

File content as of revision 28:4fd8a894a403:

/***
 *       _____                         _   
 *      / ____|                       | |  
 *     | (___     ___   _ __     ___  | |_ 
 *      \___ \   / _ \ | '_ \   / _ \ | __|
 *      ____) | |  __/ | | | | |  __/ | |_ 
 *     |_____/   \___| |_| |_|  \___|  \__|
 *         (C) Senet, Inc                                
 *                                         
 */
#ifndef BOARD_BOARD_H_
#define BOARD_BOARD_H_

#include "mbed.h"
#include "mDot.h"

extern Serial     debugUART;
extern DigitalOut appLED;
extern mDot       *mDotPtr;

enum EBoardState
{
	Board_init,
	Board_start,
	Board_stop,
};

struct BoardOrientation
{
	bool vertical;
	bool up;
	bool down;
	bool right;
	bool left;

	void init()
	{
		vertical = false;
		up       = false;
		down     = false;
		right    = false;
		left     = false;
	}

	BoardOrientation() { init(); }
};

/*
 * Board sensor data
 */
struct BoardSensorData
{
    float temperature;
    float pressure;
    int32_t accel_x;
    int32_t accel_y;
    int32_t accel_z;
    BoardOrientation orientation;

    inline void init()
    {
        temperature= 0;
        pressure = 0;
        accel_x = 0;
        accel_y = 0;
        accel_z = 0;
        orientation.init();
    }

    BoardSensorData() { init(); }
};

enum EBoardStatus
{
	Board_Ok,
	Board_Fail
};

EBoardStatus BoardInit();

class CBoard
{
	public:

		static EBoardStatus ReadSensors(BoardSensorData  &data ) { return (  ( boardPtr != 0 ) ? boardPtr->readSensors( data ) : Board_Fail ); }
		static EBoardStatus Init()                               { return (  ( boardPtr != 0 ) ? boardPtr->init( )  : Board_Fail ); }
		static EBoardStatus Start()                              { return (  ( boardPtr != 0 ) ? boardPtr->start( ) : Board_Fail ); }

	protected:

		virtual EBoardStatus init();

		virtual EBoardStatus readSensors ( BoardSensorData &data ) { return Board_Fail; }
		virtual EBoardStatus start()                               { return Board_Ok;   }

		static CBoard *boardPtr;

		friend EBoardStatus BoardInit();
};

#endif /* BOARD_BOARD_H_ */