00001 /*This file is prepared for Doxygen automatic documentation generation.*/ 00017 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00018 * 00019 * Redistribution and use in source and binary forms, with or without 00020 * modification, are permitted provided that the following conditions are met: 00021 * 00022 * 1. Redistributions of source code must retain the above copyright notice, this 00023 * list of conditions and the following disclaimer. 00024 * 00025 * 2. Redistributions in binary form must reproduce the above copyright notice, 00026 * this list of conditions and the following disclaimer in the documentation 00027 * and/or other materials provided with the distribution. 00028 * 00029 * 3. The name of Atmel may not be used to endorse or promote products derived 00030 * from this software without specific prior written permission. 00031 * 00032 * 4. This software may only be redistributed and used in connection with an Atmel 00033 * AVR product. 00034 * 00035 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00036 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00037 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00038 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00039 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00040 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00041 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00042 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00043 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00044 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00045 * 00046 */ 00047 #include "usart.h" 00048 #include "gpio.h" 00049 #include "board.h" 00050 #include "dsp.h" 00051 #include "dsp_debug.h" 00052 00055 00056 // Baud rate 00057 #define EXAMPLE_USART_BAUDRATE 57600 00058 // Number of bits per char 00059 #define EXAMPLE_USART_BITSPERCHAR 8 00060 // Parity 00061 #define EXAMPLE_USART_PARITY USART_NO_PARITY 00062 // Stop bit 00063 #define EXAMPLE_USART_STOPBIT USART_1_STOPBIT 00064 00065 #define EXAMPLE_USART (&AVR32_USART1) 00066 #define EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_0_PIN 00067 #define EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_0_FUNCTION 00068 #define EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_0_PIN 00069 #define EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_0_FUNCTION 00070 #define EXAMPLE_USART_IRQ AVR32_USART1_IRQ 00072 00074 void dsp_debug_write_fct(char c) 00075 { 00076 usart_putchar(EXAMPLE_USART, c); 00077 } 00078 00080 char dsp_debug_read_fct() 00081 { 00082 return usart_getchar(EXAMPLE_USART); 00083 } 00084 00086 void dsp_debug_init(int fosc) 00087 { 00088 static const gpio_map_t USART_GPIO_MAP = 00089 { 00090 {EXAMPLE_USART_RX_PIN, EXAMPLE_USART_RX_FUNCTION}, 00091 {EXAMPLE_USART_TX_PIN, EXAMPLE_USART_TX_FUNCTION} 00092 }; 00093 00094 // Configuration structure for the USART module 00095 static const usart_options_t USART_OPTIONS = 00096 { 00097 // Baudrate 00098 .baudrate = EXAMPLE_USART_BAUDRATE, 00099 // Number of bits per character 00100 .charlength = EXAMPLE_USART_BITSPERCHAR, 00101 // Parity 00102 .paritytype = EXAMPLE_USART_PARITY, 00103 // Stop bit 00104 .stopbits = EXAMPLE_USART_STOPBIT, 00105 // Mode normal 00106 .channelmode = USART_NORMAL_CHMODE 00107 }; 00108 00109 // Assign GPIO to USART. 00110 gpio_enable_module(USART_GPIO_MAP, 00111 sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0])); 00112 00113 // Initialize USART in RS232 mode. 00114 usart_init_rs232(EXAMPLE_USART, &USART_OPTIONS, fosc); 00115 00116 // New window 00117 dsp_debug_print_fct("\x0C\n"); 00118 }