MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_hw_rtc_init

Function rt_hw_rtc_init

bsp/efm32/drv_rtc.c:132–189  ·  view source on GitHub ↗

/ * @brief * Initialize all RTC module related hardware and register RTC device to kernel * * @details * * @note ******************************************************************************/

Source from the content-addressed store, hash-verified

130 * @note
131 ******************************************************************************/
132void rt_hw_rtc_init(void)
133{
134 rt_uint32_t reset;
135
136 reset = RMU_ResetCauseGet();
137
138 // TODO: What is the current reset mode?
139 if (reset & RMU_RSTCAUSE_PORST || reset & RMU_RSTCAUSE_EXTRST)
140 {
141 RTC_Init_TypeDef rtcInit;
142 efm32_irq_hook_init_t hook;
143
144 rtcInit.enable = true;
145 rtcInit.debugRun = false;
146 rtcInit.comp0Top = false;
147
148 rtc_time = 0UL;
149
150 rt_kprintf("rtc is not configured\n");
151 rt_kprintf("please configure with set_date and set_time\n");
152
153 /* Configuring clock */
154 CMU_ClockDivSet(cmuClock_RTC,cmuClkDiv_32768);
155 CMU_ClockEnable(cmuClock_RTC, true);
156
157 /* Initialize and enable RTC */
158 RTC_Reset();
159 RTC_Init(&rtcInit);
160
161 hook.type = efm32_irq_type_rtc;
162 hook.unit = 0;
163 hook.cbFunc = rt_hw_rtc_isr;
164 hook.userPtr = RT_NULL;
165 efm32_irq_hook_register(&hook);
166
167 /* Enabling Interrupt from RTC */
168 RTC_IntEnable(RTC_IFC_OF);
169 RTC_IntClear(RTC_IFC_OF);
170
171 NVIC_ClearPendingIRQ(RTC_IRQn);
172 NVIC_SetPriority(RTC_IRQn, EFM32_IRQ_PRI_DEFAULT);
173 NVIC_EnableIRQ(RTC_IRQn);
174 }
175
176 /* register rtc device */
177 rtc.type = RT_Device_Class_RTC;
178 rtc.rx_indicate = RT_NULL;
179 rtc.tx_complete = RT_NULL;
180 rtc.init = RT_NULL;
181 rtc.open = rt_rtc_open;
182 rtc.close = RT_NULL;
183 rtc.read = rt_rtc_read;
184 rtc.write = RT_NULL;
185 rtc.control = rt_rtc_control;
186 rtc.user_data = RT_NULL; /* no private */
187
188 rt_device_register(&rtc, RT_RTC_NAME, RT_DEVICE_FLAG_RDWR | EFM32_NO_DATA);
189}

Callers 1

rt_hw_driver_initFunction · 0.70

Calls 13

RMU_ResetCauseGetFunction · 0.85
rt_kprintfFunction · 0.85
CMU_ClockDivSetFunction · 0.85
CMU_ClockEnableFunction · 0.85
efm32_irq_hook_registerFunction · 0.85
RTC_IntEnableFunction · 0.85
RTC_IntClearFunction · 0.85
rt_device_registerFunction · 0.85
RTC_ResetFunction · 0.50
RTC_InitFunction · 0.50
NVIC_ClearPendingIRQFunction · 0.50
NVIC_SetPriorityFunction · 0.50

Tested by

no test coverage detected