久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

帖子
查看: 2026|回復: 0
打印 上一主題 下一主題
收起左側

Nations G031源碼 點亮LED燈

[復制鏈接]
跳轉到指定樓層
樓主
ID:1036413 發表于 2022-6-22 16:15 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
LED閃爍的程序源碼:

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

/**
* @brief  Main program.
*/
int main(void)
{
    /*SystemInit() function has been called by startup file startup_n32g031.s*/

    /* Initialize Led1~Led3 as output pushpull mode*/
    LedInit(PORT_GROUP, LED1_PIN | LED2_PIN | LED3_PIN);

    /*Turn on Led1~Led3*/
    LedOn(PORT_GROUP, LED1_PIN | LED2_PIN | LED3_PIN);

    while (1)
    {
        /*LED1_PORT, LED2_PORT and LED3_PORT are the same port group.  
         *Enable Led2 blink and not effect Led1 and Led2 by Exclusive-OR operation.*/
        LedBlink(PORT_GROUP, LED2_PIN);
        LedOff(PORT_GROUP, LED3_PIN);
        /* Insert delay */
        Delay(0x28FFFF);
         LedOff(PORT_GROUP, LED1_PIN);
      Delay(0x28FFFF);


        LedOn(PORT_GROUP, LED1_PIN | LED3_PIN);

        Delay(0x28FFFF);
    }
}
void Delay(uint32_t count)
{
    for (; count > 0; count--)
        ;
}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 if (GPIOx == GPIOC)
    {
        RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOC, ENABLE);
    }
    else if (GPIOx == GPIOF)
    {
        RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOF, 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);
    }
}
void LedOn(GPIO_Module *GPIOx, uint16_t Pin)
{
    GPIO_SetBits(GPIOx, Pin);
}
void LedOff(GPIO_Module* GPIOx, uint16_t Pin)
{
    GPIO_ResetBits(GPIOx, Pin);
}void LedBlink(GPIO_Module* GPIOx, uint16_t Pin)
{
    GPIO_TogglePin(GPIOx, Pin);
}
#ifdef USE_FULL_ASSERT
void assert_failed(const uint8_t* expr, const uint8_t* file, uint32_t line)
{
    while (1)
    {
    }
}
#endif // USE_FULL_ASSERT
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 手机av在线播放 | 综合婷婷 | 欧美日本国产 | 亚洲精品一区二区在线观看 | 22精品一区二区三区 | 青久久| 国产成人片 | 我要操网站 | 欧美日韩一区二区三区四区 | 国产精品美女毛片真酒店 | 天天草天天草 | 日韩免费一区二区 | 欧美性猛交乱大交 | 黄网在线免费观看 | 看片地址 | 国产主播一区二区 | 日韩精品一区二区三区免费视频 | 国产色一区 | 日韩精品免费一区二区夜夜嗨 | 三年中文在线观看免费大全中国 | 婷久久| 一级片大全 | 国产午夜三级 | av不卡在线播放 | 天天爽天天爽 | 久久精品欧美一区二区三区不卡 | 日韩在线播放视频 | 国产亚洲欧洲 | 天天操天天干天天 | 黄色网在线 | 在线国产一区 | 亚洲福利一区 | 精品一区二区国产 | 欧美性视频在线 | 爱啪啪av | 神马午夜嘿嘿 | 欧美久久网 | 日韩黄网| 日韩专区在线观看 | 蜜桃一区二区 | 黄色在线免费观看视频 |