File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed
chipflow_lib/software/drivers Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change 11/* SPDX-License-Identifier: BSD-2-Clause */
22#include "uart.h"
33
4+ void uart_init (volatile uart_regs_t * uart , uint32_t divisor ) {
5+ uart -> tx .config = 0 ;
6+ uart -> tx .phy_config = divisor & 0x00FFFFFF ;
7+ uart -> tx .config = 1 ;
8+ uart -> rx .config = 0 ;
9+ uart -> rx .phy_config = divisor & 0x00FFFFFF ;
10+ uart -> rx .config = 1 ;
11+ };
12+
413void uart_putc (volatile uart_regs_t * uart , char c ) {
514 if (c == '\n' )
615 uart_putc (uart , '\r' );
7- while (!uart -> tx_ready )
16+ while (!( uart -> tx . status & 0x1 ) )
817 ;
9- uart -> tx_data = c ;
18+ uart -> tx . data = c ;
1019}
1120
1221void uart_puts (volatile uart_regs_t * uart , const char * s ) {
Original file line number Diff line number Diff line change 55#include <stdint.h>
66
77typedef struct __attribute__((packed , aligned (4 ))) {
8- uint32_t tx_data ;
9- uint32_t rx_data ;
10- uint32_t tx_ready ;
11- uint32_t rx_avail ;
8+ uint8_t config ;
9+ uint8_t padding_0 [3 ];
10+ uint32_t phy_config ;
11+ uint8_t status ;
12+ uint8_t data ;
13+ uint8_t padding_1 [6 ];
14+ } uart_mod_regs_t ;
15+
16+ typedef struct __attribute__((packed , aligned (4 ))) {
17+ uart_mod_regs_t rx ;
18+ uart_mod_regs_t tx ;
1219} uart_regs_t ;
1320
21+ void uart_init (volatile uart_regs_t * uart , uint32_t divisor );
1422void uart_putc (volatile uart_regs_t * uart , char c );
1523void uart_puts (volatile uart_regs_t * uart , const char * s );
1624void uart_puthex (volatile uart_regs_t * uart , uint32_t x );
You can’t perform that action at this time.
0 commit comments