summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2018-12-03 17:41:04 +0800
committerGitHub <[email protected]>2018-12-03 17:41:04 +0800
commit9757f6b405e2f7e4df829b92ba0cdfd65ef3313d (patch)
treef26787dd79bdfa5c105ecade42937902dc6365e9 /bsp
parentefaac449d4740795032105c852f5581a9135273b (diff)
parent00f9958c38f8a7a4c6f1d644b16e571359a79303 (diff)
Merge pull request #2022 from whj4674672/master
[BSP]stm32f107 fix usart3
Diffstat (limited to 'bsp')
-rw-r--r--bsp/stm32f107/drivers/usart.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/bsp/stm32f107/drivers/usart.c b/bsp/stm32f107/drivers/usart.c
index 2ce119670f..c1bdd1b9be 100644
--- a/bsp/stm32f107/drivers/usart.c
+++ b/bsp/stm32f107/drivers/usart.c
@@ -59,19 +59,19 @@ static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_c
USART_InitStructure.USART_BaudRate = cfg->baud_rate;
- if (cfg->data_bits == DATA_BITS_8){
+ if (cfg->data_bits == DATA_BITS_8) {
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
} else if (cfg->data_bits == DATA_BITS_9) {
USART_InitStructure.USART_WordLength = USART_WordLength_9b;
}
- if (cfg->stop_bits == STOP_BITS_1){
+ if (cfg->stop_bits == STOP_BITS_1) {
USART_InitStructure.USART_StopBits = USART_StopBits_1;
- } else if (cfg->stop_bits == STOP_BITS_2){
+ } else if (cfg->stop_bits == STOP_BITS_2) {
USART_InitStructure.USART_StopBits = USART_StopBits_2;
}
- if (cfg->parity == PARITY_NONE){
+ if (cfg->parity == PARITY_NONE) {
USART_InitStructure.USART_Parity = USART_Parity_No;
} else if (cfg->parity == PARITY_ODD) {
USART_InitStructure.USART_Parity = USART_Parity_Odd;
@@ -271,9 +271,9 @@ void USART3_IRQHandler(void)
static void RCC_Configuration(void)
{
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
-#if defined(RT_USING_UART1)
+#if defined(RT_USING_UART1)
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
#endif /* RT_USING_UART1 */
@@ -293,8 +293,9 @@ static void RCC_Configuration(void)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
#endif /* RT_USING_UART2 */
-#if defined(RT_USING_UART3)
+#if defined(RT_USING_UART3)
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOC, ENABLE);
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE);
GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE);
#endif /* RT_USING_UART3 */
}
@@ -311,7 +312,7 @@ static void GPIO_Configuration(void)
GPIO_InitStructure.GPIO_Pin = UART1_GPIO_RX;
GPIO_Init(UART1_GPIO, &GPIO_InitStructure);
- /* Configure USART1 Tx (PA.09) as alternate function push-pull */
+ /* Configure USART1 Tx (PA.09) as alternate function push-pull */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Pin = UART1_GPIO_TX;
GPIO_Init(UART1_GPIO, &GPIO_InitStructure);
@@ -333,7 +334,7 @@ static void GPIO_Configuration(void)
GPIO_InitStructure.GPIO_Pin = UART3_GPIO_RX;
GPIO_Init(UART3_GPIO, &GPIO_InitStructure);
- /* Configure USART3 Tx (PC.10) as alternate function push-pull */
+ /* Configure USART3 Tx (PC.10) as alternate function push-pull */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Pin = UART3_GPIO_TX;
GPIO_Init(UART3_GPIO, &GPIO_InitStructure);