I2C. Nop.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@2704 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
barthess 2011-02-04 09:55:51 +00:00
parent 0f5f6dd222
commit 6034aab6e6
1 changed files with 17 additions and 3 deletions

View File

@ -89,7 +89,12 @@ static void i2c_serve_event_interrupt(I2CDriver *i2cp) {
return; return;
} }
else { else {
//i2c_lld_rxbyte(i2cp); // read first byte /* In order to generate the non-acknowledge pulse after the last received
* data byte, the ACK bit must be cleared just after reading the second
* last data byte (after second last RxNE event).
*/
if (i2cp->id_slave_config->rxbytes > 1)
i2cp->id_i2c->CR1 |= I2C_CR1_ACK; // set ACK bit
i2cp->id_state = I2C_MRECEIVE; // change status i2cp->id_state = I2C_MRECEIVE; // change status
return; return;
} }
@ -118,6 +123,11 @@ static void i2c_serve_event_interrupt(I2CDriver *i2cp) {
if ((i2cp->id_state == I2C_MWAIT_TF) && (i2cp->id_i2c->SR1 & I2C_SR1_RXNE | I2C_SR1_BTF | I2C_SR1_TXE)){ if ((i2cp->id_state == I2C_MWAIT_TF) && (i2cp->id_i2c->SR1 & I2C_SR1_RXNE | I2C_SR1_BTF | I2C_SR1_TXE)){
chSysLockFromIsr(); chSysLockFromIsr();
i2cp->id_slave_config->id_callback(i2cp, i2cp->id_slave_config); i2cp->id_slave_config->id_callback(i2cp, i2cp->id_slave_config);
i = i2cp->id_i2c->SR1;
n = i2cp->id_i2c->SR2;
m = i2cp->id_i2c->CR1;
chSysUnlockFromIsr(); chSysUnlockFromIsr();
return; return;
} }
@ -294,11 +304,15 @@ bool_t i2c_lld_rxbyte(I2CDriver *i2cp) {
#define rxdepth i2cp->id_slave_config->rxdepth #define rxdepth i2cp->id_slave_config->rxdepth
#define rxbytes i2cp->id_slave_config->rxbytes #define rxbytes i2cp->id_slave_config->rxbytes
/* In order to generate the non-acknowledge pulse after the last received
* data byte, the ACK bit must be cleared just after reading the second
* last data byte (after second last RxNE event).
*/
if (rxbufhead < rxbytes){ if (rxbufhead < rxbytes){
if ((rxbytes - rxbufhead) == 1){ rxbuf[rxbufhead] = i2cp->id_i2c->DR;
if ((rxbytes - rxbufhead) <= 2){
i2cp->id_i2c->CR1 &= (~I2C_CR1_ACK);// clear ACK bit for automatically send NACK i2cp->id_i2c->CR1 &= (~I2C_CR1_ACK);// clear ACK bit for automatically send NACK
} }
rxbuf[rxbufhead] = i2cp->id_i2c->DR;
rxbufhead++; rxbufhead++;
return(FALSE); return(FALSE);
} }