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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1919|回復: 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
回復

使用道具 舉報

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

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 国产一区二区欧美 | 久久1区| 欧美国产精品一区二区三区 | 久久1区 | 国产剧情一区二区三区 | 国产欧美精品一区二区 | 欧美视频免费在线观看 | 欧美日韩一区在线播放 | 亚洲成人久久久 | 午夜三级网站 | 亚洲精品综合 | 亚洲欧美日本在线 | 国产九九九 | 精品视频一区二区 | 91精品国产综合久久久动漫日韩 | 久久精品久久久久久 | 亚洲国产成人精品久久久国产成人一区 | 福利久久 | 国产美女在线观看 | 99精品视频免费观看 | 日韩精品一区二区三区中文字幕 | 不卡av电影在线播放 | 亚洲欧美国产视频 | 91亚洲欧美| www.中文字幕.com | 国产一级视频在线观看 | 中文字幕日本一区二区 | 午夜视频在线 | 国产视频一区二区 | 亚洲三区在线观看 | 久久国产精品一区二区三区 | 精品国产青草久久久久96 | 日韩一二区 | 国产精品免费小视频 | 国产精品久久久久久久久久 | 激情一区 | 成人国产在线视频 | 在线视频91 | 亚洲欧美激情四射 | 日本精品久久 | 久久不卡 |