@@ -64,49 +64,16 @@ static void rt_hw_uart_isr(int irqn, void *param)
6464
6565static rt_err_t uart_configure (struct rt_serial_device * serial , struct serial_configure * cfg )
6666{
67- // struct hw_uart_device *uart;
68- // uint32_t baudrate;
69- // uint8_t parity, stopbits, datasize, flowcontrol;
70-
71- // RT_ASSERT(serial != RT_NULL);
72- // uart = (struct hw_uart_device *)serial->parent.user_data;
73-
74- // baudrate = cfg->baud_rate;
75- // switch (cfg->data_bits)
76- // {
77- // case DATA_BITS_8:
78- // datasize = EIGHTBITS;
79- // break;
80- // case DATA_BITS_7:
81- // datasize = SEVENBITS;
82- // break;
83- // }
84- // if (cfg->stop_bits == STOP_BITS_1) stopbits = STOPBITS_ONE;
85- // else if (cfg->stop_bits == STOP_BITS_2) stopbits = STOPBITS_TWO;
86-
87- // parity = PARITY_NONE;
88- // flowcontrol = FLOWCTRL_OFF;
89-
90- // /* Initialize UART */
91- // uart_init(uart->uart_base, baudrate, parity, stopbits, datasize, flowcontrol);
92-
93- // rt_hw_interrupt_install(uart->irqn, rt_hw_uart_isr, serial, "uart");
94- // rt_hw_interrupt_mask(uart->irqn);
95-
96- // /* Set the IRQ mode for the Rx FIFO */
97- // uart_set_FIFO_mode(uart->uart_base, RX_FIFO, 1, IRQ_MODE);
98-
9967 struct hw_uart_device * uart = RT_NULL ;
10068 static lpuart_config_t config ;
10169
102- rt_hw_console_output ("uart_configure start ...\n" );
10370 RT_ASSERT (serial != RT_NULL );
10471 uart = (struct hw_uart_device * )serial -> parent .user_data ;
10572
106- rt_hw_console_output ("uart_configure LPUART_GetDefaultConfig ...\n" );
73+ rt_hw_console_output ("uart_configure start ...\n" );
10774 LPUART_GetDefaultConfig (& config );
108- rt_hw_console_output ("uart_configure LPUART_GetDefaultConfig done!\n" );
10975
76+ // baud rate
11077 config .baudRate_Bps = cfg -> baud_rate ;
11178
11279 // data bits
@@ -240,8 +207,9 @@ static int uart_putc(struct rt_serial_device *serial, char c)
240207 return 1 ;
241208}
242209
243- volatile LPUART_Type * earlycon_base = LPUART1 ;
244- const size_t earlycon_size = 4096 ; // sizeof(LPUART_Type);
210+ #if USING_EARLY_CONSOLE
211+ LPUART_Type * earlycon_base = LPUART1 ;
212+ const size_t earlycon_size = 4096 ;
245213
246214void rt_hw_earlycon_ioremap (void )
247215{
@@ -282,6 +250,7 @@ void rt_hw_earlycon_print_hex(const char *str, rt_base_t hex)
282250 rt_hw_earlycon_putc ('\r' );
283251 rt_hw_earlycon_putc ('\n' );
284252}
253+ #endif
285254
286255void rt_hw_console_putc (char c )
287256{
@@ -352,7 +321,8 @@ int rt_hw_uart_init(void)
352321 hw_uart_devices [i ]-> serial .ops = & _uart_ops ;
353322 hw_uart_devices [i ]-> serial .config = config ;
354323 rt_hw_earlycon_print_hex ("ioremap uart_instance: " , (rt_base_t )hw_uart_devices [i ]-> uart_instance );
355- hw_uart_devices [i ]-> uart_base = rt_ioremap ((void * )hw_uart_devices [i ]-> uart_instance , 0x1000 );
324+ // hw_uart_devices[i]->uart_base = rt_ioremap((void *)hw_uart_devices[i]->uart_instance, 0x1000);
325+ hw_uart_devices [i ]-> uart_base = rt_ioremap_early ((void * )hw_uart_devices [i ]-> uart_instance , 0x1000 );
356326
357327 rt_hw_serial_register (& hw_uart_devices [i ]-> serial , hw_uart_devices [i ]-> device_name ,
358328 RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX , hw_uart_devices [i ]);
@@ -361,4 +331,3 @@ int rt_hw_uart_init(void)
361331
362332 return 0 ;
363333}
364- // INIT_BOARD_EXPORT(rt_hw_uart_init);
0 commit comments