arch/arm/nrf5x/rtc/rtc.c
/*
 * rtc_open - open the RTC module
 *
 * Initialize the RTC module from LF clock
 */
open the RTC module
Initialize the RTC module from LF clock
open the RTC module Initialize the RTC module from LF clock
static int rtc_open(struct opened_resource_s *res, const char *pathname,
                    int flags,
                    mode_t mode)
{
  irq_state_t irq_state = cpu_disableint();
  if (g_opened_count == 0) {
    PRESCALER_CFG = PRESCALER_8_HZ;
    INTENSET_CFG  = 0x01;
    irq_attach(RTC0_IRQn, rtc_interrupt);
    NVIC_EnableIRQ(RTC0_IRQn);
    TASKS_START_CFG = 1;
  }
  ++g_opened_count;
  cpu_enableint(irq_state);
  return OK;
}
static int rtc_open ( struct opened_resource_s * res , const char * pathname , int flags , mode_t mode ) { irq_state_t irq_state = cpu_disableint ( ) ; if ( g_opened_count == 0 ) { PRESCALER_CFG = PRESCALER_8_HZ ; INTENSET_CFG = 0x01 ; irq_attach ( RTC0_IRQn , rtc_interrupt ) ; NVIC_EnableIRQ ( RTC0_IRQn ) ; TASKS_START_CFG = 1 ; } ++ g_opened_count ; cpu_enableint ( irq_state ) ; return OK ; }
rtc_open - open the RTC module
 Initialize the RTC module from LF clock
rtc_open - open the RTC module Initialize the RTC module from LF clock
/* fRTC [Hz] = 32768 / (PRESCALER + 1)
   * The PRESCALER should be 4095 for 8Hz tick - 125 ms counter period */ /* 1kHz -> perioada 1 ms -> 511875 */