File tree 2 files changed +23
-6
lines changed
chipflow_lib/software/drivers
2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change 1
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
2
#include "uart.h"
3
3
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
+
4
13
void uart_putc (volatile uart_regs_t * uart , char c ) {
5
14
if (c == '\n' )
6
15
uart_putc (uart , '\r' );
7
- while (!uart -> tx_ready )
16
+ while (!( uart -> tx . status & 0x1 ) )
8
17
;
9
- uart -> tx_data = c ;
18
+ uart -> tx . data = c ;
10
19
}
11
20
12
21
void uart_puts (volatile uart_regs_t * uart , const char * s ) {
Original file line number Diff line number Diff line change 5
5
#include <stdint.h>
6
6
7
7
typedef 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 ;
12
19
} uart_regs_t ;
13
20
21
+ void uart_init (volatile uart_regs_t * uart , uint32_t divisor );
14
22
void uart_putc (volatile uart_regs_t * uart , char c );
15
23
void uart_puts (volatile uart_regs_t * uart , const char * s );
16
24
void uart_puthex (volatile uart_regs_t * uart , uint32_t x );
You can’t perform that action at this time.
0 commit comments