Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
okll00
rt-thread
提交
c6be6441
R
rt-thread
项目概览
okll00
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c6be6441
编写于
12月 26, 2018
作者:
S
SummerGift
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][stm32] update stm32 mul-series drivers
上级
cb918152
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
191 addition
and
165 deletion
+191
-165
bsp/stm32/libraries/HAL_Drivers/drv_adc.c
bsp/stm32/libraries/HAL_Drivers/drv_adc.c
+7
-5
bsp/stm32/libraries/HAL_Drivers/drv_common.c
bsp/stm32/libraries/HAL_Drivers/drv_common.c
+10
-3
bsp/stm32/libraries/HAL_Drivers/drv_config.h
bsp/stm32/libraries/HAL_Drivers/drv_config.h
+9
-2
bsp/stm32/libraries/HAL_Drivers/drv_dma.h
bsp/stm32/libraries/HAL_Drivers/drv_dma.h
+1
-1
bsp/stm32/libraries/HAL_Drivers/drv_gpio.c
bsp/stm32/libraries/HAL_Drivers/drv_gpio.c
+55
-1
bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c
bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c
+25
-7
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
+11
-4
bsp/stm32/libraries/HAL_Drivers/drv_qspi.c
bsp/stm32/libraries/HAL_Drivers/drv_qspi.c
+19
-44
bsp/stm32/libraries/HAL_Drivers/drv_rtc.c
bsp/stm32/libraries/HAL_Drivers/drv_rtc.c
+5
-1
bsp/stm32/libraries/HAL_Drivers/drv_sdio.c
bsp/stm32/libraries/HAL_Drivers/drv_sdio.c
+0
-6
bsp/stm32/libraries/HAL_Drivers/drv_spi.c
bsp/stm32/libraries/HAL_Drivers/drv_spi.c
+8
-4
bsp/stm32/libraries/HAL_Drivers/drv_usart.c
bsp/stm32/libraries/HAL_Drivers/drv_usart.c
+31
-84
bsp/stm32/libraries/HAL_Drivers/drv_usart.h
bsp/stm32/libraries/HAL_Drivers/drv_usart.h
+9
-2
bsp/stm32/libraries/HAL_Drivers/drv_wdt.c
bsp/stm32/libraries/HAL_Drivers/drv_wdt.c
+1
-1
未找到文件。
bsp/stm32/libraries/HAL_Drivers/drv_adc.c
浏览文件 @
c6be6441
...
@@ -127,7 +127,7 @@ static rt_uint32_t stm32_adc_get_channel(rt_uint32_t channel)
...
@@ -127,7 +127,7 @@ static rt_uint32_t stm32_adc_get_channel(rt_uint32_t channel)
case
17
:
case
17
:
stm32_channel
=
ADC_CHANNEL_17
;
stm32_channel
=
ADC_CHANNEL_17
;
break
;
break
;
#if defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4)
#if defined(SOC_SERIES_STM32F
0) || defined(SOC_SERIES_STM32F
4) || defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4)
case
18
:
case
18
:
stm32_channel
=
ADC_CHANNEL_18
;
stm32_channel
=
ADC_CHANNEL_18
;
break
;
break
;
...
@@ -149,7 +149,7 @@ static rt_err_t stm32_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
...
@@ -149,7 +149,7 @@ static rt_err_t stm32_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
#if defined(SOC_SERIES_STM32F1)
#if defined(SOC_SERIES_STM32F1)
if
(
channel
<=
17
)
if
(
channel
<=
17
)
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32F
0) || defined(SOC_SERIES_STM32F
4) || defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4)
if
(
channel
<=
18
)
if
(
channel
<=
18
)
#endif
#endif
{
{
...
@@ -160,13 +160,15 @@ static rt_err_t stm32_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
...
@@ -160,13 +160,15 @@ static rt_err_t stm32_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
{
{
#if defined(SOC_SERIES_STM32F1)
#if defined(SOC_SERIES_STM32F1)
LOG_E
(
"ADC channel must be between 0 and 17."
);
LOG_E
(
"ADC channel must be between 0 and 17."
);
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32F
0) || defined(SOC_SERIES_STM32F
4) || defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4)
LOG_E
(
"ADC channel must be between 0 and 18."
);
LOG_E
(
"ADC channel must be between 0 and 18."
);
#endif
#endif
return
-
RT_ERROR
;
return
-
RT_ERROR
;
}
}
ADC_ChanConf
.
Rank
=
1
;
ADC_ChanConf
.
Rank
=
1
;
#if defined(SOC_SERIES_STM32F1)
#if defined(SOC_SERIES_STM32F0)
ADC_ChanConf
.
SamplingTime
=
ADC_SAMPLETIME_71CYCLES_5
;
#elif defined(SOC_SERIES_STM32F1)
ADC_ChanConf
.
SamplingTime
=
ADC_SAMPLETIME_55CYCLES_5
;
ADC_ChanConf
.
SamplingTime
=
ADC_SAMPLETIME_55CYCLES_5
;
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
ADC_ChanConf
.
SamplingTime
=
ADC_SAMPLETIME_112CYCLES
;
ADC_ChanConf
.
SamplingTime
=
ADC_SAMPLETIME_112CYCLES
;
...
@@ -186,7 +188,7 @@ static rt_err_t stm32_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
...
@@ -186,7 +188,7 @@ static rt_err_t stm32_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
HAL_ADC_Start
(
stm32_adc_handler
);
HAL_ADC_Start
(
stm32_adc_handler
);
/* Wait for the ADC to convert */
/* Wait for the ADC to convert */
HAL_ADC_PollForConversion
(
stm32_adc_handler
,
10
);
HAL_ADC_PollForConversion
(
stm32_adc_handler
,
10
0
);
/* get ADC value */
/* get ADC value */
*
value
=
(
rt_uint32_t
)
HAL_ADC_GetValue
(
stm32_adc_handler
);
*
value
=
(
rt_uint32_t
)
HAL_ADC_GetValue
(
stm32_adc_handler
);
...
...
bsp/stm32/libraries/HAL_Drivers/drv_common.c
浏览文件 @
c6be6441
...
@@ -95,6 +95,16 @@ void _Error_Handler(char *s, int num)
...
@@ -95,6 +95,16 @@ void _Error_Handler(char *s, int num)
*/
*/
RT_WEAK
void
rt_hw_board_init
()
RT_WEAK
void
rt_hw_board_init
()
{
{
#ifdef SCB_EnableICache
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache
();
#endif
#ifdef SCB_EnableDCache
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache
();
#endif
/* HAL_Init() function is called at the beginning of the program */
/* HAL_Init() function is called at the beginning of the program */
HAL_Init
();
HAL_Init
();
...
@@ -102,9 +112,6 @@ RT_WEAK void rt_hw_board_init()
...
@@ -102,9 +112,6 @@ RT_WEAK void rt_hw_board_init()
SystemClock_Config
();
SystemClock_Config
();
rt_hw_systick_init
();
rt_hw_systick_init
();
/* Hardware GPIO initialization */
MX_GPIO_Init
();
/* Heap initialization */
/* Heap initialization */
#if defined(RT_USING_HEAP)
#if defined(RT_USING_HEAP)
rt_system_heap_init
((
void
*
)
HEAP_BEGIN
,
(
void
*
)
HEAP_END
);
rt_system_heap_init
((
void
*
)
HEAP_BEGIN
,
(
void
*
)
HEAP_END
);
...
...
bsp/stm32/libraries/HAL_Drivers/drv_config.h
浏览文件 @
c6be6441
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
*
*
* Change Logs:
* Change Logs:
* Date Author Notes
* Date Author Notes
* 2018-10-30 SummerGift
change to new framework
* 2018-10-30 SummerGift
first version
*/
*/
#ifndef __DRV_CONFIG_H__
#ifndef __DRV_CONFIG_H__
...
@@ -14,7 +14,13 @@
...
@@ -14,7 +14,13 @@
#include <board.h>
#include <board.h>
#include <rtthread.h>
#include <rtthread.h>
#if defined(SOC_SERIES_STM32F1)
#if defined(SOC_SERIES_STM32F0)
#include "f0/uart_config.h"
#include "f0/spi_config.h"
#include "f0/tim_config.h"
#include "f0/pwm_config.h"
#include "f0/adc_config.h"
#elif defined(SOC_SERIES_STM32F1)
#include "f1/uart_config.h"
#include "f1/uart_config.h"
#include "f1/spi_config.h"
#include "f1/spi_config.h"
#include "f1/adc_config.h"
#include "f1/adc_config.h"
...
@@ -38,6 +44,7 @@
...
@@ -38,6 +44,7 @@
#elif defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32L4)
#include "l4/uart_config.h"
#include "l4/uart_config.h"
#include "l4/spi_config.h"
#include "l4/spi_config.h"
#include "l4/qspi_config.h"
#include "l4/adc_config.h"
#include "l4/adc_config.h"
#include "l4/tim_config.h"
#include "l4/tim_config.h"
#include "l4/pwm_config.h"
#include "l4/pwm_config.h"
...
...
bsp/stm32/libraries/HAL_Drivers/drv_dma.h
浏览文件 @
c6be6441
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#include <rthw.h>
#include <rthw.h>
#include <drv_common.h>
#include <drv_common.h>
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4)
#if defined(SOC_SERIES_STM32F
0) || (SOC_SERIES_STM32F
1) || defined(SOC_SERIES_STM32L4)
#define DMA_INSTANCE_TYPE DMA_Channel_TypeDef
#define DMA_INSTANCE_TYPE DMA_Channel_TypeDef
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
#define DMA_INSTANCE_TYPE DMA_Stream_TypeDef
#define DMA_INSTANCE_TYPE DMA_Stream_TypeDef
...
...
bsp/stm32/libraries/HAL_Drivers/drv_gpio.c
浏览文件 @
c6be6441
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
*
*
* Change Logs:
* Change Logs:
* Date Author Notes
* Date Author Notes
* 2018-11-06 balanceTWK
change to new framework
* 2018-11-06 balanceTWK
first version
*/
*/
#include <board.h>
#include <board.h>
...
@@ -217,6 +217,24 @@ static const struct pin_index pins[] =
...
@@ -217,6 +217,24 @@ static const struct pin_index pins[] =
static
const
struct
pin_irq_map
pin_irq_map
[]
=
static
const
struct
pin_irq_map
pin_irq_map
[]
=
{
{
#if defined(SOC_SERIES_STM32F0)
{
GPIO_PIN_0
,
EXTI0_1_IRQn
},
{
GPIO_PIN_1
,
EXTI0_1_IRQn
},
{
GPIO_PIN_2
,
EXTI2_3_IRQn
},
{
GPIO_PIN_3
,
EXTI2_3_IRQn
},
{
GPIO_PIN_4
,
EXTI4_15_IRQn
},
{
GPIO_PIN_5
,
EXTI4_15_IRQn
},
{
GPIO_PIN_6
,
EXTI4_15_IRQn
},
{
GPIO_PIN_7
,
EXTI4_15_IRQn
},
{
GPIO_PIN_8
,
EXTI4_15_IRQn
},
{
GPIO_PIN_9
,
EXTI4_15_IRQn
},
{
GPIO_PIN_10
,
EXTI4_15_IRQn
},
{
GPIO_PIN_11
,
EXTI4_15_IRQn
},
{
GPIO_PIN_12
,
EXTI4_15_IRQn
},
{
GPIO_PIN_13
,
EXTI4_15_IRQn
},
{
GPIO_PIN_14
,
EXTI4_15_IRQn
},
{
GPIO_PIN_15
,
EXTI4_15_IRQn
},
#else
{
GPIO_PIN_0
,
EXTI0_IRQn
},
{
GPIO_PIN_0
,
EXTI0_IRQn
},
{
GPIO_PIN_1
,
EXTI1_IRQn
},
{
GPIO_PIN_1
,
EXTI1_IRQn
},
{
GPIO_PIN_2
,
EXTI2_IRQn
},
{
GPIO_PIN_2
,
EXTI2_IRQn
},
...
@@ -233,6 +251,7 @@ static const struct pin_irq_map pin_irq_map[] =
...
@@ -233,6 +251,7 @@ static const struct pin_irq_map pin_irq_map[] =
{
GPIO_PIN_13
,
EXTI15_10_IRQn
},
{
GPIO_PIN_13
,
EXTI15_10_IRQn
},
{
GPIO_PIN_14
,
EXTI15_10_IRQn
},
{
GPIO_PIN_14
,
EXTI15_10_IRQn
},
{
GPIO_PIN_15
,
EXTI15_10_IRQn
},
{
GPIO_PIN_15
,
EXTI15_10_IRQn
},
#endif
};
};
static
struct
rt_pin_irq_hdr
pin_irq_hdr_tab
[]
=
static
struct
rt_pin_irq_hdr
pin_irq_hdr_tab
[]
=
...
@@ -608,6 +627,41 @@ void EXTI15_10_IRQHandler(void)
...
@@ -608,6 +627,41 @@ void EXTI15_10_IRQHandler(void)
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
void
EXTI0_1_IRQHandler
(
void
)
{
rt_interrupt_enter
();
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_0
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_1
);
rt_interrupt_leave
();
}
void
EXTI2_3_IRQHandler
(
void
)
{
rt_interrupt_enter
();
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_2
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_3
);
rt_interrupt_leave
();
}
void
EXTI4_15_IRQHandler
(
void
)
{
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_0
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_1
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_2
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_3
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_4
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_5
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_6
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_7
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_8
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_9
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_10
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_11
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_12
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_13
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_14
);
HAL_GPIO_EXTI_IRQHandler
(
GPIO_PIN_15
);
}
int
rt_hw_pin_init
(
void
)
int
rt_hw_pin_init
(
void
)
{
{
#if defined(__HAL_RCC_GPIOA_CLK_ENABLE)
#if defined(__HAL_RCC_GPIOA_CLK_ENABLE)
...
...
bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c
浏览文件 @
c6be6441
...
@@ -168,11 +168,13 @@ static void timer_init(struct rt_hwtimer_device *timer, rt_uint32_t state)
...
@@ -168,11 +168,13 @@ static void timer_init(struct rt_hwtimer_device *timer, rt_uint32_t state)
if
(
tim
->
Instance
==
TIM9
||
tim
->
Instance
==
TIM10
||
tim
->
Instance
==
TIM11
)
if
(
tim
->
Instance
==
TIM9
||
tim
->
Instance
==
TIM10
||
tim
->
Instance
==
TIM11
)
#elif defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32L4)
if
(
tim
->
Instance
==
TIM15
||
tim
->
Instance
==
TIM16
||
tim
->
Instance
==
TIM17
)
if
(
tim
->
Instance
==
TIM15
||
tim
->
Instance
==
TIM16
||
tim
->
Instance
==
TIM17
)
#elif defined(SOC_SERIES_STM32F1)
#elif defined(SOC_SERIES_STM32F1)
|| defined(SOC_SERIES_STM32F0)
if
(
0
)
if
(
0
)
#endif
#endif
{
{
#ifndef SOC_SERIES_STM32F0
prescaler_value
=
(
uint32_t
)(
HAL_RCC_GetPCLK2Freq
()
*
2
/
10000
)
-
1
;
prescaler_value
=
(
uint32_t
)(
HAL_RCC_GetPCLK2Freq
()
*
2
/
10000
)
-
1
;
#endif
}
}
else
else
{
{
...
@@ -190,7 +192,7 @@ static void timer_init(struct rt_hwtimer_device *timer, rt_uint32_t state)
...
@@ -190,7 +192,7 @@ static void timer_init(struct rt_hwtimer_device *timer, rt_uint32_t state)
tim
->
Init
.
CounterMode
=
TIM_COUNTERMODE_DOWN
;
tim
->
Init
.
CounterMode
=
TIM_COUNTERMODE_DOWN
;
}
}
tim
->
Init
.
RepetitionCounter
=
0
;
tim
->
Init
.
RepetitionCounter
=
0
;
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4)
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4)
|| defined(SOC_SERIES_STM32F0)
tim
->
Init
.
AutoReloadPreload
=
TIM_AUTORELOAD_PRELOAD_DISABLE
;
tim
->
Init
.
AutoReloadPreload
=
TIM_AUTORELOAD_PRELOAD_DISABLE
;
#endif
#endif
if
(
HAL_TIM_Base_Init
(
tim
)
!=
HAL_OK
)
if
(
HAL_TIM_Base_Init
(
tim
)
!=
HAL_OK
)
...
@@ -280,19 +282,23 @@ static rt_err_t timer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg)
...
@@ -280,19 +282,23 @@ static rt_err_t timer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg)
if
(
tim
->
Instance
==
TIM9
||
tim
->
Instance
==
TIM10
||
tim
->
Instance
==
TIM11
)
if
(
tim
->
Instance
==
TIM9
||
tim
->
Instance
==
TIM10
||
tim
->
Instance
==
TIM11
)
#elif defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32L4)
if
(
tim
->
Instance
==
TIM15
||
tim
->
Instance
==
TIM16
||
tim
->
Instance
==
TIM17
)
if
(
tim
->
Instance
==
TIM15
||
tim
->
Instance
==
TIM16
||
tim
->
Instance
==
TIM17
)
#elif defined(SOC_SERIES_STM32F1)
#elif defined(SOC_SERIES_STM32F1)
|| defined(SOC_SERIES_STM32F0)
if
(
0
)
if
(
0
)
#endif
#endif
{
{
#if defined(SOC_SERIES_STM32L4)
#if defined(SOC_SERIES_STM32L4)
val
=
HAL_RCC_GetPCLK2Freq
()
/
freq
;
val
=
HAL_RCC_GetPCLK2Freq
()
/
freq
;
#el
se
#el
if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32F4)
val
=
HAL_RCC_GetPCLK2Freq
()
*
2
/
freq
;
val
=
HAL_RCC_GetPCLK2Freq
()
*
2
/
freq
;
#endif
#endif
}
}
else
else
{
{
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32F4)
val
=
HAL_RCC_GetPCLK1Freq
()
*
2
/
freq
;
val
=
HAL_RCC_GetPCLK1Freq
()
*
2
/
freq
;
#elif defined(SOC_SERIES_STM32F0)
val
=
HAL_RCC_GetPCLK1Freq
()
/
freq
;
#endif
}
}
__HAL_TIM_SET_PRESCALER
(
tim
,
val
-
1
);
__HAL_TIM_SET_PRESCALER
(
tim
,
val
-
1
);
...
@@ -393,7 +399,11 @@ void TIM8_UP_TIM13_IRQHandler(void)
...
@@ -393,7 +399,11 @@ void TIM8_UP_TIM13_IRQHandler(void)
}
}
#endif
#endif
#ifdef BSP_USING_TIM14
#ifdef BSP_USING_TIM14
void
TIM8_TRG_COM_TIM14_IRQHandler
(
void
)
#if defined(SOC_SERIES_STM32F4)
void
TIM8_TRG_COM_TIM14_IRQHandler
(
void
)
#elif defined(SOC_SERIES_STM32F0)
void
TIM14_IRQHandler
(
void
)
#endif
{
{
/* enter interrupt */
/* enter interrupt */
rt_interrupt_enter
();
rt_interrupt_enter
();
...
@@ -413,7 +423,11 @@ void TIM1_BRK_TIM15_IRQHandler(void)
...
@@ -413,7 +423,11 @@ void TIM1_BRK_TIM15_IRQHandler(void)
}
}
#endif
#endif
#ifdef BSP_USING_TIM16
#ifdef BSP_USING_TIM16
void
TIM1_UP_TIM16_IRQHandler
(
void
)
#if defined(SOC_SERIES_STM32L4)
void
TIM1_UP_TIM16_IRQHandler
(
void
)
#elif defined(SOC_SERIES_STM32F0)
void
TIM16_IRQHandler
(
void
)
#endif
{
{
/* enter interrupt */
/* enter interrupt */
rt_interrupt_enter
();
rt_interrupt_enter
();
...
@@ -423,7 +437,11 @@ void TIM1_UP_TIM16_IRQHandler(void)
...
@@ -423,7 +437,11 @@ void TIM1_UP_TIM16_IRQHandler(void)
}
}
#endif
#endif
#ifdef BSP_USING_TIM17
#ifdef BSP_USING_TIM17
void
TIM1_TRG_COM_TIM17_IRQHandler
(
void
)
#if defined(SOC_SERIES_STM32L4)
void
TIM1_TRG_COM_TIM17_IRQHandler
(
void
)
#elif defined(SOC_SERIES_STM32F0)
void
TIM17_IRQHandler
(
void
)
#endif
{
{
/* enter interrupt */
/* enter interrupt */
rt_interrupt_enter
();
rt_interrupt_enter
();
...
...
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
浏览文件 @
c6be6441
...
@@ -189,15 +189,17 @@ static rt_err_t drv_pwm_get(TIM_HandleTypeDef *htim, struct rt_pwm_configuration
...
@@ -189,15 +189,17 @@ static rt_err_t drv_pwm_get(TIM_HandleTypeDef *htim, struct rt_pwm_configuration
if
(
htim
->
Instance
==
TIM9
||
htim
->
Instance
==
TIM10
||
htim
->
Instance
==
TIM11
)
if
(
htim
->
Instance
==
TIM9
||
htim
->
Instance
==
TIM10
||
htim
->
Instance
==
TIM11
)
#elif defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32L4)
if
(
htim
->
Instance
==
TIM15
||
htim
->
Instance
==
TIM16
||
htim
->
Instance
==
TIM17
)
if
(
htim
->
Instance
==
TIM15
||
htim
->
Instance
==
TIM16
||
htim
->
Instance
==
TIM17
)
#elif defined(SOC_SERIES_STM32F1)
#elif defined(SOC_SERIES_STM32F1)
|| defined(SOC_SERIES_STM32F0)
if
(
0
)
if
(
0
)
#endif
#endif
{
{
#ifndef SOC_SERIES_STM32F0
tim_clock
=
HAL_RCC_GetPCLK2Freq
()
*
2
;
tim_clock
=
HAL_RCC_GetPCLK2Freq
()
*
2
;
#endif
}
}
else
else
{
{
#if defined(SOC_SERIES_STM32L4)
#if defined(SOC_SERIES_STM32L4)
|| defined(SOC_SERIES_STM32F0)
tim_clock
=
HAL_RCC_GetPCLK1Freq
();
tim_clock
=
HAL_RCC_GetPCLK1Freq
();
#else
#else
tim_clock
=
HAL_RCC_GetPCLK1Freq
()
*
2
;
tim_clock
=
HAL_RCC_GetPCLK1Freq
()
*
2
;
...
@@ -232,15 +234,17 @@ static rt_err_t drv_pwm_set(TIM_HandleTypeDef *htim, struct rt_pwm_configuration
...
@@ -232,15 +234,17 @@ static rt_err_t drv_pwm_set(TIM_HandleTypeDef *htim, struct rt_pwm_configuration
if
(
htim
->
Instance
==
TIM9
||
htim
->
Instance
==
TIM10
||
htim
->
Instance
==
TIM11
)
if
(
htim
->
Instance
==
TIM9
||
htim
->
Instance
==
TIM10
||
htim
->
Instance
==
TIM11
)
#elif defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32L4)
if
(
htim
->
Instance
==
TIM15
||
htim
->
Instance
==
TIM16
||
htim
->
Instance
==
TIM17
)
if
(
htim
->
Instance
==
TIM15
||
htim
->
Instance
==
TIM16
||
htim
->
Instance
==
TIM17
)
#elif defined(SOC_SERIES_STM32F1)
#elif defined(SOC_SERIES_STM32F1)
|| defined(SOC_SERIES_STM32F0)
if
(
0
)
if
(
0
)
#endif
#endif
{
{
#ifndef SOC_SERIES_STM32F0
tim_clock
=
HAL_RCC_GetPCLK2Freq
()
*
2
;
tim_clock
=
HAL_RCC_GetPCLK2Freq
()
*
2
;
#endif
}
}
else
else
{
{
#if defined(SOC_SERIES_STM32L4)
#if defined(SOC_SERIES_STM32L4)
|| defined(SOC_SERIES_STM32F0)
tim_clock
=
HAL_RCC_GetPCLK1Freq
();
tim_clock
=
HAL_RCC_GetPCLK1Freq
();
#else
#else
tim_clock
=
HAL_RCC_GetPCLK1Freq
()
*
2
;
tim_clock
=
HAL_RCC_GetPCLK1Freq
()
*
2
;
...
@@ -407,6 +411,9 @@ __exit:
...
@@ -407,6 +411,9 @@ __exit:
static
void
pwm_get_channel
(
void
)
static
void
pwm_get_channel
(
void
)
{
{
#ifdef BSP_USING_PWM2_CH1
stm32_pwm_obj
[
PWM2_INDEX
].
channel
|=
1
<<
0
;
#endif
#ifdef BSP_USING_PWM2_CH4
#ifdef BSP_USING_PWM2_CH4
stm32_pwm_obj
[
PWM2_INDEX
].
channel
|=
1
<<
3
;
stm32_pwm_obj
[
PWM2_INDEX
].
channel
|=
1
<<
3
;
#endif
#endif
...
...
bsp/stm32/libraries/HAL_Drivers/drv_qspi.c
浏览文件 @
c6be6441
...
@@ -5,8 +5,7 @@
...
@@ -5,8 +5,7 @@
*
*
* Change Logs:
* Change Logs:
* Date Author Notes
* Date Author Notes
* 2018-11-27 zylx change to new framework
* 2018-11-27 zylx first version
* 2018-12-12 greedyhao Porting for stm32f7xx
*/
*/
#include "board.h"
#include "board.h"
...
@@ -21,14 +20,6 @@
...
@@ -21,14 +20,6 @@
#if defined(BSP_USING_QSPI)
#if defined(BSP_USING_QSPI)
#if defined (SOC_SERIES_STM32L4)
#define QUADSPI_DMA_IRQ DMA1_Channel5_IRQn
#define QUADSPI_DMA_IRQHandler DMA1_Channel5_IRQHandler
#elif defined (SOC_SERIES_STM32F7)
#define QUADSPI_DMA_IRQ DMA2_Stream2_IRQn
#define QUADSPI_DMA_IRQHandler DMA2_Stream2_IRQHandler
#endif
/* SOC_SERIES_STM32L4 */
struct
stm32_hw_spi_cs
struct
stm32_hw_spi_cs
{
{
uint16_t
Pin
;
uint16_t
Pin
;
...
@@ -58,6 +49,9 @@ static int stm32_qspi_init(struct rt_qspi_device *device, struct rt_qspi_configu
...
@@ -58,6 +49,9 @@ static int stm32_qspi_init(struct rt_qspi_device *device, struct rt_qspi_configu
struct
stm32_qspi_bus
*
qspi_bus
=
device
->
parent
.
bus
->
parent
.
user_data
;
struct
stm32_qspi_bus
*
qspi_bus
=
device
->
parent
.
bus
->
parent
.
user_data
;
rt_memset
(
&
qspi_bus
->
QSPI_Handler
,
0
,
sizeof
(
qspi_bus
->
QSPI_Handler
));
rt_memset
(
&
qspi_bus
->
QSPI_Handler
,
0
,
sizeof
(
qspi_bus
->
QSPI_Handler
));
QSPI_HandleTypeDef
QSPI_Handler_config
=
QSPI_BUS_CONFIG
;
qspi_bus
->
QSPI_Handler
=
QSPI_Handler_config
;
while
(
cfg
->
max_hz
<
HAL_RCC_GetHCLKFreq
()
/
(
i
+
1
))
while
(
cfg
->
max_hz
<
HAL_RCC_GetHCLKFreq
()
/
(
i
+
1
))
{
{
i
++
;
i
++
;
...
@@ -84,14 +78,6 @@ static int stm32_qspi_init(struct rt_qspi_device *device, struct rt_qspi_configu
...
@@ -84,14 +78,6 @@ static int stm32_qspi_init(struct rt_qspi_device *device, struct rt_qspi_configu
/* flash size */
/* flash size */
qspi_bus
->
QSPI_Handler
.
Init
.
FlashSize
=
POSITION_VAL
(
qspi_cfg
->
medium_size
)
-
1
;
qspi_bus
->
QSPI_Handler
.
Init
.
FlashSize
=
POSITION_VAL
(
qspi_cfg
->
medium_size
)
-
1
;
qspi_bus
->
QSPI_Handler
.
Instance
=
QUADSPI
;
/* fifo threshold is 4 byte */
qspi_bus
->
QSPI_Handler
.
Init
.
FifoThreshold
=
4
;
/* Sampling shift half a cycle */
qspi_bus
->
QSPI_Handler
.
Init
.
SampleShifting
=
QSPI_SAMPLE_SHIFTING_HALFCYCLE
;
/* cs high time */
qspi_bus
->
QSPI_Handler
.
Init
.
ChipSelectHighTime
=
QSPI_CS_HIGH_TIME_4_CYCLE
;
result
=
HAL_QSPI_Init
(
&
qspi_bus
->
QSPI_Handler
);
result
=
HAL_QSPI_Init
(
&
qspi_bus
->
QSPI_Handler
);
if
(
result
==
HAL_OK
)
if
(
result
==
HAL_OK
)
{
{
...
@@ -104,34 +90,23 @@ static int stm32_qspi_init(struct rt_qspi_device *device, struct rt_qspi_configu
...
@@ -104,34 +90,23 @@ static int stm32_qspi_init(struct rt_qspi_device *device, struct rt_qspi_configu
#ifdef BSP_QSPI_USING_DMA
#ifdef BSP_QSPI_USING_DMA
/* QSPI interrupts must be enabled when using the HAL_QSPI_Receive_DMA */
/* QSPI interrupts must be enabled when using the HAL_QSPI_Receive_DMA */
HAL_NVIC_SetPriority
(
Q
UAD
SPI_IRQn
,
0
,
0
);
HAL_NVIC_SetPriority
(
QSPI_IRQn
,
0
,
0
);
HAL_NVIC_EnableIRQ
(
Q
UAD
SPI_IRQn
);
HAL_NVIC_EnableIRQ
(
QSPI_IRQn
);
HAL_NVIC_SetPriority
(
Q
UADSPI_DMA_IRQ
,
0
,
0
);
HAL_NVIC_SetPriority
(
Q
SPI_DMA_IRQn
,
0
,
0
);
HAL_NVIC_EnableIRQ
(
Q
UADSPI_DMA_IRQ
);
HAL_NVIC_EnableIRQ
(
Q
SPI_DMA_IRQn
);
/* init QSPI DMA */
/* init QSPI DMA */
__HAL_RCC_DMA1_CLK_ENABLE
()
;
QSPI_DMA_CLK_ENABLE
;
HAL_DMA_DeInit
(
qspi_bus
->
QSPI_Handler
.
hdma
);
HAL_DMA_DeInit
(
qspi_bus
->
QSPI_Handler
.
hdma
);
#if defined(SOC_SERIES_STM32F4)
DMA_HandleTypeDef
hdma_quadspi_config
=
QSPI_DMA_CONFIG
;
qspi_bus
->
hdma_quadspi
.
Instance
=
DMA1_Channel5
;
qspi_bus
->
hdma_quadspi
=
hdma_quadspi_config
;
qspi_bus
->
hdma_quadspi
.
Init
.
Request
=
DMA_REQUEST_5
;
#elif defined(SOC_SERIES_STM32F7)
qspi_bus
->
hdma_quadspi
.
Instance
=
DMA2_Stream2
;
qspi_bus
->
hdma_quadspi
.
Init
.
channel
=
DMA_CHANNEL_11
;
#endif
qspi_bus
->
hdma_quadspi
.
Init
.
Direction
=
DMA_PERIPH_TO_MEMORY
;
qspi_bus
->
hdma_quadspi
.
Init
.
PeriphInc
=
DMA_PINC_DISABLE
;
qspi_bus
->
hdma_quadspi
.
Init
.
MemInc
=
DMA_MINC_ENABLE
;
qspi_bus
->
hdma_quadspi
.
Init
.
PeriphDataAlignment
=
DMA_PDATAALIGN_BYTE
;
qspi_bus
->
hdma_quadspi
.
Init
.
MemDataAlignment
=
DMA_MDATAALIGN_BYTE
;
qspi_bus
->
hdma_quadspi
.
Init
.
Mode
=
DMA_NORMAL
;
qspi_bus
->
hdma_quadspi
.
Init
.
Priority
=
DMA_PRIORITY_LOW
;
if
(
HAL_DMA_Init
(
&
qspi_bus
->
hdma_quadspi
)
!=
HAL_OK
)
if
(
HAL_DMA_Init
(
&
qspi_bus
->
hdma_quadspi
)
!=
HAL_OK
)
{
{
LOG_E
(
"qspi dma init failed (%d)!"
,
result
);
LOG_E
(
"qspi dma init failed (%d)!"
,
result
);
}
}
__HAL_LINKDMA
(
&
qspi_bus
->
QSPI_Handler
,
hdma
,
qspi_bus
->
hdma_quadspi
);
__HAL_LINKDMA
(
&
qspi_bus
->
QSPI_Handler
,
hdma
,
qspi_bus
->
hdma_quadspi
);
#endif
/* BSP_QSPI_USING_DMA */
#endif
/* BSP_QSPI_USING_DMA */
return
result
;
return
result
;
...
@@ -269,8 +244,8 @@ static rt_uint32_t qspixfer(struct rt_spi_device *device, struct rt_spi_message
...
@@ -269,8 +244,8 @@ static rt_uint32_t qspixfer(struct rt_spi_device *device, struct rt_spi_message
#endif
#endif
{
{
len
=
length
;
len
=
length
;
#ifdef BSP_QSPI_USING_DMA
#ifdef BSP_QSPI_USING_DMA
while
(
qspi_bus
->
QSPI_Handler
.
RxXferCount
!=
0
);
while
(
qspi_bus
->
QSPI_Handler
.
RxXferCount
!=
0
);
#endif
#endif
}
}
else
else
...
@@ -380,7 +355,7 @@ __exit:
...
@@ -380,7 +355,7 @@ __exit:
}
}
#ifdef BSP_QSPI_USING_DMA
#ifdef BSP_QSPI_USING_DMA
void
Q
UAD
SPI_IRQHandler
(
void
)
void
QSPI_IRQHandler
(
void
)
{
{
/* enter interrupt */
/* enter interrupt */
rt_interrupt_enter
();
rt_interrupt_enter
();
...
@@ -391,7 +366,7 @@ void QUADSPI_IRQHandler(void)
...
@@ -391,7 +366,7 @@ void QUADSPI_IRQHandler(void)
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
void
Q
UAD
SPI_DMA_IRQHandler
(
void
)
void
QSPI_DMA_IRQHandler
(
void
)
{
{
/* enter interrupt */
/* enter interrupt */
rt_interrupt_enter
();
rt_interrupt_enter
();
...
...
bsp/stm32/libraries/HAL_Drivers/drv_rtc.c
浏览文件 @
c6be6441
...
@@ -110,9 +110,13 @@ static rt_err_t rt_rtc_config(struct rt_device *dev)
...
@@ -110,9 +110,13 @@ static rt_err_t rt_rtc_config(struct rt_device *dev)
#if defined(SOC_SERIES_STM32F1)
#if defined(SOC_SERIES_STM32F1)
RTC_Handler
.
Init
.
OutPut
=
RTC_OUTPUTSOURCE_NONE
;
RTC_Handler
.
Init
.
OutPut
=
RTC_OUTPUTSOURCE_NONE
;
RTC_Handler
.
Init
.
AsynchPrediv
=
RTC_AUTO_1_SECOND
;
RTC_Handler
.
Init
.
AsynchPrediv
=
RTC_AUTO_1_SECOND
;
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32F
0) || defined(SOC_SERIES_STM32F
4) || defined(SOC_SERIES_STM32L4)
RTC_Handler
.
Init
.
AsynchPrediv
=
0X7F
;
RTC_Handler
.
Init
.
AsynchPrediv
=
0X7F
;
#ifndef SOC_SERIES_STM32F0
RTC_Handler
.
Init
.
SynchPrediv
=
0XFF
;
RTC_Handler
.
Init
.
SynchPrediv
=
0XFF
;
#else
RTC_Handler
.
Init
.
SynchPrediv
=
0x0130
;
#endif
RTC_Handler
.
Init
.
HourFormat
=
RTC_HOURFORMAT_24
;
RTC_Handler
.
Init
.
HourFormat
=
RTC_HOURFORMAT_24
;
RTC_Handler
.
Init
.
OutPut
=
RTC_OUTPUT_DISABLE
;
RTC_Handler
.
Init
.
OutPut
=
RTC_OUTPUT_DISABLE
;
RTC_Handler
.
Init
.
OutPutPolarity
=
RTC_OUTPUT_POLARITY_HIGH
;
RTC_Handler
.
Init
.
OutPutPolarity
=
RTC_OUTPUT_POLARITY_HIGH
;
...
...
bsp/stm32/libraries/HAL_Drivers/drv_sdio.c
浏览文件 @
c6be6441
...
@@ -19,12 +19,6 @@
...
@@ -19,12 +19,6 @@
#define LOG_TAG "drv.sdio"
#define LOG_TAG "drv.sdio"
#include <drv_log.h>
#include <drv_log.h>
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32F4)
#define SDCARD_INSTANCE SDIO
#elif defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7)
#define SDCARD_INSTANCE SDMMC1
#endif
/* defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32F4) */
static
struct
stm32_sdio_config
sdio_config
=
SDIO_BUS_CONFIG
;
static
struct
stm32_sdio_config
sdio_config
=
SDIO_BUS_CONFIG
;
static
struct
stm32_sdio_class
sdio_obj
;
static
struct
stm32_sdio_class
sdio_obj
;
static
struct
rt_mmcsd_host
*
host
;
static
struct
rt_mmcsd_host
*
host
;
...
...
bsp/stm32/libraries/HAL_Drivers/drv_spi.c
浏览文件 @
c6be6441
...
@@ -143,7 +143,11 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
...
@@ -143,7 +143,11 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
uint32_t
SPI_APB_CLOCK
;
uint32_t
SPI_APB_CLOCK
;
#ifdef SOC_SERIES_STM32F0
SPI_APB_CLOCK
=
HAL_RCC_GetPCLK1Freq
();
#else
SPI_APB_CLOCK
=
HAL_RCC_GetPCLK2Freq
();
SPI_APB_CLOCK
=
HAL_RCC_GetPCLK2Freq
();
#endif
if
(
cfg
->
max_hz
>=
SPI_APB_CLOCK
/
2
)
if
(
cfg
->
max_hz
>=
SPI_APB_CLOCK
/
2
)
{
{
...
@@ -202,7 +206,7 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
...
@@ -202,7 +206,7 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
return
RT_EIO
;
return
RT_EIO
;
}
}
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7)
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F
0)|| defined(SOC_SERIES_STM32F
7)
SET_BIT
(
spi_handle
->
Instance
->
CR2
,
SPI_RXFIFO_THRESHOLD_HF
);
SET_BIT
(
spi_handle
->
Instance
->
CR2
,
SPI_RXFIFO_THRESHOLD_HF
);
#endif
#endif
...
@@ -356,7 +360,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
...
@@ -356,7 +360,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
*
(
volatile
rt_uint8_t
*
)(
&
spi_handle
->
Instance
->
DR
)
=
data
;
*
(
volatile
rt_uint8_t
*
)(
&
spi_handle
->
Instance
->
DR
)
=
data
;
/* receive data once */
/* receive data once */
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7)
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F
0) || defined(SOC_SERIES_STM32F
7)
SET_BIT
(
spi_handle
->
Instance
->
CR2
,
SPI_RXFIFO_THRESHOLD_HF
);
SET_BIT
(
spi_handle
->
Instance
->
CR2
,
SPI_RXFIFO_THRESHOLD_HF
);
#endif
#endif
while
(
__HAL_SPI_GET_FLAG
(
spi_handle
,
SPI_FLAG_RXNE
)
==
RESET
);
while
(
__HAL_SPI_GET_FLAG
(
spi_handle
,
SPI_FLAG_RXNE
)
==
RESET
);
...
@@ -387,7 +391,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
...
@@ -387,7 +391,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
*
(
volatile
rt_uint16_t
*
)(
&
spi_handle
->
Instance
->
DR
)
=
data
;
*
(
volatile
rt_uint16_t
*
)(
&
spi_handle
->
Instance
->
DR
)
=
data
;
/* receive data once */
/* receive data once */
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7)
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F
0) || defined(SOC_SERIES_STM32F
7)
SET_BIT
(
spi_handle
->
Instance
->
CR2
,
SPI_RXFIFO_THRESHOLD_HF
);
SET_BIT
(
spi_handle
->
Instance
->
CR2
,
SPI_RXFIFO_THRESHOLD_HF
);
#endif
#endif
while
(
__HAL_SPI_GET_FLAG
(
spi_handle
,
SPI_FLAG_RXNE
)
==
RESET
);
while
(
__HAL_SPI_GET_FLAG
(
spi_handle
,
SPI_FLAG_RXNE
)
==
RESET
);
...
@@ -757,5 +761,5 @@ int rt_hw_spi_init(void)
...
@@ -757,5 +761,5 @@ int rt_hw_spi_init(void)
}
}
INIT_BOARD_EXPORT
(
rt_hw_spi_init
);
INIT_BOARD_EXPORT
(
rt_hw_spi_init
);
#endif
/* BSP_USING_SPI1 || BSP_USING_SPI2 || BSP_USING_SPI3 || BSP_USING_SPI4 || BSP_USING_SPI5
|| BSP_USING_SPI6
*/
#endif
/* BSP_USING_SPI1 || BSP_USING_SPI2 || BSP_USING_SPI3 || BSP_USING_SPI4 || BSP_USING_SPI5 */
#endif
/* RT_USING_SPI */
#endif
/* RT_USING_SPI */
bsp/stm32/libraries/HAL_Drivers/drv_usart.c
浏览文件 @
c6be6441
...
@@ -23,13 +23,7 @@
...
@@ -23,13 +23,7 @@
/* this driver can be disabled at menuconfig → RT-Thread Components → Device Drivers */
/* this driver can be disabled at menuconfig → RT-Thread Components → Device Drivers */
#endif
#endif
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F4)
#ifdef RT_SERIAL_USING_DMA
#define UART_INSTANCE_CLEAR_FUNCTION __HAL_UART_CLEAR_FLAG
#elif defined(SOC_SERIES_STM32F7)
#define UART_INSTANCE_CLEAR_FUNCTION __HAL_UART_CLEAR_IT
#endif
#ifdef BSP_UART_USING_DMA_RX
static
void
stm32_dma_config
(
struct
rt_serial_device
*
serial
);
static
void
stm32_dma_config
(
struct
rt_serial_device
*
serial
);
#endif
#endif
...
@@ -137,7 +131,7 @@ static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_c
...
@@ -137,7 +131,7 @@ static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_c
static
rt_err_t
stm32_control
(
struct
rt_serial_device
*
serial
,
int
cmd
,
void
*
arg
)
static
rt_err_t
stm32_control
(
struct
rt_serial_device
*
serial
,
int
cmd
,
void
*
arg
)
{
{
struct
stm32_uart
*
uart
;
struct
stm32_uart
*
uart
;
#ifdef
BSP_UART_USING_DMA_RX
#ifdef
RT_SERIAL_USING_DMA
rt_ubase_t
ctrl_arg
=
(
rt_ubase_t
)
arg
;
rt_ubase_t
ctrl_arg
=
(
rt_ubase_t
)
arg
;
#endif
#endif
...
@@ -162,7 +156,7 @@ static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *ar
...
@@ -162,7 +156,7 @@ static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *ar
__HAL_UART_ENABLE_IT
(
&
(
uart
->
handle
),
UART_IT_RXNE
);
__HAL_UART_ENABLE_IT
(
&
(
uart
->
handle
),
UART_IT_RXNE
);
break
;
break
;
#ifdef
BSP_UART_USING_DMA_RX
#ifdef
RT_SERIAL_USING_DMA
case
RT_DEVICE_CTRL_CONFIG
:
case
RT_DEVICE_CTRL_CONFIG
:
if
(
ctrl_arg
==
RT_DEVICE_FLAG_DMA_RX
)
if
(
ctrl_arg
==
RT_DEVICE_FLAG_DMA_RX
)
{
{
...
@@ -181,7 +175,7 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
...
@@ -181,7 +175,7 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
uart
=
(
struct
stm32_uart
*
)
serial
->
parent
.
user_data
;
uart
=
(
struct
stm32_uart
*
)
serial
->
parent
.
user_data
;
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_TC
);
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_TC
);
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7)
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7)
|| defined(SOC_SERIES_STM32F0)
uart
->
handle
.
Instance
->
TDR
=
c
;
uart
->
handle
.
Instance
->
TDR
=
c
;
#else
#else
uart
->
handle
.
Instance
->
DR
=
c
;
uart
->
handle
.
Instance
->
DR
=
c
;
...
@@ -201,7 +195,7 @@ static int stm32_getc(struct rt_serial_device *serial)
...
@@ -201,7 +195,7 @@ static int stm32_getc(struct rt_serial_device *serial)
ch
=
-
1
;
ch
=
-
1
;
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_RXNE
)
!=
RESET
)
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_RXNE
)
!=
RESET
)
{
{
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7)
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7)
|| defined(SOC_SERIES_STM32F0)
ch
=
uart
->
handle
.
Instance
->
RDR
&
0xff
;
ch
=
uart
->
handle
.
Instance
->
RDR
&
0xff
;
#else
#else
ch
=
uart
->
handle
.
Instance
->
DR
&
0xff
;
ch
=
uart
->
handle
.
Instance
->
DR
&
0xff
;
...
@@ -226,7 +220,7 @@ static const struct rt_uart_ops stm32_uart_ops =
...
@@ -226,7 +220,7 @@ static const struct rt_uart_ops stm32_uart_ops =
static
void
uart_isr
(
struct
rt_serial_device
*
serial
)
static
void
uart_isr
(
struct
rt_serial_device
*
serial
)
{
{
struct
stm32_uart
*
uart
;
struct
stm32_uart
*
uart
;
#ifdef
BSP_UART_USING_DMA_RX
#ifdef
RT_SERIAL_USING_DMA
rt_size_t
recv_total_index
,
recv_len
;
rt_size_t
recv_total_index
,
recv_len
;
rt_base_t
level
;
rt_base_t
level
;
#endif
#endif
...
@@ -244,7 +238,7 @@ static void uart_isr(struct rt_serial_device *serial)
...
@@ -244,7 +238,7 @@ static void uart_isr(struct rt_serial_device *serial)
/* Clear RXNE interrupt flag */
/* Clear RXNE interrupt flag */
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_RXNE
);
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_RXNE
);
}
}
#ifdef
BSP_UART_USING_DMA_RX
#ifdef
RT_SERIAL_USING_DMA
else
if
((
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_IDLE
)
!=
RESET
)
&&
else
if
((
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_IDLE
)
!=
RESET
)
&&
(
__HAL_UART_GET_IT_SOURCE
(
&
(
uart
->
handle
),
UART_IT_IDLE
)
!=
RESET
))
(
__HAL_UART_GET_IT_SOURCE
(
&
(
uart
->
handle
),
UART_IT_IDLE
)
!=
RESET
))
{
{
...
@@ -258,50 +252,37 @@ static void uart_isr(struct rt_serial_device *serial)
...
@@ -258,50 +252,37 @@ static void uart_isr(struct rt_serial_device *serial)
{
{
rt_hw_serial_isr
(
serial
,
RT_SERIAL_EVENT_RX_DMADONE
|
(
recv_len
<<
8
));
rt_hw_serial_isr
(
serial
,
RT_SERIAL_EVENT_RX_DMADONE
|
(
recv_len
<<
8
));
}
}
__HAL_UART_CLEAR_IDLEFLAG
(
&
uart
->
handle
);
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_IDLE
);
rt_uint32_t
ch
;
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7)
ch
=
uart
->
handle
.
Instance
->
RDR
;
#else
ch
=
uart
->
handle
.
Instance
->
DR
;
#endif
ch
=
ch
;
}
}
#endif
#endif
else
else
{
{
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_ORE
)
!=
RESET
)
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_ORE
)
!=
RESET
)
{
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_ORE
);
__HAL_UART_CLEAR_OREFLAG
(
&
uart
->
handle
);
}
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_NE
)
!=
RESET
)
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_NE
)
!=
RESET
)
{
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_NE
);
__HAL_UART_CLEAR_NEFLAG
(
&
uart
->
handle
);
}
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_FE
)
!=
RESET
)
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_FE
)
!=
RESET
)
{
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_FE
);
__HAL_UART_CLEAR_FEFLAG
(
&
uart
->
handle
);
}
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_PE
)
!=
RESET
)
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_PE
)
!=
RESET
)
{
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_PE
);
__HAL_UART_CLEAR_PEFLAG
(
&
uart
->
handle
);
}
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_CTS
)
!=
RESET
)
#if !defined(SOC_SERIES_STM32L4) && !defined(SOC_SERIES_STM32F7) && !defined(SOC_SERIES_STM32F0)
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_CTS
);
}
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32F4)
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_LBD
)
!=
RESET
)
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_LBD
)
!=
RESET
)
{
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_LBD
);
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_LBD
);
}
}
#e
lif defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4)
#e
ndif
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_
LBDF
)
!=
RESET
)
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_
CTS
)
!=
RESET
)
{
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_
LBDF
);
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_
CTS
);
}
}
#endif
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_TXE
)
!=
RESET
)
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_TXE
)
!=
RESET
)
{
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_TXE
);
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_TXE
);
...
@@ -314,40 +295,6 @@ static void uart_isr(struct rt_serial_device *serial)
...
@@ -314,40 +295,6 @@ static void uart_isr(struct rt_serial_device *serial)
{
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_RXNE
);
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_RXNE
);
}
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_IDLE
)
!=
RESET
)
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_IDLE
);
}
#if defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4)
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_TEACK
)
!=
RESET
)
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_TEACK
);
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_SBKF
)
!=
RESET
)
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_SBKF
);
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_CMF
)
!=
RESET
)
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_CMF
);
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_BUSY
)
!=
RESET
)
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_BUSY
);
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_ABRF
)
!=
RESET
)
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_ABRF
);
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_ABRE
)
!=
RESET
)
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_ABRE
);
}
if
(
__HAL_UART_GET_FLAG
(
&
(
uart
->
handle
),
UART_FLAG_CTSIF
)
!=
RESET
)
{
UART_INSTANCE_CLEAR_FUNCTION
(
&
(
uart
->
handle
),
UART_FLAG_CTSIF
);
}
#endif
}
}
}
}
...
@@ -362,7 +309,7 @@ void USART1_IRQHandler(void)
...
@@ -362,7 +309,7 @@ void USART1_IRQHandler(void)
/* leave interrupt */
/* leave interrupt */
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
#if defined(
BSP_UART_USING_DMA_RX
) && defined(USART1_RX_DMA_ISR)
#if defined(
RT_SERIAL_USING_DMA
) && defined(USART1_RX_DMA_ISR)
void
USART1_RX_DMA_ISR
(
void
)
void
USART1_RX_DMA_ISR
(
void
)
{
{
/* enter interrupt */
/* enter interrupt */
...
@@ -373,7 +320,7 @@ void USART1_RX_DMA_ISR(void)
...
@@ -373,7 +320,7 @@ void USART1_RX_DMA_ISR(void)
/* leave interrupt */
/* leave interrupt */
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
#endif
/* defined(
BSP_UART_USING_DMA_RX
) && defined(USART1_RX_DMA_ISR) */
#endif
/* defined(
RT_SERIAL_USING_DMA
) && defined(USART1_RX_DMA_ISR) */
#endif
/* BSP_USING_UART1 */
#endif
/* BSP_USING_UART1 */
#if defined(BSP_USING_UART2)
#if defined(BSP_USING_UART2)
...
@@ -387,7 +334,7 @@ void USART2_IRQHandler(void)
...
@@ -387,7 +334,7 @@ void USART2_IRQHandler(void)
/* leave interrupt */
/* leave interrupt */
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
#if defined(
BSP_UART_USING_DMA_RX
) && defined(USART2_RX_DMA_ISR)
#if defined(
RT_SERIAL_USING_DMA
) && defined(USART2_RX_DMA_ISR)
void
USART2_RX_DMA_ISR
(
void
)
void
USART2_RX_DMA_ISR
(
void
)
{
{
/* enter interrupt */
/* enter interrupt */
...
@@ -398,7 +345,7 @@ void USART2_RX_DMA_ISR(void)
...
@@ -398,7 +345,7 @@ void USART2_RX_DMA_ISR(void)
/* leave interrupt */
/* leave interrupt */
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
#endif
/* defined(
BSP_UART_USING_DMA_RX
) && defined(USART2_RX_DMA_ISR) */
#endif
/* defined(
RT_SERIAL_USING_DMA
) && defined(USART2_RX_DMA_ISR) */
#endif
/* BSP_USING_UART2 */
#endif
/* BSP_USING_UART2 */
#if defined(BSP_USING_UART3)
#if defined(BSP_USING_UART3)
...
@@ -412,7 +359,7 @@ void USART3_IRQHandler(void)
...
@@ -412,7 +359,7 @@ void USART3_IRQHandler(void)
/* leave interrupt */
/* leave interrupt */
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
#if defined(
BSP_UART_USING_DMA_RX
) && defined(USART3_RX_DMA_ISR)
#if defined(
RT_SERIAL_USING_DMA
) && defined(USART3_RX_DMA_ISR)
void
USART3_RX_DMA_ISR
(
void
)
void
USART3_RX_DMA_ISR
(
void
)
{
{
/* enter interrupt */
/* enter interrupt */
...
@@ -437,7 +384,7 @@ void UART4_IRQHandler(void)
...
@@ -437,7 +384,7 @@ void UART4_IRQHandler(void)
/* leave interrupt */
/* leave interrupt */
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
#if defined(
BSP_UART_USING_DMA_RX
) && defined(USART1_RX_DMA_ISR)
#if defined(
RT_SERIAL_USING_DMA
) && defined(USART1_RX_DMA_ISR)
void
USART4_RX_DMA_ISR
(
void
)
void
USART4_RX_DMA_ISR
(
void
)
{
{
/* enter interrupt */
/* enter interrupt */
...
@@ -462,7 +409,7 @@ void UART5_IRQHandler(void)
...
@@ -462,7 +409,7 @@ void UART5_IRQHandler(void)
/* leave interrupt */
/* leave interrupt */
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
#if defined(
BSP_UART_USING_DMA_RX
) && defined(USART5_RX_DMA_ISR)
#if defined(
RT_SERIAL_USING_DMA
) && defined(USART5_RX_DMA_ISR)
void
USART5_RX_DMA_ISR
(
void
)
void
USART5_RX_DMA_ISR
(
void
)
{
{
/* enter interrupt */
/* enter interrupt */
...
@@ -473,10 +420,10 @@ void USART5_RX_DMA_ISR(void)
...
@@ -473,10 +420,10 @@ void USART5_RX_DMA_ISR(void)
/* leave interrupt */
/* leave interrupt */
rt_interrupt_leave
();
rt_interrupt_leave
();
}
}
#endif
/* defined(
BSP_UART_USING_DMA_RX
) && defined(USART5_RX_DMA_ISR) */
#endif
/* defined(
RT_SERIAL_USING_DMA
) && defined(USART5_RX_DMA_ISR) */
#endif
/* BSP_USING_UART5*/
#endif
/* BSP_USING_UART5*/
#ifdef
BSP_UART_USING_DMA_RX
#ifdef
RT_SERIAL_USING_DMA
static
void
stm32_dma_config
(
struct
rt_serial_device
*
serial
)
static
void
stm32_dma_config
(
struct
rt_serial_device
*
serial
)
{
{
RT_ASSERT
(
serial
!=
RT_NULL
);
RT_ASSERT
(
serial
!=
RT_NULL
);
...
@@ -488,7 +435,7 @@ static void stm32_dma_config(struct rt_serial_device *serial)
...
@@ -488,7 +435,7 @@ static void stm32_dma_config(struct rt_serial_device *serial)
{
{
rt_uint32_t
tmpreg
=
0x00U
;
rt_uint32_t
tmpreg
=
0x00U
;
#if defined(SOC_SERIES_STM32F1)
#if defined(SOC_SERIES_STM32F1)
|| defined(SOC_SERIES_STM32F0)
/* enable DMA clock && Delay after an RCC peripheral clock enabling*/
/* enable DMA clock && Delay after an RCC peripheral clock enabling*/
SET_BIT
(
RCC
->
AHBENR
,
uart
->
config
->
dma_rcc
);
SET_BIT
(
RCC
->
AHBENR
,
uart
->
config
->
dma_rcc
);
tmpreg
=
READ_BIT
(
RCC
->
AHBENR
,
uart
->
config
->
dma_rcc
);
tmpreg
=
READ_BIT
(
RCC
->
AHBENR
,
uart
->
config
->
dma_rcc
);
...
@@ -502,7 +449,7 @@ static void stm32_dma_config(struct rt_serial_device *serial)
...
@@ -502,7 +449,7 @@ static void stm32_dma_config(struct rt_serial_device *serial)
__HAL_LINKDMA
(
&
(
uart
->
handle
),
hdmarx
,
uart
->
dma
.
handle
);
__HAL_LINKDMA
(
&
(
uart
->
handle
),
hdmarx
,
uart
->
dma
.
handle
);
#if defined(SOC_SERIES_STM32F1)
#if defined(SOC_SERIES_STM32F1)
|| defined(SOC_SERIES_STM32F0)
uart
->
dma
.
handle
.
Instance
=
uart
->
config
->
dma
.
Instance
;
uart
->
dma
.
handle
.
Instance
=
uart
->
config
->
dma
.
Instance
;
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
uart
->
dma
.
handle
.
Instance
=
uart
->
config
->
dma
.
Instance
;
uart
->
dma
.
handle
.
Instance
=
uart
->
config
->
dma
.
Instance
;
...
@@ -544,10 +491,10 @@ static void stm32_dma_config(struct rt_serial_device *serial)
...
@@ -544,10 +491,10 @@ static void stm32_dma_config(struct rt_serial_device *serial)
__HAL_UART_ENABLE_IT
(
&
(
uart
->
handle
),
UART_IT_IDLE
);
__HAL_UART_ENABLE_IT
(
&
(
uart
->
handle
),
UART_IT_IDLE
);
/* enable rx irq */
/* enable rx irq */
HAL_NVIC_SetPriority
(
uart
->
config
->
dma_irq
,
1
,
0
);
HAL_NVIC_SetPriority
(
uart
->
config
->
dma_irq
,
0
,
0
);
HAL_NVIC_EnableIRQ
(
uart
->
config
->
dma_irq
);
HAL_NVIC_EnableIRQ
(
uart
->
config
->
dma_irq
);
HAL_NVIC_SetPriority
(
uart
->
config
->
irq_type
,
0
,
0
);
HAL_NVIC_SetPriority
(
uart
->
config
->
irq_type
,
1
,
0
);
HAL_NVIC_EnableIRQ
(
uart
->
config
->
irq_type
);
HAL_NVIC_EnableIRQ
(
uart
->
config
->
irq_type
);
LOG_D
(
"%s dma RX instance: %x"
,
uart
->
config
->
name
,
uart
->
dma
.
handle
.
Instance
);
LOG_D
(
"%s dma RX instance: %x"
,
uart
->
config
->
name
,
uart
->
dma
.
handle
.
Instance
);
...
@@ -598,7 +545,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
...
@@ -598,7 +545,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
rt_hw_serial_isr
(
serial
,
RT_SERIAL_EVENT_RX_DMADONE
|
(
recv_len
<<
8
));
rt_hw_serial_isr
(
serial
,
RT_SERIAL_EVENT_RX_DMADONE
|
(
recv_len
<<
8
));
}
}
}
}
#endif
/*
BSP_UART_USING_DMA_RX
*/
#endif
/*
RT_SERIAL_USING_DMA
*/
int
rt_hw_usart_init
(
void
)
int
rt_hw_usart_init
(
void
)
{
{
...
@@ -619,7 +566,7 @@ int rt_hw_usart_init(void)
...
@@ -619,7 +566,7 @@ int rt_hw_usart_init(void)
/* register UART device */
/* register UART device */
result
=
rt_hw_serial_register
(
&
uart_obj
[
i
].
serial
,
uart_obj
[
i
].
config
->
name
,
result
=
rt_hw_serial_register
(
&
uart_obj
[
i
].
serial
,
uart_obj
[
i
].
config
->
name
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
#if defined(
BSP_UART_USING_DMA_RX
)
#if defined(
RT_SERIAL_USING_DMA
)
|
RT_DEVICE_FLAG_DMA_RX
|
RT_DEVICE_FLAG_DMA_RX
#endif
#endif
,
&
uart_obj
[
i
]);
,
&
uart_obj
[
i
]);
...
...
bsp/stm32/libraries/HAL_Drivers/drv_usart.h
浏览文件 @
c6be6441
...
@@ -18,12 +18,19 @@
...
@@ -18,12 +18,19 @@
int
rt_hw_usart_init
(
void
);
int
rt_hw_usart_init
(
void
);
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4)
#if defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4)
#define DMA_INSTANCE_TYPE DMA_Channel_TypeDef
#define DMA_INSTANCE_TYPE DMA_Channel_TypeDef
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
#define DMA_INSTANCE_TYPE DMA_Stream_TypeDef
#define DMA_INSTANCE_TYPE DMA_Stream_TypeDef
#endif
/* defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4) */
#endif
/* defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4) */
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F4)
#define UART_INSTANCE_CLEAR_FUNCTION __HAL_UART_CLEAR_FLAG
#elif defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32F0)
#define UART_INSTANCE_CLEAR_FUNCTION __HAL_UART_CLEAR_IT
#endif
/* stm32 config class */
/* stm32 config class */
struct
stm32_uart_config
struct
stm32_uart_config
{
{
...
@@ -69,7 +76,7 @@ struct stm32_uart
...
@@ -69,7 +76,7 @@ struct stm32_uart
const
struct
stm32_uart_config
*
config
;
const
struct
stm32_uart_config
*
config
;
#ifdef
BSP_UART_USING_DMA_RX
#ifdef
RT_SERIAL_USING_DMA
struct
struct
{
{
DMA_HandleTypeDef
handle
;
DMA_HandleTypeDef
handle
;
...
...
bsp/stm32/libraries/HAL_Drivers/drv_wdt.c
浏览文件 @
c6be6441
...
@@ -26,7 +26,7 @@ static rt_err_t wdt_init(rt_watchdog_t *wdt)
...
@@ -26,7 +26,7 @@ static rt_err_t wdt_init(rt_watchdog_t *wdt)
hiwdg
.
Init
.
Prescaler
=
IWDG_PRESCALER_32
;
hiwdg
.
Init
.
Prescaler
=
IWDG_PRESCALER_32
;
hiwdg
.
Init
.
Reload
=
0x00000FFE
;
hiwdg
.
Init
.
Reload
=
0x00000FFE
;
#if defined(SOC_SERIES_STM32
L4
)
#if defined(SOC_SERIES_STM32
F0) || defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F7
)
hiwdg
.
Init
.
Window
=
0x00000FFF
;
hiwdg
.
Init
.
Window
=
0x00000FFF
;
#endif
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录