/* Configure the RTT to generate an alarm at the given time. alarm happens when CRTV value equals ALMV+1, so RTT_AR should be alarmtime - 1. if you want to get alarm when rtt hit 0 , ALMV should be set to 0xFFFFFFFF.  */
uint32_t rtt_write_alarm_time(Rtt *p_rtt, uint32_t ul_alarm_time)
/* Configure the RTT to generate an alarm at the given time. alarm happens when CRTV value equals ALMV+1, so RTT_AR should be alarmtime - 1. if you want to get alarm when rtt hit 0 , ALMV should be set to 0xFFFFFFFF.  */
uint32_t rtt_write_alarm_time(Rtt *p_rtt, uint32_t ul_alarm_time)
{
	uint32_t flag;
	flag = p_rtt->RTT_MR & RTT_MR_ALMIEN;
	rtt_disable_interrupt(RTT, RTT_MR_ALMIEN);
	if(ul_alarm_time == 0) {
		p_rtt->RTT_AR = 0xFFFFFFFF;
	}
	else {
		p_rtt->RTT_AR = ul_alarm_time - 1;
	}
	if (flag) {
		rtt_enable_interrupt(RTT, RTT_MR_ALMIEN);
	}
	return 0;
}