BV: use recommended pulse duration

This commit is contained in:
King Kévin 2018-03-22 12:09:18 +01:00
parent c36e786d93
commit ad4c9e06dd
2 changed files with 11 additions and 8 deletions

View File

@ -104,6 +104,9 @@
#define BUSVOODOO_HW_VERSION_CHANNEL 8 /**< ADC to identify hardware version */
/** @} */
/** recommended duration in ms for pulsing LEDs to show activity */
#define BUSVOODOO_LED_PULSE 100
/** BusVoodoo mode interface */
struct busvoodoo_mode_t {
const char* name; /**< name of the mode (i.e. protocol shortcut for the menu) */

View File

@ -119,7 +119,7 @@ static bool busvoodoo_i2c_setup(char** prefix, const char* line)
i2c_master_setup(BUSVOODOO_I2C, busvoodoo_i2c_speed); // setup I2C
if (busvoodoo_i2c_embedded_pullup) {
busvoodoo_embedded_pullup(true); // set pull-up
printf("use LV to set voltage\n");
printf("use LV to set pull-up voltage\n");
}
led_off(); // disable LED because there is no activity
busvoodoo_i2c_setting = BUSVOODOO_I2C_SETTING_NONE; // restart settings next time
@ -155,7 +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
busvoodoo_led_blue_pulse(BUSVOODOO_LED_PULSE); // 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
@ -182,7 +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
busvoodoo_led_red_pulse(BUSVOODOO_LED_PULSE); // 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");
@ -218,7 +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
busvoodoo_led_red_pulse(BUSVOODOO_LED_PULSE); // 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");
@ -267,7 +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
busvoodoo_led_red_pulse(BUSVOODOO_LED_PULSE); // pulse red LED to show we send start condition
printf("%s ", I2C_MASTER_RC_NONE==i2c_master_start(BUSVOODOO_I2C) ? "sent" : "error");
}
printf("\n");
@ -277,7 +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
busvoodoo_led_red_pulse(BUSVOODOO_LED_PULSE); // pulse red LED to show we send stop condition
printf("%s ", I2C_MASTER_RC_NONE==i2c_master_stop(BUSVOODOO_I2C) ? "sent" : "error");
}
printf("\n");
@ -440,10 +440,10 @@ static void busvoodoo_i2c_command_scan(void* argument)
int16_t i2c_slaves = 0; // number of slaves found
// check for I2C slaves by going through the address space
for (uint16_t address=0; address < (1<<busvoodoo_i2c_addressbits); address++) {
busvoodoo_led_blue(100); // pulse blue LED to show transmission
busvoodoo_led_red_pulse(BUSVOODOO_LED_PULSE); // pulse red LED to show transmission
switch (i2c_master_select_slave(BUSVOODOO_I2C, address, 10==busvoodoo_i2c_addressbits, false)) { // try to select slave (includes start condition)
case I2C_MASTER_RC_NONE: // slave found
busvoodoo_led_red(100); // pulse red LED to show we found a slave
busvoodoo_led_red_pulse(BUSVOODOO_LED_PULSE); // pulse blue LED to show we found a slave
printf((busvoodoo_i2c_addressbits>7) ? "0x%03x " : "0x%02x ", address); // display address
i2c_slaves++; // increase slave count
break;