/**************************************************************************//** * @brief RTCC Interrupt handler which toggles GPIO pin. * * @return N/A *****************************************************************************/ void RTCC_IRQHandler(void) { /* Clear interrupt source */ RTCC_IntClear(RTCC_IF_CC1); /* Toggle GPIO pin. */ GPIO_PinOutToggle((GPIO_Port_TypeDef)gpioPortNo, gpioPinNo ); }
void isr_rtcc(void) { if (RTCC_IntGet() & RTCC_IF_CC0) { if (rtc_state.alarm_cb != NULL) { /* check if year matches, otherwise alarm would go off each year */ if (RTCC_BCD2Year(RTCC_DateGet()) + RTC_YEAR_OFFSET == rtc_state.alarm_year) { rtc_state.alarm_cb(rtc_state.alarm_arg); } } RTCC_IntClear(RTCC_IFC_CC0); } if (sched_context_switch_request) { thread_yield(); } }
void vPortSetupTimerInterrupt( void ) { /* Configure the RTCC to generate the RTOS tick interrupt. */ /* The maximum number of ticks that can be suppressed depends on the clock frequency. */ xMaximumPossibleSuppressedTicks = ULONG_MAX / ulReloadValueForOneTick; /* Ensure LE modules are accessible. */ CMU_ClockEnable( cmuClock_CORELE, true ); /* Use LFXO. */ CMU_ClockSelectSet( cmuClock_LFE, cmuSelect_LFXO ); /* Enable clock to the RTC module. */ CMU_ClockEnable( cmuClock_RTCC, true ); /* Use channel 1 to generate the RTOS tick interrupt. */ RTCC_ChannelCCVSet( lpRTCC_CHANNEL, ulReloadValueForOneTick ); RTCC_Init( &xRTCInitStruct ); RTCC_ChannelInit( lpRTCC_CHANNEL, &xRTCCChannel1InitStruct ); RTCC_EM4WakeupEnable( true ); /* Disable RTCC interrupt. */ RTCC_IntDisable( _RTCC_IF_MASK ); RTCC_IntClear( _RTCC_IF_MASK ); RTCC->CNT = _RTCC_CNT_RESETVALUE; /* The tick interrupt must be set to the lowest priority possible. */ NVIC_SetPriority( RTCC_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY ); NVIC_ClearPendingIRQ( RTCC_IRQn ); NVIC_EnableIRQ( RTCC_IRQn ); RTCC_IntEnable( RTCC_IEN_CC1 ); RTCC_Enable( true ); #if( lpUSE_TEST_TIMER == 1 ) { void prvSetupTestTimer( void ); /* A second timer is used to test the path where the MCU is brought out of a low power state by a timer other than the tick timer. */ prvSetupTestTimer(); } #endif }
int rtc_set_alarm(struct tm *time, rtc_alarm_cb_t cb, void *arg) { rtc_state.alarm_cb = cb; rtc_state.alarm_arg = arg; rtc_state.alarm_year = time->tm_year; /* disable interrupt so it doesn't accidentally trigger */ RTCC_IntDisable(RTCC_IEN_CC0); /* set compare registers */ RTCC_ChannelDateSet(0, RTCC_Channel_Month2BCD(time->tm_mon) | RTCC_Channel_Day2BCD(time->tm_mday)); RTCC_ChannelTimeSet(0, RTCC_Channel_Hour2BCD(time->tm_hour) | RTCC_Channel_Minute2BCD(time->tm_min) | RTCC_Channel_Second2BCD(time->tm_sec)); /* enable the interrupt */ RTCC_IntClear(RTCC_IFC_CC0); RTCC_IntEnable(RTCC_IEN_CC0); return 0; }
inline void lp_ticker_clear_interrupt() { RTCC_IntClear(RTCC_IF_CC0); }