/********************************** (C) COPYRIGHT *******************************
* File Name : KEY.c
* Author : WCH
* Version : V1.0
* Date : 2014/05/12
* Descrip
tion :
*******************************************************************************/
/******************************************************************************/
/* 头文件包含 */
#include "CH57x_common.h"
#include "HAL.h"
/**************************************************************************************************
* GLOBAL VARIABLES
**************************************************************************************************/
uint8 Hal_KeyIntEnable; /* interrupt enable/disable flag */
// Registered keys task ID, initialized to NOT USED.
static uint8 registeredKeysTaskID = TASK_NO_TASK;
static uint8 halKeySavedKeys; /* 保留按键最后的状态,用于查询是否有键值变化 */
static uint8 KeyConfigFlag; /* 按键是否配置标志位 */
/**************************************************************************************************
* FUNCTIONS - Local
**************************************************************************************************/
static halKeyCBack_t pHalKeyProcessFunction; /* callback function */
/**************************************************************************************************
* @fn HAL_KeyInit
*
* @brief Initilize Key Service
*
* @param none
*
* @return None
**************************************************************************************************/
void HAL_KeyInit( void )
{
/* Initialize previous key to 0 */
halKeySavedKeys = 0;
/* Initialize callback function */
pHalKeyProcessFunction = NULL;
/* Start with key is not configured */
KeyConfigFlag = FALSE;
KEY1_DIR;
KEY1_PU;
KEY2_DIR;
KEY2_PU;
KEY3_DIR;
KEY3_PU;
KEY4_DIR;
KEY4_PU;
KEY5_DIR;
KEY5_PU;
KEY6_DIR;
KEY6_PU;
KEY7_DIR;
KEY7_PU;
KEY8_DIR;
KEY8_PU;
KEY9_DIR;
KEY9_PU;
KEY10_DIR;
KEY10_PU;
KEY11_DIR;
KEY11_PU;
KEY12_DIR;
KEY12_PU;
HalKeyConfig( HAL_KEY_INTERRUPT_ENABLE, HalKeyCallback );
}
void HAL_KEY_RegisterForKeys( tmosTaskID id )
{
registeredKeysTaskID = id;
}
/**************************************************************************************************
* @fn HalKeyConfig
*
* @brief Configure the Key serivce
*
* @param interruptEnable - TRUE/FALSE, enable/disable interrupt
* cback - pointer to the CallBack function
*
* @return None
**************************************************************************************************/
void HalKeyConfig (uint8 interruptEnable, halKeyCBack_t cback)
{
/* Enable/Disable Interrupt or */
Hal_KeyIntEnable = interr
加载更多