Skip to content

Commit 56c7daf

Browse files
committed
pios_usart: Add flag field and DMA hint.
1 parent d87b816 commit 56c7daf

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

flight/PiOS/STM32/inc/pios_usart_priv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
#include <pios_stm32.h>
3535
#include "pios_usart.h"
3636

37+
#define PIOS_USART_ALLOW_RECEIVE_DMA 0x1
38+
#define PIOS_USART_ALLOW_TRANSMIT_DMA 0x2
39+
3740
extern const struct pios_com_driver pios_usart_com_driver;
3841

3942
#if defined(STM32F4XX)
@@ -63,6 +66,7 @@ struct pios_usart_params {
6366
bool tx_invert;
6467
bool rxtx_swap;
6568
bool single_wire;
69+
uint8_t flags;
6670
};
6771

6872
extern int32_t PIOS_USART_Init(uintptr_t * usart_id, const struct pios_usart_cfg * cfg, struct pios_usart_params * params);

flight/PiOS/STM32F4xx/pios_usart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ int32_t PIOS_USART_Init(uintptr_t * usart_id, const struct pios_usart_cfg * cfg,
226226
// FIXME XXX Clear / reset uart here - sends NUL char else
227227

228228
/* Check DMA transmit configuration and prepare DMA. */
229-
if (cfg->dma_send) {
229+
if (cfg->dma_send && (params->flags & PIOS_USART_ALLOW_TRANSMIT_DMA)) {
230230
usart_dev->dma_send_buffer = (uint32_t)PIOS_malloc(PIOS_USART_DMA_SEND_BUFFER_SZ);
231231

232232
if (usart_dev->dma_send_buffer) {
@@ -237,7 +237,7 @@ int32_t PIOS_USART_Init(uintptr_t * usart_id, const struct pios_usart_cfg * cfg,
237237
}
238238

239239
/* Check DMA receive configuration, and setup and start DMA. */
240-
if (cfg->dma_recv) {
240+
if (cfg->dma_recv && (params->flags & PIOS_USART_ALLOW_RECEIVE_DMA)) {
241241
usart_dev->dma_recv_buffer = (uint32_t)PIOS_malloc(PIOS_USART_DMA_RECV_BUFFER_SZ);
242242

243243
if (usart_dev->dma_recv_buffer) {

0 commit comments

Comments
 (0)