Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
Diff: akmsensormanager.cpp
- Revision:
- 24:1d37438f31a9
- Parent:
- 23:50c98b286e41
- Parent:
- 18:b7182d5ad8d5
- Child:
- 33:d3e1e9eb2ef9
--- a/akmsensormanager.cpp Thu Apr 13 22:15:54 2017 +0000 +++ b/akmsensormanager.cpp Thu Apr 13 22:50:02 2017 +0000 @@ -13,7 +13,6 @@ #include "Message.h" #include "mcp342x.h" #include "I2CNano.h" -#include "tca9554a.h" #define MAGNETOMETER_ID 0x0A @@ -33,7 +32,7 @@ "Current Sensor", "MISC(Analog)", "Linear Sensor", - "TBD3", + "Motor Drivers", "IR Sensor", "Angle Sensor(SPI)", "AKD Daughter Cards(I2C)" @@ -79,6 +78,7 @@ AkmSensor* sensor = NULL; switch(primaryId){ + case AkmSensor::AKM_PRIMARY_ID_AKD_SPI: case AkmSensor::AKM_PRIMARY_ID_AKD_I2C: { @@ -92,6 +92,7 @@ } break; } + case AkmSensor::AKM_PRIMARY_ID_ANGLE_SENSOR: { if(subId == Ak7451Ctrl::SUB_ID_AK7451){ @@ -106,6 +107,7 @@ } break; } + case AkmSensor::AKM_PRIMARY_ID_UNIPOLAR: case AkmSensor::AKM_PRIMARY_ID_OMNIPOLAR: case AkmSensor::AKM_PRIMARY_ID_LATCH: @@ -116,7 +118,7 @@ sensor = hallswitch; break; } - case AkmSensor::AKM_PRIMARY_ID_LINEAR_SENSOR_LEGACY: +// case AkmSensor::AKM_PRIMARY_ID_LINEAR_SENSOR_LEGACY: case AkmSensor::AKM_PRIMARY_ID_LINEAR_SENSOR: case AkmSensor::AKM_PRIMARY_ID_CURRENT_SENSOR: case AkmSensor::AKM_PRIMARY_ID_MISC_ANALOG: @@ -125,6 +127,7 @@ sensor = analogsensor; break; } + case AkmSensor::AKM_PRIMARY_ID_IR_SENSOR: { if(subId == Ak9750Ctrl::SUB_ID_AK9750){ @@ -142,9 +145,10 @@ break; } + default: { - MSG("#Can't find ID=%d SubID=%d %s\r\n", primaryId, subId, AKM_PRIMARY_ID_STR[primaryId]); + MSG("#Can't find ID=%d SubID=%d %s\r\n", primaryId, subId, AKM_PRIMARY_ID_STR[primaryId]); return NULL; // couldn't find } } @@ -158,6 +162,9 @@ return sensor; } + +void AkmSensorManager::dummyCallbackForCommandReceived(){} + AkmSensorManager::Status AkmSensorManager::commandReceived(char* buf){ // Construct message Status status = SUCCESS; @@ -168,7 +175,9 @@ eventCommandReceived = false; }else{ eventCommandReceived = true; +// MSG("#Parsed message. %s\r\n", buf); } + t.attach(callback(this, &AkmSensorManager::dummyCallbackForCommandReceived),0); // wake-up from ble.waitForEvent return status; } @@ -374,6 +383,7 @@ // If event is a command received from the host if(eventCommandReceived) { +// MSG("#Command received.\r\n"); processCommand(); eventCommandReceived = false; // clear the flag } @@ -381,6 +391,7 @@ // If event is sensor read data event, read the message if(sensor->isEvent()) { +// MSG("#Sensor event received.\r\n"); Message msg; if( sensor->readSensorData(&msg) != AkmSensor::SUCCESS) status = AkmSensorManager::ERROR; throwMessage(&msg); // Process and output message to USB/BLE