mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
PiOS I2C: Swap the convention of returned values for I2C
This commit is contained in:
parent
465527a980
commit
627c931c79
@ -248,7 +248,7 @@ static bool Read(uint32_t start, uint8_t length, uint8_t * buffer)
|
||||
cmd[3] = (uint8_t) (start >> 8);
|
||||
cmd[4] = length;
|
||||
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)) == 0;
|
||||
}
|
||||
|
||||
static bool Write(uint32_t start, uint8_t length, const uint8_t * buffer)
|
||||
|
@ -30,7 +30,7 @@
|
||||
*
|
||||
* Blinking Blue LED: No errors detected, test continues
|
||||
* Blinking Red LED: Error detected, test stopped
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/* OpenPilot Includes */
|
||||
|
@ -331,7 +331,7 @@ static bool PIOS_HMC5843_Read(uint8_t address, uint8_t * buffer, uint8_t len)
|
||||
}
|
||||
};
|
||||
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -359,7 +359,7 @@ static bool PIOS_HMC5843_Write(uint8_t address, uint8_t buffer)
|
||||
,
|
||||
};
|
||||
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)) == 0;
|
||||
}
|
||||
|
||||
void PIOS_HMC5843_IRQHandler(void)
|
||||
|
@ -908,7 +908,13 @@ out_fail:
|
||||
return(-1);
|
||||
}
|
||||
|
||||
bool PIOS_I2C_Transfer(uint32_t i2c_id, const struct pios_i2c_txn txn_list[], uint32_t num_txns)
|
||||
/**
|
||||
* @brief Perform a series of I2C transactions
|
||||
* @returns 0 if success or error code
|
||||
* @retval -1 for failed transaction
|
||||
* @retval -2 for failure to get semaphore
|
||||
*/
|
||||
int32_t PIOS_I2C_Transfer(uint32_t i2c_id, const struct pios_i2c_txn txn_list[], uint32_t num_txns)
|
||||
{
|
||||
struct pios_i2c_adapter * i2c_adapter = (struct pios_i2c_adapter *)i2c_id;
|
||||
|
||||
@ -978,7 +984,9 @@ bool PIOS_I2C_Transfer(uint32_t i2c_id, const struct pios_i2c_txn txn_list[], ui
|
||||
i2c_timeout_counter++;
|
||||
#endif /* USE_FREERTOS */
|
||||
|
||||
return (!i2c_adapter->bus_error) && semaphore_success;
|
||||
return !semaphore_success ? -2 :
|
||||
i2c_adapter->bus_error ? -1 :
|
||||
0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -239,7 +239,7 @@ int32_t PIOS_BMP085_Read(uint8_t address, uint8_t * buffer, uint8_t len)
|
||||
}
|
||||
};
|
||||
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)) ? 0 : -1;
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -267,7 +267,7 @@ int32_t PIOS_BMP085_Write(uint8_t address, uint8_t buffer)
|
||||
,
|
||||
};
|
||||
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)) ? 0 : -1;
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ struct pios_i2c_fault_history {
|
||||
};
|
||||
|
||||
/* Public Functions */
|
||||
extern bool PIOS_I2C_Transfer(uint32_t i2c_id, const struct pios_i2c_txn txn_list[], uint32_t num_txns);
|
||||
extern int32_t PIOS_I2C_Transfer(uint32_t i2c_id, const struct pios_i2c_txn txn_list[], uint32_t num_txns);
|
||||
extern bool PIOS_I2C_Transfer_Callback(uint32_t i2c_id, const struct pios_i2c_txn txn_list[], uint32_t num_txns, void *callback);
|
||||
extern void PIOS_I2C_EV_IRQ_Handler(uint32_t i2c_id);
|
||||
extern void PIOS_I2C_ER_IRQ_Handler(uint32_t i2c_id);
|
||||
|
Loading…
Reference in New Issue
Block a user