没有对应芯片手册,不知道哪些IO口可以控,测试demo

 

//sdk\apps\earphone\include\app_config.h
//////////↓↓↓↓↓↓↓↓↓↓code snippet from xwh↓↓↓↓↓↓↓↓↓↓////////////////////
#define LED0_IO IO_PORTA_01
#define LED0_ONOFF(x) do{gpio_set_pull_down(   LED0_IO, 0);\
                         gpio_set_pull_up(     LED0_IO, 0);\
                         gpio_direction_output(LED0_IO, x);}while(0)
#define LED1_IO IO_PORTA_02
#define LED1_ONOFF(x) do{gpio_set_pull_down(   LED1_IO, 0);\
                         gpio_set_pull_up(     LED1_IO, 0);\
                         gpio_direction_output(LED1_IO, x);}while(0)
#define LED2_IO IO_PORTA_03
#define LED2_ONOFF(x) do{gpio_set_pull_down(   LED2_IO, 0);\
                         gpio_set_pull_up(     LED2_IO, 0);\
                         gpio_direction_output(LED2_IO, x);}while(0)
//////////↑↑↑↑↑↑↑↑↑↑code snippet from xwh↑↑↑↑↑↑↑↑↑↑////////////////////

//sdk\apps\earphone\include\app_main.h
typedef struct _APP_VAR {
//...
    //////////↓↓↓↓↓↓↓↓↓↓code snippet from xwh↓↓↓↓↓↓↓↓↓↓////////////////////
    u8 mutex_var0;
    u8 led0_flash;
    u8 led1_flash;
    u8 led2_flash;
    //////////↑↑↑↑↑↑↑↑↑↑code snippet from xwh↑↑↑↑↑↑↑↑↑↑////////////////////
} APP_VAR;

//sdk\apps\earphone\board\br36\board_ac700n_demo.c
//////////↓↓↓↓↓↓↓↓↓↓code snippet from xwh↓↓↓↓↓↓↓↓↓↓////////////////////
#include "app_main.h"
void delay_execute_func(void*priv)
{
    static unsigned char cnt0;cnt0++;cnt0%=2;
    if(app_var.led0_flash)
    {
        printfbl("cnt0:%d\n",cnt0);
        LED0_ONOFF(cnt0);
    }
    if(app_var.led1_flash)
    {
        printfbl("cnt0:%d\n",cnt0);
        LED1_ONOFF(cnt0);
    }
    if(app_var.led2_flash)
    {
        printfbl("cnt0:%d\n",cnt0);
        LED2_ONOFF(cnt0);
    }
    printfr("led0_flash:%d,led1_flash:%d,led2_flash:%d\n",app_var.led0_flash,app_var.led1_flash,app_var.led2_flash);
}
//////////↑↑↑↑↑↑↑↑↑↑code snippet from xwh↑↑↑↑↑↑↑↑↑↑////////////////////
void board_init()
{
//...
//////////↓↓↓↓↓↓↓↓↓↓code snippet from xwh↓↓↓↓↓↓↓↓↓↓////////////////////
    u16 timer_id=0;
    if(!timer_id)
    {
        timer_id=sys_timer_add(NULL,delay_execute_func,1500);
        printf("bg color 底色\n");
        for(u8 i=40;i<48;i++)
        {
            //font
            printf("\e[%dm                                                                   %d\e[0m不加粗\n",i,i);
            printf("\e[1;%dm                                                                   %d\e[0m  加粗\n",i,i);
        }
    }
//////////↑↑↑↑↑↑↑↑↑↑code snippet from xwh↑↑↑↑↑↑↑↑↑↑////////////////////
}

//sdk\apps\earphone\key_event_deal.c
//////////↓↓↓↓↓↓↓↓↓↓code snippet from xwh↓↓↓↓↓↓↓↓↓↓////////////////////
#include "asm/pwm_led.h"
u8 key_value_bak;
void delay_change_led_mode(void *priv)
{
    static unsigned char pwmled_mode=PWM_LED_MODE_START;
    if(pwmled_mode>=PWM_LED_MODE_END){
        pwmled_mode=PWM_LED_MODE_START;
    }
    else
    {
        if((*((u8*)priv))>=11&&(*((u8*)priv))<=20)
        {
            pwmled_mode=*((u8*)priv);
        }
        else
        {
            switch (*((u8*)priv))
            {
            case 9:
                pwmled_mode--;
                break;
            case 10:
                pwmled_mode++;
                break;
            default:
                break;
            }
        }
        printfc("pwmled_mode:%d\n",pwmled_mode);
        pwm_led_mode_set(pwmled_mode);
        app_var.mutex_var0=1;
    }
}
//////////↑↑↑↑↑↑↑↑↑↑code snippet from xwh↑↑↑↑↑↑↑↑↑↑////////////////////
int app_earphone_key_event_handler(struct sys_event *event)
{
//////////↓↓↓↓↓↓↓↓↓↓code snippet from xwh↓↓↓↓↓↓↓↓↓↓////////////////////
    key_value_bak=key->value;
    sys_timeout_add(&key_value_bak,delay_change_led_mode,100);
    // return;
    switch (key_value_bak)
    {
    case 6:
        app_var.led0_flash=!app_var.led0_flash;
        printfy("KEY 6\n");
        break;
    case 7:
        printfy("KEY 7\n");
        app_var.led1_flash=!app_var.led1_flash;
        break;
    case 8:
        printfy("KEY 8\n");
        app_var.led2_flash=!app_var.led2_flash;
        break;
    default:
        break;
    }
//////////↑↑↑↑↑↑↑↑↑↑code snippet from xwh↑↑↑↑↑↑↑↑↑↑////////////////////
//...
}

 

posted @ 2024-04-25 11:00  败人两字非傲即惰  阅读(4)  评论(0编辑  收藏  举报