who am i reg is now checked

This commit is contained in:
Robin Müller 2021-02-24 11:24:31 +01:00 committed by Robin Mueller
parent 873412f3fb
commit a8f612f051
3 changed files with 477 additions and 461 deletions

View File

@ -3,18 +3,18 @@
MGMHandlerLIS3MDL::MGMHandlerLIS3MDL(object_id_t objectId, MGMHandlerLIS3MDL::MGMHandlerLIS3MDL(object_id_t objectId,
object_id_t deviceCommunication, CookieIF* comCookie): object_id_t deviceCommunication, CookieIF* comCookie):
DeviceHandlerBase(objectId, deviceCommunication, comCookie), DeviceHandlerBase(objectId, deviceCommunication, comCookie),
dataset(this) { dataset(this) {
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
debugDivider = new PeriodicOperationDivider(10); debugDivider = new PeriodicOperationDivider(10);
#endif #endif
/* Set to default values right away. */ /* Set to default values right away. */
registers[0] = MGMLIS3MDL::CTRL_REG1_DEFAULT; registers[0] = MGMLIS3MDL::CTRL_REG1_DEFAULT;
registers[1] = MGMLIS3MDL::CTRL_REG2_DEFAULT; registers[1] = MGMLIS3MDL::CTRL_REG2_DEFAULT;
registers[2] = MGMLIS3MDL::CTRL_REG3_DEFAULT; registers[2] = MGMLIS3MDL::CTRL_REG3_DEFAULT;
registers[3] = MGMLIS3MDL::CTRL_REG4_DEFAULT; registers[3] = MGMLIS3MDL::CTRL_REG4_DEFAULT;
registers[4] = MGMLIS3MDL::CTRL_REG5_DEFAULT; registers[4] = MGMLIS3MDL::CTRL_REG5_DEFAULT;
} }
@ -23,400 +23,416 @@ MGMHandlerLIS3MDL::~MGMHandlerLIS3MDL() {
void MGMHandlerLIS3MDL::doStartUp() { void MGMHandlerLIS3MDL::doStartUp() {
switch (internalState) { switch (internalState) {
case(InternalState::STATE_NONE): case(InternalState::STATE_NONE): {
internalState = InternalState::STATE_FIRST_CONTACT; internalState = InternalState::STATE_FIRST_CONTACT;
break; break;
}
case(InternalState::STATE_FIRST_CONTACT): case(InternalState::STATE_FIRST_CONTACT): {
internalState = InternalState::STATE_SETUP; /* Will be set by checking device ID (WHO AM I register) */
break; if(commandExecuted) {
commandExecuted = false;
case(InternalState::STATE_SETUP): }
internalState = InternalState::STATE_CHECK_REGISTERS; internalState = InternalState::STATE_SETUP;
break; break;
}
case(InternalState::STATE_CHECK_REGISTERS): { case(InternalState::STATE_SETUP): {
/* Set up cached registers which will be used to configure the MGM. */ internalState = InternalState::STATE_CHECK_REGISTERS;
if(commandExecuted) { break;
commandExecuted = false; }
/* Replace _MODE_TO_ON with MODE_NORMAL to jump to normal mode quickly */ case(InternalState::STATE_CHECK_REGISTERS): {
setMode(_MODE_TO_ON); /* Set up cached registers which will be used to configure the MGM. */
} if(commandExecuted) {
break; commandExecuted = false;
} /* Replace _MODE_TO_ON with MODE_NORMAL to jump to normal mode quickly */
default: setMode(_MODE_TO_ON);
break; }
} break;
}
default:
break;
}
} }
void MGMHandlerLIS3MDL::doShutDown() { void MGMHandlerLIS3MDL::doShutDown() {
setMode(_MODE_POWER_DOWN); setMode(_MODE_POWER_DOWN);
} }
ReturnValue_t MGMHandlerLIS3MDL::buildTransitionDeviceCommand( ReturnValue_t MGMHandlerLIS3MDL::buildTransitionDeviceCommand(
DeviceCommandId_t *id) { DeviceCommandId_t *id) {
switch (internalState) { switch (internalState) {
case(InternalState::STATE_NONE): case(InternalState::STATE_NONE):
case(InternalState::STATE_NORMAL): { case(InternalState::STATE_NORMAL): {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
case(InternalState::STATE_FIRST_CONTACT): { case(InternalState::STATE_FIRST_CONTACT): {
*id = MGMLIS3MDL::IDENTIFY_DEVICE; *id = MGMLIS3MDL::IDENTIFY_DEVICE;
break; break;
} }
case(InternalState::STATE_SETUP): { case(InternalState::STATE_SETUP): {
*id = MGMLIS3MDL::SETUP_MGM; *id = MGMLIS3MDL::SETUP_MGM;
break; break;
} }
case(InternalState::STATE_CHECK_REGISTERS): { case(InternalState::STATE_CHECK_REGISTERS): {
*id = MGMLIS3MDL::READ_CONFIG_AND_DATA; *id = MGMLIS3MDL::READ_CONFIG_AND_DATA;
break; break;
} }
default: { default: {
/* might be a configuration error. */ /* might be a configuration error. */
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "GyroHandler::buildTransitionDeviceCommand: Unknown internal state!" << sif::warning << "GyroHandler::buildTransitionDeviceCommand: Unknown internal state!" <<
std::endl; std::endl;
#else #else
sif::printWarning("GyroHandler::buildTransitionDeviceCommand: Unknown internal state!\n"); sif::printWarning("GyroHandler::buildTransitionDeviceCommand: Unknown internal state!\n");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
} }
return buildCommandFromCommand(*id, NULL, 0); return buildCommandFromCommand(*id, NULL, 0);
} }
uint8_t MGMHandlerLIS3MDL::readCommand(uint8_t command, bool continuousCom) { uint8_t MGMHandlerLIS3MDL::readCommand(uint8_t command, bool continuousCom) {
command |= (1 << MGMLIS3MDL::RW_BIT); command |= (1 << MGMLIS3MDL::RW_BIT);
if (continuousCom == true) { if (continuousCom == true) {
command |= (1 << MGMLIS3MDL::MS_BIT); command |= (1 << MGMLIS3MDL::MS_BIT);
} }
return command; return command;
} }
uint8_t MGMHandlerLIS3MDL::writeCommand(uint8_t command, bool continuousCom) { uint8_t MGMHandlerLIS3MDL::writeCommand(uint8_t command, bool continuousCom) {
command &= ~(1 << MGMLIS3MDL::RW_BIT); command &= ~(1 << MGMLIS3MDL::RW_BIT);
if (continuousCom == true) { if (continuousCom == true) {
command |= (1 << MGMLIS3MDL::MS_BIT); command |= (1 << MGMLIS3MDL::MS_BIT);
} }
return command; return command;
} }
void MGMHandlerLIS3MDL::setupMgm() { void MGMHandlerLIS3MDL::setupMgm() {
registers[0] = MGMLIS3MDL::CTRL_REG1_DEFAULT; registers[0] = MGMLIS3MDL::CTRL_REG1_DEFAULT;
registers[1] = MGMLIS3MDL::CTRL_REG2_DEFAULT; registers[1] = MGMLIS3MDL::CTRL_REG2_DEFAULT;
registers[2] = MGMLIS3MDL::CTRL_REG3_DEFAULT; registers[2] = MGMLIS3MDL::CTRL_REG3_DEFAULT;
registers[3] = MGMLIS3MDL::CTRL_REG4_DEFAULT; registers[3] = MGMLIS3MDL::CTRL_REG4_DEFAULT;
registers[4] = MGMLIS3MDL::CTRL_REG5_DEFAULT; registers[4] = MGMLIS3MDL::CTRL_REG5_DEFAULT;
prepareCtrlRegisterWrite(); prepareCtrlRegisterWrite();
} }
ReturnValue_t MGMHandlerLIS3MDL::buildNormalDeviceCommand( 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) {
*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 {
*id = MGMLIS3MDL::READ_TEMPERATURE; *id = MGMLIS3MDL::READ_TEMPERATURE;
communicationStep = CommunicationStep::DATA; communicationStep = CommunicationStep::DATA;
return buildCommandFromCommand(*id, NULL, 0); return buildCommandFromCommand(*id, NULL, 0);
} }
} }
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) {
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));
commandBuffer[0] = readCommand(MGMLIS3MDL::CTRL_REG1, true); commandBuffer[0] = readCommand(MGMLIS3MDL::CTRL_REG1, true);
rawPacket = commandBuffer; rawPacket = commandBuffer;
rawPacketLen = MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1; rawPacketLen = MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1;
return RETURN_OK; return RETURN_OK;
} }
case(MGMLIS3MDL::READ_TEMPERATURE): { case(MGMLIS3MDL::READ_TEMPERATURE): {
std::memset(commandBuffer, 0, 3); std::memset(commandBuffer, 0, 3);
commandBuffer[0] = readCommand(MGMLIS3MDL::TEMP_LOWBYTE, true); commandBuffer[0] = readCommand(MGMLIS3MDL::TEMP_LOWBYTE, true);
rawPacket = commandBuffer; rawPacket = commandBuffer;
rawPacketLen = 3; rawPacketLen = 3;
return RETURN_OK; return RETURN_OK;
} }
case(MGMLIS3MDL::IDENTIFY_DEVICE): { case(MGMLIS3MDL::IDENTIFY_DEVICE): {
return identifyDevice(); return identifyDevice();
} }
case(MGMLIS3MDL::TEMP_SENSOR_ENABLE): { case(MGMLIS3MDL::TEMP_SENSOR_ENABLE): {
return enableTemperatureSensor(commandData, commandDataLen); return enableTemperatureSensor(commandData, commandDataLen);
} }
case(MGMLIS3MDL::SETUP_MGM): { case(MGMLIS3MDL::SETUP_MGM): {
setupMgm(); setupMgm();
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
case(MGMLIS3MDL::ACCURACY_OP_MODE_SET): { case(MGMLIS3MDL::ACCURACY_OP_MODE_SET): {
return setOperatingMode(commandData, commandDataLen); return setOperatingMode(commandData, commandDataLen);
} }
default: default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
} }
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t MGMHandlerLIS3MDL::identifyDevice() { ReturnValue_t MGMHandlerLIS3MDL::identifyDevice() {
uint32_t size = 2; uint32_t size = 2;
commandBuffer[0] = readCommand(MGMLIS3MDL::IDENTIFY_DEVICE_REG_ADDR); commandBuffer[0] = readCommand(MGMLIS3MDL::IDENTIFY_DEVICE_REG_ADDR);
commandBuffer[1] = 0x00; commandBuffer[1] = 0x00;
rawPacket = commandBuffer; rawPacket = commandBuffer;
rawPacketLen = size; rawPacketLen = size;
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t MGMHandlerLIS3MDL::scanForReply(const uint8_t *start, ReturnValue_t MGMHandlerLIS3MDL::scanForReply(const uint8_t *start,
size_t len, DeviceCommandId_t *foundId, size_t *foundLen) { size_t len, DeviceCommandId_t *foundId, size_t *foundLen) {
*foundLen = len; *foundLen = len;
if (len == MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1) { if (len == MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1) {
*foundLen = len; *foundLen = len;
*foundId = MGMLIS3MDL::READ_CONFIG_AND_DATA; *foundId = MGMLIS3MDL::READ_CONFIG_AND_DATA;
// Check validity by checking config registers // Check validity by checking config registers
if (start[1] != registers[0] or start[2] != registers[1] or if (start[1] != registers[0] or start[2] != registers[1] or
start[3] != registers[2] or start[4] != registers[3] or start[3] != registers[2] or start[4] != registers[3] or
start[5] != registers[4]) { start[5] != registers[4]) {
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
sif::warning << "MGMHandlerLIS3MDL::scanForReply: Invalid registers!" << std::endl; sif::warning << "MGMHandlerLIS3MDL::scanForReply: Invalid registers!" << std::endl;
#endif #endif
return DeviceHandlerIF::INVALID_DATA; return DeviceHandlerIF::INVALID_DATA;
} }
if(mode == _MODE_START_UP) { if(mode == _MODE_START_UP) {
commandExecuted = true; commandExecuted = true;
} }
} }
else if(len == MGMLIS3MDL::TEMPERATURE_REPLY_LEN) { else if(len == MGMLIS3MDL::TEMPERATURE_REPLY_LEN) {
*foundLen = len; *foundLen = len;
*foundId = MGMLIS3MDL::READ_TEMPERATURE; *foundId = MGMLIS3MDL::READ_TEMPERATURE;
} }
else if (len == MGMLIS3MDL::SETUP_REPLY_LEN) { else if (len == MGMLIS3MDL::SETUP_REPLY_LEN) {
*foundLen = len; *foundLen = len;
*foundId = MGMLIS3MDL::SETUP_MGM; *foundId = MGMLIS3MDL::SETUP_MGM;
} }
else if (len == SINGLE_COMMAND_ANSWER_LEN) { else if (len == SINGLE_COMMAND_ANSWER_LEN) {
*foundLen = len; *foundLen = len;
*foundId = getPendingCommand(); *foundId = getPendingCommand();
} if(*foundId == MGMLIS3MDL::IDENTIFY_DEVICE) {
else { if(start[1] != MGMLIS3MDL::DEVICE_ID) {
return DeviceHandlerIF::INVALID_DATA; #if OBSW_VERBOSE_LEVEL >= 1
} sif::warning << "MGMHandlerLIS3MDL::scanForReply: Invalid registers!" << std::endl;
#endif
return DeviceHandlerIF::INVALID_DATA;
}
// Data with SPI Interface has always this answer if(mode == _MODE_START_UP) {
if (start[0] == 0b11111111) { commandExecuted = true;
return RETURN_OK; }
} }
else { }
return DeviceHandlerIF::INVALID_DATA; else {
} return DeviceHandlerIF::INVALID_DATA;
}
/* Data with SPI Interface always has this answer */
if (start[0] == 0b11111111) {
return RETURN_OK;
}
else {
return DeviceHandlerIF::INVALID_DATA;
}
} }
ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id, ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) { const uint8_t *packet) {
switch (id) { switch (id) {
case MGMLIS3MDL::IDENTIFY_DEVICE: { case MGMLIS3MDL::IDENTIFY_DEVICE: {
break; break;
} }
case MGMLIS3MDL::SETUP_MGM: { case MGMLIS3MDL::SETUP_MGM: {
break; break;
} }
case MGMLIS3MDL::READ_CONFIG_AND_DATA: { case MGMLIS3MDL::READ_CONFIG_AND_DATA: {
// TODO: Store configuration in new local datasets. // TODO: Store configuration in new local datasets.
uint8_t scale = getFullScale(registers[2]); uint8_t scale = getFullScale(registers[2]);
float sensitivityFactor = getSensitivityFactor(scale); float sensitivityFactor = getSensitivityFactor(scale);
int16_t mgmMeasurementRawX = packet[MGMLIS3MDL::X_HIGHBYTE_IDX] << 8 int16_t mgmMeasurementRawX = packet[MGMLIS3MDL::X_HIGHBYTE_IDX] << 8
| packet[MGMLIS3MDL::X_LOWBYTE_IDX] ; | packet[MGMLIS3MDL::X_LOWBYTE_IDX] ;
int16_t mgmMeasurementRawY = packet[MGMLIS3MDL::Y_HIGHBYTE_IDX] << 8 int16_t mgmMeasurementRawY = packet[MGMLIS3MDL::Y_HIGHBYTE_IDX] << 8
| packet[MGMLIS3MDL::Y_LOWBYTE_IDX] ; | packet[MGMLIS3MDL::Y_LOWBYTE_IDX] ;
int16_t mgmMeasurementRawZ = packet[MGMLIS3MDL::Z_HIGHBYTE_IDX] << 8 int16_t mgmMeasurementRawZ = packet[MGMLIS3MDL::Z_HIGHBYTE_IDX] << 8
| packet[MGMLIS3MDL::Z_LOWBYTE_IDX] ; | packet[MGMLIS3MDL::Z_LOWBYTE_IDX] ;
/* Target value in microtesla */ /* Target value in microtesla */
float mgmX = static_cast<float>(mgmMeasurementRawX) * sensitivityFactor float mgmX = static_cast<float>(mgmMeasurementRawX) * sensitivityFactor
* MGMLIS3MDL::GAUSS_TO_MICROTESLA_FACTOR; * MGMLIS3MDL::GAUSS_TO_MICROTESLA_FACTOR;
float mgmY = static_cast<float>(mgmMeasurementRawY) * sensitivityFactor float mgmY = static_cast<float>(mgmMeasurementRawY) * sensitivityFactor
* MGMLIS3MDL::GAUSS_TO_MICROTESLA_FACTOR; * MGMLIS3MDL::GAUSS_TO_MICROTESLA_FACTOR;
float mgmZ = static_cast<float>(mgmMeasurementRawZ) * sensitivityFactor float mgmZ = static_cast<float>(mgmMeasurementRawZ) * sensitivityFactor
* MGMLIS3MDL::GAUSS_TO_MICROTESLA_FACTOR; * MGMLIS3MDL::GAUSS_TO_MICROTESLA_FACTOR;
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
if(debugDivider->checkAndIncrement()) { if(debugDivider->checkAndIncrement()) {
sif::info << "MGMHandlerLIS3: Magnetic field strength in" sif::info << "MGMHandlerLIS3: Magnetic field strength in"
" microtesla:" << std::endl; " microtesla:" << std::endl;
/* Set terminal to utf-8 if there is an issue with micro printout. */ /* Set terminal to utf-8 if there is an issue with micro printout. */
sif::info << "X: " << mgmX << " \xC2\xB5T" << std::endl; sif::info << "X: " << mgmX << " \xC2\xB5T" << std::endl;
sif::info << "Y: " << mgmY << " \xC2\xB5T" << std::endl; sif::info << "Y: " << mgmY << " \xC2\xB5T" << std::endl;
sif::info << "Z: " << mgmZ << " \xC2\xB5T" << std::endl; sif::info << "Z: " << mgmZ << " \xC2\xB5T" << std::endl;
} }
#endif #endif
PoolReadHelper readHelper(&dataset); PoolReadHelper readHelper(&dataset);
if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) { if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
dataset.fieldStrengthX = mgmX; dataset.fieldStrengthX = mgmX;
dataset.fieldStrengthY = mgmY; dataset.fieldStrengthY = mgmY;
dataset.fieldStrengthZ = mgmZ; dataset.fieldStrengthZ = mgmZ;
dataset.setValidity(true, true); dataset.setValidity(true, true);
} }
break; break;
} }
case MGMLIS3MDL::READ_TEMPERATURE: { case MGMLIS3MDL::READ_TEMPERATURE: {
int16_t tempValueRaw = packet[2] << 8 | packet[1]; int16_t tempValueRaw = packet[2] << 8 | packet[1];
float tempValue = 25.0 + ((static_cast<float>(tempValueRaw)) / 8.0); float tempValue = 25.0 + ((static_cast<float>(tempValueRaw)) / 8.0);
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
if(debugDivider->check()) { if(debugDivider->check()) {
/* Set terminal to utf-8 if there is an issue with micro printout. */ /* Set terminal to utf-8 if there is an issue with micro printout. */
sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " \xC2\xB0" << "C" << sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " \xC2\xB0" << "C" <<
std::endl; std::endl;
} }
#endif #endif
ReturnValue_t result = dataset.read(); ReturnValue_t result = dataset.read();
if(result == HasReturnvaluesIF::RETURN_OK) { if(result == HasReturnvaluesIF::RETURN_OK) {
dataset.temperature = tempValue; dataset.temperature = tempValue;
dataset.commit(); dataset.commit();
} }
break; break;
} }
default: { default: {
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
} }
} }
return RETURN_OK; return RETURN_OK;
} }
uint8_t MGMHandlerLIS3MDL::getFullScale(uint8_t ctrlRegister2) { uint8_t MGMHandlerLIS3MDL::getFullScale(uint8_t ctrlRegister2) {
bool FS0 = false; bool FS0 = false;
bool FS1 = false; bool FS1 = false;
if ((ctrlRegister2 >> 5) == 1) if ((ctrlRegister2 >> 5) == 1)
FS0 = true; FS0 = true;
if ((ctrlRegister2 >> 6) == 1) if ((ctrlRegister2 >> 6) == 1)
FS1 = true; FS1 = true;
if ((FS0 == true) && (FS1 == true)) if ((FS0 == true) && (FS1 == true))
return 16; return 16;
else if ((FS0 == false) && (FS1 == true)) else if ((FS0 == false) && (FS1 == true))
return 12; return 12;
else if ((FS0 == true) && (FS1 == false)) else if ((FS0 == true) && (FS1 == false))
return 8; return 8;
else else
return 4; return 4;
} }
float MGMHandlerLIS3MDL::getSensitivityFactor(uint8_t scale) { float MGMHandlerLIS3MDL::getSensitivityFactor(uint8_t scale) {
return (float) scale / (INT16_MAX); return (float) scale / (INT16_MAX);
} }
ReturnValue_t MGMHandlerLIS3MDL::enableTemperatureSensor( ReturnValue_t MGMHandlerLIS3MDL::enableTemperatureSensor(
const uint8_t *commandData, size_t commandDataLen) { const uint8_t *commandData, size_t commandDataLen) {
triggerEvent(CHANGE_OF_SETUP_PARAMETER); triggerEvent(CHANGE_OF_SETUP_PARAMETER);
uint32_t size = 2; uint32_t size = 2;
commandBuffer[0] = writeCommand(MGMLIS3MDL::CTRL_REG1); commandBuffer[0] = writeCommand(MGMLIS3MDL::CTRL_REG1);
if (commandDataLen > 1) { if (commandDataLen > 1) {
return INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS; return INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS;
} }
switch (*commandData) { switch (*commandData) {
case (MGMLIS3MDL::ON): { case (MGMLIS3MDL::ON): {
commandBuffer[1] = registers[0] | (1 << 7); commandBuffer[1] = registers[0] | (1 << 7);
break; break;
} }
case (MGMLIS3MDL::OFF): { case (MGMLIS3MDL::OFF): {
commandBuffer[1] = registers[0] & ~(1 << 7); commandBuffer[1] = registers[0] & ~(1 << 7);
break; break;
} }
default: default:
return INVALID_COMMAND_PARAMETER; return INVALID_COMMAND_PARAMETER;
} }
registers[0] = commandBuffer[1]; registers[0] = commandBuffer[1];
rawPacket = commandBuffer; rawPacket = commandBuffer;
rawPacketLen = size; rawPacketLen = size;
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t MGMHandlerLIS3MDL::setOperatingMode(const uint8_t *commandData, ReturnValue_t MGMHandlerLIS3MDL::setOperatingMode(const uint8_t *commandData,
size_t commandDataLen) { size_t commandDataLen) {
triggerEvent(CHANGE_OF_SETUP_PARAMETER); triggerEvent(CHANGE_OF_SETUP_PARAMETER);
if (commandDataLen != 1) { if (commandDataLen != 1) {
return INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS; return INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS;
} }
switch (commandData[0]) { switch (commandData[0]) {
case MGMLIS3MDL::LOW: case MGMLIS3MDL::LOW:
registers[0] = (registers[0] & (~(1 << MGMLIS3MDL::OM1))) & (~(1 << MGMLIS3MDL::OM0)); registers[0] = (registers[0] & (~(1 << MGMLIS3MDL::OM1))) & (~(1 << MGMLIS3MDL::OM0));
registers[3] = (registers[3] & (~(1 << MGMLIS3MDL::OMZ1))) & (~(1 << MGMLIS3MDL::OMZ0)); registers[3] = (registers[3] & (~(1 << MGMLIS3MDL::OMZ1))) & (~(1 << MGMLIS3MDL::OMZ0));
break; break;
case MGMLIS3MDL::MEDIUM: case MGMLIS3MDL::MEDIUM:
registers[0] = (registers[0] & (~(1 << MGMLIS3MDL::OM1))) | (1 << MGMLIS3MDL::OM0); registers[0] = (registers[0] & (~(1 << MGMLIS3MDL::OM1))) | (1 << MGMLIS3MDL::OM0);
registers[3] = (registers[3] & (~(1 << MGMLIS3MDL::OMZ1))) | (1 << MGMLIS3MDL::OMZ0); registers[3] = (registers[3] & (~(1 << MGMLIS3MDL::OMZ1))) | (1 << MGMLIS3MDL::OMZ0);
break; break;
case MGMLIS3MDL::HIGH: case MGMLIS3MDL::HIGH:
registers[0] = (registers[0] | (1 << MGMLIS3MDL::OM1)) & (~(1 << MGMLIS3MDL::OM0)); registers[0] = (registers[0] | (1 << MGMLIS3MDL::OM1)) & (~(1 << MGMLIS3MDL::OM0));
registers[3] = (registers[3] | (1 << MGMLIS3MDL::OMZ1)) & (~(1 << MGMLIS3MDL::OMZ0)); registers[3] = (registers[3] | (1 << MGMLIS3MDL::OMZ1)) & (~(1 << MGMLIS3MDL::OMZ0));
break; break;
case MGMLIS3MDL::ULTRA: case MGMLIS3MDL::ULTRA:
registers[0] = (registers[0] | (1 << MGMLIS3MDL::OM1)) | (1 << MGMLIS3MDL::OM0); registers[0] = (registers[0] | (1 << MGMLIS3MDL::OM1)) | (1 << MGMLIS3MDL::OM0);
registers[3] = (registers[3] | (1 << MGMLIS3MDL::OMZ1)) | (1 << MGMLIS3MDL::OMZ0); registers[3] = (registers[3] | (1 << MGMLIS3MDL::OMZ1)) | (1 << MGMLIS3MDL::OMZ0);
break; break;
default: default:
break; break;
} }
return prepareCtrlRegisterWrite(); return prepareCtrlRegisterWrite();
} }
void MGMHandlerLIS3MDL::fillCommandAndReplyMap() { void MGMHandlerLIS3MDL::fillCommandAndReplyMap() {
/* /*
* Regarding ArduinoBoard: * Regarding ArduinoBoard:
* Actually SPI answers directly, but as commanding ArduinoBoard the * Actually SPI answers directly, but as commanding ArduinoBoard the
* communication could be delayed * communication could be delayed
* SPI always has to be triggered, so there could be no periodic answer of * SPI always has to be triggered, so there could be no periodic answer of
* the device, the device has to asked with a command, so periodic is zero. * the device, the device has to asked with a command, so periodic is zero.
* *
* We dont read single registers, we just expect special * We dont read single registers, we just expect special
* reply from he Readall_MGM * reply from he Readall_MGM
*/ */
insertInCommandAndReplyMap(MGMLIS3MDL::READ_CONFIG_AND_DATA, 1, &dataset); insertInCommandAndReplyMap(MGMLIS3MDL::READ_CONFIG_AND_DATA, 1, &dataset);
insertInCommandAndReplyMap(MGMLIS3MDL::READ_TEMPERATURE, 1); insertInCommandAndReplyMap(MGMLIS3MDL::READ_TEMPERATURE, 1);
insertInCommandAndReplyMap(MGMLIS3MDL::SETUP_MGM, 1); insertInCommandAndReplyMap(MGMLIS3MDL::SETUP_MGM, 1);
insertInCommandAndReplyMap(MGMLIS3MDL::IDENTIFY_DEVICE, 1); insertInCommandAndReplyMap(MGMLIS3MDL::IDENTIFY_DEVICE, 1);
insertInCommandAndReplyMap(MGMLIS3MDL::TEMP_SENSOR_ENABLE, 1); insertInCommandAndReplyMap(MGMLIS3MDL::TEMP_SENSOR_ENABLE, 1);
insertInCommandAndReplyMap(MGMLIS3MDL::ACCURACY_OP_MODE_SET, 1); insertInCommandAndReplyMap(MGMLIS3MDL::ACCURACY_OP_MODE_SET, 1);
} }
ReturnValue_t MGMHandlerLIS3MDL::prepareCtrlRegisterWrite() { ReturnValue_t MGMHandlerLIS3MDL::prepareCtrlRegisterWrite() {
commandBuffer[0] = writeCommand(MGMLIS3MDL::CTRL_REG1, true); commandBuffer[0] = writeCommand(MGMLIS3MDL::CTRL_REG1, true);
for (size_t i = 0; i < MGMLIS3MDL::NR_OF_CTRL_REGISTERS; i++) { for (size_t i = 0; i < MGMLIS3MDL::NR_OF_CTRL_REGISTERS; i++) {
commandBuffer[i + 1] = registers[i]; commandBuffer[i + 1] = registers[i];
} }
rawPacket = commandBuffer; rawPacket = commandBuffer;
rawPacketLen = MGMLIS3MDL::NR_OF_CTRL_REGISTERS + 1; rawPacketLen = MGMLIS3MDL::NR_OF_CTRL_REGISTERS + 1;
/* We dont have to check if this is working because we just did it */ /* We dont have to check if this is working because we just did it */
return RETURN_OK; return RETURN_OK;
} }
void MGMHandlerLIS3MDL::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { void MGMHandlerLIS3MDL::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
@ -424,24 +440,24 @@ void MGMHandlerLIS3MDL::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
} }
uint32_t MGMHandlerLIS3MDL::getTransitionDelayMs(Mode_t from, Mode_t to) { uint32_t MGMHandlerLIS3MDL::getTransitionDelayMs(Mode_t from, Mode_t to) {
return 30000; return 30000;
} }
void MGMHandlerLIS3MDL::modeChanged(void) { void MGMHandlerLIS3MDL::modeChanged(void) {
internalState = InternalState::STATE_NONE; internalState = InternalState::STATE_NONE;
} }
ReturnValue_t MGMHandlerLIS3MDL::initializeLocalDataPool( ReturnValue_t MGMHandlerLIS3MDL::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_X, localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_X,
new PoolEntry<float>({0.0})); new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Y, localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Y,
new PoolEntry<float>({0.0})); new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Z, localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Z,
new PoolEntry<float>({0.0})); new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS,
new PoolEntry<float>({0.0})); new PoolEntry<float>({0.0}));
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
void MGMHandlerLIS3MDL::performOperationHook() { void MGMHandlerLIS3MDL::performOperationHook() {

View File

@ -18,150 +18,150 @@
*/ */
class MGMHandlerLIS3MDL: public DeviceHandlerBase { class MGMHandlerLIS3MDL: public DeviceHandlerBase {
public: public:
enum class CommunicationStep { enum class CommunicationStep {
DATA, DATA,
TEMPERATURE TEMPERATURE
}; };
static const uint8_t INTERFACE_ID = CLASS_ID::MGM_LIS3MDL; static const uint8_t INTERFACE_ID = CLASS_ID::MGM_LIS3MDL;
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::MGM_LIS3MDL; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::MGM_LIS3MDL;
//Notifies a command to change the setup parameters //Notifies a command to change the setup parameters
static const Event CHANGE_OF_SETUP_PARAMETER = MAKE_EVENT(0, severity::LOW); static const Event CHANGE_OF_SETUP_PARAMETER = MAKE_EVENT(0, severity::LOW);
MGMHandlerLIS3MDL(uint32_t objectId, object_id_t deviceCommunication, MGMHandlerLIS3MDL(uint32_t objectId, object_id_t deviceCommunication,
CookieIF* comCookie); CookieIF* comCookie);
virtual ~MGMHandlerLIS3MDL(); virtual ~MGMHandlerLIS3MDL();
protected: protected:
/** DeviceHandlerBase overrides */ /** DeviceHandlerBase overrides */
void doShutDown() override; void doShutDown() override;
void doStartUp() override; void doStartUp() override;
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override; uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
ReturnValue_t buildCommandFromCommand( ReturnValue_t buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t *commandData, DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override; size_t commandDataLen) override;
ReturnValue_t buildTransitionDeviceCommand( ReturnValue_t buildTransitionDeviceCommand(
DeviceCommandId_t *id) override; DeviceCommandId_t *id) override;
ReturnValue_t buildNormalDeviceCommand( ReturnValue_t buildNormalDeviceCommand(
DeviceCommandId_t *id) override; DeviceCommandId_t *id) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t len, ReturnValue_t scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) override; DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override; const uint8_t *packet) override;
void fillCommandAndReplyMap() override; void fillCommandAndReplyMap() override;
void modeChanged(void) override; void modeChanged(void) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override; LocalDataPoolManager &poolManager) override;
private: private:
MGMLIS3MDL::MgmPrimaryDataset dataset; MGMLIS3MDL::MgmPrimaryDataset dataset;
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* Device specific commands and variables */ /* Device specific commands and variables */
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/** /**
* Sets the read bit for the command * Sets the read bit for the command
* @param single command to set the read-bit at * @param single command to set the read-bit at
* @param boolean to select a continuous read bit, default = false * @param boolean to select a continuous read bit, default = false
*/ */
uint8_t readCommand(uint8_t command, bool continuousCom = false); uint8_t readCommand(uint8_t command, bool continuousCom = false);
/** /**
* Sets the write bit for the command * Sets the write bit for the command
* @param single command to set the write-bit at * @param single command to set the write-bit at
* @param boolean to select a continuous write bit, default = false * @param boolean to select a continuous write bit, default = false
*/ */
uint8_t writeCommand(uint8_t command, bool continuousCom = false); uint8_t writeCommand(uint8_t command, bool continuousCom = false);
/** /**
* This Method gets the full scale for the measurement range * This Method gets the full scale for the measurement range
* e.g.: +- 4 gauss. See p.25 datasheet. * e.g.: +- 4 gauss. See p.25 datasheet.
* @return The ReturnValue does not contain the sign of the value * @return The ReturnValue does not contain the sign of the value
*/ */
uint8_t getFullScale(uint8_t ctrlReg2); uint8_t getFullScale(uint8_t ctrlReg2);
/** /**
* The 16 bit value needs to be divided by the full range of a 16bit value * The 16 bit value needs to be divided by the full range of a 16bit value
* and then multiplied with the current scale of the MGM. * and then multiplied with the current scale of the MGM.
* This factor returns the factor required to achieve this with * This factor returns the factor required to achieve this with
* one multiplication. * one multiplication.
* *
* @param scale is the return value of the getFulscale Method * @param scale is the return value of the getFulscale Method
* @return Multiplication factor to get the sensor value from raw data. * @return Multiplication factor to get the sensor value from raw data.
*/ */
float getSensitivityFactor(uint8_t scale); float getSensitivityFactor(uint8_t scale);
/** /**
* This Command detects the device ID * This Command detects the device ID
*/ */
ReturnValue_t identifyDevice(); ReturnValue_t identifyDevice();
virtual void setupMgm(); virtual void setupMgm();
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* Non normal commands */ /* Non normal commands */
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/** /**
* Enables/Disables the integrated Temperaturesensor * Enables/Disables the integrated Temperaturesensor
* @param commandData On or Off * @param commandData On or Off
* @param length of the commandData: has to be 1 * @param length of the commandData: has to be 1
*/ */
virtual ReturnValue_t enableTemperatureSensor(const uint8_t *commandData, virtual ReturnValue_t enableTemperatureSensor(const uint8_t *commandData,
size_t commandDataLen); size_t commandDataLen);
/** /**
* Sets the accuracy of the measurement of the axis. The noise is changing. * Sets the accuracy of the measurement of the axis. The noise is changing.
* @param commandData LOW, MEDIUM, HIGH, ULTRA * @param commandData LOW, MEDIUM, HIGH, ULTRA
* @param length of the command, has to be 1 * @param length of the command, has to be 1
*/ */
virtual ReturnValue_t setOperatingMode(const uint8_t *commandData, virtual ReturnValue_t setOperatingMode(const uint8_t *commandData,
size_t commandDataLen); size_t commandDataLen);
//Length a sindgle command SPI answer //Length a sindgle command SPI answer
static const uint8_t SINGLE_COMMAND_ANSWER_LEN = 2; static const uint8_t SINGLE_COMMAND_ANSWER_LEN = 2;
//Single SPIcommand has 2 bytes, first for adress, second for content //Single SPIcommand has 2 bytes, first for adress, second for content
size_t singleComandSize = 2; size_t singleComandSize = 2;
//has the size for all adresses of the lis3mdl + the continous write bit //has the size for all adresses of the lis3mdl + the continous write bit
uint8_t commandBuffer[MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1]; uint8_t commandBuffer[MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1];
/** /**
* We want to save the registers we set, so we dont have to read the * We want to save the registers we set, so we dont have to read the
* registers when we want to change something. * registers when we want to change something.
* --> everytime we change set a register we have to save it * --> everytime we change set a register we have to save it
*/ */
uint8_t registers[MGMLIS3MDL::NR_OF_CTRL_REGISTERS]; uint8_t registers[MGMLIS3MDL::NR_OF_CTRL_REGISTERS];
uint8_t statusRegister = 0; uint8_t statusRegister = 0;
/** /**
* 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
* saved register * saved register
* *
*/ */
ReturnValue_t prepareCtrlRegisterWrite(); ReturnValue_t prepareCtrlRegisterWrite();
enum class InternalState { enum class InternalState {
STATE_NONE, STATE_NONE,
STATE_FIRST_CONTACT, STATE_FIRST_CONTACT,
STATE_SETUP, STATE_SETUP,
STATE_CHECK_REGISTERS, STATE_CHECK_REGISTERS,
STATE_NORMAL STATE_NORMAL
}; };
InternalState internalState = InternalState::STATE_NONE; InternalState internalState = InternalState::STATE_NONE;
CommunicationStep communicationStep = CommunicationStep::DATA; CommunicationStep communicationStep = CommunicationStep::DATA;
bool commandExecuted = false; bool commandExecuted = false;
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
PeriodicOperationDivider* debugDivider; PeriodicOperationDivider* debugDivider;
#endif #endif
void performOperationHook() override; void performOperationHook() override;
}; };

