Skip to content

Commit 7e9c622

Browse files
committed
提交了国民技术的定时器外部时钟1和外部时钟2计数驱动程序,驱动已经在N32L406和N32G457平台测试OK,引脚Pin配置使用KConfig方式配置
1 parent 8b64727 commit 7e9c622

File tree

5 files changed

+147
-51
lines changed

5 files changed

+147
-51
lines changed

bsp/n32/libraries/n32_drivers/SConscript

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ if GetDepend(['RT_USING_WDT']):
5050

5151
if GetDepend(['BSP_USING_PWM']):
5252
src += ['drv_pwm.c']
53+
54+
if GetDepend(['BSP_USING_TIM_ETR_CNT']):
55+
src += ['tim_ext_clk2.c']
56+
57+
if GetDepend(['BSP_USING_TIM_EXT_COUNTER']):
58+
src += ['tim_ext_clk1.c']
5359

60+
5461
path = [cwd]
5562
path += [cwd + '/config']
5663

bsp/n32/n32l40xcl-stb/.config

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,13 +1441,27 @@ CONFIG_BSP_USING_USART1=y
14411441
# CONFIG_BSP_USING_DAC is not set
14421442
# CONFIG_BSP_USING_CAN is not set
14431443
CONFIG_BSP_USING_PWM=y
1444-
CONFIG_BSP_USING_TIM1_PWM=y
1445-
# CONFIG_BSP_USING_TIM1_PWM_CH1 is not set
1446-
# CONFIG_BSP_USING_TIM1_PWM_CH2 is not set
1447-
# CONFIG_BSP_USING_TIM1_PWM_CH3 is not set
1448-
CONFIG_BSP_USING_TIM1_PWM_CH4=y
1449-
# CONFIG_BSP_USING_TIM2_PWM is not set
1444+
# CONFIG_BSP_USING_TIM1_PWM is not set
1445+
CONFIG_BSP_USING_TIM2_PWM=y
1446+
CONFIG_BSP_USING_TIM2_PWM_CH1=y
1447+
CONFIG_TIM2_CH1_PA0=y
1448+
# CONFIG_TIM2_CH1_PA15 is not set
1449+
# CONFIG_BSP_USING_TIM2_PWM_CH2 is not set
1450+
# CONFIG_BSP_USING_TIM2_PWM_CH3 is not set
1451+
# CONFIG_BSP_USING_TIM2_PWM_CH4 is not set
14501452
# CONFIG_BSP_USING_TIM3_PWM is not set
1453+
CONFIG_BSP_USING_TIM_ETR_CNT=y
1454+
# CONFIG_BSP_USING_TIM_ETR_CNT_DEBUG is not set
1455+
# CONFIG_BSP_USING_TIM1_ETR_CNT is not set
1456+
# CONFIG_BSP_USING_TIM2_ETR_CNT is not set
1457+
CONFIG_TIM2_ETR_PIN_PA0=y
1458+
# CONFIG_TIM1_ETR_PIN_PA15 is not set
1459+
CONFIG_BSP_USING_TIM3_ETR_CNT=y
1460+
# CONFIG_BSP_USING_TIM9_ETR_CNT is not set
1461+
CONFIG_BSP_USING_TIM_EXT_COUNTER=y
1462+
CONFIG_BSP_USING_TIM1_EXT_COUNTER=y
1463+
CONFIG_TIM1_CH1_PA8=y
1464+
# CONFIG_TIM1_CH2_PA9 is not set
14511465
# end of On-chip Peripheral Drivers
14521466

14531467
#

