Device Handler Updates #9
@ -105,13 +105,11 @@ ReturnValue_t MGMHandlerLIS3MDL::buildNormalDeviceCommand(
|
|||||||
DeviceCommandId_t *id) {
|
DeviceCommandId_t *id) {
|
||||||
// Data/config register will be read in an alternating manner.
|
// Data/config register will be read in an alternating manner.
|
||||||
if(communicationStep == CommunicationStep::DATA) {
|
if(communicationStep == CommunicationStep::DATA) {
|
||||||
lastSentCommand = MGMLIS3MDL::READ_CONFIG_AND_DATA;
|
|
||||||
*id = MGMLIS3MDL::READ_CONFIG_AND_DATA;
|
*id = MGMLIS3MDL::READ_CONFIG_AND_DATA;
|
||||||
communicationStep = CommunicationStep::TEMPERATURE;
|
communicationStep = CommunicationStep::TEMPERATURE;
|
||||||
return buildCommandFromCommand(*id, NULL, 0);
|
return buildCommandFromCommand(*id, NULL, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lastSentCommand = MGMLIS3MDL::READ_TEMPERATURE;
|
|
||||||
*id = MGMLIS3MDL::READ_TEMPERATURE;
|
*id = MGMLIS3MDL::READ_TEMPERATURE;
|
||||||
communicationStep = CommunicationStep::DATA;
|
communicationStep = CommunicationStep::DATA;
|
||||||
return buildCommandFromCommand(*id, NULL, 0);
|
return buildCommandFromCommand(*id, NULL, 0);
|
||||||
@ -122,7 +120,6 @@ ReturnValue_t MGMHandlerLIS3MDL::buildNormalDeviceCommand(
|
|||||||
ReturnValue_t MGMHandlerLIS3MDL::buildCommandFromCommand(
|
ReturnValue_t MGMHandlerLIS3MDL::buildCommandFromCommand(
|
||||||
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
|
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
lastSentCommand = deviceCommand;
|
|
||||||
switch(deviceCommand) {
|
switch(deviceCommand) {
|
||||||
case(MGMLIS3MDL::READ_CONFIG_AND_DATA): {
|
case(MGMLIS3MDL::READ_CONFIG_AND_DATA): {
|
||||||
std::memset(commandBuffer, 0, sizeof(commandBuffer));
|
std::memset(commandBuffer, 0, sizeof(commandBuffer));
|
||||||
@ -154,7 +151,6 @@ ReturnValue_t MGMHandlerLIS3MDL::buildCommandFromCommand(
|
|||||||
return setOperatingMode(commandData, commandDataLen);
|
return setOperatingMode(commandData, commandDataLen);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
lastSentCommand = DeviceHandlerIF::NO_COMMAND;
|
|
||||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
@ -198,7 +194,7 @@ ReturnValue_t MGMHandlerLIS3MDL::scanForReply(const uint8_t *start,
|
|||||||
}
|
}
|
||||||
else if (len == SINGLE_COMMAND_ANSWER_LEN) {
|
else if (len == SINGLE_COMMAND_ANSWER_LEN) {
|
||||||
*foundLen = len;
|
*foundLen = len;
|
||||||
*foundId = lastSentCommand;
|
*foundId = getPendingCommand();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return DeviceHandlerIF::INVALID_DATA;
|
return DeviceHandlerIF::INVALID_DATA;
|
||||||
|
@ -137,13 +137,6 @@ private:
|
|||||||
|
|
||||||
uint8_t statusRegister = 0;
|
uint8_t statusRegister = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* As this is a SPI Device, we get the Answer of the last sent command in
|
|
||||||
* the next read cycle, so we could check the command for identification.
|
|
||||||
*/
|
|
||||||
DeviceCommandId_t lastSentCommand = DeviceHandlerIF::NO_COMMAND;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We always update all registers together, so this method updates
|
* We always update all registers together, so this method updates
|
||||||
* the rawpacket and rawpacketLen, so we just manipulate the local
|
* the rawpacket and rawpacketLen, so we just manipulate the local
|
||||||
|
Loading…
Reference in New Issue
Block a user