Both_Way_Comm_SY8833/TP3310_Demo.si4project/Backup/hall(5574).c

166 lines
3.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
******************************************************************************
*
* @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 高电平
{
//P10 = 1;
#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
{
//P10 = 0;
#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;
//LED_On_Timer1 = 0;
Vox_TX_Timer = 0;
Hall_Sta_bk = Hall_Sta;
}
}
}
#endif