Skip to content

Commit 91ffe90

Browse files
committed
为复旦微电子FM33LC0XX添加BSP。包含UART驱动,已经在板子上测试通过。
1 parent 05098bd commit 91ffe90

File tree

163 files changed

+68021
-635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+68021
-635
lines changed

bsp/fm33lc0xx/.config

Lines changed: 550 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// File: STM32F0x1_0x2_0x8.dbgconf
2+
// Version: 1.0.0
3+
// Note: refer to STM32F0x1/STM32F0x2/STM32F0x8 Reference manual (RM0091)
4+
// refer to STM32F031x4/x6, STM32F051x4/x6/x8, STM32F071x8/xB datasheets
5+
// STM32F091xB/xC, STM32F042x4/x6, STM32F072x8/xB, STM32F038x6 datasheets
6+
// STM32F048x6, STM32F058x8, STM32F078xB, STM32F098xC datasheets
7+
8+
// <<< Use Configuration Wizard in Context Menu >>>
9+
10+
// <h> Debug MCU configuration register (DBGMCU_CR)
11+
// <o.2> DBG_STANDBY <i> Debug standby mode
12+
// <o.1> DBG_STOP <i> Debug stop mode
13+
// </h>
14+
DbgMCU_CR = 0x00000006;
15+
16+
// <h> Debug MCU APB1 freeze register (DBGMCU_APB1_FZ)
17+
// <i> Reserved bits must be kept at reset value
18+
// <o.25> DBG_CAN_STOP <i> CAN stopped when core is halted
19+
// <o.21> DBG_I2C1_TIMEOUT <i> I2C1 SMBUS timeout mode stopped when core is halted
20+
// <o.12> DBG_IWDG_STOP <i> Independent watchdog stopped when core is halted
21+
// <o.11> DBG_WWDG_STOP <i> Window watchdog stopped when core is halted
22+
// <o.10> DBG_RTC_STOP <i> RTC stopped when core is halted
23+
// <o.8> DBG_TIM14_STOP <i> TIM14 counter stopped when core is halted
24+
// <o.5> DBG_TIM7_STOP <i> TIM7 counter stopped when core is halted
25+
// <o.4> DBG_TIM6_STOP <i> TIM6 counter stopped when core is halted
26+
// <o.1> DBG_TIM3_STOP <i> TIM3 counter stopped when core is halted
27+
// <o.0> DBG_TIM2_STOP <i> TIM2 counter stopped when core is halted
28+
// </h>
29+
DbgMCU_APB1_Fz = 0x00000000;
30+
31+
// <h> Debug MCU APB2 freeze register (DBGMCU_APB2_FZ)
32+
// <i> Reserved bits must be kept at reset value
33+
// <o.18> DBG_TIM17_STOP <i> TIM17 counter stopped when core is halted
34+
// <o.17> DBG_TIM16_STOP <i> TIM16 counter stopped when core is halted
35+
// <o.16> DBG_TIM15_STOP <i> TIM15 counter stopped when core is halted
36+
// <o.11> DBG_TIM1_STOP <i> TIM1 counter stopped when core is halted
37+
// </h>
38+
DbgMCU_APB2_Fz = 0x00000000;
39+
40+
// <<< end of configuration section >>>

bsp/fm33lc0xx/Kconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
mainmenu "RT-Thread Configuration"
2+
3+
config BSP_DIR
4+
string
5+
option env="BSP_ROOT"
6+
default "."
7+
8+
config RTT_DIR
9+
string
10+
option env="RTT_ROOT"
11+
default "../.."
12+
13+
config PKGS_DIR
14+
string
15+
option env="PKGS_ROOT"
16+
default "packages"
17+
18+
source "$RTT_DIR/Kconfig"
19+
source "$PKGS_DIR/Kconfig"
20+
source "libraries/Kconfig"
21+
source "board/Kconfig"
22+

bsp/fm33lc0xx/SConscript

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# for module compiling
2+
import os
3+
Import('RTT_ROOT')
4+
from building import *
5+
6+
cwd = GetCurrentDir()
7+
objs = []
8+
list = os.listdir(cwd)
9+
10+
for d in list:
11+
path = os.path.join(cwd, d)
12+
if os.path.isfile(os.path.join(path, 'SConscript')):
13+
objs = objs + SConscript(os.path.join(d, 'SConscript'))
14+
15+
Return('objs')

