47 #define CR1_UE_Set ((uint16_t)0x2000)
48 #define CR1_UE_Reset ((uint16_t)0xDFFF)
50 #define CR1_WAKE_Mask ((uint16_t)0xF7FF)
52 #define CR1_RWU_Set ((uint16_t)0x0002)
53 #define CR1_RWU_Reset ((uint16_t)0xFFFD)
54 #define CR1_SBK_Set ((uint16_t)0x0001)
55 #define CR1_CLEAR_Mask ((uint16_t)0xE9F3)
56 #define CR2_Address_Mask ((uint16_t)0xFFF0)
58 #define CR2_LINEN_Set ((uint16_t)0x4000)
59 #define CR2_LINEN_Reset ((uint16_t)0xBFFF)
61 #define CR2_LBDL_Mask ((uint16_t)0xFFDF)
62 #define CR2_STOP_CLEAR_Mask ((uint16_t)0xCFFF)
63 #define CR2_CLOCK_CLEAR_Mask ((uint16_t)0xF0FF)
65 #define CR3_SCEN_Set ((uint16_t)0x0020)
66 #define CR3_SCEN_Reset ((uint16_t)0xFFDF)
68 #define CR3_NACK_Set ((uint16_t)0x0010)
69 #define CR3_NACK_Reset ((uint16_t)0xFFEF)
71 #define CR3_HDSEL_Set ((uint16_t)0x0008)
72 #define CR3_HDSEL_Reset ((uint16_t)0xFFF7)
74 #define CR3_IRLP_Mask ((uint16_t)0xFFFB)
75 #define CR3_CLEAR_Mask ((uint16_t)0xFCFF)
77 #define CR3_IREN_Set ((uint16_t)0x0002)
78 #define CR3_IREN_Reset ((uint16_t)0xFFFD)
79 #define GTPR_LSB_Mask ((uint16_t)0x00FF)
80 #define GTPR_MSB_Mask ((uint16_t)0xFF00)
81 #define IT_Mask ((uint16_t)0x001F)
84 #define CR1_OVER8_Set ((u16)0x8000)
85 #define CR1_OVER8_Reset ((u16)0x7FFF)
88 #define CR3_ONEBITE_Set ((u16)0x0800)
89 #define CR3_ONEBITE_Reset ((u16)0xF7FF)
140 else if (USARTx ==
USART2)
145 else if (USARTx ==
USART3)
150 else if (USARTx ==
UART4)
178 uint32_t tmpreg = 0x00, apbclock = 0x00;
179 uint32_t integerdivider = 0x00;
180 uint32_t fractionaldivider = 0x00;
181 uint32_t usartxbase = 0;
197 usartxbase = (uint32_t)USARTx;
200 tmpreg = USARTx->
CR2;
208 USARTx->
CR2 = (uint16_t)tmpreg;
211 tmpreg = USARTx->
CR1;
221 USARTx->
CR1 = (uint16_t)tmpreg;
224 tmpreg = USARTx->
CR3;
231 USARTx->
CR3 = (uint16_t)tmpreg;
249 integerdivider = ((25 * apbclock) / (2 * (USART_InitStruct->
USART_BaudRate)));
254 integerdivider = ((25 * apbclock) / (4 * (USART_InitStruct->
USART_BaudRate)));
256 tmpreg = (integerdivider / 100) << 4;
259 fractionaldivider = integerdivider - (100 * (tmpreg >> 4));
264 tmpreg |= ((((fractionaldivider * 8) + 50) / 100)) & ((uint8_t)0x07);
268 tmpreg |= ((((fractionaldivider * 16) + 50) / 100)) & ((uint8_t)0x0F);
272 USARTx->
BRR = (uint16_t)tmpreg;
304 uint32_t tmpreg = 0x00;
313 tmpreg = USARTx->
CR2;
324 USARTx->
CR2 = (uint16_t)tmpreg;
390 uint32_t usartreg = 0x00, itpos = 0x00, itmask = 0x00;
391 uint32_t usartxbase = 0x00;
402 usartxbase = (uint32_t)USARTx;
405 usartreg = (((uint8_t)USART_IT) >> 0x05);
409 itmask = (((uint32_t)0x01) << itpos);
411 if (usartreg == 0x01)
415 else if (usartreg == 0x02)
425 *(
__IO uint32_t*)usartxbase |= itmask;
429 *(
__IO uint32_t*)usartxbase &= ~itmask;
458 USARTx->
CR3 |= USART_DMAReq;
464 USARTx->
CR3 &= (uint16_t)~USART_DMAReq;
485 USARTx->
CR2 |= USART_Address;
506 USARTx->
CR1 |= USART_WakeUp;
554 USARTx->
CR2 |= USART_LINBreakDetectLength;
599 USARTx->
DR = (Data & (uint16_t)0x01FF);
615 return (uint16_t)(USARTx->
DR & (uint16_t)0x01FF);
649 USARTx->
GTPR |= (uint16_t)((uint16_t)USART_GuardTime << 0x08);
669 USARTx->
GTPR |= USART_Prescaler;
825 USARTx->
CR3 |= USART_IrDAMode;
886 if ((USARTx->
SR & USART_FLAG) != (uint16_t)
RESET)
934 USARTx->
SR = (uint16_t)~USART_FLAG;
958 uint32_t bitpos = 0x00, itmask = 0x00, usartreg = 0x00;
970 usartreg = (((uint8_t)USART_IT) >> 0x05);
973 itmask = (uint32_t)0x01 << itmask;
975 if (usartreg == 0x01)
977 itmask &= USARTx->
CR1;
979 else if (usartreg == 0x02)
981 itmask &= USARTx->
CR2;
985 itmask &= USARTx->
CR3;
988 bitpos = USART_IT >> 0x08;
989 bitpos = (uint32_t)0x01 << bitpos;
990 bitpos &= USARTx->
SR;
991 if ((itmask != (uint16_t)
RESET)&&(bitpos != (uint16_t)
RESET))
1032 uint16_t bitpos = 0x00, itmask = 0x00;
1042 bitpos = USART_IT >> 0x08;
1043 itmask = ((uint16_t)0x01 << (uint16_t)bitpos);
1044 USARTx->
SR = (uint16_t)~itmask;