1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 */ 9 #ifndef __RT_HW_SERIAL_H__ 10 #define __RT_HW_SERIAL_H__ 11 12 #include <rthw.h> 13 #include <rtthread.h> 14 15 #include "s3c24x0.h" 16 17 #define USTAT_RCV_READY 0x01 /* receive data ready */ 18 #define USTAT_TXB_EMPTY 0x02 /* tx buffer empty */ 19 #define BPS 115200 /* serial baudrate */ 20 21 #define UART_RX_BUFFER_SIZE 64 22 #define UART_TX_BUFFER_SIZE 64 23 24 struct serial_int_rx 25 { 26 rt_uint8_t rx_buffer[UART_RX_BUFFER_SIZE]; 27 rt_uint32_t read_index, save_index; 28 }; 29 30 struct serial_int_tx 31 { 32 rt_uint8_t tx_buffer[UART_TX_BUFFER_SIZE]; 33 rt_uint32_t write_index, save_index; 34 }; 35 36 typedef struct uartport 37 { 38 volatile rt_uint32_t ulcon; 39 volatile rt_uint32_t ucon; 40 volatile rt_uint32_t ufcon; 41 volatile rt_uint32_t umcon; 42 volatile rt_uint32_t ustat; 43 volatile rt_uint32_t urxb; 44 volatile rt_uint32_t ufstat; 45 volatile rt_uint32_t umstat; 46 volatile rt_uint32_t utxh; 47 volatile rt_uint32_t urxh; 48 volatile rt_uint32_t ubrd; 49 }uartport; 50 51 struct serial_device 52 { 53 uartport* uart_device; 54 55 /* rx structure */ 56 struct serial_int_rx* int_rx; 57 58 /* tx structure */ 59 struct serial_int_tx* int_tx; 60 }; 61 62 rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct serial_device *serial); 63 64 void rt_hw_serial_isr(rt_device_t device); 65 66 #endif 67