mirror of
https://gitee.com/cosyos/cosyos.git
synced 2026-10-06 04:59:34 +08:00
81 lines
2.3 KiB
Plaintext
81 lines
2.3 KiB
Plaintext
RISC-V32 之系统构建
|
|
|
|
|
|
概述
|
|
1、rv32 目前暂不支持 cube 安装,用户需手动移植。移植过程中遇到问题
|
|
可加入社区获取技术支持。
|
|
2、CosyOS for rv32,是不能启用硬件压栈功能的。
|
|
3、目前仅支持 PSP栈模式,即不存在全局唯一主栈或中断专用栈,而是当前
|
|
任务栈即为当前主栈。这导致所有中断都是入任务栈,所以中断嵌套深度
|
|
应尽量配置少一些,同时任务栈SIZE应尽量大一些,以防溢出。
|
|
|
|
|
|
构建流程
|
|
|
|
1、系统配置
|
|
CosyOS-配置 / syscfg.h -> 系统配置>>标准头文件,应首先被正确定义。
|
|
|
|
2、main函数
|
|
在main函数的末尾处,先配置 DEBUG(如果需要使用 CosyOS-任务管理器),
|
|
最后再启动 CosyOS(必须)。
|
|
|
|
3、中断
|
|
首先,所有中断函数都不能声明为硬件压栈中断,只能是软件压栈中断。
|
|
CosyOS 固定采用 SysTick_Handler 和 SW_Handler 做为系统中断。
|
|
用户需要自行在 SysTick_Handler 中调用 tCosyTick_Handler。
|
|
用户不要自行创建 SW_Handler。
|
|
|
|
在未来,用户仍需重点关注如下内容:
|
|
|
|
1、系统配置
|
|
Port / syscfg.h
|
|
|
|
2、MCU配置
|
|
Port / port_x32 / RISC-V32 / mcucfg_rv32.h
|
|
|
|
3、启动文件、ld文件配置等
|
|
|
|
|
|
例程-main
|
|
int main(void)
|
|
{
|
|
/* USER INIT CODE BEGIN */
|
|
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
|
SystemCoreClockUpdate();
|
|
Delay_Init();
|
|
////USART_Printf_Init(115200);
|
|
USART1_UART_Init (115200);
|
|
printf("SystemClk:%d\r\n",SystemCoreClock);
|
|
printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() );
|
|
printf("This is printf example\r\n");
|
|
/* USER INIT CODE END */
|
|
|
|
/* USER DEBUG CONFIG */// for CosyOS-Taskmgr
|
|
#if (SYSCFG_DEBUGGING == 1)
|
|
if(1){
|
|
void Debug_Config(void);
|
|
Debug_Config();
|
|
}// defined in demo_debug.c
|
|
#endif
|
|
|
|
/* USER 启动 CosyOS */// 在main函数的末尾处
|
|
if(1){
|
|
#if 1 // 建议前期调试时开启,如果CosyOS启动失败会返回错误码提示用户!
|
|
unsigned char _ecode = uStartCosyOS();
|
|
printf("CosyOS startup failed, error code: %d.\r\n", (int)_ecode);
|
|
#else
|
|
uStartCosyOS();
|
|
#endif
|
|
}
|
|
|
|
while(1);
|
|
}
|
|
|
|
例程-SysTick_Handler
|
|
void SysTick_Handler(void) __attribute__((interrupt));
|
|
void SysTick_Handler(void)
|
|
{
|
|
SysTick->SR = 0;
|
|
tCosyTick_Handler();
|
|
}
|