From e88598d324d73f84f8739b525ed9f2264b87e3eb Mon Sep 17 00:00:00 2001 From: Andrei Date: Sun, 4 Jun 2017 15:48:53 +0300 Subject: [PATCH] stopTsPort() needed by Bluetooth setup code --- firmware/console/binary/tunerstudio_io.cpp | 30 ++++++++++++++++++++++ firmware/console/binary/tunerstudio_io.h | 1 + 2 files changed, 31 insertions(+) diff --git a/firmware/console/binary/tunerstudio_io.cpp b/firmware/console/binary/tunerstudio_io.cpp index b18e2e4883..79d3bbbb79 100644 --- a/firmware/console/binary/tunerstudio_io.cpp +++ b/firmware/console/binary/tunerstudio_io.cpp @@ -124,6 +124,36 @@ void startTsPort(ts_channel_s *tsChannel) { #endif /* EFI_PROD_CODE */ } +bool stopTsPort(ts_channel_s *tsChannel) { +#if EFI_PROD_CODE || defined(__DOXYGEN__) +#if EFI_USB_SERIAL || defined(__DOXYGEN__) + if (isCommandLineConsoleOverTTL()) { +#if 0 + usb_serial_stop(); +#endif + // don't stop USB! + return false; + } else +#endif + { + if (boardConfiguration->useSerialPort) { + // todo: disable Rx/Tx pads? +#if TS_UART_DMA_MODE + uartStop(TS_DMA_UART_DEVICE); +#else + sdStop(TS_SERIAL_UART_DEVICE); +#endif /* TS_UART_DMA_MODE */ + } + } + + tsChannel->channel = (BaseChannel *) NULL; + return true; +#else /* EFI_PROD_CODE */ + // don't stop simulator! + return false; +#endif /* EFI_PROD_CODE */ +} + void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) { efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 64, "tunerStudioWriteData"); #if EFI_SIMULATOR || defined(__DOXYGEN__) diff --git a/firmware/console/binary/tunerstudio_io.h b/firmware/console/binary/tunerstudio_io.h index d7e2bd69b2..b34a3ae9b1 100644 --- a/firmware/console/binary/tunerstudio_io.h +++ b/firmware/console/binary/tunerstudio_io.h @@ -90,6 +90,7 @@ typedef struct { void startTsPort(ts_channel_s *tsChannel); +bool stopTsPort(ts_channel_s *tsChannel); // that's 1 second #define BINARY_IO_TIMEOUT MS2ST(1000)