From c3ed78423d23aaa3ff8284bd656e88e6eefef6dd Mon Sep 17 00:00:00 2001 From: Hardy Griech Date: Mon, 17 Apr 2023 22:39:46 +0200 Subject: [PATCH] show PICOPROBE_LED_TARGET_TX on debug probe output board on startup --- include/boards/pico.h | 3 +- include/boards/pico_debug_probe.h | 5 ++- include/boards/pico_w.h | 3 +- src/cdc_uart.c | 2 +- src/led.c | 63 +++++++++++++++++++++++++------ src/led.h | 4 +- src/main.c | 9 +++++ src/rtt_console.c | 2 +- 8 files changed, 73 insertions(+), 18 deletions(-) diff --git a/include/boards/pico.h b/include/boards/pico.h index 81b0a3a..cbfd410 100755 --- a/include/boards/pico.h +++ b/include/boards/pico.h @@ -9,7 +9,8 @@ // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES // ----------------------------------------------------- -// This header may be included by other board headers as "boards/pico.h" +// This header may be included by other board headers as "boards/pico.h". +// But normally this is included via "#include " if PICO_BOARD is set accordingly. #ifndef _BOARDS_PICO_H #define _BOARDS_PICO_H diff --git a/include/boards/pico_debug_probe.h b/include/boards/pico_debug_probe.h index 91f72da..abb806d 100755 --- a/include/boards/pico_debug_probe.h +++ b/include/boards/pico_debug_probe.h @@ -9,7 +9,8 @@ // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES // ----------------------------------------------------- -// This header may be included by other board headers as "boards/pico_debug_probe.h" +// This header may be included by other board headers as "boards/pico_debug_probe.h". +// But normally this is included via "#include " if PICO_BOARD is set accordingly. // Schematic: https://datasheets.raspberrypi.com/debug/raspberry-pi-debug-probe-schematics.pdf #ifndef _BOARDS_PICO_DEBUG_PROBE_H @@ -47,6 +48,8 @@ #define PICOPROBE_LED PICO_DEFAULT_LED_PIN #define PICOPROBE_LED_CONNECTED 15 #define PICOPROBE_LED_RUNNING 16 +#define PICOPROBE_LED_TARGET_RX 7 // host -> probe -> target UART / RTT data, i.e. target is receiving +#define PICOPROBE_LED_TARGET_TX 8 // target -> probe -> host UART / RTT data, i.e. target is transmitting // PIO config #define PROBE_PIO pio0 diff --git a/include/boards/pico_w.h b/include/boards/pico_w.h index 6d0ad7a..790b9cb 100755 --- a/include/boards/pico_w.h +++ b/include/boards/pico_w.h @@ -9,7 +9,8 @@ // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES // ----------------------------------------------------- -// This header may be included by other board headers as "boards/pico.h" +// This header may be included by other board headers as "boards/pico.h". +// But normally this is included via "#include " if PICO_BOARD is set accordingly. #ifndef _BOARDS_PICO_W_H #define _BOARDS_PICO_W_H diff --git a/src/cdc_uart.c b/src/cdc_uart.c index 9c8430e..12eca98 100644 --- a/src/cdc_uart.c +++ b/src/cdc_uart.c @@ -222,7 +222,7 @@ void on_uart_rx(void) } if (cnt != 0) { - led_state(LS_UART_DATA); + led_state(LS_UART_RX_DATA); cdc_uart_put_into_stream(buf, cnt, true); } diff --git a/src/led.c b/src/led.c index 5c91dfc..374a623 100644 --- a/src/led.c +++ b/src/led.c @@ -33,6 +33,7 @@ #include "FreeRTOS.h" #include "task.h" +#include "timers.h" #include "picoprobe_config.h" #include "led.h" @@ -41,14 +42,50 @@ static TaskHandle_t task_led; -static bool msc_connected; -static bool dapv1_connected; -static bool dapv2_connected; -static led_state_t sigrok_state; -static bool target_found; -static unsigned rtt_flash_cnt; -static uint64_t uart_data_trigger; -static uint64_t rtt_data_trigger; +static bool msc_connected; +static bool dapv1_connected; +static bool dapv2_connected; +static led_state_t sigrok_state; +static bool target_found; +static unsigned rtt_flash_cnt; +static uint64_t uart_data_trigger; +static uint64_t rtt_data_trigger; + + + +#ifdef PICOPROBE_LED_TARGET_TX + static TimerHandle_t timer_led_tx_off; + static void *timer_led_tx_off_id; + + + static void led_tx_off(TimerHandle_t xTimer) + { + gpio_put(PICOPROBE_LED_TARGET_TX, false); + } + + + static void rx_data_from_target(void) + { + static bool initialized; + + if ( !initialized) { + initialized = true; + gpio_init(PICOPROBE_LED_TARGET_TX); + gpio_set_dir(PICOPROBE_LED_TARGET_TX, GPIO_OUT); + } + gpio_put(PICOPROBE_LED_TARGET_TX, true); + xTimerReset(timer_led_tx_off, 10); + } // rx_data_from_target + + + static void rx_data_from_target_init(void) + { + timer_led_tx_off = xTimerCreate("led_tx_off", pdMS_TO_TICKS(5), pdFALSE, timer_led_tx_off_id, led_tx_off); + } // rx_data_from_target_init +#else + #define rx_data_from_target() + #define led_tx_off_init() +#endif @@ -149,7 +186,7 @@ void led_thread(void *ptr) vTaskDelay(pdMS_TO_TICKS(200)); } led(0); - vTaskDelay(pdMS_TO_TICKS(1000 - rtt_flash_cnt * 220)); + vTaskDelay(pdMS_TO_TICKS(1000 - flash_cnt * 220)); } } } // led_thread @@ -205,12 +242,14 @@ void led_state(led_state_t state) rtt_flash_cnt = 2; break; - case LS_RTT_DATA: + case LS_RTT_RX_DATA: rtt_data_trigger = time_us_64(); + rx_data_from_target(); break; - case LS_UART_DATA: + case LS_UART_RX_DATA: uart_data_trigger = time_us_64(); + rx_data_from_target(); break; case LS_SIGROK_WAIT: @@ -235,5 +274,7 @@ void led_init(uint32_t task_prio) led(1); + rx_data_from_target_init(); + xTaskCreateAffinitySet(led_thread, "LED", configMINIMAL_STACK_SIZE, NULL, task_prio, 1, &task_led); } // led_init diff --git a/src/led.h b/src/led.h index cde1d7d..7fa4633 100644 --- a/src/led.h +++ b/src/led.h @@ -34,8 +34,8 @@ typedef enum _led_state { LS_TARGET_FOUND, // there is a target LS_NO_TARGET, // no target found LS_RTT_CB_FOUND, // found an RTT control block on target - LS_RTT_DATA, // RTT data received from target - LS_UART_DATA, // UART data received from target + LS_RTT_RX_DATA, // RTT data received from target + LS_UART_RX_DATA, // UART data received from target LS_MSC_CONNECTED, // MSC connected LS_MSC_DISCONNECTED, // MSC disconnected LS_DAPV1_CONNECTED, // DAPV1 connected diff --git a/src/main.c b/src/main.c index 1641cde..81ee9f0 100644 --- a/src/main.c +++ b/src/main.c @@ -515,6 +515,15 @@ int main(void) picoprobe_info_out(" [DAPLink MSC]"); #endif picoprobe_info_out("\n"); +#if defined(TARGET_BOARD_PICO) + picoprobe_info(" Probe HW: Pico\n"); +#elif defined(TARGET_BOARD_PICO_W) + picoprobe_info(" Probe HW: Pico_W\n"); +#elif defined(TARGET_BOARD_PICO_DEBUG_PROBE) + picoprobe_info(" Probe HW: Pico Debug Probe\n"); +#else + picoprobe_info(" Running on UNKNOWN board\n"); +#endif picoprobe_info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); events = xEventGroupCreate(); diff --git a/src/rtt_console.c b/src/rtt_console.c index 0999310..1a83da8 100755 --- a/src/rtt_console.c +++ b/src/rtt_console.c @@ -159,7 +159,7 @@ static void do_rtt_console(uint32_t rtt_cb) // put received data into CDC UART cdc_uart_write(buf, cnt); - led_state(LS_RTT_DATA); + led_state(LS_RTT_RX_DATA); } } } // do_rtt_console