芯片开放社区
直播中

李勇俊

7年用户 1465经验值
私信 关注
[技术讨论]

【1024平头哥开发套件开发体验】 点灯-button(pb5)



环境建好,做第一个程序 。在改app_key_user.c程序


'''c++



1. /*


2. * Copyright (C) 2019-2020 Alibaba Group Holding Limited


3. */


4. #include


5. #include "app_main.h"


6. //#include "app_lpm.h"


7. //#include


8. #include "app_sys.h"


9.

10. #define TAG "keyusr"


11.

12. extern int wIFi_prov_method;


13.

14. typedef enum {


15.     button_id0 = 0,


16. } button_id_t;


17.

18. typedef enum {


19.     nothing = 1,


20.     network,


21. } button_event_t;


22.

23. void button_evt(int event_id, void *priv)


24. {


25.     LOGD(TAG, "button(%s)n", (char *)priv);


26.     switch (event_id) {


27.                 case network:


28.                         LOGE(TAG, "ble prov");


29.                         aos_kv_setint("wprov_method", wifi_prov_method);


30.                         if (wifi_prov_method == WIFI_PROVISION_SL_BLE) {


31.                                 printf("wifi_prov_method=WIFI_PROVISION_SL_BLEn");


32.                                 aos_kv_del("AUTH_AC_AS");


33.                                 aos_kv_del("AUTH_KEY_PAIRS");


34.                         }


35.                         app_sys_set_boot_reason(BOOT_REASON_WIFI_CONFIG);//zz


36.                         //aos_reboot();


37.                         printf("BUTTON_PRESS——LONG_DOWNn");


38. //                        //g_pwm_LED_ctx = {1, 60, PWM1_PIN, PWM1_CH, PWM1_PIN_FUNC};


39.                         app_pwm_led_control(0);


40.

41.                         break;


42.                 case nothing:


43.                         printf("BUTTON_PRESSn");


44. //                        //g_pwm_led_ctx = {1, 60, PWM1_PIN, PWM1_CH, PWM1_PIN_FUNC};


45.                         app_pwm_led_control(1);


46.

47.                         //TODO


48.                         break;


49.                 default:


50.                         break;


51.     }


52. }


53.

54. void app_button_init(void)


55. {


56.     button_init();


57.     button_add_gpio(button_id0, PB5, LOW_LEVEL);//添加gpio按键


58.

59.     button_evt_t b_tbl[] = {


60.         {


61.             .button_id  = button_id0,


62.             .event_id   = BUTTON_PRESS_UP,//1


63.             .press_time = 20,


64.         }


65.     };


66.         button_add_event(nothing, b_tbl, sizeof(b_tbl)/sizeof(button_evt_t), button_evt, "nothing");//为当前按键表参数 添加事件


67.        


68.         b_tbl[0].button_id = button_id0;


69.         b_tbl[0].event_id = BUTTON_PRESS_LONG_DOWN;//2


70.         b_tbl[0].press_time = 2000;


71.         button_add_event(network, b_tbl, sizeof(b_tbl)/sizeof(button_evt_t), button_evt, "network");//为当前按键表参数 添加事件


72. }


73.




F7编译

size of target:

  text       data       bss       dec       hex   filename

698864     5264  191980   896108    dac6c   ./Obj/lst.elf

checksum value of target:0x3D2346AF(4,323,264)

Obj/lst.elf is modified at: 2021/11/30/Öܶþ12:20:15

Executing Post Build commands ...

[INFO] Generated output files ...

----------------------------------------------------------------

                boot, 0, 0, 0x08002400,0x0000dc00, 0x08010000, boot

                misc, 0, 0, 0x08010000,0x000c0000, 0x080d0000

                prim, 1, 2, 0x080d0400,0x000efc00, 0x081c0000, prim

                imtb, 0, 0, 0x081c0000,0x00001000, 0x081c1000, imtb

                  kv, 0, 0, 0x081c1000,0x00008000, 0x081c9000

   boot,    43088 bytes

   prim,   704128 bytes

   imtb,     4096 bytes

----------------------------------------------------------------

Create wm bin files

generate normal image completed.

generate normal image completed.

compress binary completed.

generate compressed image completed.

generate normal image completed.

Done

====0 error(s), 0 warning(s), total time :28s849ms====



com口


CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC[   0.000]INIT Build:Nov 302021,12:02:58

[  0.310]INIT find 5 partitions

[  0.660]bt_hci_h4 bt_w800_register

[  0.680]bt_hci_h4 h4_hal_init

[  0.700]app


[  0.910get_free_info_id]<, D26>, ch app_net0

,tart net configget_free_info_id

_wifi_pair_thread36, , idx 3212


[  1.030]SL_PROV call ble config start

[  1.100]app PWM led off.

[  1.110]combo missingProductKey/ProductSecret/DeviceName/DeviceSecret/PID!



[2841.930]keyusr button(nothing)


BUTTON_PRESS

[2841.950]app PWM led on.

[2841.960]app PWM led set tobrightness 60

[2851.290]keyusr button(network)



[4230.940]keyusr ble prov

wifi_prov_method=WIFI_PROVISION_SL_BLE

BUTTON_PRESS鈥斺€擫ONG_DOWN

[4231.090]app PWM led off.






正常工作:



文章转载自:平头哥芯片开放社区 作者:lust

更多回帖

×
20
完善资料,
赚取积分