I2C. Fixes.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3694 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
b581177630
commit
72266f8b59
|
@ -110,10 +110,10 @@ extern "C" {
|
|||
void i2cObjectInit(I2CDriver *i2cp);
|
||||
void i2cStart(I2CDriver *i2cp, const I2CConfig *config);
|
||||
void i2cStop(I2CDriver *i2cp);
|
||||
inline i2cflags_t i2cGetErrors(I2CDriver *i2cp);
|
||||
i2cflags_t i2cGetErrors(I2CDriver *i2cp);
|
||||
msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp,
|
||||
i2caddr_t addr,
|
||||
uint8_t *txbuf, size_t txbytes,
|
||||
const uint8_t *txbuf, size_t txbytes,
|
||||
uint8_t *rxbuf, size_t rxbytes,
|
||||
systime_t timeout);
|
||||
msg_t i2cMasterReceiveTimeout(I2CDriver *i2cp,
|
||||
|
|
|
@ -563,7 +563,7 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp,
|
|||
* @retval RDY_TIMEOUT if a timeout occurred before operation end.
|
||||
*/
|
||||
msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, uint8_t slave_addr,
|
||||
uint8_t *txbuf, size_t txbytes,
|
||||
const uint8_t *txbuf, size_t txbytes,
|
||||
uint8_t *rxbuf, size_t rxbytes,
|
||||
systime_t timeout){
|
||||
|
||||
|
@ -578,7 +578,6 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, uint8_t slave_addr,
|
|||
i2cp->slave_addr = (slave_addr << 1) & 0x00FE; /* LSB = 0 -> write */
|
||||
i2cp->txbytes = txbytes;
|
||||
i2cp->rxbytes = rxbytes;
|
||||
i2cp->txbuf = txbuf;
|
||||
i2cp->rxbuf = rxbuf;
|
||||
i2cp->errors = 0;
|
||||
|
||||
|
|
|
@ -308,7 +308,6 @@ struct I2CDriver{
|
|||
__IO size_t txbytes; /*!< @brief Number of bytes to be transmitted. */
|
||||
__IO size_t rxbytes; /*!< @brief Number of bytes to be received. */
|
||||
uint8_t *rxbuf; /*!< @brief Pointer to receive buffer. */
|
||||
uint8_t *txbuf; /*!< @brief Pointer to transmit buffer.*/
|
||||
|
||||
__IO i2cflags_t errors; /*!< @brief Error flags.*/
|
||||
|
||||
|
@ -384,6 +383,7 @@ struct I2CDriver{
|
|||
Thread *tp = (i2cp)->id_thread; \
|
||||
(i2cp)->id_thread = NULL; \
|
||||
chSysLockFromIsr(); \
|
||||
tp->p_u.rdymsg = RDY_RESET; \
|
||||
chSchReadyI(tp); \
|
||||
chSysUnlockFromIsr(); \
|
||||
} \
|
||||
|
@ -448,7 +448,7 @@ void i2c_lld_set_opmode(I2CDriver *i2cp);
|
|||
void i2c_lld_start(I2CDriver *i2cp);
|
||||
void i2c_lld_stop(I2CDriver *i2cp);
|
||||
msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, uint8_t slave_addr,
|
||||
uint8_t *txbuf, size_t txbytes,
|
||||
const uint8_t *txbuf, size_t txbytes,
|
||||
uint8_t *rxbuf, size_t rxbytes,
|
||||
systime_t timeout);
|
||||
msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp,
|
||||
|
|
|
@ -78,7 +78,6 @@ void i2cObjectInit(I2CDriver *i2cp) {
|
|||
i2cp->id_state = I2C_STOP;
|
||||
i2cp->id_config = NULL;
|
||||
i2cp->rxbuf = NULL;
|
||||
i2cp->txbuf = NULL;
|
||||
i2cp->id_thread = NULL;
|
||||
|
||||
#if I2C_USE_MUTUAL_EXCLUSION
|
||||
|
@ -179,7 +178,7 @@ i2cflags_t i2cGetErrors(I2CDriver *i2cp) {
|
|||
*/
|
||||
msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp,
|
||||
i2caddr_t addr,
|
||||
uint8_t *txbuf,
|
||||
const uint8_t *txbuf,
|
||||
size_t txbytes,
|
||||
uint8_t *rxbuf,
|
||||
size_t rxbytes,
|
||||
|
@ -202,10 +201,7 @@ msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp,
|
|||
rxbuf, rxbytes, timeout);
|
||||
i2cp->id_state = I2C_READY;
|
||||
chSysUnlock();
|
||||
if (i2cGetErrors(i2cp) != I2CD_NO_ERROR)
|
||||
return RDY_RESET;
|
||||
else
|
||||
return rdymsg;
|
||||
return rdymsg;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,10 +248,7 @@ msg_t i2cMasterReceiveTimeout(I2CDriver *i2cp,
|
|||
rdymsg = i2c_lld_master_receive_timeout(i2cp, addr, rxbuf, rxbytes, timeout);
|
||||
i2cp->id_state = I2C_READY;
|
||||
chSysUnlock();
|
||||
if (i2cGetErrors(i2cp) != I2CD_NO_ERROR)
|
||||
return RDY_RESET;
|
||||
else
|
||||
return rdymsg;
|
||||
return rdymsg;
|
||||
}
|
||||
|
||||
#if I2C_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
|
||||
|
|
Loading…
Reference in New Issue