Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

akmsensormanager.h

Committer:
masahikofukasawa
Date:
2017-01-04
Revision:
16:d85be9bafb80
Parent:
15:1238993fd75f
Child:
24:1d37438f31a9
Child:
27:41aa9fb23a2f

File content as of revision 16:d85be9bafb80:

#ifndef AKMSENSORMANAGER_H
#define AKMSENSORMANAGER_H

#include "mbed.h"
#include "SerialNano.h"
#include "akmsensor.h"
#include "Message.h"
#include "debug.h"
#include "ble/BLE.h"
#include "mcp342x.h"

#define ANALOG_SENSOR_ID             P0_4
#define ANALOG_SENSOR_ID_SUB         P0_5

class AkmSensorManager {
    public:
    
    typedef enum {
        SUCCESS = 0,
        ERROR,
    } Status;
    
    AkmSensorManager(SerialNano* com);
    Status init(uint8_t id, uint8_t subid);
    void setBleUartService(UARTService* service);
    void setEventConnected();
    void setEventDisconnected();
    Status commandReceived(char* buf);
    bool isEvent();
    Status processEvent();
    char* getSensorName();
    
    void processCommand();
    Status throwMessage(const Message *msg);
//    void releaseTWI();
    uint8_t getId(PinName pin, uint8_t bits);
    
    private:
    
    AkmSensor* sensor;
    SerialNano* serial;
    UARTService* uartService;
    Message msg;
    Timeout t;

    uint8_t         primaryId;
    uint8_t         subId;
    bool isEnabledBle;
    bool isEnabledUsb;
    bool eventCommandReceived;
    bool eventConnected;
    bool eventDisconnected;

    char userCommand[20];
    
    AkmSensor* getAkmSensor();
    void dataOut(char* str);
    int16_t getAdcData(MCP342X *mcp3428, MCP342X::AdcChannel ch, MCP342X::SampleSetting s);
    void dummyCallbackForCommandReceived();
};

#endif // AKMSENSORMANAGER_H