Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

Committer:
masahikofukasawa
Date:
Fri Nov 03 19:45:33 2017 +0000
Revision:
42:b48b3ab8690e
Parent:
41:a3ea80c594ec
Child:
43:45225713cd58
TBD. Try to change serial baud rate to 1Mbps or 921600bps.

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