/********************************************************************************
 * @file    BTM_Complementary.c
 * @author  SOC AE Team
 * @version V1.1
 * @date    2025-06-27
 * @brief   配置BTM中断时间为500mS。
 *
 *******************************************************************************/
#include "sc32_conf.h"
#include "Function_Init.h"
#include "stdio.h"


void BTM_Base_Function(void)
{
#if defined(SC32f10xx)||defined(SC32f12xx)
	/* 使能BTM时钟 */
	RCC_APB2Cmd(ENABLE);
#endif
	
	/* BTM定时时间设置	*/
	BTM_FSConfig(BTM,BTM_FreqSelect_500MS);
	
	/* 使能BTM中断 */
	BTM_ITConfig(BTM,BTM_IT_INT,ENABLE);
	NVIC_EnableIRQ(BTM_IRQn);
	
	/* BTM外设初始化 */
	BTM_Cmd(BTM,ENABLE);

	while(1);
}

void BTM_BTMHandler(void)
{
	/* 判断BTM0中断是否置起 */
	if(BTM_GetFlagStatus(BTM,BTM_FLAG_IF) == SET)
	{
		BTM_ClearFlag(BTM,BTM_FLAG_IF);	//清除BTM0中断
		printf("The BTM interrupt is triggered every 500mS.\r\n");
	}
}
