start mod06 ex00

This commit is contained in:
hugogogo
2025-03-15 18:56:04 +01:00
parent bd23d89706
commit 4f18cd2c56
6 changed files with 20 additions and 138 deletions

View File

@@ -13,8 +13,8 @@ void i2c_start(void) {
TWCR = SEND_START_CONDITION; // 22.9.2 : (Control Register) send Start condition (22.7.1) ! writting 1 to TWINT clears it (set it to 0)
while (!(TEST(TWCR, TWINT))); // p225 example code : Wait for TWINT Flag set. This indicates that the START condition has been transmitted
uint8_t status = TWSR & 0b11111000; // p225 example code : Check value of TWI Status Register. Mask prescaler bits. If status different from START go to ERROR
uart_printstr_itoa_base_endl(status);
uint8_t status = TWSR & 0b11111000; // Table 22-2. Status codes for Master Transmitter Mode
uart_printstr_itoa_base_endl(status, 2);
if (status != TW_START && status != TW_REP_START) {
TWCR = SEND_STOP_CONDITION;
return;