File tree Expand file tree Collapse file tree 3 files changed +79
-0
lines changed
src/platform/drivers/imx_uart Expand file tree Collapse file tree 3 files changed +79
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright (c) Bao Project and Contributors. All rights reserved.
4+ */
5+
6+ #include <drivers/imx_uart.h>
7+ #include <fences.h>
8+
9+ #define IMX_UART_STAT2_TXDC (1 << 3)
10+ #define IMX_UART_STAT2_TXFULL (1 << 4)
11+
12+ void uart_init (volatile struct imx_uart * uart )
13+ {
14+ UNUSED_ARG (uart );
15+ return ;
16+ }
17+
18+ void uart_enable (volatile struct imx_uart * uart )
19+ {
20+ UNUSED_ARG (uart );
21+ return ;
22+ }
23+
24+ void uart_putc (volatile struct imx_uart * uart , int8_t c )
25+ {
26+ while (uart -> ts & IMX_UART_STAT2_TXFULL ) { }
27+ uart -> txd = (uint32_t )c ;
28+ while (!(uart -> stat2 & IMX_UART_STAT2_TXDC )) { }
29+ }
30+
31+ void uart_puts (volatile struct imx_uart * uart , int8_t const * str )
32+ {
33+ while (* str ) {
34+ uart_putc (uart , * str ++ );
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ /**
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright (c) Bao Project and Contributors. All rights reserved.
4+ */
5+
6+ #ifndef IMX_UART_H
7+ #define IMX_UART_H
8+
9+ #include <stdint.h>
10+
11+ struct imx_uart {
12+ uint32_t rxd ; /* 0x0 */
13+ uint32_t reserved1 [0xf ]; /* (0x40 - 0x4) / 4 */
14+ uint32_t txd ; /* 0x40*/
15+ uint32_t reserved2 [0xf ]; /* (0x80 - 0x44) / 4 */
16+ uint32_t cr1 ; /* 0x80 */
17+ uint32_t cr2 ; /* 0x84 */
18+ uint32_t cr3 ; /* 0x88 */
19+ uint32_t cr4 ; /* 0x8c */
20+ uint32_t fcr ; /* 0x90 */
21+ uint32_t stat1 ; /* 0x94 */
22+ uint32_t stat2 ; /* 0x98 */
23+ uint32_t esc ; /* 0x9c */
24+ uint32_t tim ; /* 0xa0 */
25+ uint32_t bir ; /* 0xa4 */
26+ uint32_t bmr ; /* 0xa8 */
27+ uint32_t brc ; /* 0xac */
28+ uint32_t onems ; /* 0xb0 */
29+ uint32_t ts ; /* 0xb4 */
30+ };
31+
32+ typedef volatile struct imx_uart bao_uart_t ;
33+
34+ void uart_enable (volatile struct imx_uart * uart );
35+ void uart_init (volatile struct imx_uart * uart );
36+ void uart_puts (volatile struct imx_uart * uart , const int8_t * str );
37+ void uart_putc (volatile struct imx_uart * uart , int8_t str );
38+
39+ #endif /* IMX_UART_H */
Original file line number Diff line number Diff line change 1+ # # SPDX-License-Identifier: Apache-2.0
2+ # # Copyright (c) Bao Project and Contributors. All rights reserved.
3+
4+ drivers-objs-y+ =imx_uart/imx_uart.o
You can’t perform that action at this time.
0 commit comments