rusefi-1/firmware/console/connector_uart_dma.h

43 lines
969 B
C
Raw Normal View History

2020-06-21 12:50:21 -07:00
/*
* @file connector_uart_dma.h
*
* @date Jun 21, 2020
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#pragma once
#include "global.h"
#include "tunerstudio_io.h"
#if HAL_USE_UART && EFI_USE_UART_DMA
2020-06-21 12:50:21 -07:00
// See uart_dma_s
#define TS_FIFO_BUFFER_SIZE (BLOCKING_FACTOR + 30)
// This must be a power of 2!
#define TS_DMA_BUFFER_SIZE 32
class UartDmaTsChannel : public UartTsChannel {
public:
UartDmaTsChannel(UARTDriver& uartDriver);
void start(uint32_t baud) override;
// Override only read from UartTsChannel
size_t readTimeout(uint8_t* buffer, size_t size, int timeout) override;
void copyDataFromDMA();
private:
// RX FIFO implementation
2020-06-21 12:50:21 -07:00
// circular DMA buffer
uint8_t dmaBuffer[TS_DMA_BUFFER_SIZE];
// current read position for the DMA buffer
volatile int readPos;
// secondary FIFO buffer for async. transfer
uint8_t buffer[TS_FIFO_BUFFER_SIZE];
// input FIFO Rx queue
input_queue_t fifoRxQueue;
};
2020-06-21 13:37:33 -07:00
#endif // HAL_USE_UART && EFI_USE_UART_DMA