View File

@ -24,11 +24,11 @@ static const DeviceCommandId_t IDENTIFY_DEVICE = 0x03;
static const DeviceCommandId_t TEMP_SENSOR_ENABLE = 0x04; static const DeviceCommandId_t TEMP_SENSOR_ENABLE = 0x04;
static const DeviceCommandId_t ACCURACY_OP_MODE_SET = 0x05; static const DeviceCommandId_t ACCURACY_OP_MODE_SET = 0x05;
//Number of all control registers /* Number of all control registers */
static const uint8_t NR_OF_CTRL_REGISTERS = 5; static const uint8_t NR_OF_CTRL_REGISTERS = 5;
//Number of registers in the MGM /* Number of registers in the MGM */
static const uint8_t NR_OF_REGISTERS = 19; static const uint8_t NR_OF_REGISTERS = 19;
//Total number of adresses for all registers /* Total number of adresses for all registers */
static const uint8_t TOTAL_NR_OF_ADRESSES = 52; static const uint8_t TOTAL_NR_OF_ADRESSES = 52;
static const uint8_t NR_OF_DATA_AND_CFG_REGISTERS = 14; static const uint8_t NR_OF_DATA_AND_CFG_REGISTERS = 14;
static const uint8_t TEMPERATURE_REPLY_LEN = 3; static const uint8_t TEMPERATURE_REPLY_LEN = 3;
@ -37,47 +37,47 @@ static const uint8_t SETUP_REPLY_LEN = 6;
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* Register adresses */ /* Register adresses */
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
// Register adress returns identifier of device with default 0b00111101 /* Register adress returns identifier of device with default 0b00111101 */
static const uint8_t IDENTIFY_DEVICE_REG_ADDR = 0b00001111; static const uint8_t IDENTIFY_DEVICE_REG_ADDR = 0b00001111;
static const uint8_t DEVICE_ID = 0b00111101; // Identifier for Device static const uint8_t DEVICE_ID = 0b00111101; // Identifier for Device
//Register adress to access register 1 /* Register adress to access register 1 */
static const uint8_t CTRL_REG1 = 0b00100000; static const uint8_t CTRL_REG1 = 0b00100000;
//Register adress to access register 2 /* Register adress to access register 2 */
static const uint8_t CTRL_REG2 = 0b00100001; static const uint8_t CTRL_REG2 = 0b00100001;
//Register adress to access register 3 /* Register adress to access register 3 */
static const uint8_t CTRL_REG3 = 0b00100010; static const uint8_t CTRL_REG3 = 0b00100010;
//Register adress to access register 4 /* Register adress to access register 4 */
static const uint8_t CTRL_REG4 = 0b00100011; static const uint8_t CTRL_REG4 = 0b00100011;
//Register adress to access register 5 /* Register adress to access register 5 */
static const uint8_t CTRL_REG5 = 0b00100100; static const uint8_t CTRL_REG5 = 0b00100100;
//Register adress to access status register /* Register adress to access status register */
static const uint8_t STATUS_REG_IDX = 8; static const uint8_t STATUS_REG_IDX = 8;
static const uint8_t STATUS_REG = 0b00100111; static const uint8_t STATUS_REG = 0b00100111;
//Register adress to access low byte of x-axis /* Register adress to access low byte of x-axis */
static const uint8_t X_LOWBYTE_IDX = 9; static const uint8_t X_LOWBYTE_IDX = 9;
static const uint8_t X_LOWBYTE = 0b00101000; static const uint8_t X_LOWBYTE = 0b00101000;
//Register adress to access high byte of x-axis /* Register adress to access high byte of x-axis */
static const uint8_t X_HIGHBYTE_IDX = 10; static const uint8_t X_HIGHBYTE_IDX = 10;
static const uint8_t X_HIGHBYTE = 0b00101001; static const uint8_t X_HIGHBYTE = 0b00101001;
//Register adress to access low byte of y-axis /* Register adress to access low byte of y-axis */
static const uint8_t Y_LOWBYTE_IDX = 11; static const uint8_t Y_LOWBYTE_IDX = 11;
static const uint8_t Y_LOWBYTE = 0b00101010; static const uint8_t Y_LOWBYTE = 0b00101010;
//Register adress to access high byte of y-axis /* Register adress to access high byte of y-axis */
static const uint8_t Y_HIGHBYTE_IDX = 12; static const uint8_t Y_HIGHBYTE_IDX = 12;
static const uint8_t Y_HIGHBYTE = 0b00101011; static const uint8_t Y_HIGHBYTE = 0b00101011;
//Register adress to access low byte of z-axis /* Register adress to access low byte of z-axis */
static const uint8_t Z_LOWBYTE_IDX = 13; static const uint8_t Z_LOWBYTE_IDX = 13;
static const uint8_t Z_LOWBYTE = 0b00101100; static const uint8_t Z_LOWBYTE = 0b00101100;
//Register adress to access high byte of z-axis /* Register adress to access high byte of z-axis */
static const uint8_t Z_HIGHBYTE_IDX = 14; static const uint8_t Z_HIGHBYTE_IDX = 14;
static const uint8_t Z_HIGHBYTE = 0b00101101; static const uint8_t Z_HIGHBYTE = 0b00101101;
//Register adress to access low byte of temperature sensor /* Register adress to access low byte of temperature sensor */
static const uint8_t TEMP_LOWBYTE = 0b00101110; static const uint8_t TEMP_LOWBYTE = 0b00101110;
//Register adress to access high byte of temperature sensor /* Register adress to access high byte of temperature sensor */
static const uint8_t TEMP_HIGHBYTE = 0b00101111; static const uint8_t TEMP_HIGHBYTE = 0b00101111;
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/