打印
[RTOS]

AT32F413 rt thread nano版demo

[复制链接]
955|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
muyichuan2012|  楼主 | 2021-1-11 18:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 muyichuan2012 于 2021-1-11 18:21 编辑

AT32F413  rt thread nano版demo

/*
* Copyright (c) 2006-2019, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date           Author       Notes
* 2020-05-12     shelton      First edition
*/

#include "at32f4xx.h"
#include <rtthread.h>

#define LED2_PIN  GPIO_Pins_2
#define LED2_PORT GPIOC
#define LED3_PIN  GPIO_Pins_3
#define LED3_PORT GPIOC
#define LED4_PIN  GPIO_Pins_5
#define LED4_PORT GPIOC

void AT32_LED_Init(void);

int main(void)
{
  AT32_LED_Init();

  while (1)
  {
    GPIO_ResetBits(LED2_PORT, LED2_PIN);
    rt_thread_mdelay(200);
    GPIO_ResetBits(LED3_PORT, LED3_PIN);
    rt_thread_mdelay(200);
    GPIO_ResetBits(LED4_PORT, LED4_PIN);
    rt_thread_mdelay(200);
    GPIO_SetBits(LED2_PORT, LED2_PIN);
    rt_thread_mdelay(200);
    GPIO_SetBits(LED3_PORT, LED3_PIN);
    rt_thread_mdelay(200);
    GPIO_SetBits(LED4_PORT, LED4_PIN);
    rt_thread_mdelay(200);
  }
}

void AT32_LED_Init(void)
{
  GPIO_InitType GPIO_InitStructure;
  /*Enable the LED Clock*/
  RCC_APB2PeriphClockCmd(RCC_APB2PERIPH_GPIOC, ENABLE);

  /*Configure the LED pin as ouput push-pull*/
  GPIO_StructInit(&GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Pins = LED2_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT_PP;                  
  GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;       
  GPIO_Init(LED2_PORT, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pins = LED3_PIN;
  GPIO_Init(LED3_PORT, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pins = LED4_PIN;
  GPIO_Init(LED4_PORT, &GPIO_InitStructure);
}


rt-thread-nano.zip

4.21 MB

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

189

主题

1864

帖子

28

粉丝