BV I2C: add activity LED

This commit is contained in:
King Kévin 2018-03-21 15:41:09 +01:00
parent 87d68d5b48
commit 53dda1e50f
1 changed files with 5 additions and 0 deletions

View File

@ -155,6 +155,7 @@ static void busvoodoo_i2c_exit(void)
static void busvoodoo_i2c_read(void)
{
printf("read: ");
busvoodoo_blue_blue(100); // pulse blue LED to show we read data
uint8_t data; // to store the data read
switch (i2c_master_read(BUSVOODOO_I2C, &data, 1)) {
case I2C_MASTER_RC_NONE: // all went fine
@ -181,6 +182,7 @@ static void busvoodoo_i2c_read(void)
static void busvoodoo_i2c_write(uint8_t data)
{
printf("write 0x%02x: ", data);
busvoodoo_red_blue(100); // pulse red LED to show we send data
switch (i2c_master_write(BUSVOODOO_I2C, &data, 1)) {
case I2C_MASTER_RC_NONE: // all went fine
printf("ack");
@ -216,6 +218,7 @@ static void busvoodoo_i2c_select(uint16_t slave, bool write)
printf("0x%02x", slave);
}
printf(" to %s: ", write ? "write" : "read");
busvoodoo_red_blue(100); // pulse red LED to show we send the slave address
switch (i2c_master_select_slave(BUSVOODOO_I2C, slave, 10==busvoodoo_i2c_addressbits, write)) {
case I2C_MASTER_RC_NONE: // all went fine
printf("selected");
@ -264,6 +267,7 @@ static bool busvoodoo_i2c_action(const char* action, uint32_t repetition, bool p
}
printf("send start condition: ");
for (uint32_t i=0; i<repetition; i++) {
busvoodoo_red_blue(100); // pulse red LED to show we send start condition
printf("%s ", I2C_MASTER_RC_NONE==i2c_master_start(BUSVOODOO_I2C) ? "sent" : "error");
}
printf("\n");
@ -273,6 +277,7 @@ static bool busvoodoo_i2c_action(const char* action, uint32_t repetition, bool p
}
printf("send stop condition: ");
for (uint32_t i=0; i<repetition; i++) {
busvoodoo_red_blue(100); // pulse red LED to show we send stop condition
printf("%s ", I2C_MASTER_RC_NONE==i2c_master_stop(BUSVOODOO_I2C) ? "sent" : "error");
}
printf("\n");