Rev 473 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 473 | Rev 474 | ||
---|---|---|---|
Line 232... | Line 232... | ||
232 | //-------------------------------------------------------------- |
232 | //-------------------------------------------------------------- |
233 | void I2C1_IRQHandler(void) |
233 | void I2C1_IRQHandler(void) |
234 | { |
234 | { |
235 | static u8 Rx_Idx = 0, Tx_Idx = 0; |
235 | static u8 Rx_Idx = 0, Tx_Idx = 0; |
236 | u16 status; |
236 | u16 status; |
237 | - | ||
- | 237 | u16 timeout = 500; |
|
238 | //IENABLE; // do not enable IRQ nesting for I2C!!!! |
238 | //IENABLE; // do not enable IRQ nesting for I2C!!!! |
239 | // detemine I2C State |
239 | // detemine I2C State |
240 | status = I2C_GetLastEvent(I2C1); |
240 | status = I2C_GetLastEvent(I2C1); |
Line 241... | Line 241... | ||
241 | 241 | ||
242 | if(status & (I2C_FLAG_AF|I2C_FLAG_BERR)) // if an acknowledge failure or bus error occured |
242 | if(status & (I2C_FLAG_AF|I2C_FLAG_BERR)) // if an acknowledge failure or bus error occured |
243 | { // Set and subsequently clear the STOP bit while BTF is set. |
243 | { // Set and subsequently clear the STOP bit while BTF is set. |
244 | while(I2C_GetFlagStatus (I2C1, I2C_FLAG_BTF) != RESET) |
244 | while(I2C_GetFlagStatus (I2C1, I2C_FLAG_BTF) != RESET) |
245 | { |
245 | { |
246 | I2C_GenerateSTOP (I2C1, ENABLE); // free the bus |
246 | I2C_GenerateSTOP(I2C1, ENABLE); // free the bus |
- | 247 | I2C_GenerateSTOP(I2C1, DISABLE); // free the bus |
|
- | 248 | if(--timeout == 0) |
|
- | 249 | { |
|
- | 250 | DebugOut.Analog[14]++; // count I2C error |
|
- | 251 | break; |
|
247 | I2C_GenerateSTOP (I2C1, DISABLE); // free the bus |
252 | } |
248 | } |
253 | } |
249 | I2C1_State = I2C_STATE_IDLE; |
254 | I2C1_State = I2C_STATE_IDLE; |
250 | I2C1_Error = I2C_ERROR_NOACK; |
255 | I2C1_Error = I2C_ERROR_NOACK; |
251 | VIC_ITCmd(I2C1_ITLine, DISABLE); |
256 | VIC_ITCmd(I2C1_ITLine, DISABLE); |