/* ****************************************************************************** * * @file hall.c * @brief hall module * * * @version 1.0 * @date 2022/08/04 15:00:40 * @author Alex Xu * * Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd. * All Rights Reserved * * History: * Revision Date Author Desc * 1.0.0 2022/08/04 Alex build this file ******************************************************************************/ /*_____ I N C L U D E S ____________________________________________________*/ #include "hall.h" #include "key.h" #include "led.h" #include "vox_module.h" #include "userapp.h" #include "charger_module.h" /******************************************************************************\ Macro definitions \******************************************************************************/ /******************************************************************************\ Variables definitions \******************************************************************************/ uint8_t Hall_Sta_bk = 0xff; CoverStatus_E CoverStatus; bit CoverEvent_Flg = 0; //Hall开关触发事件标志位 bit CoverEvent_Flg_led = 0; #if KEY_HALL_ENABLE /******************************************************************************\ Functions definitions \******************************************************************************/ /* ******************************************************************************* * void Hall_Init(void) * * Description : Hall Initialization * * Arguments : * Returns : * Notes : * ******************************************************************************* */ #if 0 void Hall_Init(void) { while ( !(CHIP_STA0 & 0x10) ); //Hall analog first detection complete status,hall flag valid only after this bit sets. if(CHIP_STA0 & 0x08) //获取HALL初始状态 { #if HALL_OPEN_LEV_SET CoverStatus = CLOSE; #else CoverStatus = OPEN; #endif } else { #if HALL_OPEN_LEV_SET CoverStatus = OPEN; #else CoverStatus = CLOSE; #endif } //Hall_Sta_bk = (CHIP_STA0 & 0x08); } #endif /* ******************************************************************************* * void Hall_Handle(void) * * Description : Hall Handle --- 主循环中调用,调用周期10ms。CoverStatus --- 充电仓盖子状态。 * * Arguments : NONE * Returns : NONE * Notes : NONE * ******************************************************************************* */ void Hall_Handler(void) { uint8_t Hall_Sta = 0; if( CHIP_STA0 & 0x10 ) { Hall_Sta = CHIP_STA0 & 0x08; if( Hall_Sta != Hall_Sta_bk) { if(CHIP_STA0 & 0x08) //Hall 高电平 { #if HALL_OPEN_LEV_SET CoverStatus = OPEN; #else CoverStatus = CLOSE; led_blink_1time_flag = 0; #endif #ifdef _DEBUG_HALL #if HALL_OPEN_LEV_SET printf("Open Hall Status:0x%x,sta0:0x%x\r\n",(uint16_t)CoverStatus,(uint16_t)CHIP_STA0); #else printf("Close Hall Status:0x%x\r\n",(uint16_t)CoverStatus); #endif #endif } else { #if HALL_OPEN_LEV_SET CoverStatus = CLOSE; led_blink_1time_flag = 0; #else CoverStatus = OPEN; #endif #ifdef _DEBUG_HALL #if HALL_OPEN_LEV_SET printf("Close Hall Status:0x%x,sta0:0x%x\r\n",(uint16_t)CoverStatus,(uint16_t)CHIP_STA0); #else printf("Open Hall Status:0x%x\r\n",(uint16_t)CoverStatus); #endif #endif } CoverEvent_Flg = 1; CoverEvent_Flg_led = 1; LED_On_Timer = 0; Vox_TX_Timer = 0; Hall_Sta_bk = Hall_Sta; } } } #endif