[BSP][NUCLEI] Format application and board source code

Signed-off-by: Huaqi Fang <578567190@qq.com>
This commit is contained in:
Huaqi Fang 2020-04-15 12:38:04 +08:00
parent b432308b20
commit 8fd31727bc
4 changed files with 40 additions and 21 deletions

View File

@ -47,13 +47,16 @@ GDB = rtconfig.GDB
# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT)
bsp_library_type = 'gd32vf103'
bsp_library_type = rtconfig.NUCLEI_SDK_SOC
rtconfig.BSP_LIBRARY_TYPE = bsp_library_type
openocd_cfg = rtconfig.NUCLEI_SDK_OPENOCD_CFG.replace('\\', '/')
# include hal drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, bsp_library_type, 'HAL_Drivers', 'SConscript')))
hal_sconscript = os.path.join(libraries_path_prefix, bsp_library_type, 'HAL_Drivers', 'SConscript')
if os.path.isfile(hal_sconscript):
objs.extend(SConscript(hal_sconscript))
# make a building
DoBuilding(TARGET, objs)

View File

@ -1,11 +1,11 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-07-23 tyustli first version
* 2020-04-15 hqfang first version
*/
#include <rtthread.h>
@ -28,12 +28,14 @@ static void thread_entry(void *parameter)
{
rt_uint32_t count = 0;
while (1) {
while (1)
{
#ifdef APP_DEBUG_PRINT
rt_kprintf("thread %d count: %d\n", (rt_uint32_t)parameter, count++);
#endif
rt_thread_mdelay(500);
if ((rt_uint32_t)parameter < (LEDn-1)) {
if ((rt_uint32_t)parameter < (LEDn - 1))
{
gd_rvstar_led_toggle((rt_uint32_t)parameter);
}
}
@ -45,17 +47,19 @@ int create_thread_demo(void)
int i;
static char tname[9] = "thread";
for (i = 0; i < THREAD_NUM; i ++) {
for (i = 0; i < THREAD_NUM; i ++)
{
/* Create static threads */
tname[6] = i/10 + '0';
tname[7] = i%10 + '0';
tname[6] = i / 10 + '0';
tname[7] = i % 10 + '0';
tname[8] = '\0';
rt_thread_init(&tid[i], tname, thread_entry, (void *)i, thread_stack[i],
THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE);
}
/* Startup threads */
for (i = 0; i < THREAD_NUM; i ++) {
for (i = 0; i < THREAD_NUM; i ++)
{
rt_thread_startup(&tid[i]);
}
@ -67,12 +71,14 @@ int main(void)
rt_uint32_t count = 0;
create_thread_demo();
for (int i = 0; i < LEDn; i ++) {
for (int i = 0; i < LEDn; i ++)
{
gd_rvstar_led_init(i);
}
while (1) {
while (1)
{
#ifdef APP_DEBUG_PRINT
rt_kprintf("Main thread count: %d\n", count++);
#endif

View File

@ -5,37 +5,47 @@
*
* Change Logs:
* Date Author Notes
* 2020-04-02 Huaqi Fang first version
* 2020-04-02 hqfang first version
*
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "board.h"
#include "cpuport.h"
#ifdef RT_USING_SERIAL
#include <drv_usart.h>
#include <drv_usart.h>
#endif
/** _end symbol defined in linker script of Nuclei SDK */
extern void *_end;
/** _heap_end symbol defined in linker script of Nuclei SDK */
extern void *_heap_end;
#define HEAP_BEGIN &_end
#define HEAP_END &_heap_end
/*
* - Implemented and defined in Nuclei SDK system_<Device>.c file
* - Required macro NUCLEI_BANNER set to 0
*/
extern void _init(void);
extern void vPortSetupTimerInterrupt(void);
/**
* @brief Setup hardware board for rt-thread
*
*/
void rt_hw_board_init(void)
{
/* OS Tick Configuration */
vPortSetupTimerInterrupt();
rt_hw_ticksetup();
#ifdef RT_USING_HEAP
rt_system_heap_init((void *) HEAP_BEGIN, (void *) HEAP_END);
#endif
_init(); // __libc_init_array is not used
_init(); // __libc_init_array is not used in RT-Thread
/* USART driver initialization is open by default */
#ifdef RT_USING_SERIAL

View File

@ -5,7 +5,7 @@
*
* Change Logs:
* Date Author Notes
* 2020-04-02 Huaqi Fang first version
* 2020-04-02 hqfang first version
*
*/