From 7b9b895838dced9fad83346b33c7af5bfc7fe858 Mon Sep 17 00:00:00 2001 From: supowang Date: Thu, 24 Oct 2019 11:36:41 +0800 Subject: [PATCH] add GD32VF103C_EVAL support --- board/GigaDevice_GD32VF103C_EVAL/.project | 11 + .../BSP/Inc/mcu_init.h | 9 + .../BSP/Inc/usart.h | 10 + .../BSP/Src/gd32vf103_it.c | 11 + .../BSP/Src/mcu_init.c | 15 + .../BSP/Src/usart.c | 28 ++ .../TOS_CONFIG/tos_config.h | 70 +++ .../eclipse/hello_world/.cproject | 438 ++++++++++++++++++ .../eclipse/hello_world/.gitignore | 1 + .../eclipse/hello_world/.project | 94 ++++ .../eclipse/hello_world/gd32vf103_libopt.h | 61 +++ .../eclipse/hello_world/link.lds | 175 +++++++ .../eclipse/hello_world/main.c | 71 +++ .../eclipse/hello_world/openocd_gdlink.cfg | 45 ++ 14 files changed, 1039 insertions(+) create mode 100644 board/GigaDevice_GD32VF103C_EVAL/.project create mode 100644 board/GigaDevice_GD32VF103C_EVAL/BSP/Inc/mcu_init.h create mode 100644 board/GigaDevice_GD32VF103C_EVAL/BSP/Inc/usart.h create mode 100644 board/GigaDevice_GD32VF103C_EVAL/BSP/Src/gd32vf103_it.c create mode 100644 board/GigaDevice_GD32VF103C_EVAL/BSP/Src/mcu_init.c create mode 100644 board/GigaDevice_GD32VF103C_EVAL/BSP/Src/usart.c create mode 100644 board/GigaDevice_GD32VF103C_EVAL/TOS_CONFIG/tos_config.h create mode 100644 board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.cproject create mode 100644 board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.gitignore create mode 100644 board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.project create mode 100644 board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/gd32vf103_libopt.h create mode 100644 board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/link.lds create mode 100644 board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/main.c create mode 100644 board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/openocd_gdlink.cfg diff --git a/board/GigaDevice_GD32VF103C_EVAL/.project b/board/GigaDevice_GD32VF103C_EVAL/.project new file mode 100644 index 00000000..87584654 --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/.project @@ -0,0 +1,11 @@ + + + GigaDevice_GD32VF103C_START + + + + + + + + diff --git a/board/GigaDevice_GD32VF103C_EVAL/BSP/Inc/mcu_init.h b/board/GigaDevice_GD32VF103C_EVAL/BSP/Inc/mcu_init.h new file mode 100644 index 00000000..7f906dd8 --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/BSP/Inc/mcu_init.h @@ -0,0 +1,9 @@ +#ifndef __MCU_INIT_H +#define __MCU_INIT_H + +#include "gd32vf103.h" +#include "usart.h" + +void board_init(); + +#endif //__MCU_INIT_H diff --git a/board/GigaDevice_GD32VF103C_EVAL/BSP/Inc/usart.h b/board/GigaDevice_GD32VF103C_EVAL/BSP/Inc/usart.h new file mode 100644 index 00000000..bb5f1594 --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/BSP/Inc/usart.h @@ -0,0 +1,10 @@ +#ifndef __USART_H +#define __USART_H + +#define USART0_GPIO_TX_PIN GPIO_PIN_9 +#define USART0_GPIO_RX_PIN GPIO_PIN_10 +#define USART0_GPIO_PORT GPIOA + +void usart0_init(int baud); + +#endif // __USART_H diff --git a/board/GigaDevice_GD32VF103C_EVAL/BSP/Src/gd32vf103_it.c b/board/GigaDevice_GD32VF103C_EVAL/BSP/Src/gd32vf103_it.c new file mode 100644 index 00000000..aa33583b --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/BSP/Src/gd32vf103_it.c @@ -0,0 +1,11 @@ +#include "tos.h" + +// systick handler +void eclic_mtip_handler() { + port_systick_config((uint32_t)k_cpu_cycle_per_tick); + if (tos_knl_is_running()) { + tos_knl_irq_enter(); + tos_tick_handler(); + tos_knl_irq_leave(); + } +} diff --git a/board/GigaDevice_GD32VF103C_EVAL/BSP/Src/mcu_init.c b/board/GigaDevice_GD32VF103C_EVAL/BSP/Src/mcu_init.c new file mode 100644 index 00000000..3bf35474 --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/BSP/Src/mcu_init.c @@ -0,0 +1,15 @@ +#include "mcu_init.h" + +void board_init() { + + SystemInit(); + + rcu_periph_clock_enable(RCU_GPIOC); + rcu_periph_clock_enable(RCU_GPIOE); + + gpio_init(GPIOC, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_0 | GPIO_PIN_2); + gpio_init(GPIOE, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_0 | GPIO_PIN_1); + + gpio_bit_reset(GPIOC, GPIO_PIN_0 | GPIO_PIN_2); + gpio_bit_reset(GPIOE, GPIO_PIN_0 | GPIO_PIN_1); +} diff --git a/board/GigaDevice_GD32VF103C_EVAL/BSP/Src/usart.c b/board/GigaDevice_GD32VF103C_EVAL/BSP/Src/usart.c new file mode 100644 index 00000000..9d6c0d6f --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/BSP/Src/usart.c @@ -0,0 +1,28 @@ +#include "gd32vf103.h" +#include "usart.h" +void usart0_init(int baud) +{ + /* enable GPIO clock */ + rcu_periph_clock_enable(RCU_GPIOA); + + /* enable USART0 clock */ + rcu_periph_clock_enable(RCU_USART0); + + /* connect port to USART0_Tx */ + gpio_init(USART0_GPIO_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, USART0_GPIO_TX_PIN); + + /* connect port to USART0_Rx */ + gpio_init(USART0_GPIO_PORT, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, USART0_GPIO_RX_PIN); + + /* USART0 configure */ + usart_deinit(USART0); + usart_baudrate_set(USART0, baud); + usart_word_length_set(USART0, USART_WL_8BIT); + usart_stop_bit_set(USART0, USART_STB_1BIT); + usart_parity_config(USART0, USART_PM_NONE); + usart_hardware_flow_rts_config(USART0, USART_RTS_DISABLE); + usart_hardware_flow_cts_config(USART0, USART_CTS_DISABLE); + usart_receive_config(USART0, USART_RECEIVE_ENABLE); + usart_transmit_config(USART0, USART_TRANSMIT_ENABLE); + usart_enable(USART0); +} diff --git a/board/GigaDevice_GD32VF103C_EVAL/TOS_CONFIG/tos_config.h b/board/GigaDevice_GD32VF103C_EVAL/TOS_CONFIG/tos_config.h new file mode 100644 index 00000000..e007b9ec --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/TOS_CONFIG/tos_config.h @@ -0,0 +1,70 @@ +#ifndef INC_TOS_CONFIG_H_ +#define INC_TOS_CONFIG_H_ + +#include "gd32vf103.h" +#include "stddef.h" + +// 配置TencentOS tiny默认支持的最大优先级数量 +#define TOS_CFG_TASK_PRIO_MAX 10u + +// 配置TencentOS tiny的内核是否开启时间片轮转 +#define TOS_CFG_ROUND_ROBIN_EN 0u + +// 配置TencentOS tiny是否校验指针合法 +#define TOS_CFG_OBJECT_VERIFY 0u + +// TencentOS tiny 事件模块功能宏 +#define TOS_CFG_EVENT_EN 1u + +// 配置TencentOS tiny是否开启动态内存模块 +#define TOS_CFG_MMHEAP_EN 1u + +// 配置TencentOS tiny动态内存池大小 +#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 8192 + +// 配置TencentOS tiny是否开启互斥锁模块 +#define TOS_CFG_MUTEX_EN 1u + +// 配置TencentOS tiny是否开启队列模块 +#define TOS_CFG_QUEUE_EN 1u + +// 配置TencentOS tiny是否开启软件定时器模块 +#define TOS_CFG_TIMER_EN 0u + +// 配置TencentOS tiny是否开启信号量模块 +#define TOS_CFG_SEM_EN 1u + +#define TOS_CFG_CPU_SYSTICK_PRIO 0xF + +#if (TOS_CFG_QUEUE_EN > 0u) +#define TOS_CFG_MSG_EN 1u +#else +#define TOS_CFG_MSG_EN 0u +#endif + +// 配置TencentOS tiny消息队列大小 +#define TOS_CFG_MSG_POOL_SIZE 10u + +// 配置TencentOS tiny空闲任务栈大小 +#define TOS_CFG_IDLE_TASK_STK_SIZE 512u + +// 配置TencentOS tiny中断栈大小 +#define TOS_CFG_IRQ_STK_SIZE 128u + +// 配置TencentOS tiny的tick频率 +#define TOS_CFG_CPU_TICK_PER_SECOND 1000u + +// 配置TencentOS tiny CPU频率 +// 除4的原因是,Bumblebee内核通过core_clk_aon四分频来更新mtime寄存器 +// 具体信息参见《Bumblebee内核简明数据手册》 +#define TOS_CFG_CPU_CLOCK (SystemCoreClock/4) + +// 配置是否将TIMER配置成函数模式 +#define TOS_CFG_TIMER_AS_PROC 1u + +#define TOS_CFG_VFS_EN 1u + +#define TOS_CFG_MMBLK_EN 1u + + +#endif /* INC_TOS_CONFIG_H_ */ diff --git a/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.cproject b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.cproject new file mode 100644 index 00000000..28693a92 --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.cproject @@ -0,0 +1,438 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.gitignore b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.gitignore new file mode 100644 index 00000000..3df573fe --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.gitignore @@ -0,0 +1 @@ +/Debug/ diff --git a/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.project b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.project new file mode 100644 index 00000000..c505a084 --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/.project @@ -0,0 +1,94 @@ + + + hello_world + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + Application + 2 + virtual:/virtual + + + GD32VF103_Firmware_Library + 2 + $%7BPARENT-4-PROJECT_LOC%7D/platform/vendor_bsp/gd/GD32VF103_Firmware_Library + + + TencentOS_tiny + 2 + virtual:/virtual + + + Application/Inc + 2 + $%7BPARENT-2-PROJECT_LOC%7D/BSP/Inc + + + Application/Src + 2 + $%7BPARENT-2-PROJECT_LOC%7D/BSP/Src + + + Application/tos_config.h + 1 + $%7BPARENT-2-PROJECT_LOC%7D/TOS_CONFIG/tos_config.h + + + TencentOS_tiny/arch + 2 + virtual:/virtual + + + TencentOS_tiny/kernel + 2 + $%7BPARENT-4-PROJECT_LOC%7D/kernel + + + TencentOS_tiny/arch/risc-v + 2 + virtual:/virtual + + + TencentOS_tiny/arch/risc-v/bumblebee + 2 + TOP_DIR/arch/risc-v/bumblebee/gcc + + + TencentOS_tiny/arch/risc-v/common + 2 + $%7BPARENT-4-PROJECT_LOC%7D/arch/risc-v/common + + + TencentOS_tiny/arch/risc-v/rv32i + 2 + TOP_DIR/arch/risc-v/rv32i/gcc + + + + + TOP_DIR + $%7BPARENT-4-PROJECT_LOC%7D + + + diff --git a/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/gd32vf103_libopt.h b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/gd32vf103_libopt.h new file mode 100644 index 00000000..875ff748 --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/gd32vf103_libopt.h @@ -0,0 +1,61 @@ +/*! + \file gd32vf103_libopt.h + \brief library optional for gd32vf103 + + \version 2019-6-5, V1.0.0, demo for GD32VF103 +*/ + +/* + Copyright (c) 2019, GigaDevice Semiconductor Inc. + + Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +OF SUCH DAMAGE. +*/ + +#ifndef GD32VF103_LIBOPT_H +#define GD32VF103_LIBOPT_H + +#include "gd32vf103_adc.h" +#include "gd32vf103_bkp.h" +#include "gd32vf103_can.h" +#include "gd32vf103_crc.h" +#include "gd32vf103_dac.h" +#include "gd32vf103_dma.h" +#include "gd32vf103_eclic.h" +#include "gd32vf103_exmc.h" +#include "gd32vf103_exti.h" +#include "gd32vf103_fmc.h" +#include "gd32vf103_gpio.h" +#include "gd32vf103_i2c.h" +#include "gd32vf103_fwdgt.h" +#include "gd32vf103_dbg.h" +#include "gd32vf103_pmu.h" +#include "gd32vf103_rcu.h" +#include "gd32vf103_rtc.h" +#include "gd32vf103_spi.h" +#include "gd32vf103_timer.h" +#include "gd32vf103_usart.h" +#include "gd32vf103_wwdgt.h" +#include "n200_func.h" + +#endif /* GD32VF103_LIBOPT_H */ diff --git a/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/link.lds b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/link.lds new file mode 100644 index 00000000..1c32e640 --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/link.lds @@ -0,0 +1,175 @@ +OUTPUT_ARCH( "riscv" ) + +ENTRY( _start ) + +MEMORY +{ + /* Run in FLASH */ + flash (rxai!w) : ORIGIN = 0x08000000, LENGTH = 128k + ram (wxa!ri) : ORIGIN = 0x20000000, LENGTH = 32K + + /* Run in RAM */ +/* flash (rxai!w) : ORIGIN = 0x20000000, LENGTH = 24k + ram (wxa!ri) : ORIGIN = 0x20006000, LENGTH = 8K +*/ +} + + +SECTIONS +{ + __stack_size = DEFINED(__stack_size) ? __stack_size : 2K; + + + .init : + { + KEEP (*(SORT_NONE(.init))) + } >flash AT>flash + + .ilalign : + { + . = ALIGN(4); + PROVIDE( _ilm_lma = . ); + } >flash AT>flash + + .ialign : + { + PROVIDE( _ilm = . ); + } >flash AT>flash + + .text : + { + *(.rodata .rodata.*) + *(.text.unlikely .text.unlikely.*) + *(.text.startup .text.startup.*) + *(.text .text.*) + *(.gnu.linkonce.t.*) + } >flash AT>flash + + .fini : + { + KEEP (*(SORT_NONE(.fini))) + } >flash AT>flash + + . = ALIGN(4); + + PROVIDE (__etext = .); + PROVIDE (_etext = .);/*0x80022c8*/ + PROVIDE (etext = .);/*0x80022c8*/ + PROVIDE( _eilm = . ); + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >flash AT>flash + + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) + PROVIDE_HIDDEN (__init_array_end = .); + } >flash AT>flash + + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) + KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >flash AT>flash + + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } >flash AT>flash + + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } >flash AT>flash + + . = ALIGN(4); + PROVIDE( _eilm = . ); + + .lalign : + { + . = ALIGN(4); + PROVIDE( _data_lma = . ); + } >flash AT>flash + + .dalign : + { + . = ALIGN(4); + PROVIDE( _data = . ); + } >ram AT>flash + + + .data : + { + *(.rdata) + + *(.gnu.linkonce.r.*) + *(.data .data.*) + *(.gnu.linkonce.d.*) + . = ALIGN(8); + PROVIDE( __global_pointer$ = . + 0x800); + *(.sdata .sdata.*) + *(.gnu.linkonce.s.*) + . = ALIGN(8); + *(.srodata.cst16) + *(.srodata.cst8) + *(.srodata.cst4) + *(.srodata.cst2) + *(.srodata .srodata.*) + } >ram AT>flash + + . = ALIGN(4); + PROVIDE( _edata = . ); + PROVIDE( edata = . ); + + PROVIDE( _fbss = . ); /*0X200052A0 0X200002A0*/ + PROVIDE( __bss_start = . ); + .bss : + { + *(.sbss*) + *(.gnu.linkonce.sb.*) + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + } >ram AT>ram + + . = ALIGN(8); + PROVIDE( _end = . ); /*0X2000,0340*/ + PROVIDE( end = . ); + + .stack ORIGIN(ram) + LENGTH(ram) - __stack_size : + { + PROVIDE( _heap_end = . ); + . = __stack_size; + PROVIDE( _sp = . ); + } >ram AT>ram +} diff --git a/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/main.c b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/main.c new file mode 100644 index 00000000..08a84995 --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/main.c @@ -0,0 +1,71 @@ +#include "mcu_init.h" +#include "tos.h" + +#define TASK_SIZE 1024 +k_task_t k_task_task1; +k_task_t k_task_task2; +uint8_t k_task1_stk[TASK_SIZE]; +uint8_t k_task2_stk[TASK_SIZE]; + +void task1(void *pdata) +{ + int task_cnt1 = 0; + while (1) { + printf("hello world from %s cnt: %d\n", __func__, task_cnt1++); + if (task_cnt1 % 2 == 0) + { + gpio_bit_write(GPIOC, GPIO_PIN_0,SET); + gpio_bit_write(GPIOC, GPIO_PIN_2,SET); + } + else + { + gpio_bit_write(GPIOC, GPIO_PIN_0,RESET); + gpio_bit_write(GPIOC, GPIO_PIN_2,RESET); + } + tos_task_delay(1000); + } +} + +void task2(void *pdata) +{ + int task_cnt2 = 0; + while (1) { + printf("hello world from %s cnt: %d\n", __func__, task_cnt2++); + if (task_cnt2 %2 == 0) + { + gpio_bit_write(GPIOE, GPIO_PIN_0,SET); + gpio_bit_write(GPIOE, GPIO_PIN_1,SET); + } + else + { + gpio_bit_write(GPIOE, GPIO_PIN_0,RESET); + gpio_bit_write(GPIOE, GPIO_PIN_1,RESET); + } + tos_task_delay(500); + } +} + + +void main(void) { + board_init(); + + usart0_init(115200); + + tos_knl_init(); + + tos_task_create(&k_task_task1, "task1", task1, NULL, 3, k_task1_stk, TASK_SIZE, 0); + tos_task_create(&k_task_task2, "task2", task2, NULL, 3, k_task2_stk, TASK_SIZE, 0); + + tos_knl_start(); + +} + + +int _put_char(int ch) +{ + usart_data_transmit(USART0, (uint8_t) ch ); + while (usart_flag_get(USART0, USART_FLAG_TBE)== RESET){ + } + + return ch; +} diff --git a/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/openocd_gdlink.cfg b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/openocd_gdlink.cfg new file mode 100644 index 00000000..3ec85d42 --- /dev/null +++ b/board/GigaDevice_GD32VF103C_EVAL/eclipse/hello_world/openocd_gdlink.cfg @@ -0,0 +1,45 @@ +adapter_khz 1000 +reset_config srst_only +adapter_nsrst_assert_width 100 + + + +interface cmsis-dap + +transport select jtag + +#autoexit true + +set _CHIPNAME riscv +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1000563d + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME riscv -chain-position $_TARGETNAME +$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 20480 -work-area-backup 0 + + +# Work-area is a space in RAM used for flash programming +if { [info exists WORKAREASIZE] } { + set _WORKAREASIZE $WORKAREASIZE +} else { + set _WORKAREASIZE 0x5000 +} + +# Allow overriding the Flash bank size +if { [info exists FLASH_SIZE] } { + set _FLASH_SIZE $FLASH_SIZE +} else { + # autodetect size + set _FLASH_SIZE 0 +} + +# flash size will be probed +set _FLASHNAME $_CHIPNAME.flash + +flash bank $_FLASHNAME gd32vf103 0x08000000 0 0 0 $_TARGETNAME +riscv set_reset_timeout_sec 1 +init + +halt + +