aboutsummaryrefslogtreecommitdiff
path: root/include/libopenstm32
diff options
context:
space:
mode:
authorPiotr Esden-Tempski2010-01-15 03:41:16 +0100
committerPiotr Esden-Tempski2010-01-15 17:00:18 +0100
commit0c6b661502c48baed8f7d4e36205d95c8ace663e (patch)
tree354d2007e57f4c91f1b59c9fb5dff62e2ee8f6b6 /include/libopenstm32
parentd173306c31e8533cc6619f23f44c284cf247e1b2 (diff)
Adapted to the new header style. Added some defs.
Diffstat (limited to 'include/libopenstm32')
-rw-r--r--include/libopenstm32/usart.h155
1 files changed, 126 insertions, 29 deletions
diff --git a/include/libopenstm32/usart.h b/include/libopenstm32/usart.h
index 924b452..74fb515 100644
--- a/include/libopenstm32/usart.h
+++ b/include/libopenstm32/usart.h
@@ -90,41 +90,91 @@
/* --- USART_SR values ----------------------------------------------------- */
-#define USART_SR_CTS (1 << 9) /* N/A on UART4/5 */
+/* CTS: CTS flag */
+/* Note: N/A on UART4/5 */
+#define USART_SR_CTS (1 << 9)
+
+/* LBD: LIN break detection flag */
#define USART_SR_LBD (1 << 8)
+
+/* TXE: Transmit data buffer empty */
#define USART_SR_TXE (1 << 7)
+
+/* TC: Transmission complete */
#define USART_SR_TC (1 << 6)
+
+/* RXNE: Read data register not empty */
#define USART_SR_RXNE (1 << 5)
+
+/* IDLE: Idle line detected */
#define USART_SR_IDLE (1 << 4)
+
+/* ORE: Overrun error */
#define USART_SR_ORE (1 << 3)
+
+/* NE: Noise error flag */
#define USART_SR_NE (1 << 2)
+
+/* FE: Framing error */
#define USART_SR_FE (1 << 1)
+
+/* PE: Parity error */
#define USART_SR_PE (1 << 0)
/* --- USART_DR values ----------------------------------------------------- */
/* USART_DR[8:0]: DR[8:0]: Data value */
+#define USART_DR_MASK 0xFF
/* --- USART_BRR values ---------------------------------------------------- */
-/* USART_BRR[15:4]: DIV_Mantissa[11:0]: mantissa of USARTDIV */
-/* USART_BRR[3:0]: DIV_Fraction[3:0]: fraction of USARTDIV */
+/* DIV_Mantissa[11:0]: mantissa of USARTDIV */
+#define USART_BRR_DIV_MANTISSA_MASK (0xFFF << 4)
+/* DIV_Fraction[3:0]: fraction of USARTDIV */
+#define USART_BRR_DIV_FRACTION_MASK 0xF
/* --- USART_CR1 values ---------------------------------------------------- */
+/* UE: USART enable */
#define USART_CR1_UE (1 << 13)
+
+/* M: Word length */
#define USART_CR1_M (1 << 12)
+
+/* WAKE: Wakeup method */
#define USART_CR1_WAKE (1 << 11)
+
+/* PCE: Parity control enable */
#define USART_CR1_PCE (1 << 10)
+
+/* PS: Parity selection */
#define USART_CR1_PS (1 << 9)
+
+/* PEIE: PE interrupt enable */
#define USART_CR1_PEIE (1 << 8)
+
+/* TXEIE: TXE interrupt enable */
#define USART_CR1_TXEIE (1 << 7)
+
+/* TCIE: Transmission complete interrupt enable */
#define USART_CR1_TCIE (1 << 6)
+
+/* RXNEIE: RXNE interrupt enable */
#define USART_CR1_RXNEIE (1 << 5)
+
+/* IDLEIE: IDLE interrupt enable */
#define USART_CR1_IDLEIE (1 << 4)
+
+/* TE: Transmitter enable */
#define USART_CR1_TE (1 << 3)
+
+/* RE: Receiver enable */
#define USART_CR1_RE (1 << 2)
+
+/* RWU: Receiver wakeup */
#define USART_CR1_RWU (1 << 1)
+
+/* SBK: Send break */
#define USART_CR1_SBK (1 << 0)
/* CR1_PCE / CR1_PS combined values */
@@ -139,35 +189,77 @@
/* --- USART_CR2 values ---------------------------------------------------- */
-#define USART_CR2_LINEN (1 << 14) /* LIN mode enable */
-/* USART_CR2[13:12]: STOP */
-#define USART_CR2_CLKEN (1 << 11) /* Clock enable */
-#define USART_CR2_CPOL (1 << 10) /* Clock polarity */
-#define USART_CR2_CPHA (1 << 9) /* Clock phase */
-#define USART_CR2_LBCL (1 << 8) /* Last bit clock pulse */
-#define USART_CR2_LBDIE (1 << 6) /* LIN break det. int. en. */
-#define USART_CR2_LBDL (1 << 5) /* LIN break det. length */
-/* USART_CR2[3:0]: ADD */
-
-/* STOP values */
+/* LINEN: LIN mode enable */
+#define USART_CR2_LINEN (1 << 14)
+
+/* STOP[13:12]: STOP bits */
#define USART_STOPBITS_1 0x00 /* 1 stop bit */
#define USART_STOPBITS_0_5 0x01 /* 0.5 stop bits */
#define USART_STOPBITS_2 0x02 /* 2 stop bits */
#define USART_STOPBITS_1_5 0x03 /* 1.5 stop bits */
+/* CLKEN: Clock enable */
+#define USART_CR2_CLKEN (1 << 11)
+
+/* CPOL: Clock polarity */
+#define USART_CR2_CPOL (1 << 10)
+
+/* CPHA: Clock phase */
+#define USART_CR2_CPHA (1 << 9)
+
+/* LBCL: Last bit clock pulse */
+#define USART_CR2_LBCL (1 << 8)
+
+/* LBDIE: LIN break detection interrupt enable */
+#define USART_CR2_LBDIE (1 << 6)
+
+/* LBDL: LIN break detection length */
+#define USART_CR2_LBDL (1 << 5)
+
+/* ADD[3:0]: Addres of the usart node */
+#define USART_CR2_ADD_MASK 0xF
+
/* --- USART_CR3 values ---------------------------------------------------- */
-#define USART_CR3_CTSIE (1 << 10) /* CTS interrupt enable */
-#define USART_CR3_CTSE (1 << 9) /* CTS enable */
-#define USART_CR3_RTSE (1 << 8) /* RTS enable */
-#define USART_CR3_DMAT (1 << 7) /* DMA enable transmitter */
-#define USART_CR3_DMAR (1 << 6) /* DMA enable receiver */
-#define USART_CR3_SCEN (1 << 5) /* Smartcard mode enable */
-#define USART_CR3_NACK (1 << 4) /* Smartcard NACK enable */
-#define USART_CR3_HDSEL (1 << 3) /* Half-duplex selection */
-#define USART_CR3_IRLP (1 << 2) /* IrDA low-power */
-#define USART_CR3_IREN (1 << 1) /* IrDA mode enable */
-#define USART_CR3_EIE (1 << 0) /* Error interrupt enable */
+/* CTSIE: CTS interrupt enable */
+/* Note: N/A on UART4 & UART5 */
+#define USART_CR3_CTSIE (1 << 10)
+
+/* CTSE: CTS enable */
+/* Note: N/A on UART4 & UART5 */
+#define USART_CR3_CTSE (1 << 9)
+
+/* RTSE: RTS enable */
+/* Note: N/A on UART4 & UART5 */
+#define USART_CR3_RTSE (1 << 8)
+
+/* DMAT: DMA enable transmitter */
+/* Note: N/A on UART5 */
+#define USART_CR3_DMAT (1 << 7)
+
+/* DMAR: DMA enable receiver */
+/* Note: N/A on UART5 */
+#define USART_CR3_DMAR (1 << 6)
+
+/* SCEN: Smartcard mode enable */
+/* Note: N/A on UART4 & UART5 */
+#define USART_CR3_SCEN (1 << 5)
+
+/* NACK: Smartcard NACK enable */
+/* Note: N/A on UART4 & UART5 */
+#define USART_CR3_NACK (1 << 4)
+
+/* HDSEL: Half-duplex selection */
+#define USART_CR3_HDSEL (1 << 3)
+
+/* IRLP: IrDA low-power */
+#define USART_CR3_IRLP (1 << 2)
+
+/* IREN: IrDA mode enable */
+#define USART_CR3_IREN (1 << 1)
+
+/* EIE: Error interrupt enable */
+#define USART_CR3_EIE (1 << 0)
/* CR3_CTSE/CR3_RTSE combined values */
#define USART_FLOWCONTROL_NONE 0x00
@@ -177,10 +269,15 @@
/* --- USART_GTPR values --------------------------------------------------- */
-/* USART_GTPR[15:8]: GT[7:0]: Guard time value */ /* N/A on UART4/5 */
-/* USART_GTPR[7:0]: PSC[7:0]: Prescaler value */ /* N/A on UART4/5 */
+/* GT[7:0]: Guard time value */
+/* Note: N/A on UART4 & UART5 */
+#define USART_GTPR_GT_MASK (0xFF << 8)
+
+/* PSC[7:0]: Prescaler value */
+/* Note: N/A on UART4/5 */
+#define USART_GTPR_PSC_MASK 0xFF
-/* TODO */
+/* TODO */ /* Note to Uwe: what needs to be done here? */
/* --- Function prototypes ------------------------------------------------- */
@@ -195,4 +292,4 @@ void usart_disable(u32 usart);
void usart_send(u32 usart, u16 data);
u16 usart_recv(u32 usart);
-#endif
+#endif /* LIBOPENSTM32_USART_H */