分类: 嵌入式
2010-11-17 15:55:32
今天整理一下按键驱动开发步骤, 采用Zilog CPU
1.用宏定义好input output GPIO口线的mask, 首先对口线进行初始化.初始化步骤如下:
//step1: Configure the GPIO0s as the universal IO Pin //step2: Configure the Input Pin //step3: Configure the Output Pin, and OutPut low //step4: Configure input pins' interrupt //Step4.1: Clear the input GPIO0s Pin's interrupt //Step4.2: Clear Interrupt Pending Flop //Step4.3: Configure as A channel Interrupt //Step4.4: Configure GPIO0s as Level trigger Interrupt //Step4.5: Configure GPIO0s as Falling Interrupt //Step5: Init global variables //Step6: Set GPIO interrup handler and init timer event //Step7: Enable Input pins' Interrupt //Step8: Enable the GPIO0A Interrupt Control PS:中断口都作为Input, output口线要配置电平.2.初始化后, 编写Step6中的Interrupt handler.
//Step1: Disable Gpio interrupt //Step2: init variable. //Step3: Start timer event, every 20ms do a scan. //Step4: clear interrupt pending.3.很重要的一步:用20ms中断定时器事件进行键值扫描.