BV SPI: add LED activity indication
This commit is contained in:
parent
ad4c9e06dd
commit
93c8494b31
|
@ -238,7 +238,7 @@ static bool busvoodoo_spi_setup(char** prefix, const char* line)
|
|||
spi_enable(SPI(BUSVOODOO_SPI_ID)); // enable SPI
|
||||
if (!busvoodoo_spi_drive && busvoodoo_spi_pullup) {
|
||||
busvoodoo_embedded_pullup(true); // set embedded pull-ups
|
||||
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_spi_setting = BUSVOODOO_SPI_SETTING_NONE; // restart settings next time
|
||||
|
@ -274,10 +274,12 @@ static void busvoodoo_spi_write(uint16_t value)
|
|||
} else {
|
||||
printf("write: 0x%04x\n", value);
|
||||
}
|
||||
busvoodoo_led_red_pulse(BUSVOODOO_LED_PULSE); // pulse red LED to show we are writing
|
||||
while (!(SPI_SR(SPI(BUSVOODOO_SPI_ID))&SPI_SR_TXE)); // wait until Tx is empty
|
||||
(void)SPI_DR(SPI(BUSVOODOO_SPI_ID)); // clear RXNE flag by reading previously received data
|
||||
spi_send(SPI(BUSVOODOO_SPI_ID), value); // send data
|
||||
if (busvoodoo_spi_duplex) {
|
||||
busvoodoo_led_blue_pulse(BUSVOODOO_LED_PULSE); // pulse blue LED to show we read data
|
||||
value = spi_read(SPI(BUSVOODOO_SPI_ID)); // read data
|
||||
if (8==busvoodoo_spi_databits) {
|
||||
printf("read: 0x%02x\n", (uint8_t)value);
|
||||
|
@ -294,6 +296,7 @@ static void busvoodoo_spi_read(void)
|
|||
if (busvoodoo_spi_duplex) { // in full duplex mode
|
||||
busvoodoo_spi_write(0xffff); // send any value in order to read
|
||||
} else { // unidirectional mode
|
||||
busvoodoo_led_red_pulse(BUSVOODOO_LED_PULSE); // pulse blue LED to show we are reading
|
||||
gpio_set_mode(SPI_MOSI_PORT(BUSVOODOO_SPI_ID), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, SPI_MOSI_PIN(BUSVOODOO_SPI_ID)); // set MOSI as input
|
||||
while (!(SPI_SR(SPI(BUSVOODOO_SPI_ID))&SPI_SR_TXE)); // wait until Tx is empty
|
||||
(void)SPI_DR(SPI(BUSVOODOO_SPI_ID)); // clear RXNE flag by reading previously received data
|
||||
|
|
Loading…
Reference in New Issue