static uint32_t I2C_Start (LPC_I2C_TypeDef *I2Cx) { I2Cx->I2CONSET = I2C_I2CONSET_STA; I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; // Wait for complete while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI)); // <--- HERE IT GETS STUCK I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK); } |
The master transmitter mode may now be entered by setting the STA bit. The I2C logic will now test the I2C-bus and generate a START condition as soon as the bus becomes free. When a START condition is transmitted, the serial interrupt flag (SI) is set ... |
...then wait for interrupt == ..check the interrupt flag |
The master transmitter mode may now be entered by setting the STA bit. The I2C logic will now test the I2C-bus and generate a START condition as soon as the bus becomes free. When a START condition is transmitted, the serial interrupt flag (SI) is set ... |
I2Cx->I2CONSET = I2C_I2CONSET_STA; I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; |
static uint32_t I2C_Start (LPC_I2C_TypeDef *I2Cx) { int i = 10000, retry = 3; // Wait for complete while (retry){ i = 10000; I2Cx->I2CONSET = I2C_I2CONSET_STA; I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; while(!(I2Cx->I2CONSET & I2C_I2CONSET_SI) && i --); if(i) break; global_retries ++; retry --; } // if retry == 0 create infinite loop if(!retry) while(1); I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK); } |
I2Cx->I2CONSET = I2C_I2CONSET_STA; I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; |
static uint32_t I2C_Start (LPC_I2C_TypeDef *I2Cx) { int i = 10000, retry = 3; // Wait for complete while (retry){ i = 10000; I2Cx->I2CONSET = I2C_I2CONSET_STA; I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; while(!(I2Cx->I2CONSET & I2C_I2CONSET_SI) && i --); if(i) break; retry --; } // if retry == 0 create infinite loop if(!retry) while(1); I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK); } |