Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

ak09970ctrl.h

Committer:
masahikofukasawa
Date:
2016-07-08
Revision:
10:5c69b067d88a
Child:
13:d008249f0359

File content as of revision 10:5c69b067d88a:

#ifndef AK09970CTRL_H
#define AK09970CTRL_H

#include "mbed.h"
#include "SerialNano.h"
#include "akmsensor.h"
#include "ak09970.h"

class Ak09970Ctrl : public AkmSensor
{

public:

    // SUB ID
    typedef enum {                           // 5bit ID
        SUB_ID_AK09970              = 0x03,  // 3
    } SubIdSwitch;
    
    /**
     * Constructor.
     *
     */
    Ak09970Ctrl();

    /**
     * Destructor.
     *
     */
    virtual ~Ak09970Ctrl();
    virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid);
    virtual bool isEvent();
    virtual AkmSensor::Status startSensor();
    virtual AkmSensor::Status startSensor(const float sec);
    virtual AkmSensor::Status stopSensor();
    virtual AkmSensor::Status readSensorData(Message* msg);
    virtual AkmSensor::Status requestCommand(Message* in, Message* out);

    void checkINT();
    void detectINT();
    char* getSensorName();
    
private:
    bool            event;    
    uint8_t         primaryId;
    uint8_t         subId;
    AK09970*        ak09970;

    // hold settings for AK09970
    AK09970::Threshold threshold;
    AK09970::OperationMode mode;
    AK09970::SensorDriveMode sensorDriveMode;
    AK09970::SensorMeasurementRange sensorMeasurementRange;
    AK09970::ReadConfig readConfig;
    AK09970::SwitchConfig switchConfig;

    InterruptIn*    sw;    
    char*           sensorName;
};

#endif