mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-1273 OP-1282 OP-1283 uncrustify
This commit is contained in:
parent
5ed417323e
commit
830f13596e
@ -60,6 +60,7 @@ int8_t PIOS_MS4525DO_Read(uint16_t *values)
|
||||
int8_t retVal = PIOS_MS4525DO_ReadI2C(data, sizeof(data));
|
||||
|
||||
uint8_t status = data[0] & 0xC0;
|
||||
|
||||
if (status == 0x80) {
|
||||
/* stale data */
|
||||
return -5;
|
||||
|
@ -756,7 +756,7 @@ static void i2c_adapter_reset_bus(struct pios_i2c_adapter *i2c_adapter)
|
||||
|
||||
// for delays during transfer timeouts
|
||||
// one tick correspond to transmission of 1 byte i.e. 9 clock ticks
|
||||
i2c_adapter->transfer_delay_uS=9000000/(((I2C_InitTypeDef *)&(i2c_adapter->cfg->init))->I2C_ClockSpeed);
|
||||
i2c_adapter->transfer_delay_uS = 9000000 / (((I2C_InitTypeDef *)&(i2c_adapter->cfg->init))->I2C_ClockSpeed);
|
||||
|
||||
|
||||
if (i2c_adapter->cfg->regs->SR2 & I2C_FLAG_BUSY) {
|
||||
@ -796,13 +796,15 @@ static bool i2c_adapter_callback_handler(struct pios_i2c_adapter *i2c_adapter)
|
||||
/* transfer_timeout_ticks is set by PIOS_I2C_Transfer_Callback */
|
||||
/* Spin waiting for the transfer to finish */
|
||||
while (!i2c_adapter_fsm_terminated(i2c_adapter)) {
|
||||
//sleep 1 byte, as FSM can't be faster
|
||||
// sleep 1 byte, as FSM can't be faster
|
||||
// FIXME: clock delay could make problems, but citing NPX: alsmost no slave device implements clock delay
|
||||
// three times the expected time should cover clock delay
|
||||
PIOS_DELAY_WaituS(i2c_adapter->transfer_delay_uS);
|
||||
|
||||
i2c_adapter->transfer_timeout_ticks--;
|
||||
if(i2c_adapter->transfer_timeout_ticks==0)break;
|
||||
if (i2c_adapter->transfer_timeout_ticks == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i2c_adapter_wait_for_stopped(i2c_adapter)) {
|
||||
@ -982,7 +984,9 @@ int32_t PIOS_I2C_Transfer(uint32_t i2c_id, const struct pios_i2c_txn txn_list[],
|
||||
|
||||
bool valid = PIOS_I2C_validate(i2c_adapter);
|
||||
|
||||
if(!valid)return -1;
|
||||
if (!valid) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PIOS_Assert(valid)
|
||||
|
||||
@ -1021,12 +1025,12 @@ int32_t PIOS_I2C_Transfer(uint32_t i2c_id, const struct pios_i2c_txn txn_list[],
|
||||
|
||||
// used in the i2c_adapter_callback_handler function
|
||||
// Estimate bytes of transmission. Per txns: 1 adress byte + length
|
||||
i2c_adapter->transfer_timeout_ticks= num_txns;
|
||||
for(uint32_t i=0;i<num_txns;i++){
|
||||
i2c_adapter->transfer_timeout_ticks = num_txns;
|
||||
for (uint32_t i = 0; i < num_txns; i++) {
|
||||
i2c_adapter->transfer_timeout_ticks += txn_list[i].len;
|
||||
}
|
||||
// timeout if it takes three times the expected time
|
||||
i2c_adapter->transfer_timeout_ticks*=3;
|
||||
i2c_adapter->transfer_timeout_ticks *= 3;
|
||||
|
||||
i2c_adapter->callback = NULL;
|
||||
i2c_adapter->bus_error = false;
|
||||
@ -1047,7 +1051,9 @@ int32_t PIOS_I2C_Transfer(uint32_t i2c_id, const struct pios_i2c_txn txn_list[],
|
||||
PIOS_DELAY_WaituS(i2c_adapter->transfer_delay_uS);
|
||||
|
||||
i2c_adapter->transfer_timeout_ticks--;
|
||||
if(i2c_adapter->transfer_timeout_ticks==0)break;
|
||||
if (i2c_adapter->transfer_timeout_ticks == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i2c_adapter_wait_for_stopped(i2c_adapter)) {
|
||||
@ -1080,7 +1086,9 @@ int32_t PIOS_I2C_Transfer_Callback(uint32_t i2c_id, const struct pios_i2c_txn tx
|
||||
|
||||
bool valid = PIOS_I2C_validate(i2c_adapter);
|
||||
|
||||
if(!valid)return -1;
|
||||
if (!valid) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PIOS_Assert(valid)
|
||||
PIOS_Assert(callback);
|
||||
@ -1117,12 +1125,12 @@ int32_t PIOS_I2C_Transfer_Callback(uint32_t i2c_id, const struct pios_i2c_txn tx
|
||||
|
||||
// used in the i2c_adapter_callback_handler function
|
||||
// Estimate bytes of transmission. Per txns: 1 adress byte + length
|
||||
i2c_adapter->transfer_timeout_ticks= num_txns;
|
||||
for(uint32_t i=0;i<num_txns;i++){
|
||||
i2c_adapter->transfer_timeout_ticks = num_txns;
|
||||
for (uint32_t i = 0; i < num_txns; i++) {
|
||||
i2c_adapter->transfer_timeout_ticks += txn_list[i].len;
|
||||
}
|
||||
// timeout if it takes three times the expected time
|
||||
i2c_adapter->transfer_timeout_ticks*=3;
|
||||
i2c_adapter->transfer_timeout_ticks *= 3;
|
||||
|
||||
i2c_adapter->callback = callback;
|
||||
i2c_adapter->bus_error = false;
|
||||
@ -1137,7 +1145,9 @@ void PIOS_I2C_EV_IRQ_Handler(uint32_t i2c_id)
|
||||
|
||||
bool valid = PIOS_I2C_validate(i2c_adapter);
|
||||
|
||||
if(!valid)return;
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
PIOS_Assert(valid)
|
||||
|
||||
@ -1272,7 +1282,9 @@ void PIOS_I2C_ER_IRQ_Handler(uint32_t i2c_id)
|
||||
|
||||
bool valid = PIOS_I2C_validate(i2c_adapter);
|
||||
|
||||
if(!valid)return;
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
PIOS_Assert(valid)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user