[DemoCode下载]在M471KI开发板跑新版的RT-Thread Nano

RT-Thread Nano ,原来的版本是3.1.3,近期已经提供了最新版的3.1.5我们先跑一个老版本的试试
新建工程,先选中这个M471的芯片,然后在RTE里勾选一下基本内容
 具体步骤可参考我之前在另外一个单片机上的移植过程

新唐新出单片机M0A23移植RT-Thread竟然这么容易,十分钟搞定。 - - 21ic电子技术开**坛

等一通 操作完成,编译下载,串口助手就可以打印出系统的消息了

然后我升级了一下RT-Thread Nano 系统,重新编译烧录后就失败了
原来新版的RTT 重新设计了配置,现在的报错就是告诉你要分几步走,完城配置,按照几个错误提示的步骤重新配置,完成。
例如第三步的配置,我们屏蔽掉这个报错消息,然后填入相应的代码。




 M471.rar (3.44 MB)

board.c

/*

 * Copyright (c) 2006-2019, RT-Thread Development Team

 *

 * SPDX-License-Identifier: Apache-2.0

 *

 * Change Logs:

 * Date           Author       Notes

 * 2021-05-24                  the first version

 */



#include <rthw.h>

#include <rtthread.h>



#include <stdio.h>

#include <NUMicro.h>



#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)

/*

 * Please modify RT_HEAP_SIZE if you enable RT_USING_HEAP

 * the RT_HEAP_SIZE max value = (sram size - ZI size), 1024 means 1024 bytes

 */

#define RT_HEAP_SIZE (15*1024)

static rt_uint8_t rt_heap[RT_HEAP_SIZE];



RT_WEAK void *rt_heap_begin_get(void)

{

    return rt_heap;

}



RT_WEAK void *rt_heap_end_get(void)

{

    return rt_heap + RT_HEAP_SIZE;

}

#endif



void rt_os_tick_callback(void)

{

    rt_interrupt_enter();

    

    rt_tick_increase();



    rt_interrupt_leave();

}



/**

 * This function will initial your board.

 */



void SYS_Init(void)

{

    /* Unlock protected registers */

    SYS_UnlockReg();



    /* Set XT1_OUT(PF.2) and XT1_IN(PF.3) to input mode */

    PF->MODE &= ~(GPIO_MODE_MODE2_Msk | GPIO_MODE_MODE3_Msk);



    /* Enable HIRC clock (Internal RC 48 MHz) */

    CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);



    /* Wait for HIRC clock ready */

    CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);



    /* Set core clock as 96MHz from PLL */

    CLK_SetCoreClock(FREQ_96MHZ);



    /* Set PCLK0/PCLK1 to HCLK/2 */

    CLK->PCLKDIV = (CLK_PCLKDIV_APB0DIV_DIV2 | CLK_PCLKDIV_APB1DIV_DIV2);



    /* Enable UART clock */

    CLK_EnableModuleClock(UART0_MODULE);



    /* Select UART clock source from HIRC */

    CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART0SEL_HIRC, CLK_CLKDIV0_UART0(1));



    /* Update System Core Clock */

    /* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */

    SystemCoreClockUpdate();



    /*----------------------------------------------------------------------*/

    /* Init I/O Multi-function                                              */

    /*----------------------------------------------------------------------*/

    /* Set GPB multi-function pins for UART0 RXD and TXD */

    SYS->GPB_MFPH = (SYS->GPB_MFPH & ~(SYS_GPB_MFPH_PB12MFP_Msk | SYS_GPB_MFPH_PB13MFP_Msk)) |

                    (SYS_GPB_MFPH_PB12MFP_UART0_RXD | SYS_GPB_MFPH_PB13MFP_UART0_TXD);



    /* Lock protected registers */

    SYS_LockReg();

}





void rt_hw_board_init(void)

{

//#error "TODO 1: OS Tick Configuration."

    /* 

     * 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. 

     */

SYS_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

}



#ifdef RT_USING_CONSOLE



static int uart_init(void)

{

//#error "TODO 2: Enable the hardware uart and config baudrate."

        

    /* Reset UART0 */

    SYS_ResetModule(UART0_RST);



    /* Configure UART0 and set UART0 baud rate */

    UART_Open(UART0, 115200);

        

    return 0;

}

INIT_BOARD_EXPORT(uart_init);



void rt_hw_console_output(const char *str)

{

//#error "TODO 3: Output the string 'str' through the uart."

printf("%s",str);

}



#endif













finsh_port.c

/*

 * Copyright (c) 2006-2021, RT-Thread Development Team

 *

 * SPDX-License-Identifier: Apache-2.0

 *

 * Change Logs:

 * Date           Author       Notes

 */



#include <rthw.h>

#include <rtconfig.h>

#include <stdio.h>

#ifndef RT_USING_FINSH

#error Please uncomment the line <#include "finsh_config.h"> in the rtconfig.h 

#endif



#ifdef RT_USING_FINSH



RT_WEAK char rt_hw_console_getchar(void)

{

    /* Note: the initial value of ch must < 0 */

    int ch = -1;



//#error "TODO 4: Read a char from the uart and assign it to 'ch'."

                ch=getchar();

    return ch;

}



#endif /* RT_USING_FINSH */



配置选项如下

---------------------
作者:gaoyang9992006
链接:https://bbs.21ic.com/icview-3153478-1-1.html
来源:21ic.com
此文章已获得原创/原创奖标签,著作权归21ic所有,任何人未经允许禁止转载。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值