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

Function efm32_hw_keys_init

bsp/efm32/dev_keys.c:265–315  ·  view source on GitHub ↗

/ * @brief * Initialize keys related hardware and register joystic device to kernel * * @details * * @note * ******************************************************************************/

Source from the content-addressed store, hash-verified

263 *
264 ******************************************************************************/
265void efm32_hw_keys_init(void)
266{
267 /* Configure joystick interrupt pin */
268 GPIO_PinModeSet(KEYS_INT_PORT, KEYS_INT_PIN, gpioModeInputPullFilter, 1);
269
270 /* Enable joystick interrupt */
271 GPIO_IntConfig(KEYS_INT_PORT, KEYS_INT_PIN, true, true, true);
272
273 efm32_irq_hook_init_t hook;
274 hook.type = efm32_irq_type_gpio;
275 hook.unit = KEYS_INT_PIN;
276 hook.cbFunc = efm32_keys_isr;
277 hook.userPtr = RT_NULL;
278 efm32_irq_hook_register(&hook);
279
280 if ((rt_uint8_t)KEYS_INT_PIN % 2)
281 {
282 NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
283 NVIC_SetPriority(GPIO_ODD_IRQn, EFM32_IRQ_PRI_DEFAULT);
284 NVIC_EnableIRQ(GPIO_ODD_IRQn);
285 }
286 else
287 {
288 NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
289 NVIC_SetPriority(GPIO_EVEN_IRQn, EFM32_IRQ_PRI_DEFAULT);
290 NVIC_EnableIRQ(GPIO_EVEN_IRQn);
291 }
292
293 /* Enable DVK joystick interrupt */
294 DVK_enableInterrupt(BC_INTEN_JOYSTICK);
295
296 rt_timer_init(&joy.timer,
297 "joy_tmr",
298 efm32_keys_timer_isr,
299 RT_NULL,
300 KEYS_POLL_TIME,
301 RT_TIMER_FLAG_PERIODIC);
302
303 joy_dev.init = efm32_keys_init;
304 joy_dev.open = RT_NULL;
305 joy_dev.close = RT_NULL;
306 joy_dev.read = RT_NULL;
307 joy_dev.write = RT_NULL;
308 joy_dev.control = RT_NULL;
309 joy_dev.user_data = (void *)&joy;
310
311 /* register joy stick device */
312 rt_device_register(&joy_dev, "joy", RT_DEVICE_FLAG_RDWR);
313
314 keys_debug("Keys: H/W init OK!\n");
315}
316
317#endif /* defined(EFM32_USING_KEYS) */
318/***************************************************************************//**

Callers 1

rt_hw_driver_initFunction · 0.85

Calls 9

GPIO_PinModeSetFunction · 0.85
efm32_irq_hook_registerFunction · 0.85
rt_timer_initFunction · 0.85
rt_device_registerFunction · 0.85
GPIO_IntConfigFunction · 0.50
NVIC_ClearPendingIRQFunction · 0.50
NVIC_SetPriorityFunction · 0.50
NVIC_EnableIRQFunction · 0.50
DVK_enableInterruptFunction · 0.50

Tested by

no test coverage detected