Пример #1
0
/**
 * @brief Sets the prescaler load value for the rtc.
 * @param value New prescaler load value (use 0x7fff to get 1 second period with 32.768 Hz clock).
 */
void rtc_set_prescaler_load(uint32 value) {
	rtc_wait_finished();
	rtc_enter_config_mode();
	RTC->regs->PRLH = (value >> 16) & 0xffff;
	RTC->regs->PRLL = value & 0xffff;
	rtc_exit_config_mode();
}
Пример #2
0
void rtc_set_counter_val(u32 counter_val)
{
	rtc_enter_config_mode();
	RTC_CNTH = (counter_val & 0xffff0000) >> 16; /* CNT[31:16] */
	RTC_CNTL = counter_val & 0x0000ffff;         /* CNT[15:0] */
	rtc_exit_config_mode();
}
Пример #3
0
/**
 * @brief Sets the counter value (i.e. time/date) for the rtc.
 * @param value New counter value
 */
void rtc_set_count(uint32 value) {
	rtc_wait_finished();
	rtc_enter_config_mode();
	RTC->regs->CNTH = (value >> 16) & 0xffff;
	RTC->regs->CNTL = value & 0xffff;
	rtc_exit_config_mode();
}
Пример #4
0
void rtc_set_prescale_val(u32 prescale_val)
{
	rtc_enter_config_mode();
	RTC_PRLL = prescale_val & 0x0000ffff;         /* PRL[15:0] */
	RTC_PRLH = (prescale_val & 0x000f0000) >> 16; /* PRL[19:16] */
	rtc_exit_config_mode();
}
Пример #5
0
void rtc_set_alarm_time(u32 alarm_time)
{
	rtc_enter_config_mode();
	RTC_ALRL = (alarm_time & 0x0000ffff);
	RTC_ALRH = (alarm_time & 0xffff0000) >> 16;
	rtc_exit_config_mode();
}
Пример #6
0
/**
 * @brief Sets the alarm value (i.e. time/date) for the rtc.
 * @param value New alarm value
 */
void rtc_set_alarm(uint32 value) {
	rtc_wait_finished();
	rtc_enter_config_mode();
	RTC->regs->ALRH = (value >> 16) & 0xffff;
	RTC->regs->ALRL = value & 0xffff;
	rtc_exit_config_mode();
	rtc_wait_finished();
}
Пример #7
0
void rtc_interrupt_disable(rtcflag_t flag_val)
{
	rtc_enter_config_mode();

	/* Disable the correct interrupt enable. */
	switch (flag_val) {
	case RTC_SEC:
		RTC_CRH &= ~RTC_CRH_SECIE;
		break;
	case RTC_ALR:
		RTC_CRH &= ~RTC_CRH_ALRIE;
		break;
	case RTC_OW:
		RTC_CRH &= ~RTC_CRH_OWIE;
		break;
	}

	rtc_exit_config_mode();
}
Пример #8
0
void rtc_disable_alarm(void)
{
	rtc_enter_config_mode();
	RTC_CRH &= ~RTC_CRH_ALRIE;
	rtc_exit_config_mode();
}
Пример #9
0
void rtc_enable_alarm(void)
{
	rtc_enter_config_mode();
	RTC_CRH |= RTC_CRH_ALRIE;
	rtc_exit_config_mode();
}