serial.h 1.2 KB

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