【上海航芯 ACM32F070开发板+触控功能评估板测评】移植RT-Thread Nano
[复制链接]
【上海航芯 ACM32F070开发板+触控功能评估板测评】移植RT-Thread Nano
为了更好的方便大家,同时方便自己,按照我的习惯,放上我的Github地址: ,大家需要的可以自取。
一、创建工程
我自己首先按照官方的GPIO例程,复制出一个单独的例程,官方的文件管理还是做的比较到位,在国产厂商里面。很快就移植好了单独的工程文件。
官方的所有相关的文件都在Core_Drivers中,并且已经在里面分类好了。
二、移植RT-Thread Nano
首先,大家安装RT-Thread Nano的MDK包:https://www.rt-thread.org/download/mdk/RealThread.RT-Thread.3.1.5.pack 。安装后,在工程中添加就可以。
然后,我们把System_ACM32F0x0.c的 异常处理函数 HardFault_Handler()和SysTick_Handler()注释掉,再将SysTick_Handler放在board.c中。
/*********************************************************************************
* Function : HardFault_Handler
* Description : Hard Fault handle, while(1) loop, wait for debug
* Input : none
* Output : none
* Author : xwl
**********************************************************************************/
//void HardFault_Handler(void)
//{
// while(1);
//}
void (*SysTick_Handler_Callback)(void);//SystickÖD¶Ï»Øμ÷oˉêyÖ¸Õë
/*********************************************************************************
* Function : SysTick_Handler
* Description : System tick handler
* Input : none
* Output : none
* Author : Chris_Kyle
**********************************************************************************/
//void SysTick_Handler(void)
//{
// gu32_SystemCount++;
// if(SysTick_Handler_Callback != NULL)
// {
// SysTick_Handler_Callback();
// }
//}
void rt_os_tick_callback(void)
{
rt_interrupt_enter();
rt_tick_increase();
rt_interrupt_leave();
}
/* System count in SysTick_Handler */
extern volatile uint32_t gu32_SystemCount;
void SysTick_Handler(void)
{
gu32_SystemCount++;
rt_os_tick_callback();
}
/**
* This function will initial your board.
*/
void rt_hw_board_init(void)
{
/*
* TODO 1: OS Tick Configuration
* Enable the hardware timer and call the rt_os_tick_callback function
* periodically with the frequency RT_TICK_PER_SECOND.
*/
System_Init();
/* Call components board initial (use INIT_BOARD_EXPORT()) */
#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
#endif
}
main.c
#include "ACM32Fxx_HAL.h"
#include <rtthread.h>
int main(void)
{
System_Init();
GPIO_InitTypeDef GPIOD_Handle;
GPIOD_Handle.Pin = GPIO_PIN_3;
GPIOD_Handle.Mode = GPIO_MODE_OUTPUT_PP;
GPIOD_Handle.Pull = GPIO_PULLUP;
GPIOD_Handle.Alternate = GPIO_FUNCTION_0;
HAL_GPIO_Init(GPIOD, &GPIOD_Handle);
while (1)
{
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_SET);
rt_thread_mdelay(500);
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_CLEAR);
rt_thread_mdelay(500);
}
}
工程大家可以看Github中,里面都有,移植起来也没有遇到什么问题。
三、效果
|