1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

LP-328 uncrustified

This commit is contained in:
Vladimir Zidar 2016-06-02 12:47:31 +02:00
parent 10637550d7
commit f27db8b65c

View File

@ -48,7 +48,7 @@ typedef struct {
uint16_t magCountMax; uint16_t magCountMax;
uint16_t magCount; uint16_t magCount;
volatile bool data_ready; volatile bool data_ready;
bool hw_error; bool hw_error;
uint32_t lastConfigTime; uint32_t lastConfigTime;
} pios_hmc5x83_dev_data_t; } pios_hmc5x83_dev_data_t;
@ -270,8 +270,8 @@ static int32_t PIOS_HMC5x83_Config(pios_hmc5x83_dev_data_t *dev)
} }
#ifdef PIOS_INCLUDE_WDG #ifdef PIOS_INCLUDE_WDG
// give HMC5x83 on I2C some extra time // give HMC5x83 on I2C some extra time
PIOS_WDG_Clear(); PIOS_WDG_Clear();
#endif /* PIOS_INCLUDE_WDG */ #endif /* PIOS_INCLUDE_WDG */
if (PIOS_HMC5x83_Test((pios_hmc5x83_dev_t)dev) != 0) { if (PIOS_HMC5x83_Test((pios_hmc5x83_dev_t)dev) != 0) {
@ -448,8 +448,8 @@ int32_t PIOS_HMC5x83_Test(pios_hmc5x83_dev_t handler)
pios_hmc5x83_dev_data_t *dev = dev_validate(handler); pios_hmc5x83_dev_data_t *dev = dev_validate(handler);
#ifdef PIOS_INCLUDE_WDG #ifdef PIOS_INCLUDE_WDG
// give HMC5x83 on I2C some extra time to allow for reset, etc. if needed // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed
// this is not in a loop, so it is safe // this is not in a loop, so it is safe
PIOS_WDG_Clear(); PIOS_WDG_Clear();
#endif /* PIOS_INCLUDE_WDG */ #endif /* PIOS_INCLUDE_WDG */
@ -712,7 +712,7 @@ int32_t PIOS_HMC5x83_I2C_Write(pios_hmc5x83_dev_t handler, uint8_t address, uint
bool PIOS_HMC5x83_driver_Test(__attribute__((unused)) uintptr_t context) bool PIOS_HMC5x83_driver_Test(__attribute__((unused)) uintptr_t context)
{ {
return true; // Do not do tests now, Sensors module takes this rather too seriously. return true; // Do not do tests now, Sensors module takes this rather too seriously.
// return !PIOS_HMC5x83_Test((pios_hmc5x83_dev_t)context); // return !PIOS_HMC5x83_Test((pios_hmc5x83_dev_t)context);
} }
void PIOS_HMC5x83_driver_Reset(__attribute__((unused)) uintptr_t context) {} void PIOS_HMC5x83_driver_Reset(__attribute__((unused)) uintptr_t context) {}
@ -731,36 +731,31 @@ void PIOS_HMC5x83_driver_fetch(void *data, uint8_t size, uintptr_t context)
pios_hmc5x83_dev_data_t *dev = dev_validate((pios_hmc5x83_dev_t)context); pios_hmc5x83_dev_data_t *dev = dev_validate((pios_hmc5x83_dev_t)context);
PIOS_SENSORS_3Axis_SensorsWithTemp *tmp = data; PIOS_SENSORS_3Axis_SensorsWithTemp *tmp = data;
if(!dev->hw_error && (PIOS_HMC5x83_ReadMag((pios_hmc5x83_dev_t)context, mag) == 0)) if (!dev->hw_error && (PIOS_HMC5x83_ReadMag((pios_hmc5x83_dev_t)context, mag) == 0)) {
{
tmp->count = 1; tmp->count = 1;
tmp->sample[0].x = mag[0]; tmp->sample[0].x = mag[0];
tmp->sample[0].y = mag[1]; tmp->sample[0].y = mag[1];
tmp->sample[0].z = mag[2]; tmp->sample[0].z = mag[2];
} } else {
else
{
tmp->count = 1; tmp->count = 1;
tmp->sample[0].x = 0; tmp->sample[0].x = 0;
tmp->sample[0].y = 0; tmp->sample[0].y = 0;
tmp->sample[0].z = 0; tmp->sample[0].z = 0;
dev->hw_error = true; dev->hw_error = true;
} }
tmp->temperature = 0; tmp->temperature = 0;
} }
bool PIOS_HMC5x83_driver_poll(uintptr_t context) bool PIOS_HMC5x83_driver_poll(uintptr_t context)
{ {
pios_hmc5x83_dev_data_t *dev = dev_validate((pios_hmc5x83_dev_t)context); pios_hmc5x83_dev_data_t *dev = dev_validate((pios_hmc5x83_dev_t)context);
if(dev->hw_error) {
if(PIOS_DELAY_DiffuS(dev->lastConfigTime) < 1000000) { if (dev->hw_error) {
if (PIOS_DELAY_DiffuS(dev->lastConfigTime) < 1000000) {
return false; return false;
} }
@ -769,10 +764,9 @@ bool PIOS_HMC5x83_driver_poll(uintptr_t context)
PIOS_WDG_Clear(); PIOS_WDG_Clear();
#endif /* PIOS_INCLUDE_WDG */ #endif /* PIOS_INCLUDE_WDG */
if(PIOS_HMC5x83_Config(dev) == 0) { if (PIOS_HMC5x83_Config(dev) == 0) {
dev->hw_error = false; dev->hw_error = false;
} }
} }
return PIOS_HMC5x83_NewDataAvailable((pios_hmc5x83_dev_t)context); return PIOS_HMC5x83_NewDataAvailable((pios_hmc5x83_dev_t)context);