Fix build if no TS_UART_DMA_MODE, TS_UART_MODE and TS_SERIAL_DEVICE defined (#729)

This commit is contained in:
dron0gus 2019-04-02 00:39:07 +03:00 committed by rusefi
parent 99bff37869
commit 9d95127260
1 changed files with 64 additions and 70 deletions

View File

@ -82,86 +82,80 @@ static SerialConfig tsSerialConfig = { 0, 0, USART_CR2_STOP1_BITS | USART_CR2_LI
void startTsPort(ts_channel_s *tsChannel) { void startTsPort(ts_channel_s *tsChannel) {
#if EFI_PROD_CODE || defined(__DOXYGEN__) tsChannel->channel = (BaseChannel *) NULL;
#if EFI_USB_SERIAL || defined(__DOXYGEN__)
if (true) {
print("TunerStudio over USB serial");
/**
* This method contains a long delay, that's the reason why this is not done on the main thread
*/
usb_serial_start();
// if console uses UART then TS uses USB
tsChannel->channel = (BaseChannel *) &CONSOLE_USB_DEVICE;
} else
#endif
{
if (CONFIGB(useSerialPort)) {
print("TunerStudio over USART"); #if EFI_PROD_CODE || defined(__DOXYGEN__)
efiSetPadMode("tunerstudio rx", engineConfiguration->binarySerialRxPin, PAL_MODE_ALTERNATE(TS_SERIAL_AF)); #if defined(CONSOLE_USB_DEVICE) || defined(__DOXYGEN__)
efiSetPadMode("tunerstudio tx", engineConfiguration->binarySerialTxPin, PAL_MODE_ALTERNATE(TS_SERIAL_AF)); print("TunerStudio over USB serial");
/**
* This method contains a long delay, that's the reason why this is not done on the main thread
*/
usb_serial_start();
// if console uses UART then TS uses USB
tsChannel->channel = (BaseChannel *) &CONSOLE_USB_DEVICE;
return;
#endif
#if defined(TS_UART_DEVICE) || defined(TS_SERIAL_DEVICE)
if (CONFIGB(useSerialPort)) {
#if TS_UART_DMA_MODE print("TunerStudio over USART");
print("Using UART-DMA mode"); efiSetPadMode("tunerstudio rx", engineConfiguration->binarySerialRxPin, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
// init FIFO queue efiSetPadMode("tunerstudio tx", engineConfiguration->binarySerialTxPin, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
iqObjectInit(&tsUartDma.fifoRxQueue, tsUartDma.buffer, sizeof(tsUartDma.buffer), NULL, NULL);
// start DMA driver
tsDmaUartConfig.speed = CONFIGB(tunerStudioSerialSpeed);
uartStart(TS_UART_DEVICE, &tsDmaUartConfig);
// start continuous DMA transfer using our circular buffer #if TS_UART_DMA_MODE
tsUartDma.readPos = 0; print("Using UART-DMA mode");
uartStartReceive(TS_UART_DEVICE, sizeof(tsUartDma.dmaBuffer), tsUartDma.dmaBuffer); // init FIFO queue
#elif TS_UART_MODE iqObjectInit(&tsUartDma.fifoRxQueue, tsUartDma.buffer, sizeof(tsUartDma.buffer), NULL, NULL);
print("Using UART mode");
// start DMA driver
tsUartConfig.speed = CONFIGB(tunerStudioSerialSpeed);
uartStart(TS_UART_DEVICE, &tsUartConfig);
#else
print("Using Serial mode");
tsSerialConfig.speed = CONFIGB(tunerStudioSerialSpeed);
sdStart(TS_SERIAL_DEVICE, &tsSerialConfig); // start DMA driver
tsDmaUartConfig.speed = CONFIGB(tunerStudioSerialSpeed);
tsChannel->channel = (BaseChannel *) TS_SERIAL_DEVICE; uartStart(TS_UART_DEVICE, &tsDmaUartConfig);
#endif /* TS_UART_DMA_MODE */
} else // start continuous DMA transfer using our circular buffer
tsChannel->channel = (BaseChannel *) NULL; // actually not used tsUartDma.readPos = 0;
} uartStartReceive(TS_UART_DEVICE, sizeof(tsUartDma.dmaBuffer), tsUartDma.dmaBuffer);
#else /* EFI_PROD_CODE */ #elif TS_UART_MODE
tsChannel->channel = (BaseChannel *) TS_SIMULATOR_PORT; print("Using UART mode");
#endif /* EFI_PROD_CODE */ // start DMA driver
tsUartConfig.speed = CONFIGB(tunerStudioSerialSpeed);
uartStart(TS_UART_DEVICE, &tsUartConfig);
#elif defined(TS_SERIAL_DEVICE)
print("Using Serial mode");
tsSerialConfig.speed = CONFIGB(tunerStudioSerialSpeed);
sdStart(TS_SERIAL_DEVICE, &tsSerialConfig);
tsChannel->channel = (BaseChannel *) TS_SERIAL_DEVICE;
#endif
}
#endif /* TS_UART_DMA_MODE || TS_UART_MODE */
#else /* EFI_PROD_CODE */
tsChannel->channel = (BaseChannel *) TS_SIMULATOR_PORT;
#endif /* EFI_PROD_CODE */
} }
bool stopTsPort(ts_channel_s *tsChannel) { bool stopTsPort(ts_channel_s *tsChannel) {
#if EFI_PROD_CODE || defined(__DOXYGEN__) #if EFI_PROD_CODE || defined(__DOXYGEN__)
#if EFI_USB_SERIAL || defined(__DOXYGEN__) #if EFI_USB_SERIAL || defined(__DOXYGEN__)
if (true) { // don't stop USB!
#if 0 //usb_serial_stop();
usb_serial_stop(); return false;
#endif #endif
// don't stop USB!
return false;
} else
#endif
{
if (CONFIGB(useSerialPort)) { if (CONFIGB(useSerialPort)) {
// todo: disable Rx/Tx pads? // todo: disable Rx/Tx pads?
#if (TS_UART_DMA_MODE || TS_UART_MODE) #if (TS_UART_DMA_MODE || TS_UART_MODE)
uartStop(TS_UART_DEVICE); uartStop(TS_UART_DEVICE);
#else #endif /* TS_UART_DMA_MODE || TS_UART_MODE */
sdStop(TS_SERIAL_DEVICE); #ifdef TS_SERIAL_DEVICE
#endif /* TS_UART_DMA_MODE */ sdStop(TS_SERIAL_DEVICE);
#endif /* TS_SERIAL_DEVICE */
} }
} tsChannel->channel = (BaseChannel *) NULL;
return true;
tsChannel->channel = (BaseChannel *) NULL; #else /* EFI_PROD_CODE */
return true; // don't stop simulator!
#else /* EFI_PROD_CODE */ return false;
// don't stop simulator! #endif /* EFI_PROD_CODE */
return false;
#endif /* EFI_PROD_CODE */
} }
void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) { void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) {