drv-usart-dma.h (1168B)
1 #ifndef __DRV_USART_DMA_H__ 2 #define __DRV_USART_DMA_H__ 3 4 #include <libopencm3/stm32/usart.h> 5 #include <libopencm3/stm32/dma.h> 6 7 #define DMA_RX_BUFFER_SIZE (0x100U) // 128B 8 #define DMA_TX_BUFFER_SIZE (0x400U) // 1KiB 9 10 typedef struct { 11 uint32_t addr; 12 uint32_t clock; 13 uint32_t tx_stream; 14 uint32_t rx_stream; 15 uint8_t *rxBuf; 16 uint8_t *txBuf; 17 uint32_t tx_stream_irq; 18 uint32_t rx_stream_irq; 19 } DMA_t; 20 21 typedef struct { 22 uint32_t port; 23 uint32_t clock; 24 uint32_t nvic_irq; 25 uint32_t gpio_port; 26 uint32_t gpio_rx; 27 uint32_t gpio_tx; 28 DMA_t dma; 29 } USART_t; 30 31 extern USART_t dbg; 32 extern USART_t gsm; 33 extern USART_t *comm; 34 35 void res_usart_init(void); 36 void res_usart_dma_gsm_setup(void); 37 void res_usart_dma_dbg_setup(void); 38 void res_usart_write(const USART_t *usart, const uint8_t *data, const uint32_t length); 39 uint32_t res_usart_read(uint8_t *data, const uint32_t length); 40 uint8_t res_usart_read_byte(void); 41 bool res_usart_data_available(void); 42 void res_usart_dma_write(const USART_t *usart, const uint16_t offset, const uint32_t length); 43 uint16_t res_usart_dma_get_buffer_tail(USART_t *usart); 44 45 #endif // __DRV_USART_DMA_H__