serial.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include "s3c24x0.h"
  14. #define USTAT_RCV_READY 0x01 /* receive data ready */
  15. #define USTAT_TXB_EMPTY 0x02 /* tx buffer empty */
  16. #define BPS 115200 /* serial baudrate */
  17. #define UART_RX_BUFFER_SIZE 64
  18. #define UART_TX_BUFFER_SIZE 64
  19. struct serial_int_rx
  20. {
  21. rt_uint8_t rx_buffer[UART_RX_BUFFER_SIZE];
  22. rt_uint32_t read_index, save_index;
  23. };
  24. struct serial_int_tx
  25. {
  26. rt_uint8_t tx_buffer[UART_TX_BUFFER_SIZE];
  27. rt_uint32_t write_index, save_index;
  28. };
  29. typedef struct uartport
  30. {
  31. volatile rt_uint32_t ulcon;
  32. volatile rt_uint32_t ucon;
  33. volatile rt_uint32_t ufcon;
  34. volatile rt_uint32_t umcon;
  35. volatile rt_uint32_t ustat;
  36. volatile rt_uint32_t urxb;
  37. volatile rt_uint32_t ufstat;
  38. volatile rt_uint32_t umstat;
  39. volatile rt_uint32_t utxh;
  40. volatile rt_uint32_t urxh;
  41. volatile rt_uint32_t ubrd;
  42. }uartport;
  43. struct serial_device
  44. {
  45. uartport* uart_device;
  46. /* rx structure */
  47. struct serial_int_rx* int_rx;
  48. /* tx structure */
  49. struct serial_int_tx* int_tx;
  50. };
  51. rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct serial_device *serial);
  52. void rt_hw_serial_isr(rt_device_t device);
  53. #endif