-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: David Cerdeira <[email protected]>
- Loading branch information
1 parent
43c4321
commit efc5f7b
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) Bao Project and Contributors. All rights reserved. | ||
*/ | ||
|
||
#include <drivers/imx_uart.h> | ||
#include <fences.h> | ||
|
||
#define IMX_UART_STAT2_TXDC (1 << 3) | ||
#define IMX_UART_STAT2_TXFULL (1 << 4) | ||
|
||
void uart_init(volatile struct imx_uart* uart) | ||
{ | ||
UNUSED_ARG(uart); | ||
return; | ||
} | ||
|
||
void uart_enable(volatile struct imx_uart* uart) | ||
{ | ||
UNUSED_ARG(uart); | ||
return; | ||
} | ||
|
||
void uart_putc(volatile struct imx_uart* uart, int8_t c) | ||
{ | ||
while (uart->ts & IMX_UART_STAT2_TXFULL) { } | ||
uart->txd = (uint32_t)c; | ||
while (!(uart->stat2 & IMX_UART_STAT2_TXDC)) { } | ||
} | ||
|
||
void uart_puts(volatile struct imx_uart* uart, int8_t const* str) | ||
{ | ||
while (*str) { | ||
uart_putc(uart, *str++); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) Bao Project and Contributors. All rights reserved. | ||
*/ | ||
|
||
#ifndef IMX_UART_H | ||
#define IMX_UART_H | ||
|
||
#include <stdint.h> | ||
|
||
struct imx_uart { | ||
uint32_t rxd; /* 0x0 */ | ||
uint32_t reserved1[0xf]; /* (0x40 - 0x4) / 4 */ | ||
uint32_t txd; /* 0x40*/ | ||
uint32_t reserved2[0xf]; /* (0x80 - 0x44) / 4 */ | ||
uint32_t cr1; /* 0x80 */ | ||
uint32_t cr2; /* 0x84 */ | ||
uint32_t cr3; /* 0x88 */ | ||
uint32_t cr4; /* 0x8c */ | ||
uint32_t fcr; /* 0x90 */ | ||
uint32_t stat1; /* 0x94 */ | ||
uint32_t stat2; /* 0x98 */ | ||
uint32_t esc; /* 0x9c */ | ||
uint32_t tim; /* 0xa0 */ | ||
uint32_t bir; /* 0xa4 */ | ||
uint32_t bmr; /* 0xa8 */ | ||
uint32_t brc; /* 0xac */ | ||
uint32_t onems; /* 0xb0 */ | ||
uint32_t ts; /* 0xb4 */ | ||
}; | ||
|
||
typedef volatile struct imx_uart bao_uart_t; | ||
|
||
void uart_enable(volatile struct imx_uart* uart); | ||
void uart_init(volatile struct imx_uart* uart); | ||
void uart_puts(volatile struct imx_uart* uart, const int8_t* str); | ||
void uart_putc(volatile struct imx_uart* uart, int8_t str); | ||
|
||
#endif /* IMX_UART_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## SPDX-License-Identifier: Apache-2.0 | ||
## Copyright (c) Bao Project and Contributors. All rights reserved. | ||
|
||
drivers-objs-y+=imx_uart/imx_uart.o |