zoukankan      html  css  js  c++  java
  • LED操作

    灯上拉

    GPIO_InitTypeDef GPIO_InitStruct;
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);

    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
    GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStruct.GPIO_Speed =GPIO_Speed_Level_3;
    GPIO_Init(GPIOB, &GPIO_InitStruct);

    GPIO_SetBits(GPIOB, GPIO_Pin_0);

    取反:

    #define RE_LED1 GPIO_WriteBit(GPIOB, GPIO_Pin_1,(BitAction)((1-GPIO_ReadOutputDataBit(GPIOB, GPIO_Pin_1))));

    置为0或1

    #define LED1OFF {GPIOB->BSRR = GPIO_Pin_0;} //B0 = 1
    #define LED1ON {GPIOB->BRR = GPIO_Pin_0;} //B0 = 0

    /*****************************************************************************
    可置任意管脚为 1
    ******************************************************************************/
    void LED_Close(GPIO_TypeDef* GPIOx,uint16_t GPIO_Pin)
    {
    GPIO_SetBits(GPIOx, GPIO_Pin);

    }
    /*****************************************************************************
    可置任意管脚为 0
    ******************************************************************************/
    void LED_Open(GPIO_TypeDef* GPIOx,uint16_t GPIO_Pin)
    {
    GPIO_ResetBits(GPIOx, GPIO_Pin);
    }

  • 相关阅读:
    javascript实现动态侧边栏
    javascript实现图片滚动
    C语言-----野指针
    守护进程daemon.c
    UDP网络程序设计
    TCP网络程序设计
    网络编程模型
    fork和vfork
    网络协议分析
    多线程同步
  • 原文地址:https://www.cnblogs.com/luckytimor/p/5403213.html
Copyright © 2011-2022 走看看