void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct)
typedef struct { uint32_t USART_BaudRate; uint16_t USART_WordLength; uint16_t USART_StopBits; uint16_t USART_Parity; uint16_t USART_HardwareFlowControl; uint16_t USART_Mode; } USART_InitTypeDef
IntegerDivider = ((APBClock) / (16 * (USART_InitStruct->USART_BaudRate))) FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5
USART_WordLength | 説明 |
USART_WordLength_8b | 8 bits Data |
USART_WordLength_9b | 9 bits Data |
USART_StopBits | 説明 |
USART_StopBits_1 | 1 stop bit is transmitted at the end of frame |
USART_StopBits_0_5 | 0.5 stop bit is transmitted at the end of frame |
USART_StopBits_2 2 | stop bits are transmitted at the end of frame |
USART_StopBits_1_5 | 1.5 stop bit is transmitted at the end of frame |
USART_Parity | 説明 |
USART_Parity_No | Parity Disable |
USART_Parity_Even | Even Parity |
USART_Parity_Odd | Odd Parity |
USART_HardwareFlowControl | 説明 |
USART_HardwareFlowControl_None HFC | Disabled |
USART_HardwareFlowControl_RTS RTS | enabled |
USART_HardwareFlowControl_CTS CTS | enabled |
USART_HardwareFlowControl_RTS_CTS | RTS and CTS enabled |
USART_Mode | 説明 |
USART_Mode_Tx | Transmit enabled |
USART_Mode_Rx | Receive enabled |
/* The following example illustrates how to configure the USART1 */ USART_InitTypeDef USART_InitStructure; USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_Odd; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS; USART_InitStructure.USART_Mode = USART_Mode_Tx I USART_Mode_Rx; USART_Init(USART1, &USART_InitStructure);