MAV'RIC
|
00001 /******************************************************************************* 00002 * Copyright (c) 2009-2016, MAV'RIC Development Team 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 00011 * 2. Redistributions in binary form must reproduce the above copyright notice, 00012 * this list of conditions and the following disclaimer in the documentation 00013 * and/or other materials provided with the distribution. 00014 * 00015 * 3. Neither the name of the copyright holder nor the names of its contributors 00016 * may be used to endorse or promote products derived from this software without 00017 * specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00023 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00029 * POSSIBILITY OF SUCH DAMAGE. 00030 ******************************************************************************/ 00031 00032 /******************************************************************************* 00033 * \file uart_default_config.h 00034 * 00035 * \author MAV'RIC Team 00036 * 00037 * \brief Default configuration for uarts 00038 * 00039 ******************************************************************************/ 00040 00041 #ifndef UART_DEFAULT_CONFIG_H_ 00042 #define UART_DEFAULT_CONFIG_H_ 00043 00044 #ifdef __cplusplus 00045 extern "C" { 00046 #endif 00047 00048 00049 static inline usart_config_t usart_default_config_console() 00050 { 00051 usart_config_t usart_config = {}; 00052 usart_config.mode = UART_IN_OUT; 00053 usart_config.uart_device.uart = (avr32_usart_t*)&AVR32_USART4; 00054 usart_config.uart_device.IRQ = AVR32_USART4_IRQ; 00055 usart_config.uart_device.receive_stream = NULL; 00056 usart_config.options = {}; 00057 usart_config.options.baudrate = 57600; 00058 usart_config.options.charlength = 8; 00059 usart_config.options.paritytype = USART_NO_PARITY; 00060 usart_config.options.stopbits = USART_1_STOPBIT; 00061 usart_config.options.channelmode = USART_NORMAL_CHMODE; 00062 usart_config.rx_pin_map = {AVR32_USART4_RXD_2_PIN, AVR32_USART4_RXD_2_FUNCTION}; 00063 usart_config.tx_pin_map = {AVR32_USART4_TXD_2_PIN, AVR32_USART4_TXD_2_FUNCTION}; 00064 00065 return usart_config; 00066 }; 00067 00068 00069 static inline usart_config_t usart_default_config_gps() 00070 { 00071 usart_config_t usart_config = {}; 00072 usart_config.mode = UART_IN_OUT; 00073 usart_config.uart_device.uart = (avr32_usart_t*)&AVR32_USART3; 00074 usart_config.uart_device.IRQ = AVR32_USART3_IRQ; 00075 usart_config.uart_device.receive_stream = NULL; 00076 usart_config.options = {}; 00077 usart_config.options.baudrate = 38400; 00078 usart_config.options.charlength = 8; 00079 usart_config.options.paritytype = USART_NO_PARITY; 00080 usart_config.options.stopbits = USART_1_STOPBIT; 00081 usart_config.options.channelmode = USART_NORMAL_CHMODE; 00082 usart_config.rx_pin_map = {AVR32_USART3_RXD_0_0_PIN, AVR32_USART3_RXD_0_0_FUNCTION}; 00083 usart_config.tx_pin_map = {AVR32_USART3_TXD_0_0_PIN, AVR32_USART3_TXD_0_0_FUNCTION}; 00084 00085 return usart_config; 00086 }; 00087 00088 00089 static inline usart_config_t usart_default_config_spektrum() 00090 { 00091 usart_config_t usart_config = {}; 00092 usart_config.mode = UART_IN_OUT; 00093 usart_config.uart_device.uart = (avr32_usart_t*)&AVR32_USART1; 00094 usart_config.uart_device.IRQ = AVR32_USART1_IRQ; 00095 usart_config.uart_device.receive_stream = NULL; 00096 usart_config.options = {}; 00097 usart_config.options.baudrate = 115200; 00098 usart_config.options.charlength = 8; 00099 usart_config.options.paritytype = USART_NO_PARITY; 00100 usart_config.options.stopbits = USART_1_STOPBIT; 00101 usart_config.options.channelmode = USART_NORMAL_CHMODE; 00102 usart_config.rx_pin_map = { AVR32_USART1_RXD_0_1_PIN, AVR32_USART1_RXD_0_1_FUNCTION }; 00103 usart_config.tx_pin_map = { AVR32_USART1_TXD_0_1_PIN, AVR32_USART1_TXD_0_1_FUNCTION }; 00104 00105 return usart_config; 00106 }; 00107 00108 00109 static inline usart_config_t usart_default_config_xbee() 00110 { 00111 usart_config_t usart_config = {}; 00112 usart_config.mode = UART_IN_OUT; 00113 usart_config.uart_device.uart = (avr32_usart_t*)&AVR32_USART0; 00114 usart_config.uart_device.IRQ = AVR32_USART0_IRQ; 00115 usart_config.uart_device.receive_stream = NULL; 00116 usart_config.options = {}; 00117 usart_config.options.baudrate = 57600; 00118 usart_config.options.charlength = 8; 00119 usart_config.options.paritytype = USART_NO_PARITY; 00120 usart_config.options.stopbits = USART_1_STOPBIT; 00121 usart_config.options.channelmode = USART_NORMAL_CHMODE; 00122 usart_config.rx_pin_map = {AVR32_USART0_RXD_0_0_PIN, AVR32_USART0_RXD_0_0_FUNCTION}; 00123 usart_config.tx_pin_map = {AVR32_USART0_TXD_0_0_PIN, AVR32_USART0_TXD_0_0_FUNCTION}; 00124 00125 return usart_config; 00126 }; 00127 00128 00129 #ifdef __cplusplus 00130 } 00131 #endif 00132 00133 #endif // UART_DEFAULT_CONFIG_H_