key_obj?input_key[CLICK_KEY_NUM]; __attribute__((section(".highcode"))) uint8_t?key1_read(void) { ????return?IN1_READ(); } __attribute__((section(".highcode"))) uint8_t?key2_read(void) { ????return?IN1_READ(); } __attribute__((section(".highcode"))) uint8_t?key3_read(void) { ????return?IN1_READ(); } __attribute__((section(".highcode"))) uint8_t?key4_read(void) { ????return?IN1_READ(); } __attribute__((section(".highcode"))) uint8_t?key5_read(void) { ????return?IN1_READ(); } void?*key_read_func[CLICK_KEY_NUM]?=?{key1_read,key2_read,key3_read,key4_read,key5_read}; static?void?key_obj_init(key_obj?*obj,?uint8_t?key_cnt) { ????uint8_t?i; ????for(i?=?0;?i?<?key_cnt;?i?++) ????{ ????????(*(obj?+?i)).act_level?=?ACTIVE_LEVEL_HIGH; ????????(*(obj?+?i)).cnts?=?0; ????????(*(obj?+?i)).code?=?CODE_NONE; ????????(*(obj?+?i)).cur_status?=?0; ????????(*(obj?+?i)).key_read?=?key_read_func[i]; ????} }
中斷讀取
__attribute__((section(".highcode"))) void?button_obj_handle(key_obj?*obj,?uint8_t?key_cnt) { ????uint8_t?i; ????for(i?=?0;?i?<?key_cnt;?i?++) ????{ ????????if((*(obj?+?i)).cur_status?==?0) ????????{ ????????????if(((*(obj?+?i)).key_read)?==?(*(obj?+?i)).act_level) ????????????{ ????????????????(*(obj?+?i)).cur_status?=?1; ????????????} ????????} ????????else?if((*(obj?+?i)).cur_status?==?1) ????????{ ????????????if(((*(obj?+?i)).key_read)?==?(*(obj?+?i)).act_level) ????????????{ ????????????????(*(obj?+?i)).cur_status?=?2; ????????????} ????????????else ????????????{ ????????????????(*(obj?+?i)).cur_status?=?0; ????????????} ????????????(*(obj?+?i)).cnts?=?0; ????????} ????} }
十幾測試讀不到正確的電平,不清楚是不是編譯器或者語法問題
熱門產(chǎn)品 :
CH394: 以太網(wǎng)協(xié)議棧芯片