busvoodoo_uart: remove features unsupported by dongle

This commit is contained in:
King Kévin 2020-03-09 13:01:18 +01:00
parent 67b7243736
commit f4231c9cc0
3 changed files with 28 additions and 7 deletions

View File

@ -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<LENGTH(pinout_io) && i<LENGTH(busvoodoo_global_pinout_io); i++) {
busvoodoo_global_pinout_io[i] = pinout_io[i]; // set pin names
}
#if BUSVOODOO_HARDWARE_VERSION != 2
if (busvoodoo_full) {
const char* pinout_rscan[5] = {"HV", NULL, NULL, NULL, NULL}; // HiZ mode RS/CAN pinout
for (uint8_t i=0; i<LENGTH(pinout_rscan) && i<LENGTH(busvoodoo_global_pinout_rscan); i++) {
busvoodoo_global_pinout_rscan[i] = pinout_rscan[i]; // set pin names
}
}
busvoodoo_oled_text_left(*prefix); // set mode title on OLED display
busvoodoo_oled_text_pinout((const char**)pinout_io, true); // set pinout on display
busvoodoo_oled_update(); // update display to show text and pinout
#endif
}
return complete;
}

View File

@ -12,11 +12,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/** 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 <kingkevin@cuvoodoo.info>
* @date 2018
* @date 2018-2020
*/
/* standard libraries */
#include <stdint.h> // 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
}

View File

@ -12,11 +12,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/** 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 <kingkevin@cuvoodoo.info>
* @date 2018
* @date 2018-2020
*/
#include <libopencm3/stm32/timer.h> // timer library