968|4

5097

帖子

3

TA的资源

版主

 

【国民技术N32WB031_STB开发板评测】创建MDK模版 [复制链接]

 

1、下载pack包,【国民技术N32WB031_STB开发板评测】资源的下载 - RF/无线 - 电子工程世界-论坛 (eeworld.com.cn)

2、解压SDK后,我们双击安装Pack包:

image.png   3、安装的话一路Nexct就行了。

4、新建一个template文件夹,用来创建我们以后的工程:

image.png

5、拷贝SDK中的firmware、bsp文件到模版目录:

  1682601295083.png   image.png 6、新建APP用于存放man.c,新建MDK用于保存mdk的输出文件、工程文件等:

image.png  

  7、在MDK目录下面新建文件夹bin、Listings、Objects分别用来存放bin或者hex固件、链接文件、编译的中间文件

image.png

8、打开MDK,新建工程到template的MDK文件夹下:

image.png  

1682601898125.png  

image.png   9、按下图添加启动汇编文件startup_n32wb03x.s,如下图所示:

1682602137665.png   10、新建CMSIS,并添加system_n32wb03x.c

image.png  

  11、新建FWLB用于存官方驱动,添加misc.c、n32wb03x_gpio.c、n32wb03x_rcc.c、n32wb03x_usart.c

image.png  

12、新建DOC用于存放readme.txt记录日志等。新建bsp把log.c加入进来,新建APP用来存放main.c

image.png   目录与文件大致如下图:

image.png

13、添加头文件:

  image.png   14、添加rebuild输出 :fromelf --bin --output=.\bin\N32WB03.bin .\Objects\N32WB03_Template.axf

image.png   15、添加宏定义:N32WB03X, USE_STDPERIPH_DRIVER, USE_FULL_ASSERT

image.png   17、编译一下,没有报错:

image.png  到些模块就建好了。

18、添加测试代码:

#include "main.h"
#include <stdio.h>
#include <stdint.h>


int main(void)
{

    LedInit(LED1_PORT, LED1_PIN);
    LedInit(LED2_PORT, LED2_PIN);
    

    LedOn(LED1_PORT, LED1_PIN);
    LedOn(LED2_PORT, LED2_PIN);

    while (1)
    {
        LedBlink(LED1_PORT, LED1_PIN);


        LedOff(LED2_PORT, LED2_PIN);

        Delay(0x28FFFF);


        LedOn(LED2_PORT, LED2_PIN);

        Delay(0x28FFFF);

    }
}


/**
 * [url=home.php?mod=space&uid=159083]@brief[/url] Configures LED GPIO.
 * @param GPIOx x can be A to G to select the GPIO port.
 * @param Pin This parameter can be GPIO_PIN_0~GPIO_PIN_15.
 */
void LedInit(GPIO_Module* GPIOx, uint16_t Pin)
{
    GPIO_InitType GPIO_InitStructure;

    /* Check the parameters */
    assert_param(IS_GPIO_ALL_PERIPH(GPIOx));

    /* Enable the GPIO Clock */
    if (GPIOx == GPIOA)
    {
        RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA, ENABLE);
    }
    else if (GPIOx == GPIOB)
    {
        RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOB, ENABLE);
    }
    else
    {
        return;
    }

    /* Configure the GPIO pin */
    if (Pin <= GPIO_PIN_ALL)
    {
        GPIO_InitStruct(&GPIO_InitStructure);
        GPIO_InitStructure.Pin = Pin;
        GPIO_InitStructure.GPIO_Mode = GPIO_MODE_OUTPUT_PP;
        GPIO_InitPeripheral(GPIOx, &GPIO_InitStructure);
    }
}

/**
 * @brief  Turns selected Led on.
 * @param GPIOx x can be A to G to select the GPIO port.
 * @param Pin This parameter can be GPIO_PIN_0~GPIO_PIN_15.
 */
void LedOn(GPIO_Module *GPIOx, uint16_t Pin)
{
    GPIO_SetBits(GPIOx, Pin);
}

/**
 * @brief  Turns selected Led Off.
 * @param GPIOx x can be A to G to select the GPIO port.
 * @param Pin This parameter can be GPIO_PIN_0~GPIO_PIN_15.
 */
void LedOff(GPIO_Module* GPIOx, uint16_t Pin)
{
    GPIO_ResetBits(GPIOx, Pin);
}

/**
 * @brief  Toggles the selected Led.
 * @param GPIOx x can be A to G to select the GPIO port.
 * @param Pin This parameter can be GPIO_PIN_0~GPIO_PIN_15.
 */
void LedBlink(GPIO_Module* GPIOx, uint16_t Pin)
{
    GPIO_TogglePin(GPIOx, Pin);
}




下载后,就可以看到两个LED灯在闪烁了。

此帖出自RF/无线论坛

最新回复

附图要是清楚一些就完美了  详情 回复 发表于 2023-7-20 15:01
 

回复

5097

帖子

3

TA的资源

版主

 

模版上传于此,如果有需要请下载,如果有不足之处,请大家指正。

template.zip (209.56 KB, 下载次数: 1)
此帖出自RF/无线论坛
 
 

回复

4589

帖子

4

TA的资源

版主

 

写的挺好,这个步骤就写的很详细了

此帖出自RF/无线论坛

点评

能得到版主大大的肯定,使得我更加有动力了,非常感谢!  详情 回复 发表于 2023-4-29 20:57
 
 
 

回复

5097

帖子

3

TA的资源

版主

 
led2015 发表于 2023-4-29 20:00 写的挺好,这个步骤就写的很详细了

能得到版主大大的肯定,使得我更加有动力了,非常感谢!

此帖出自RF/无线论坛
 
 
 

回复

1

帖子

0

TA的资源

一粒金砂(初级)

 
附图要是清楚一些就完美了
此帖出自RF/无线论坛
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/8 下一条
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2023 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表