This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HalLedBlink问题

HalLedBlink(P0_6, 0, 50, 500);

这个算法主要的作用就是闪烁,但是第一个参数应该如何设置,我们想利用这个参数设置P0_6端口控制的灯一闪一闪的。

  • 搜一下这个函数HalLedOnOff,看看里面根据不同的if调用对应的HAL_TURN_ON_LED1,搜一下这个宏就会明白了,其实最终都是对端口直接写0或者1,实现输出低或者高

  • 该函数的说明如下

    void HalLedBlink (uint8 leds, uint8 numBlinks, uint8 percent, uint16 period) 

    /***************************************************************************************************

    * @fn HalLedBlink

    * @brief Blink the leds

    * @param leds - bit mask value of leds to be blinked

    * numBlinks - number of blinks

    * percent - the percentage in each period where the led will be on

    * period - length of each cycle in milliseconds

    * @return None

    ***************************************************************************************************/

    您还需要在hal_board_cfg.h 文件内设置IO口,如下所示

    /* 3 - Yellow */

    #define LED3_BV BV(7)

    #define LED3_SBIT P1_7

    #define LED3_DDR P1DIR

    #define LED3_POLARITY ACTIVE_HIGH