Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
449 changes: 449 additions & 0 deletions bsp/gd32/gd32205/.config

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions bsp/gd32/gd32205/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
mainmenu "RT-Thread Configuration"

config BSP_DIR
string
option env="BSP_ROOT"
default "."

config RTT_DIR
string
option env="RTT_ROOT"
default "../../.."

# you can change the RTT_ROOT default: "rt-thread"
# example : default "F:/git_repositories/rt-thread"

config PKGS_DIR
string
option env="PKGS_ROOT"
default "packages"

source "$RTT_DIR/Kconfig"
source "$PKGS_DIR/Kconfig"
source "$BSP_DIR/../libraries/Kconfig"

if SOC_SERIES_GD32F2
config SOC_GD32205Rx
bool "GD32F205Rx chip"
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
default y
endif

config BSP_USING_UART0
bool "using uart0"
select RT_USING_SERIAL
default n
config BSP_USING_UART1
bool "using uart1"
select RT_USING_SERIAL
default n
50 changes: 50 additions & 0 deletions bsp/gd32/gd32205/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# GD32F205RKT6

## 简介

GD32F205RKT6 是-兆易创新推出的一颗 Cortex-M3 的处理器,芯片资源主要如下:

| 硬件 | 描述 |
| --------- | ------------- |
| 芯片型号 | GD32F205RKT6 |
| CPU | ARM Cortex M3 |
| 主频 | 120M |
| 片内SRAM | 256K |
| 片内FLASH | 3072K |

## 编译说明

GD32450Z-EVAL板级包支持MDK5开发环境以下是具体版本信息:

| IDE/编译器 | 已测试版本 |
| ---------- | ---------- |
| GCC | gcc version 6.2.1 20161205 |

## 烧写及执行

下载程序:下载程序到开发板需要一套 JLink 或者使用 GD-Link 工具。

串口连接:使用串口线连接到COM1(UART0),或者使用USB转TTL模块连接PA9(MCU TX)和PA10(MCU RX)。

### 运行结果

如果编译 & 烧写无误,当复位设备后,会在串口上看到RT-Thread的启动logo信息:

```bash
\ | /
- RT - Thread Operating System
/ | \ 4.0.4 build Sep 20 2021
2006 - 2021 Copyright by rt-thread team
msh >
```
## 驱动支持情况及计划

| 驱动 | 支持情况 | 备注 |
| --------- | -------- | :------------------------: |
| UART | 支持 | UART0~1 |
| GPIO | 支持 | ALL |

## 联系人信息

维护人:[iysheng](https://gitee.com/iysheng)
邮箱:[email protected]
14 changes: 14 additions & 0 deletions bsp/gd32/gd32205/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# for module compiling
import os
Import('RTT_ROOT')

cwd = str(Dir('#'))
objs = []
list = os.listdir(cwd)

for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))

Return('objs')
59 changes: 59 additions & 0 deletions bsp/gd32/gd32205/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import os
import sys
import rtconfig

if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')

sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
try:
from building import *
except:
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
print(RTT_ROOT)
exit(-1)

TARGET = 'rtthread.' + rtconfig.TARGET_EXT

DefaultEnvironment(tools=[])
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)

if rtconfig.PLATFORM == 'iar':
env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
env.Replace(ARFLAGS = [''])
env.Replace(LINKCOM = env["LINKCOM"] + ' --map project.map')

Export('RTT_ROOT')
Export('rtconfig')

SDK_ROOT = os.path.abspath('./')

if os.path.exists(SDK_ROOT + '/libraries'):
libraries_path_prefix = SDK_ROOT + '/libraries'
else:
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'

SDK_LIB = libraries_path_prefix
Export('SDK_LIB')

# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)

gd32_library = 'GD32F2xx_STD'
rtconfig.BSP_LIBRARY_TYPE = gd32_library

# include libraries
objs.extend(SConscript(os.path.join(libraries_path_prefix, gd32_library, 'SConscript')))

# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'GD32_Drivers', 'SConscript')))

# make a building
DoBuilding(TARGET, objs)
11 changes: 11 additions & 0 deletions bsp/gd32/gd32205/applications/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Import('RTT_ROOT')
Import('rtconfig')
from building import *

