/* Set the alarm time for the specified alarm. 
Sets the time and mask specified to the requested alarm. */
enum status_code rtc_calendar_set_alarm(struct rtc_module *const module, const struct rtc_calendar_alarm_time *const alarm, const enum rtc_calendar_alarm alarm_index)
/* Set the alarm time for the specified alarm. 
Sets the time and mask specified to the requested alarm. */
enum status_code rtc_calendar_set_alarm(struct rtc_module *const module, const struct rtc_calendar_alarm_time *const alarm, const enum rtc_calendar_alarm alarm_index)
{
	Assert(module);
	Assert(module->hw);
	Rtc *const rtc_module = module->hw;
	if ((uint32_t)alarm_index > RTC_NUM_OF_ALARMS) {
		return STATUS_ERR_INVALID_ARG;
	}
	uint32_t register_value = rtc_calendar_time_to_register_value(module, &(alarm->time));
	while (rtc_calendar_is_syncing(module)) {
	}
	rtc_module->MODE2.Mode2Alarm[alarm_index].ALARM.reg = register_value;
	while (rtc_calendar_is_syncing(module)) {
	}
	rtc_module->MODE2.Mode2Alarm[alarm_index].MASK.reg = alarm->mask;
	while (rtc_calendar_is_syncing(module)) {
	}
	return STATUS_OK;
}