蓝桥嵌入式Led配置

  1. cube32中,PC8-PC15 PD2设置为 Output ,High_level,push-pull(推挽模式)

  2. led_app.c 底层
    void led_disp(uint8_t *ucLed)
    {
    uint8_t temp = 0x00;
    static uint8_t temp_old = 0xff;

    for(int i = 0;i < 8;i++)
    {
    temp |= (ucLed[i] << (7-i));
    }

    if(temp != temp_old)
    {
    GPIOC -> ODR &= 0x00ff;
    GPIOC -> ODR |= ~(temp << 8);
    GPIOD -> BSRR |= 0x01 << 2;
    GPIOD -> BRR |= 0x01 << 2;
    temp_old = temp;
    }

    }

  3. 逻辑层
    void led_proc(void)
    {
    led_disp(ucLed);
    }