#include "usart.h"
#include "../pio/pio.h"
#include "../debug/print_funcs.h"
#include <sys/interrupts.h>
#include <avr32/intc.h>
Include dependency graph for usart_example1.c:
Go to the source code of this file.
Defines | |
| #define | USART_ADDR AVR32_USART2_ADDRESS |
Functions | |
| int | main (void) |
| __int_handler * | usart_int_handler () |
| #define USART_ADDR AVR32_USART2_ADDRESS |
Definition at line 15 of file usart_example1.c.
Referenced by main(), tick_delay(), and usart_int_handler().
| int main | ( | void | ) |
Definition at line 30 of file usart_example1.c.
References usart_options_t::baudrate, usart_options_t::channelmode, usart_options_t::charlength, usart_options_t::paritytype, pio_enable_module(), print(), usart_options_t::stopbits, USART_1_STOPBIT, USART_ADDR, usart_init_rs232(), usart_int_handler(), USART_NO_PARITY, and USART_NORMAL_CHMODE.
00031 { 00032 int cpu_hz = 20000000; 00033 struct usart_options_t opt; 00034 00035 volatile avr32_usart_t *usart = (void *) USART_ADDR; 00036 00037 avr32_piomap_t usart_piomap = { \ 00038 {AVR32_USART2_RXD_0_PIN, AVR32_USART2_RXD_0_FUNCTION}, \ 00039 {AVR32_USART2_TXD_0_PIN, AVR32_USART2_TXD_0_FUNCTION}, \ 00040 {AVR32_USART0_CLK_0_PIN, AVR32_USART0_CLK_0_FUNCTION}, \ 00041 {AVR32_USART0_CTS_0_PIN, AVR32_USART0_CTS_0_FUNCTION}, \ 00042 {AVR32_USART0_RTS_0_PIN, AVR32_USART0_RTS_0_FUNCTION} \ 00043 }; 00044 00045 // Set options for the USART 00046 opt.baudrate = 57600; 00047 opt.charlength = 8; 00048 opt.paritytype = USART_NO_PARITY; 00049 opt.stopbits = USART_1_STOPBIT; 00050 opt.channelmode = USART_NORMAL_CHMODE; 00051 00052 // Initialize it in RS232 mode 00053 usart_init_rs232(usart, &opt, cpu_hz); 00054 00055 // Setup pio for USART 00056 pio_enable_module(usart_piomap, 2); 00057 00058 print(usart, "soo many assholes,so few.... bullets.\n"); 00059 00060 /* Setup interrupts */ 00061 set_interrupts_base( (void *) AVR32_INTC_ADDRESS ); 00062 print(usart, "\nSetting interrupts base...\n"); 00063 register_interrupt( (__int_handler) (usart_int_handler), AVR32_USART2_IRQ/32, AVR32_USART2_IRQ % 32, INT0); 00064 print(usart, "Adding interrupt handler...\n"); 00065 init_interrupts(); 00066 print(usart, "Initializing interrupts\n"); 00067 usart->ier = 0x000Fffff; 00068 // (1<<INT_RXRDY) | (1<<INT_TXRDY) | (1<<INT_RXBRK) | (1<<INT_ENDRX) | (1<<INT_ENDTX) | (1<<INT_TXBUFE) | (1<<INT_RXBUFF) 00069 00070 while(1); 00071 00072 return 42; 00073 }
Here is the call graph for this function:
| __int_handler* usart_int_handler | ( | ) |
Definition at line 18 of file usart_example1.c.
References print_char(), USART_ADDR, and usart_getchar().
Referenced by main().
00019 { 00020 volatile avr32_usart_t * usart = (void *) USART_ADDR; 00021 /* 00022 print_hex( usart, usart->csr); 00023 print(usart, "\n\r"); 00024 */ 00025 print_char( usart, usart_getchar(usart) ); 00026 00027 return (void *) 0; 00028 }
Here is the call graph for this function:
1.5.1