cwd = os.path.join(str(Dir('#')), 'applications')
src = Glob('*.c')
CPPPATH = [cwd, str(Dir('#'))]

group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)

Return('group')
29 changes: 29 additions & 0 deletions bsp/gd32/gd32205/applications/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-09-21 iysheng the first version
*/

#include <stdio.h>
#include <rtthread.h>
#include "rtdevice.h"

/* HEART PIN is GPIOB_15 */
#define HEART_PIN 31

int main(void)
{
while(1)
{
rt_pin_write(HEART_PIN, PIN_HIGH);
rt_thread_mdelay(500);
rt_pin_write(HEART_PIN, PIN_LOW);
rt_thread_mdelay(500);
}

return 0;
}
16 changes: 16 additions & 0 deletions bsp/gd32/gd32205/drivers/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Import('RTT_ROOT')
Import('rtconfig')
from building import *

cwd = os.path.join(str(Dir('#')), 'drivers')

# add the general drivers.
src = Split("""
board.c
""")

CPPPATH = [cwd]

group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)

Return('group')
89 changes: 89 additions & 0 deletions bsp/gd32/gd32205/drivers/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2009-01-05 Bernard first implementation
*/
#include <stdint.h>
#include <rthw.h>
#include <rtthread.h>

#include <gd32f20x.h>
#include <board.h>
#include <drv_usart.h>

/**
* @brief This function is executed in case of error occurrence.
* @param None
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler */
/* User can add his own implementation to report the HAL error return state */
while (1)
{
}
/* USER CODE END Error_Handler */
}

/** System Clock Configuration
*/
void SystemClock_Config(void)
{
SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
NVIC_SetPriority(SysTick_IRQn, 0);
}

/**
* This is the timer interrupt service routine.
*
*/
void SysTick_Handler(void)
{
/* enter interrupt */
rt_interrupt_enter();

rt_tick_increase();

/* leave interrupt */
rt_interrupt_leave();
}

char heap[1024 *16];
/**
* This function will initial GD32 board.
*/
void rt_hw_board_init()
{
/* NVIC Configuration */
#define NVIC_VTOR_MASK 0x3FFFFF80
#ifdef VECT_TAB_RAM
/* Set the Vector Table base location at 0x10000000 */
SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
#else /* VECT_TAB_FLASH */
/* Set the Vector Table base location at 0x08000000 */
SCB->VTOR = (0x08000000 & NVIC_VTOR_MASK);
#endif

SystemClock_Config();
#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif

#ifdef RT_USING_CONSOLE
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif

#ifdef BSP_USING_SDRAM
rt_system_heap_init((void *)EXT_SDRAM_BEGIN, (void *)EXT_SDRAM_END);
#else
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
#endif

}

/*@}*/
47 changes: 47 additions & 0 deletions bsp/gd32/gd32205/drivers/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2009-09-22 Bernard add board.h to this bsp
* 2021-09-21 iysheng modify to suite with gd32f2xx chip
*/

// <<< Use Configuration Wizard in Context Menu >>>
#ifndef __BOARD_H__
#define __BOARD_H__

#include <gd32f20x.h>

#define EXT_SDRAM_BEGIN (0xC0000000U) /* the begining address of external SDRAM */
#define EXT_SDRAM_END (EXT_SDRAM_BEGIN + (32U * 1024 * 1024)) /* the end address of external SDRAM */

// <o> Internal SRAM memory size[Kbytes] <128-256>
// <i>Default: 256
#ifdef __ICCARM__
// Use *.icf ram symbal, to avoid hardcode.
extern char __ICFEDIT_region_RAM_end__;
#define GD32_SRAM_END &__ICFEDIT_region_RAM_end__
#else
#define GD32_SRAM_SIZE 256
#define GD32_SRAM_END (0x20000000 + GD32_SRAM_SIZE * 1024)
#endif

#ifdef __CC_ARM
extern int Image$$RW_IRAM1$$ZI$$Limit;
#define HEAP_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
#elif __ICCARM__
#pragma section="HEAP"
#define HEAP_BEGIN (__segment_end("HEAP"))
#else
extern int __bss_end;
#define HEAP_BEGIN (&__bss_end)
#endif

#define HEAP_END GD32_SRAM_END

#endif

//*** <<< end of configuration section >>> ***
Loading