I2C. Added dirty hack to realize thread safe dirver. Needs to be rewrited.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3100 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
f73960c8dc
commit
551a1c1f22
|
@ -210,10 +210,16 @@ struct I2CSlaveConfig{
|
|||
(i2cp)->id_state = I2C_COMPLETE; \
|
||||
if(((i2cp)->id_slave_config)->id_callback) { \
|
||||
((i2cp)->id_slave_config)->id_callback(i2cp, i2cscfg); \
|
||||
if((i2cp)->id_state == I2C_COMPLETE) \
|
||||
(i2cp)->id_state = I2C_READY; \
|
||||
} \
|
||||
else \
|
||||
(i2cp)->id_state = I2C_READY; \
|
||||
_i2c_wakeup_isr(i2cp); \
|
||||
i2cReleaseBus(i2cp); \
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -71,6 +71,8 @@ void i2cObjectInit(I2CDriver *i2cp) {
|
|||
i2cp->id_config = NULL;
|
||||
i2cp->rxbuff_p = NULL;
|
||||
i2cp->txbuff_p = NULL;
|
||||
i2cp->rxbuf = NULL;
|
||||
i2cp->txbuf = NULL;
|
||||
i2cp->id_slave_config = NULL;
|
||||
|
||||
#if I2C_USE_WAIT
|
||||
|
@ -154,6 +156,8 @@ void i2cMasterTransmit(I2CDriver *i2cp,
|
|||
uint8_t *rxbuf,
|
||||
size_t rxbytes) {
|
||||
|
||||
i2cAcquireBus(i2cp);
|
||||
|
||||
chDbgCheck((i2cp != NULL) && (i2cscfg != NULL) &&\
|
||||
(slave_addr != 0) &&\
|
||||
(txbytes > 0) &&\
|
||||
|
@ -180,11 +184,6 @@ void i2cMasterTransmit(I2CDriver *i2cp,
|
|||
i2cp->id_state = I2C_ACTIVE;
|
||||
i2c_lld_master_transmit(i2cp, slave_addr, txbuf, txbytes, rxbuf, rxbytes);
|
||||
_i2c_wait_s(i2cp);
|
||||
#if !I2C_USE_WAIT
|
||||
i2c_lld_wait_bus_free(i2cp);
|
||||
#endif
|
||||
if (i2cp->id_state == I2C_COMPLETE)
|
||||
i2cp->id_state = I2C_READY;
|
||||
chSysUnlock();
|
||||
}
|
||||
|
||||
|
@ -205,6 +204,8 @@ void i2cMasterReceive(I2CDriver *i2cp,
|
|||
uint8_t *rxbuf,
|
||||
size_t rxbytes){
|
||||
|
||||
i2cAcquireBus(i2cp);
|
||||
|
||||
chDbgCheck((i2cp != NULL) && (i2cscfg != NULL) &&\
|
||||
(slave_addr != 0) &&\
|
||||
(rxbytes > 0) && \
|
||||
|
@ -231,11 +232,6 @@ void i2cMasterReceive(I2CDriver *i2cp,
|
|||
i2cp->id_state = I2C_ACTIVE;
|
||||
i2c_lld_master_receive(i2cp, slave_addr, rxbuf, rxbytes);
|
||||
_i2c_wait_s(i2cp);
|
||||
#if !I2C_USE_WAIT
|
||||
i2c_lld_wait_bus_free(i2cp);
|
||||
#endif
|
||||
if (i2cp->id_state == I2C_COMPLETE)
|
||||
i2cp->id_state = I2C_READY;
|
||||
chSysUnlock();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue