refactor(vd960Loop): 算法回退到 DLD154V4B,四通道适配
- 用 DLD154V4B vd1_task/per_channel 替换 vds_task 复杂算法
- 移除 FUNCTION_B/二次判断/快速变化/多重确认等增强特性
- 保留平坦性离开算法 (CN200910309382),每通道独立状态
- 灵敏度表改为 DLD154V4B 4级: {216,108,36,10} / {108,72,18,9}
- 清理废弃类型: FltHistoryManager, Loop_ACS_Info, StageRangeConfig 等
- 首次添加 vd960DBN 完整源码
This commit is contained in:
140
vd960DBN/BLE/HAL/KEY.c
Normal file
140
vd960DBN/BLE/HAL/KEY.c
Normal file
@@ -0,0 +1,140 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : KEY.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2022/01/18
|
||||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* Header file contains */
|
||||
#include "HAL.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
**************************************************************************************************/
|
||||
|
||||
static uint8_t halKeySavedKeys; /* Keep the last state of the button to query whether there is a key value change */
|
||||
|
||||
/**************************************************************************************************
|
||||
* 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;
|
||||
|
||||
RCC_APB2PeriphClockCmd(KEY1_PCENR, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = KEY1_BV;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
||||
GPIO_Init(KEY1_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
/**************************************************************************************************
|
||||
* @fn HalKeyConfig
|
||||
*
|
||||
* @brief Configure the Key serivce
|
||||
*
|
||||
* @param cback - pointer to the CallBack function
|
||||
*
|
||||
* @return None
|
||||
**************************************************************************************************/
|
||||
void HalKeyConfig(halKeyCBack_t cback)
|
||||
{
|
||||
/* Register the callback fucntion */
|
||||
pHalKeyProcessFunction = cback;
|
||||
tmos_start_task(halTaskID, HAL_KEY_EVENT, HAL_KEY_POLLING_VALUE); /* Kick off polling */
|
||||
}
|
||||
|
||||
/**************************************************************************************************
|
||||
* @fn HalKeyRead
|
||||
*
|
||||
* @brief Read the current value of a key
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return keys - current keys status
|
||||
**************************************************************************************************/
|
||||
uint8_t HalKeyRead(void)
|
||||
{
|
||||
uint8_t keys = 0;
|
||||
|
||||
if(HAL_PUSH_BUTTON1())
|
||||
{ //Read button 1
|
||||
keys |= HAL_KEY_SW_1;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON2())
|
||||
{ //Read button 1
|
||||
keys |= HAL_KEY_SW_2;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON3())
|
||||
{ //Read button 1
|
||||
keys |= HAL_KEY_SW_3;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON4())
|
||||
{ //Read button 1
|
||||
keys |= HAL_KEY_SW_4;
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
/**************************************************************************************************
|
||||
* @fn HAL_KeyPoll
|
||||
*
|
||||
* @brief Called by hal_driver to poll the keys
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
**************************************************************************************************/
|
||||
void HAL_KeyPoll(void)
|
||||
{
|
||||
uint8_t keys = 0;
|
||||
if(HAL_PUSH_BUTTON1())
|
||||
{
|
||||
keys |= HAL_KEY_SW_1;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON2())
|
||||
{
|
||||
keys |= HAL_KEY_SW_2;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON3())
|
||||
{
|
||||
keys |= HAL_KEY_SW_3;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON4())
|
||||
{
|
||||
keys |= HAL_KEY_SW_4;
|
||||
}
|
||||
if(keys == halKeySavedKeys)
|
||||
{ /* Exit - since no keys have changed */
|
||||
return;
|
||||
}
|
||||
halKeySavedKeys = keys; /* Store the current keys for comparation next time */
|
||||
/* Invoke Callback if new keys were depressed */
|
||||
if(keys && (pHalKeyProcessFunction))
|
||||
{
|
||||
(pHalKeyProcessFunction)(keys);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************** endfile @ key ******************************/
|
||||
Reference in New Issue
Block a user