基于2020年9月9号的CS版本r000128.1,3040新版本发布,支持ANC与游戏低延时!

qcc512x qcc302x qcc303x earbud led使用说明

发表时间:2020-02-04 15:09


qcc512x-qcc302x-qcc303x earbud led使用说明

1.LED默认情况,默认工程是一个LED,(定义的宏 HAVE_1_LED)

如下截图 MED     Project     General    DEFS

    

    

同时也可以参考如下代码

#if defined(HAVE_1_LED)


/*! The number of LEDs led_manager will control. If one LED is configured,

    it will use appConfigLed0Pio(), if two LEDs are configured it will use

    appConfigLed0Pio() and appConfigLed1Pio() etc. */

#define appConfigNumberOfLeds()   (1)


/*! PIO to control LED0 */

#define appConfigLed0Pio()       CHIP_LED_0_PIO

/*! PIO to control LED1 (not used) */

#define appConfigLed1Pio()       (0)

/*! PIO to control LED2 (not used) */

#define appConfigLed2Pio()       (0)


#elif defined(HAVE_3_LEDS)


/* The number of LEDs led_manager will control. */

#define appConfigNumberOfLeds()   (3)

/*! PIO to control LED0 */

#define appConfigLed0Pio()       CHIP_LED_0_PIO

/*! PIO to control LED1 */

#define appConfigLed1Pio()       CHIP_LED_1_PIO

/*! PIO to control LED2 */

#define appConfigLed2Pio()       CHIP_LED_2_PIO


#else

#error LED config not correctly defined.

#endif


以及LED更新显示函数



/*! \brief Update LEDs


    This function is called to update the LEDs, it checks the current LED state and

    runs through the active filters modifying the LEDs state as specified by

    the filters.

*/

static void appLedUpdate(ledTaskData *theLed)

{

    int filter;

    uint16 led_state = theLed->led_state;

    const unsigned nleds = appConfigNumberOfLeds();


    /* Run LEDs through filters */

    for (filter = 0; filter < LED_NUM_FILTERS; filter++)

    {

        ledFilter filter_func = theLed->filter[filter];

        if (filter_func)

            led_state = filter_func(led_state);

    }


    /* Update LEDs */

    switch (nleds)

    {

        /* Jump then fall-through to set the correct number of LEDS */

#ifdef LED_USE_PIOS

        case 3: PioSet32Bank(LED_2_BANK, LED_2_PIO_MASK, led_state & 0x04 ? 0 : LED_2_PIO_MASK);

        case 2: PioSet32Bank(LED_1_BANK, LED_1_PIO_MASK, led_state & 0x02 ? 0 : LED_1_PIO_MASK);

        case 1: PioSet32Bank(LED_0_BANK, LED_0_PIO_MASK, led_state & 0x01 ? 0 : LED_0_PIO_MASK);

#else

        case 3: LedConfigure(2, LED_ENABLE, led_state & 0x04 ? 1 : 0);

        case 2: LedConfigure(1, LED_ENABLE, led_state & 0x02 ? 1 : 0);

        case 1: LedConfigure(0, LED_ENABLE, led_state & 0x01 ? 1 : 0);

#endif

        default: break;

    }

}


我们可以根据实际项目情况来定义使用几个LED针对的定义宏

HAVE_3_LEDS HAVE_1_LED、也可以增加HAVE_2_LEDSHAVE_0_LED然后做相对应的修改。


根据实际项目修改

#define LED_RED      (LED_0_STATE)

#define LED_GREEN   (LED_1_STATE)

#define LED_BLUE    (LED_2_STATE)

#define LED_WHITE   (LED_0_STATE | LED_1_STATE | LED_2_STATE)

#define LED_YELLOW   (LED_RED | LED_GREEN)


以及修改对应状态的ledPattern可以参考现成的定义

const ledPattern app_led_pattern_power_on[] =

{

    LED_LOCK,

    LED_ON(LED_RED),    LED_WAIT(100),

    LED_ON(LED_GREEN),   LED_WAIT(100),

    LED_ON(LED_BLUE),   LED_WAIT(100),

    LED_OFF(LED_RED),   LED_WAIT(100),

    LED_OFF(LED_GREEN), LED_WAIT(100),

    LED_OFF(LED_BLUE),   LED_WAIT(100),

    LED_UNLOCK,

    LED_END

};


此外qcc512x-qcc302xLED可以按照之前的系列,使用LedConfigure 控制,也可以当作PIO来控制。


分享到:
联系QQ:646701628
手机号码:17150309559
联系邮箱:tws@tengtaijishu.com
联系地址:广东省深圳市龙华区民治街道彩悦大厦510B

微信号:tengtaijishu02


微信公众号:tengtaijishu