diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2020-11-16 21:02:48 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2020-11-16 21:02:48 -0700 |
commit | c0e1b4cdf20c55f2cbbdf3a5889f447974135fd8 (patch) | |
tree | 003c27f4551f02de304da28cc60314a4516c40ed /02-usart/include/usart.h | |
parent | cd115ba47253ce8d2680178248116d251abacb23 (diff) | |
download | stm32l4-c0e1b4cdf20c55f2cbbdf3a5889f447974135fd8.tar.gz stm32l4-c0e1b4cdf20c55f2cbbdf3a5889f447974135fd8.tar.bz2 stm32l4-c0e1b4cdf20c55f2cbbdf3a5889f447974135fd8.zip |
Got the DMA to send a simple message through UART2.
Diffstat (limited to '02-usart/include/usart.h')
-rw-r--r-- | 02-usart/include/usart.h | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/02-usart/include/usart.h b/02-usart/include/usart.h index d806397..c645e92 100644 --- a/02-usart/include/usart.h +++ b/02-usart/include/usart.h @@ -6,6 +6,7 @@ #include "common.h" #include "rcc.h" +#include <assert.h> #define USART1 (* (__IO usart_t*) USART1_BASE) #define USART2 (* (__IO usart_t*) USART2_BASE) @@ -23,7 +24,7 @@ typedef enum { typedef struct { /* USART configuration registers 0x04 - 0x0c. */ union { - uint32_t c_r1; + __IO uint32_t c_r1; struct { bits_t ue:1; /* UART enable */ bits_t uesm:1; /* UART enabled in stop mode. */ @@ -49,10 +50,10 @@ typedef struct { bits_t reserved:3; } PACKED c1_bf; /* c1_bf = c1 bit field */ }; /* USART Control Register 1. */ - uint32_t c_r2; + __IO uint32_t c_r2; union { - uint32_t c_r3; + __IO uint32_t c_r3; struct { bits_t eie:1; // Error interrupt enable. bits_t iren:1; // IrDA mode enabled @@ -88,7 +89,7 @@ typedef struct { /* USART ISR register. Offset = 0x1c*/ union { - uint32_t is_r; /* Interrupt service register. */ + __IO uint32_t is_r; /* Interrupt service register. */ struct { bits_t pe:1; // Parity error bits_t fe:1; // Framing error @@ -118,11 +119,36 @@ typedef struct { bits_t reserved2:6; } PACKED is_bf; /* Interrupt servite bit field. */ }; - uint32_t ic_r; + union { + __IO uint32_t ic_r; + struct { + bits_t pecf:1; // Parity error clear flag + bits_t fecf:1; // Framing error clear flag + bits_t ncf:1; // Noise detected clear flag + bits_t orecf:1; // Overrun error clear flag + bits_t idlecf:1; // Idle line detected clear flag + bits_t reserved0:1; + bits_t tccf:1; // Transmission complete clear flag + bits_t tcbgtcf:1; // Transmission completed before guard time clear flag + bits_t lbdcf:1; // LIN break detection clear flag + bits_t ctscf:1; // CTS clear flag + bits_t reserved1:1; + bits_t rtocf:1; // Receiver timeout clear flag + bits_t eobcf:1; // End of block clear flag + bits_t reserved2:4; + bits_t cmcf:1; // Character match clear flag + bits_t reserved3:2; // Character match clear flag + bits_t wucf:1; // Wakeup from Stop mode clear flag. + bits_t reserved4:11; + } PACKED ic_bf; + }; uint32_t rd_r; uint32_t td_r; } usart_t; +static_assert(offsetof(usart_t, ic_r) == 0x20, "Offset assertion failed."); +static_assert(offsetof(usart_t, rd_r) == 0x24, "Offset assertion failed."); + typedef enum { OVERSAMPLE_8, OVERSAMPLE_16 @@ -170,6 +196,8 @@ void usart_set_parity(__IO usart_t* usart, usart_parity_t parity); void usart_set_enabled(__IO usart_t* usart, usart_enable_t enabled); +void usart_enable_dma(__IO usart_t* usart, usart_enable_t enabled); + /* * Send a byte on the usart, This command blocks until the data * is fully sent. |