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

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 2008|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

Nations G031源碼 點(diǎn)亮LED燈

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:1036413 發(fā)表于 2022-6-22 16:15 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
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空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 亚洲乱码一区二区 | 天天插日日操 | 免费黄色片在线观看 | 亚洲国产情侣自拍 | 成人不卡在线 | 国产一区不卡 | 国产精品亚洲综合 | 国产丝袜一区二区三区免费视频 | 午夜精品一区 | 本道综合精品 | 日韩在线一区二区三区 | 国产中文字幕在线观看 | 国产黄色精品在线观看 | 国产日韩欧美在线 | 中文字幕在线观看 | 日韩三区在线观看 | 欧美一区二区在线播放 | 欧美不卡 | 精品欧美乱码久久久久久 | 成人做爰69片免费观看 | 国产丝袜一区二区三区免费视频 | 欧美日韩一区二区三区不卡视频 | 国产精品久久久 | 日本天天操 | 亚洲精精品 | 久草热视频 | 九九久视频 | 91在线第一页| 成人国产精品久久 | 欧美成年人| av免费网站在线观看 | 一区二区三区国产 | 国产综合久久 | 神马影院一区二区三区 | 中国xxxx性xxxx产国 | 免费日韩网站 | 精品一区二区三区中文字幕 | 古装三级在线播放 | 欧美中文在线 | 国产1区2区| 精品日韩欧美一区二区 |