bsp/fm33lc0xx/SConstruct

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import os
2+
import sys
3+
import rtconfig
4+
5+
if os.getenv('RTT_ROOT'):
6+
RTT_ROOT = os.getenv('RTT_ROOT')
7+
else:
8+
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
9+
10+
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
11+
try:
12+
from building import *
13+
except:
14+
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
15+
print(RTT_ROOT)
16+
exit(-1)
17+
18+
TARGET = 'rt-thread.' + rtconfig.TARGET_EXT
19+
20+
DefaultEnvironment(tools=[])
21+
env = Environment(tools = ['mingw'],
22+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
23+
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
24+
AR = rtconfig.AR, ARFLAGS = '-rc',
25+
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
26+
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
27+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
28+
29+
if rtconfig.PLATFORM == 'iar':
30+
env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
31+
env.Replace(ARFLAGS = [''])
32+
env.Replace(LINKCOM = ['$LINK $SOURCES $LINKFLAGS -o $TARGET --map rt-thread.map'])
33+
34+
Export('RTT_ROOT')
35+
Export('rtconfig')
36+
37+
SDK_ROOT = os.path.abspath('./')
38+
39+
if os.path.exists(SDK_ROOT + '/libraries'):
40+
libraries_path_prefix = SDK_ROOT + '/libraries'
41+
else:
42+
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
43+
44+
SDK_LIB = libraries_path_prefix
45+
Export('SDK_LIB')
46+
47+
# prepare building environment
48+
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
49+
50+
stm32_library = 'FM33LC0xx_FL_Driver'
51+
rtconfig.BSP_LIBRARY_TYPE = stm32_library
52+
53+
# include libraries
54+
objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
55+
56+
# include drivers
57+
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
58+
59+
# make a building
60+
DoBuilding(TARGET, objs)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from building import *
2+
3+
cwd = GetCurrentDir()
4+
src = Glob('*.c') + Glob('*.cpp')
5+
CPPPATH = [cwd]
6+
7+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
8+
9+
Return('group')

bsp/fm33lc0xx/applications/main.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2018-11-06 zylx first version
9+
*/
10+
11+
#include <rtthread.h>
12+
#include <rtdevice.h>
13+
#include "fm33lc0xx_fl_gpio.h"
14+
#include "fm33lc0xx_fl_flash.h"
15+
#include "main.h"
16+
17+
18+
static void LED_init(void)
19+
{
20+
FL_GPIO_InitTypeDef GPIO_InitStruct = {0};
21+
22+
FL_GPIO_SetOutputPin(GPIOD,FL_GPIO_PIN_4);
23+
GPIO_InitStruct.pin = FL_GPIO_PIN_4;
24+
GPIO_InitStruct.mode = FL_GPIO_MODE_OUTPUT;
25+
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
26+
GPIO_InitStruct.pull = FL_DISABLE;
27+
FL_GPIO_Init(GPIOD, &GPIO_InitStruct);
28+
}
29+
30+
31+
int main(void)
32+
{
33+
LED_init();
34+
while (1)
35+
{
36+
FL_GPIO_SetOutputPin(GPIOD,FL_GPIO_PIN_4);
37+
rt_thread_mdelay(500);
38+
FL_GPIO_ResetOutputPin(GPIOD,FL_GPIO_PIN_4);
39+
rt_thread_mdelay(500);
40+
}
41+
42+
// return RT_EOK;
43+
}
44+
45+

bsp/fm33lc0xx/applications/main.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* USER CODE BEGIN Header */
2+
/**
3+
******************************************************************************
4+
* @file : main.h
5+
* @brief : Header for main.c file.
6+
* This file contains the common defines of the application.
7+
******************************************************************************
8+
* @attention
9+
*
10+
* Copyright (c) [2019] [Fudan Microelectronics]
11+
* THIS SOFTWARE is licensed under the Mulan PSL v1.
12+
* can use this software according to the terms and conditions of the Mulan PSL v1.
13+
* You may obtain a copy of Mulan PSL v1 at:
14+
* http://license.coscl.org.cn/MulanPSL
15+
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
17+
* PURPOSE.
18+
* See the Mulan PSL v1 for more details.
19+
*
20+
******************************************************************************
21+
*/
22+
/* USER CODE END Header */
23+
24+
/* Define to prevent recursive inclusion -------------------------------------*/
25+
#ifndef __MAIN_H
26+
#define __MAIN_H
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
33+
#ifdef __cplusplus
34+
}
35+
#endif
36+
37+
#endif /* __MAIN_H */
38+
39+
/************************ (C) COPYRIGHT FMSH *****END OF FILE****/

bsp/fm33lc0xx/board/Kconfig

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
menu "Hardware Drivers Config"
2+
3+
config SOC_FM33LC0XX
4+
bool
5+
select SOC_SERIES_FM33LC0XX
6+
select RT_USING_COMPONENTS_INIT
7+
select RT_USING_USER_MAIN
8+
default y
9+
10+
menu "Onboard Peripheral Drivers"
11+
12+
endmenu
13+
14+
menu "On-chip Peripheral Drivers"
15+
16+
menuconfig BSP_USING_UART
17+
bool "Enable UART"
18+
default y
19+
select RT_USING_SERIAL
20+
if BSP_USING_UART
21+
config BSP_USING_UART0
22+
bool "Enable UART0"
23+
default n
24+
25+
config BSP_USING_UART1
26+
bool "Enable UART1"
27+
default y
28+
29+
config BSP_USING_UART4
30+
bool "Enable UART4"
31+
default n
32+
33+
config BSP_USING_UART5
34+
bool "Enable UART5"
35+
default y
36+
endif
37+
source "libraries/HAL_Drivers/Kconfig"
38+
39+
endmenu
40+
41+
menu "Board extended module Drivers"
42+
43+
endmenu
44+
45+
endmenu

bsp/fm33lc0xx/board/SConscript

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import rtconfig
3+
from building import *
4+
5+
Import('SDK_LIB')
6+
7+
cwd = GetCurrentDir()
8+
9+
# add general drivers
10+
src = Split('''
11+
board.c
12+
''')
13+
14+
path = [cwd]
15+
16+
startup_path_prefix = SDK_LIB
17+
18+
if rtconfig.CROSS_TOOL == 'gcc':
19+
src += [startup_path_prefix + '/FM/FM33xx/Source/Templates/gcc/startup_fm33lc0xx.s']
20+
elif rtconfig.CROSS_TOOL == 'keil':
21+
src += [startup_path_prefix + '/FM/FM33xx/Source/Templates/ARM/startup_fm33lc0xx.s']
22+
elif rtconfig.CROSS_TOOL == 'iar':
23+
src += [startup_path_prefix + '/FM/FM33xx/Source/Templates/iar/startup_fm33lc0xx.s']
24+
25+
# FM33LC0XX
26+
# You can select chips from the list above
27+
CPPDEFINES = ['FM33LC0XX']
28+
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
29+
Return('group')

0 commit comments

Comments
 (0)