1 /* 2 * File : serial.h 3 * This file is part of RT-Thread RTOS 4 * COPYRIGHT (C) 2009 - 2010, RT-Thread Development Team 5 * 6 * The license and distribution terms for this file may be 7 * found in the file LICENSE in this distribution or at 8 * http://www.rt-thread.org/license/LICENSE 9 * 10 * Change Logs: 11 * Date Author Notes 12 * 2009-01-05 Bernard first version 13 * 2010-03-29 Bernard remove interrupt tx and DMA rx mode. 14 * 2010-03-30 Kyle Ported from STM32 to AVR32. 15 */ 16 #ifndef __RT_HW_SERIAL_H__ 17 #define __RT_HW_SERIAL_H__ 18 19 #include <rthw.h> 20 #include <rtthread.h> 21 #include "compiler.h" 22 #include "usart.h" 23 24 #define UART_RX_BUFFER_SIZE 64 25 #define UART_TX_DMA_NODE_SIZE 4 26 27 /* data node for Tx Mode */ 28 struct avr32_serial_data_node 29 { 30 rt_uint8_t *data_ptr; 31 rt_size_t data_size; 32 struct avr32_serial_data_node *next, *prev; 33 }; 34 35 struct avr32_serial_int_rx 36 { 37 rt_uint8_t rx_buffer[UART_RX_BUFFER_SIZE]; 38 rt_uint32_t read_index, save_index; 39 }; 40 41 struct avr32_serial_device 42 { 43 avr32_usart_t *uart_device; 44 45 /* rx structure */ 46 struct avr32_serial_int_rx* int_rx; 47 }; 48 49 rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t flag, struct avr32_serial_device *serial); 50 51 void rt_hw_serial_isr(); 52 53 #endif 54