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

Function rt_hw_leuart_init

bsp/efm32/drv_leuart.c:984–1075  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

982* @note
983******************************************************************************/
984void rt_hw_leuart_init(void)
985{
986 struct efm32_leuart_device_t *leuart;
987 rt_uint32_t flag;
988 rt_uint8_t config;
989
990 do
991 {
992#ifdef RT_USING_LEUART0
993 config = 0;
994 flag = RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX;
995
996 #if (RT_CONSOLE_DEVICE == EFM_LEUART0)
997 config |= LEUART_STATE_CONSOLE;
998 flag |= RT_DEVICE_FLAG_STREAM;
999 #endif
1000
1001 #ifdef RT_LEUART0_USING_DMA
1002 RT_ASSERT(RT_LEUART0_USING_DMA < DMA_CHAN_COUNT);
1003 flag |= RT_DEVICE_FLAG_DMA_TX;
1004 #else
1005 #define RT_LEUART0_USING_DMA EFM32_NO_DMA
1006 #endif
1007
1008 /* Initialize and Register leuart0 */
1009 if ((leuart = rt_hw_leuart_unit_init(
1010 &leuart0_device,
1011 0,
1012 RT_USING_LEUART0,
1013 flag,
1014 RT_LEUART0_USING_DMA,
1015 config)) != RT_NULL)
1016 {
1017 rt_hw_leuart_register(&leuart0_device, RT_LEUART0_NAME, flag, leuart);
1018 }
1019 else
1020 {
1021 break;
1022 }
1023 /* Initialize lock for leuart0 */
1024 leuart->lock = &leuart0_lock;
1025 if (rt_sem_init(leuart->lock, RT_LEUART0_NAME, 1, RT_IPC_FLAG_FIFO) != RT_EOK)
1026 {
1027 break;
1028 }
1029#endif
1030
1031#if ((LEUART_COUNT > 1) && defined(RT_USING_LEUART1))
1032 config = 0;
1033 flag = RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX;
1034
1035 #if (RT_CONSOLE_DEVICE == EFM_LEUART1)
1036 config |= LEUART_STATE_CONSOLE;
1037 flag |= RT_DEVICE_FLAG_STREAM;
1038 #endif
1039
1040 #ifdef RT_LEUART1_USING_DMA
1041 RT_ASSERT(RT_LEUART1_USING_DMA < DMA_CHAN_COUNT);

Callers 1

rt_hw_driver_initFunction · 0.85

Calls 4

rt_hw_leuart_unit_initFunction · 0.85
rt_hw_leuart_registerFunction · 0.85
rt_sem_initFunction · 0.85
rt_kprintfFunction · 0.85

Tested by

no test coverage detected