会飞的诸 fec7404506
[bsp] wch ch32v307v-r1动态初始化堆内存 (#6849)
#### 为什么提交这份PR (why to submit this PR)
- 修复ch32v307v-r1 board.h 中变量_stack_size未声明BUG
- 提供ch32v307v-r1动态堆内存分配(宏开关)代码
- ch32v307v-r1 MD文档新增烧录方式,作为烧录后无运行结果的替代方案

#### 你的解决方案是什么 (what is your solution)
- 去掉_stack_size未声明变量
- 动态分配内存堆,将堆起始地址放在.bss段结尾,堆结束地址放在.stack段开头[详情](https://club.rt-thread.org/ask/article/001065082e9ae611.html)
- 将烧录工具替换为WCH-LinkUtility

#### 在什么测试环境下测试通过 (what is the test environment)
- 开发工具: RT-Thread Studio
- 测试板卡:ch32v307v-r1评估板
- 烧录工具:WCH-LinkUtility
2023-01-13 20:50:33 -05:00

71 lines
1.6 KiB
C

/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-08-23 liYony first version
*/
#include "board.h"
#include <stdint.h>
#include "drv_usart.h"
#include <rthw.h>
#include <rtthread.h>
extern uint32_t SystemCoreClock;
static uint32_t _SysTick_Config(rt_uint32_t ticks)
{
NVIC_SetPriority(SysTicK_IRQn, 0xf0);
NVIC_SetPriority(Software_IRQn, 0xf0);
NVIC_EnableIRQ(SysTicK_IRQn);
NVIC_EnableIRQ(Software_IRQn);
SysTick->CTLR = 0;
SysTick->SR = 0;
SysTick->CNT = 0;
SysTick->CMP = ticks - 1;
SysTick->CTLR = 0xF;
return 0;
}
/**
* This function will initial your board.
*/
void rt_hw_board_init()
{
/* System Tick Configuration */
_SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
rt_system_heap_init((void *) HEAP_BEGIN, (void *) HEAP_END);
#endif
/* USART driver initialization is open by default */
#ifdef RT_USING_SERIAL
rt_hw_usart_init();
#endif
#ifdef RT_USING_CONSOLE
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
/* Call components board initial (use INIT_BOARD_EXPORT()) */
#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif
}
void SysTick_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void SysTick_Handler(void)
{
GET_INT_SP();
/* enter interrupt */
rt_interrupt_enter();
SysTick->SR = 0;
rt_tick_increase();
/* leave interrupt */
rt_interrupt_leave();
FREE_INT_SP();
}