【Description】
在开机按power key的时候,kbd task尚未起来,没有办法调用keypad driver的function获取key的status(press/release)。
【Analyse】
既然有压key,状态寄存器是有变化的,可以通过读取寄存器状态,确认key是否被按下。
(1)通过codegen.dws获取key的ROW no和COLUMN no。
(2)阅读datasheet keypad scanner章节,keypad matrix获取key number。
(3)获取状态寄存器信息,通过key number确认key的状态寄存器地址:
keypad scanner默认有5个reg:kp+0004h,kp+0008h,kp+000ch,kp+00010h,kp+0014h
KP base请查阅SW reg_base_mt62xx.h文件,#KP_BASE宏定义
【Solution】
举例:
MT6250平台,在开机阶段确认power key+# key都被按下了。
kal_bool Is_Press_PowerAndPound()
{
kal_bool pound_key_status ;
kal_bool power_key_status ;
kal_uint16 kbd_mem1 = *(volatile kal_uint16 *)(0xA00D0004);
kal_uint16 kbd_mem2 = *(volatile kal_uint16 *)(0xA00D0008);
kal_uint16 kbd_mem3 = *(volatile kal_uint16 *)(0xA00D000C);
kal_uint16 kbd_mem4 = *(volatile kal_uint16 *)(0xA00D0010);
kal_uint16 kbd_mem5 = *(volatile kal_uint16 *)(0xA00D0014);
kal_uint16 powekey_mem = *(volatile kal_uint16 *)(0xa0730f00);//50 powerkey寄存器较特殊
if( !(kbd_mem4 & 0x0002) )
{
dbg_print("pound key is pressed!\r\n");
pound_key_status = KeyPressed;
}
else
{
dbg_print("pound key is released!\r\n");
pound_key_status = KeyReleased;
}
if (!powekey_mem)
{
dbg_print("power key is pressed!\r\n");
power_key_status = KeyPressed;
}
else
{
dbg_print("power key is released!\r\n");
power_key_status = KeyReleased;
}
if((!pound_key_status) && (!power_key_status))
{
return KAL_TRUE;
}
else
{
return KAL_FALSE;
}
}
请将此函数加在application_Initialize函数中systemInitializeResource()之前。