bsp/n32/n32l40xcl-stb/board/Kconfig

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,61 @@ menu "On-chip Peripheral Drivers"
300300
endchoice
301301
endif
302302
endif #BSP_USING_TIM3_PWM
303-
endif #BSP_USING_PWM
303+
endif # BSP_USING_PWM
304+
305+
#-----------------------------ETR_COUNTER----------------------------------
306+
menuconfig BSP_USING_TIM_ETR_CNT
307+
bool "Enable timer ETR MAX=10M "
308+
select RT_USING_HWTIMER
309+
default n
310+
if BSP_USING_TIM_ETR_CNT
311+
config BSP_USING_TIM_ETR_CNT_DEBUG
312+
bool "Enable TIM ETR debug message output"
313+
default n
314+
315+
config BSP_USING_TIM1_ETR_CNT
316+
bool "Enable TIM1 ETR PA12 AF2 "
317+
default n
318+
319+
config BSP_USING_TIM2_ETR_CNT
320+
bool "Enable TIM1 ETR "
321+
default n
322+
choice
323+
prompt "Select TIM2 ETR PIN"
324+
default TIM2_ETR_PIN_PA0
325+
config TIM2_ETR_PIN_PA0
326+
bool "PA0 AF5"
327+
config TIM1_ETR_PIN_PA15
328+
bool "PA15 AF2"
329+
endchoice #
330+
config BSP_USING_TIM3_ETR_CNT
331+
bool "Enable TIM3 ETR PD2 AF2 "
332+
default n
333+
config BSP_USING_TIM9_ETR_CNT
334+
bool "Enable TIM9 ETR PB2 AF1 "
335+
default n
336+
endif #BSP_USING_TIM_ETR_CNT
337+
338+
#-----------------------------EXT_COUNTER----------------------------------
339+
menuconfig BSP_USING_TIM_EXT_COUNTER
340+
bool "Enable TIM External Counter"
341+
default n
342+
select RT_USING_HWTIMER
343+
if BSP_USING_TIM_EXT_COUNTER
344+
config BSP_USING_TIM1_EXT_COUNTER
345+
bool "Enable TIM1 External Counter"
346+
default n
347+
choice
348+
prompt "Select TIM1 Pin"
349+
default TIM1_CH1_PA8
350+
config TIM1_CH1_PA8
351+
bool "PA8 AF2"
352+
config TIM1_CH2_PA9
353+
bool "PA9 AF2"
354+
355+
endchoice
356+
endif #---------BSP_USING_TIM_EXT_COUNTER------------
357+
304358

305359
rsource "../../libraries/n32_drivers/Kconfig"
306360

