Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

Committer:
tkstreet
Date:
Tue May 01 21:31:15 2018 +0000
Revision:
49:c8f8946129b6
Parent:
43:45225713cd58
Modified for Rev.E. compatibility.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
masahikofukasawa 0:7a00359e701e 1 #ifndef AKMAKD_H
masahikofukasawa 0:7a00359e701e 2 #define AKMAKD_H
masahikofukasawa 0:7a00359e701e 3
masahikofukasawa 0:7a00359e701e 4 #include "mbed.h"
masahikofukasawa 0:7a00359e701e 5 #include "akmsensor.h"
masahikofukasawa 0:7a00359e701e 6 #include "akmecompass.h"
masahikofukasawa 0:7a00359e701e 7
masahikofukasawa 41:a3ea80c594ec 8 #define AKDP_POLLING_FREQUENCY (10.0) // [Hz]
masahikofukasawa 20:2fca76521680 9
tkstreet 23:50c98b286e41 10 /**
tkstreet 23:50c98b286e41 11 * Collection class for handling commands to all of the specialty AKM
tkstreet 23:50c98b286e41 12 * daughter board adapter modules.
tkstreet 23:50c98b286e41 13 *
tkstreet 23:50c98b286e41 14 * 3-Axis Electronic Compass Devices: AK8963C, AK8963N, AK09911C, AK09912C,
masahikofukasawa 41:a3ea80c594ec 15 * AK09915C, AK09915D, AK09916C, AK09916D, AK09917, AK09918, AK09940
tkstreet 23:50c98b286e41 16 */
masahikofukasawa 0:7a00359e701e 17 class AkmAkd : public AkmSensor
masahikofukasawa 0:7a00359e701e 18 {
masahikofukasawa 0:7a00359e701e 19
masahikofukasawa 0:7a00359e701e 20 public:
masahikofukasawa 29:b488d2c89fba 21
masahikofukasawa 29:b488d2c89fba 22 typedef AkmSensor base;
masahikofukasawa 0:7a00359e701e 23
tkstreet 23:50c98b286e41 24 /**
tkstreet 23:50c98b286e41 25 * List of daughter board adapter devices (5-bit Sub-IDs). Primary ID = 0Fh
tkstreet 23:50c98b286e41 26 */
tkstreet 23:50c98b286e41 27 typedef enum {
masahikofukasawa 42:b48b3ab8690e 28 SUB_ID_AK8963N = 0x1A, /**< AK8963N: ID = 1Ah (26) */
masahikofukasawa 42:b48b3ab8690e 29 SUB_ID_AK8963C = 0x1C, /**< AK8963C: ID = 1Ch (28) */
tkstreet 23:50c98b286e41 30 SUB_ID_AK09911C = 0x0A, /**< AK09911C: ID = 0Ah (10) */
masahikofukasawa 42:b48b3ab8690e 31 SUB_ID_AK09912C = 0x09, /**< AK09912C: ID = 09h (9) */
tkstreet 23:50c98b286e41 32 SUB_ID_AK09915C = 0x0D, /**< AK09915C: ID = 0Dh (13) */
tkstreet 23:50c98b286e41 33 SUB_ID_AK09916C = 0x0E, /**< AK09916C: ID = 0Eh (14) */
tkstreet 23:50c98b286e41 34 SUB_ID_AK09916D = 0x0F, /**< AK09916D: ID = 0Fh (15) */
tkstreet 23:50c98b286e41 35 SUB_ID_AK09915D = 0x10, /**< AK09915D: ID = 10h (16) */
masahikofukasawa 42:b48b3ab8690e 36 SUB_ID_AK09918 = 0x11, /**< AK09918: ID = 11h (17) */
masahikofukasawa 42:b48b3ab8690e 37 SUB_ID_AK09917 = 0x12, /**< AK09917: ID = 12h (18) */
masahikofukasawa 42:b48b3ab8690e 38 SUB_ID_AK09940 = 0x13, /**< AK09940: ID = 13h (19) */
masahikofukasawa 0:7a00359e701e 39 } SubIdAkd;
masahikofukasawa 0:7a00359e701e 40
masahikofukasawa 19:8dcc4f323bdc 41 typedef enum {
masahikofukasawa 19:8dcc4f323bdc 42 INTERRUPT_DISABLED = 0x00, // Polling
masahikofukasawa 19:8dcc4f323bdc 43 INTERRUPT_ENABLED_PP = 0x01, // Push-Pull
masahikofukasawa 19:8dcc4f323bdc 44 INTERRUPT_ENABLED_OD = 0x02, // Open drain
masahikofukasawa 19:8dcc4f323bdc 45 } InterruptMode;
masahikofukasawa 19:8dcc4f323bdc 46
masahikofukasawa 0:7a00359e701e 47 /**
masahikofukasawa 0:7a00359e701e 48 * Constructor.
masahikofukasawa 0:7a00359e701e 49 *
masahikofukasawa 0:7a00359e701e 50 */
masahikofukasawa 0:7a00359e701e 51 AkmAkd();
masahikofukasawa 0:7a00359e701e 52
masahikofukasawa 0:7a00359e701e 53 /**
masahikofukasawa 0:7a00359e701e 54 * Destructor.
masahikofukasawa 0:7a00359e701e 55 *
masahikofukasawa 0:7a00359e701e 56 */
masahikofukasawa 0:7a00359e701e 57 virtual ~AkmAkd();
tkstreet 23:50c98b286e41 58
tkstreet 23:50c98b286e41 59 /**
tkstreet 23:50c98b286e41 60 * Process for intializing the selected sensor.
tkstreet 23:50c98b286e41 61 *
tkstreet 23:50c98b286e41 62 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 63 */
masahikofukasawa 0:7a00359e701e 64 virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid);
tkstreet 34:1ea3357c8d9a 65
tkstreet 23:50c98b286e41 66 /**
tkstreet 23:50c98b286e41 67 * Process abstraction for starting sensor operation.
tkstreet 23:50c98b286e41 68 *
tkstreet 23:50c98b286e41 69 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 70 */
masahikofukasawa 0:7a00359e701e 71 virtual AkmSensor::Status startSensor();
tkstreet 23:50c98b286e41 72
tkstreet 23:50c98b286e41 73 /**
tkstreet 23:50c98b286e41 74 * Process abstraction for starting sensor operation.
tkstreet 23:50c98b286e41 75 *
tkstreet 23:50c98b286e41 76 * @param sec Number of seconds of operation.
tkstreet 23:50c98b286e41 77 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 78 */
masahikofukasawa 0:7a00359e701e 79 virtual AkmSensor::Status startSensor(const float sec);
tkstreet 23:50c98b286e41 80
tkstreet 23:50c98b286e41 81 /**
tkstreet 23:50c98b286e41 82 * Process abstraction for stopping sensor operation.
tkstreet 23:50c98b286e41 83 *
tkstreet 23:50c98b286e41 84 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 85 */
masahikofukasawa 0:7a00359e701e 86 virtual AkmSensor::Status stopSensor();
tkstreet 23:50c98b286e41 87
tkstreet 23:50c98b286e41 88 /**
tkstreet 23:50c98b286e41 89 * Process abstraction for reading data from the sensor.
tkstreet 23:50c98b286e41 90 *
tkstreet 23:50c98b286e41 91 * @param msg Message object that will hold the sensor data.
tkstreet 23:50c98b286e41 92 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 93 */
masahikofukasawa 0:7a00359e701e 94 virtual AkmSensor::Status readSensorData(Message* msg);
tkstreet 23:50c98b286e41 95
tkstreet 23:50c98b286e41 96 /**
tkstreet 23:50c98b286e41 97 * Primary process for interfacing a sensor with the AKDP. When implemented
tkstreet 23:50c98b286e41 98 * in sensor class, it will transfer commands between the the sensor control
tkstreet 23:50c98b286e41 99 * class and AkmSensorManager.
tkstreet 23:50c98b286e41 100 *
tkstreet 23:50c98b286e41 101 * @param in Command message to be processed by sensor.
tkstreet 23:50c98b286e41 102 * @param out Message returned from sensor.
tkstreet 23:50c98b286e41 103 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 104 */
masahikofukasawa 0:7a00359e701e 105 virtual Status requestCommand(Message* in, Message* out);
tkstreet 23:50c98b286e41 106
tkstreet 23:50c98b286e41 107 /**
tkstreet 34:1ea3357c8d9a 108 * Set event flag.
tkstreet 23:50c98b286e41 109 */
masahikofukasawa 29:b488d2c89fba 110 virtual void setEvent();
masahikofukasawa 0:7a00359e701e 111
masahikofukasawa 0:7a00359e701e 112 int getSensorType();
masahikofukasawa 19:8dcc4f323bdc 113 InterruptMode getInterrupt(uint8_t primaryId, uint8_t subId);
masahikofukasawa 20:2fca76521680 114 AkmSensor::Status checkSensor( const uint8_t primaryid, const uint8_t subid, AkmECompass::DeviceId* devid);
masahikofukasawa 19:8dcc4f323bdc 115
masahikofukasawa 0:7a00359e701e 116 private:
masahikofukasawa 0:7a00359e701e 117 Ticker ticker;
masahikofukasawa 0:7a00359e701e 118 AkmECompass* compass;
masahikofukasawa 41:a3ea80c594ec 119 AkmECompass::Mode mode;
masahikofukasawa 41:a3ea80c594ec 120 uint8_t lenOptions;
masahikofukasawa 0:7a00359e701e 121 };
masahikofukasawa 0:7a00359e701e 122
masahikofukasawa 0:7a00359e701e 123 #endif