From f4231c9cc0534fedc7fa35d56e260f0b82f68665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 9 Mar 2020 13:01:18 +0100 Subject: [PATCH] busvoodoo_uart: remove features unsupported by dongle --- lib/busvoodoo_uart.c | 6 +++++- lib/busvoodoo_uart_generic.c | 23 ++++++++++++++++++++--- lib/busvoodoo_uart_generic.h | 6 +++--- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/busvoodoo_uart.c b/lib/busvoodoo_uart.c index 9a768d3..4d81cf9 100644 --- a/lib/busvoodoo_uart.c +++ b/lib/busvoodoo_uart.c @@ -35,7 +35,9 @@ #include "menu.h" // menu definitions #include "usart_enhanced.h" // utilities for USART enhancements #include "busvoodoo_global.h" // BusVoodoo definitions +#if BUSVOODOO_HARDWARE_VERSION != 2 #include "busvoodoo_oled.h" // OLED utilities +#endif #include "busvoodoo_uart_generic.h" // generic UART mode #include "busvoodoo_uart.h" // own definitions @@ -102,19 +104,21 @@ static bool busvoodoo_uart_setup(char** prefix, const char* line) busvoodoo_led_blue_off(); // disable blue LED because there is no activity gpio_primary_remap(AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON, AFIO_MAPR_TIM2_REMAP_PARTIAL_REMAP2); // remap timer 2 channel 4 to RX to be able to measure the edge timing *prefix = "UART"; // display mode - busvoodoo_oled_text_left(*prefix); // set mode title on OLED display const char* pinout_io[10] = {"GND", "5V", "3V3", "LV", "Rx", "Tx", "RTS", "CTS", NULL, NULL}; // UART mode pinout for (uint8_t i=0; i. * */ -/** BusVoodoo generic UART mode (code) +/** BusVoodoo generic UART mode * @note this only contains the common UART methods and should be supplied with mode specific methods and information - * @file busvoodoo_uart_generic.c + * @file * @author King Kévin - * @date 2018 + * @date 2018-2020 */ /* standard libraries */ #include // standard integer types @@ -64,8 +64,10 @@ static uint32_t busvoodoo_uart_generic_stopbits = USART_STOPBITS_1; static bool busvoodoo_uart_generic_hwflowctl = false; /** pin drive mode (true = push-pull, false = open-drain) */ static bool busvoodoo_uart_generic_drive = true; +#if BUSVOODOO_HARDWARE_VERSION != 2 /** if embedded pull-up resistors are used */ static bool busvoodoo_uart_generic_pullup = false; +#endif /** set if the timer ISR should be set in the interrupt table instead of the vector table * @note the vector table is faster, but doesn't allow to change the ISR @@ -184,8 +186,13 @@ bool busvoodoo_uart_generic_setup(char** prefix, const char* line) } if (BUSVOODOO_UART_SETTING_HWFLOWCTL==busvoodoo_uart_generic_setting) { // if next setting if (!busvoodoo_uart_generic_specific->hwflowctl) { // hardware flow control is not supported +#if BUSVOODOO_HARDWARE_VERSION != 2 busvoodoo_uart_generic_setting = BUSVOODOO_UART_SETTING_DRIVE; // go to next setting goto setting_drive; // actually go to next setting +#else + busvoodoo_uart_generic_setting = BUSVOODOO_UART_SETTING_DONE; // go to next setting + goto setting_done; // actually go to next setting +#endif } printf("1) no flow control\n"); printf("2) RTS/CTS hardware flow control\n"); @@ -199,9 +206,14 @@ bool busvoodoo_uart_generic_setup(char** prefix, const char* line) } else if (1==strlen(line)) { // setting provided if ('1'==line[0] || '2'==line[0]) { // setting provided busvoodoo_uart_generic_hwflowctl = ('2'==line[0]); // remember setting +#if BUSVOODOO_HARDWARE_VERSION != 2 busvoodoo_uart_generic_setting = BUSVOODOO_UART_SETTING_DRIVE; // go to next setting +#else + busvoodoo_uart_generic_setting = BUSVOODOO_UART_SETTING_DONE; // go to next setting +#endif } } +#if BUSVOODOO_HARDWARE_VERSION != 2 setting_drive: if (BUSVOODOO_UART_SETTING_DRIVE==busvoodoo_uart_generic_setting) { // if next setting if (!busvoodoo_uart_generic_specific->multidrive) { @@ -227,6 +239,7 @@ setting_drive: busvoodoo_uart_generic_setting = BUSVOODOO_UART_SETTING_DONE; // go to next setting } } +#endif setting_done: if (BUSVOODOO_UART_SETTING_DONE==busvoodoo_uart_generic_setting) { // we have all settings, configure UART rcc_periph_clock_enable(RCC_AFIO); // enable clock for USART alternate function @@ -264,10 +277,12 @@ setting_done: gpio_set_mode(busvoodoo_uart_generic_specific->cts_port, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, busvoodoo_uart_generic_specific->cts_pin); // setup GPIO pin USART receive } } +#if BUSVOODOO_HARDWARE_VERSION != 2 if (!busvoodoo_uart_generic_drive && busvoodoo_uart_generic_pullup) { // enable embedded pull-ups if used busvoodoo_embedded_pullup(true); // set embedded pull-ups printf("use LV to set pull-up voltage\n"); } +#endif usart_enable(busvoodoo_uart_generic_specific->usart); // enable USART // setup timer to measure RX edge timing for baud rate guessing if (busvoodoo_uart_generic_specific->timer) { @@ -297,9 +312,11 @@ void busvoodoo_uart_generic_exit(void) gpio_set_mode(busvoodoo_uart_generic_specific->rts_port, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, busvoodoo_uart_generic_specific->rts_pin); // set pin back to floating input gpio_set_mode(busvoodoo_uart_generic_specific->cts_port, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, busvoodoo_uart_generic_specific->cts_pin); // set pin back to floating input } +#if BUSVOODOO_HARDWARE_VERSION != 2 if (busvoodoo_uart_generic_specific->multidrive) { busvoodoo_embedded_pullup(false); // disable embedded pull-ups } +#endif busvoodoo_uart_generic_specific = NULL; // remove specific information } diff --git a/lib/busvoodoo_uart_generic.h b/lib/busvoodoo_uart_generic.h index b0f8b0d..f8ac811 100644 --- a/lib/busvoodoo_uart_generic.h +++ b/lib/busvoodoo_uart_generic.h @@ -12,11 +12,11 @@ * along with this program. If not, see . * */ -/** BusVoodoo generic UART mode (API) +/** BusVoodoo generic UART mode * @note this only contains the common UART methods and should be supplied with mode specific methods and information - * @file busvoodoo_uart_generic.h + * @file * @author King Kévin - * @date 2018 + * @date 2018-2020 */ #include // timer library