bsp/n32/n32l40xcl-stb/project.uvprojx

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@
334334
<v6Rtti>0</v6Rtti>
335335
<VariousControls>
336336
<MiscControls />
337-
<Define>N32L40X, __CLK_TCK=RT_TICK_PER_SECOND, RT_USING_ARMLIBC, __RTTHREAD__, USE_STDPERIPH_DRIVER, RT_USING_LIBC, __STDC_LIMIT_MACROS</Define>
337+
<Define>N32L40X, USE_STDPERIPH_DRIVER, __CLK_TCK=RT_TICK_PER_SECOND, RT_USING_LIBC, __STDC_LIMIT_MACROS, __RTTHREAD__, RT_USING_ARMLIBC</Define>
338338
<Undefine />
339-
<IncludePath>..\libraries\n32_drivers\config;..\..\..\components\drivers\include;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\include;..\..\..\components\drivers\phy;..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\inc;..\..\..\components\drivers\include;..\..\..\components\libc\posix\ipc;..\..\..\components\libc\compilers\common\include;..\..\..\components\libc\posix\io\epoll;..\..\..\libcpu\arm\common;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\N32L40x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;board;..\..\..\components\drivers\include;..\libraries\N32L40x_Firmware_Library\CMSIS\core;..\..\..\components\drivers\spi;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\..\..\components\net\utest;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension\fcntl\octal;applications;.;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\finsh;..\libraries\n32_drivers;..\..\..\components\drivers\include</IncludePath>
339+
<IncludePath>..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\spi;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\drivers\include;board;..\..\..\components\drivers\include;..\..\..\libcpu\arm\common;..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\inc;..\..\..\components\drivers\smp_call;..\..\..\components\drivers\include;..\libraries\N32L40x_Firmware_Library\CMSIS\core;..\..\..\components\drivers\include;..\..\..\components\finsh;..\..\..\components\libc\posix\ipc;..\..\..\include;.;..\libraries\N32L40x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\libraries\n32_drivers;..\..\..\components\drivers\include;..\libraries\n32_drivers\config;..\..\..\components\drivers\phy;..\..\..\components\drivers\include;..\..\..\components\drivers\include;applications;..\..\..\components\libc\compilers\common\include;..\..\..\components\drivers\include;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\net\utest;..\..\..\components\libc\posix\io\epoll</IncludePath>
340340
</VariousControls>
341341
</Cads>
342342
<Aads>
@@ -970,35 +970,49 @@
970970
<FilePath>..\libraries\n32_drivers\drv_wdt.c</FilePath>
971971
</File>
972972
</Files>
973+
<Files>
974+
<File>
975+
<FileName>tim_ext_clk1.c</FileName>
976+
<FileType>1</FileType>
977+
<FilePath>..\libraries\n32_drivers\tim_ext_clk1.c</FilePath>
978+
</File>
979+
</Files>
980+
<Files>
981+
<File>
982+
<FileName>tim_ext_clk2.c</FileName>
983+
<FileType>1</FileType>
984+
<FilePath>..\libraries\n32_drivers\tim_ext_clk2.c</FilePath>
985+
</File>
986+
</Files>
973987
</Group>
974988
<Group>
975989
<GroupName>Finsh</GroupName>
976990
<Files>
977991
<File>
978-
<FileName>msh_parse.c</FileName>
992+
<FileName>msh.c</FileName>
979993
<FileType>1</FileType>
980-
<FilePath>..\..\..\components\finsh\msh_parse.c</FilePath>
994+
<FilePath>..\..\..\components\finsh\msh.c</FilePath>
981995
</File>
982996
</Files>
983997
<Files>
984998
<File>
985-
<FileName>msh.c</FileName>
999+
<FileName>cmd.c</FileName>
9861000
<FileType>1</FileType>
987-
<FilePath>..\..\..\components\finsh\msh.c</FilePath>
1001+
<FilePath>..\..\..\components\finsh\cmd.c</FilePath>
9881002
</File>
9891003
</Files>
9901004
<Files>
9911005
<File>
992-
<FileName>shell.c</FileName>
1006+
<FileName>msh_parse.c</FileName>
9931007
<FileType>1</FileType>
994-
<FilePath>..\..\..\components\finsh\shell.c</FilePath>
1008+
<FilePath>..\..\..\components\finsh\msh_parse.c</FilePath>
9951009
</File>
9961010
</Files>
9971011
<Files>
9981012
<File>
999-
<FileName>cmd.c</FileName>
1013+
<FileName>shell.c</FileName>
10001014
<FileType>1</FileType>
1001-
<FilePath>..\..\..\components\finsh\cmd.c</FilePath>
1015+
<FilePath>..\..\..\components\finsh\shell.c</FilePath>
10021016
</File>
10031017
</Files>
10041018
</Group>
@@ -1407,16 +1421,16 @@
14071421
<GroupName>Libraries</GroupName>
14081422
<Files>
14091423
<File>
1410-
<FileName>n32l40x_spi.c</FileName>
1424+
<FileName>misc.c</FileName>
14111425
<FileType>1</FileType>
1412-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_spi.c</FilePath>
1426+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\misc.c</FilePath>
14131427
</File>
14141428
</Files>
14151429
<Files>
14161430
<File>
1417-
<FileName>system_n32l40x.c</FileName>
1431+
<FileName>n32l40x_i2c.c</FileName>
14181432
<FileType>1</FileType>
1419-
<FilePath>..\libraries\N32L40x_Firmware_Library\CMSIS\device\system_n32l40x.c</FilePath>
1433+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_i2c.c</FilePath>
14201434
</File>
14211435
</Files>
14221436
<Files>
@@ -1428,100 +1442,100 @@
14281442
</Files>
14291443
<Files>
14301444
<File>
1431-
<FileName>n32l40x_exti.c</FileName>
1445+
<FileName>n32l40x_tim.c</FileName>
14321446
<FileType>1</FileType>
1433-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_exti.c</FilePath>
1447+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_tim.c</FilePath>
14341448
</File>
14351449
</Files>
14361450
<Files>
14371451
<File>
1438-
<FileName>n32l40x_gpio.c</FileName>
1452+
<FileName>system_n32l40x.c</FileName>
14391453
<FileType>1</FileType>
1440-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_gpio.c</FilePath>
1454+
<FilePath>..\libraries\N32L40x_Firmware_Library\CMSIS\device\system_n32l40x.c</FilePath>
14411455
</File>
14421456
</Files>
14431457
<Files>
14441458
<File>
1445-
<FileName>n32l40x_can.c</FileName>
1459+
<FileName>n32l40x_dac.c</FileName>
14461460
<FileType>1</FileType>
1447-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_can.c</FilePath>
1461+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_dac.c</FilePath>
14481462
</File>
14491463
</Files>
14501464
<Files>
14511465
<File>
1452-
<FileName>n32l40x_tim.c</FileName>
1466+
<FileName>n32l40x_iwdg.c</FileName>
14531467
<FileType>1</FileType>
1454-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_tim.c</FilePath>
1468+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_iwdg.c</FilePath>
14551469
</File>
14561470
</Files>
14571471
<Files>
14581472
<File>
1459-
<FileName>n32l40x_flash.c</FileName>
1473+
<FileName>n32l40x_gpio.c</FileName>
14601474
<FileType>1</FileType>
1461-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_flash.c</FilePath>
1475+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_gpio.c</FilePath>
14621476
</File>
14631477
</Files>
14641478
<Files>
14651479
<File>
1466-
<FileName>n32l40x_i2c.c</FileName>
1480+
<FileName>n32l40x_usart.c</FileName>
14671481
<FileType>1</FileType>
1468-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_i2c.c</FilePath>
1482+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_usart.c</FilePath>
14691483
</File>
14701484
</Files>
14711485
<Files>
14721486
<File>
1473-
<FileName>n32l40x_rcc.c</FileName>
1487+
<FileName>n32l40x_spi.c</FileName>
14741488
<FileType>1</FileType>
1475-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_rcc.c</FilePath>
1489+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_spi.c</FilePath>
14761490
</File>
14771491
</Files>
14781492
<Files>
14791493
<File>
1480-
<FileName>n32l40x_rtc.c</FileName>
1494+
<FileName>n32l40x_wwdg.c</FileName>
14811495
<FileType>1</FileType>
1482-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_rtc.c</FilePath>
1496+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_wwdg.c</FilePath>
14831497
</File>
14841498
</Files>
14851499
<Files>
14861500
<File>
1487-
<FileName>n32l40x_usart.c</FileName>
1501+
<FileName>n32l40x_rcc.c</FileName>
14881502
<FileType>1</FileType>
1489-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_usart.c</FilePath>
1503+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_rcc.c</FilePath>
14901504
</File>
14911505
</Files>
14921506
<Files>
14931507
<File>
1494-
<FileName>n32l40x_iwdg.c</FileName>
1508+
<FileName>n32l40x_pwr.c</FileName>
14951509
<FileType>1</FileType>
1496-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_iwdg.c</FilePath>
1510+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_pwr.c</FilePath>
14971511
</File>
14981512
</Files>
14991513
<Files>
15001514
<File>
1501-
<FileName>n32l40x_wwdg.c</FileName>
1515+
<FileName>n32l40x_can.c</FileName>
15021516
<FileType>1</FileType>
1503-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_wwdg.c</FilePath>
1517+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_can.c</FilePath>
15041518
</File>
15051519
</Files>
15061520
<Files>
15071521
<File>
1508-
<FileName>misc.c</FileName>
1522+
<FileName>n32l40x_exti.c</FileName>
15091523
<FileType>1</FileType>
1510-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\misc.c</FilePath>
1524+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_exti.c</FilePath>
15111525
</File>
15121526
</Files>
15131527
<Files>
15141528
<File>
1515-
<FileName>n32l40x_pwr.c</FileName>
1529+
<FileName>n32l40x_flash.c</FileName>
15161530
<FileType>1</FileType>
1517-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_pwr.c</FilePath>
1531+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_flash.c</FilePath>
15181532
</File>
15191533
</Files>
15201534
<Files>
15211535
<File>
1522-
<FileName>n32l40x_dac.c</FileName>
1536+
<FileName>n32l40x_rtc.c</FileName>
15231537
<FileType>1</FileType>
1524-
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_dac.c</FilePath>
1538+
<FilePath>..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_rtc.c</FilePath>
15251539
</File>
15261540
</Files>
15271541
</Group>

bsp/n32/n32l40xcl-stb/rtconfig.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,15 @@
426426
#define BSP_USING_UART
427427
#define BSP_USING_USART1
428428
#define BSP_USING_PWM
429-
#define BSP_USING_TIM1_PWM
430-
#define BSP_USING_TIM1_PWM_CH4
429+
#define BSP_USING_TIM2_PWM
430+
#define BSP_USING_TIM2_PWM_CH1
431+
#define TIM2_CH1_PA0
432+
#define BSP_USING_TIM_ETR_CNT
433+
#define TIM2_ETR_PIN_PA0
434+
#define BSP_USING_TIM3_ETR_CNT
435+
#define BSP_USING_TIM_EXT_COUNTER
436+
#define BSP_USING_TIM1_EXT_COUNTER
437+
#define TIM1_CH1_PA8
431438
/* end of On-chip Peripheral Drivers */
432439

433440
/* Board extended module Drivers */

0 commit comments

Comments
 (0)