rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
connector_uart_dma.h
Go to the documentation of this file.
1/*
2 * @file connector_uart_dma.h
3 *
4 * @date Jun 21, 2020
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8#pragma once
9#include "global.h"
10#include "tunerstudio_io.h"
11
12#if HAL_USE_UART && EFI_USE_UART_DMA
13
14// See uart_dma_s
15#define TS_FIFO_BUFFER_SIZE (BLOCKING_FACTOR + 30)
16// This must be a power of 2!
17#define TS_DMA_BUFFER_SIZE 32
18
19class UartDmaTsChannel final : public UartTsChannel {
20public:
21 UartDmaTsChannel(UARTDriver& uartDriver);
22
23 void start(uint32_t baud) override;
24
25 // Override only read from UartTsChannel
26 size_t readTimeout(uint8_t* buffer, size_t size, int timeout) override;
27
28 void copyDataFromDMA();
29
30private:
31 // RX FIFO implementation
32 // circular DMA buffer
33 uint8_t dmaBuffer[TS_DMA_BUFFER_SIZE];
34 // current read position for the DMA buffer
35 volatile int readPos;
36 // secondary FIFO buffer for async. transfer
37 uint8_t buffer[TS_FIFO_BUFFER_SIZE];
38 // input FIFO Rx queue
39 input_queue_t fifoRxQueue;
40};
41
42#endif // HAL_USE_UART && EFI_USE_UART_DMA
void start(uint32_t baud) override
uint8_t buffer[TS_FIFO_BUFFER_SIZE]
input_queue_t fifoRxQueue
size_t readTimeout(uint8_t *buffer, size_t size, int timeout) override
uint8_t dmaBuffer[TS_DMA_BUFFER_SIZE]
Structure representing an UART driver.
composite packet size