serial.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2009-01-05 Bernard first version
  9. * 2010-03-29 Bernard remove interrupt tx and DMA rx mode.
  10. * 2010-03-30 Kyle Ported from STM32 to AVR32.
  11. */
  12. #ifndef __RT_HW_SERIAL_H__
  13. #define __RT_HW_SERIAL_H__
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "compiler.h"
  17. #include "usart.h"
  18. #define UART_RX_BUFFER_SIZE 64
  19. #define UART_TX_DMA_NODE_SIZE 4
  20. /* data node for Tx Mode */
  21. struct avr32_serial_data_node
  22. {
  23. rt_uint8_t *data_ptr;
  24. rt_size_t data_size;
  25. struct avr32_serial_data_node *next, *prev;
  26. };
  27. struct avr32_serial_int_rx
  28. {
  29. rt_uint8_t rx_buffer[UART_RX_BUFFER_SIZE];
  30. rt_uint32_t read_index, save_index;
  31. };
  32. struct avr32_serial_device
  33. {
  34. avr32_usart_t *uart_device;
  35. /* rx structure */
  36. struct avr32_serial_int_rx* int_rx;
  37. };
  38. rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct avr32_serial_device *serial);
  39. void rt_hw_serial_isr();
  40. #endif