usart_example3.c File Reference

#include <avr32/io.h>
#include <avr32/intc.h>
#include <sys/interrupts.h>
#include "usart.h"
#include "../pio/pio.h"
#include "../debug/print_funcs.h"
#include "../inc/macro.h"
#include "../pdc/pdc.h"

Include dependency graph for usart_example3.c:

Go to the source code of this file.

Defines

#define USART_ADDR   AVR32_USART2_ADDRESS

Functions

int main (void)
void tick_delay ()
__int_handler * usart_int_handler ()

Variables

char * usart_rx_buf = "1234"
static int usart_rx_buf_size = 4
char * usart_tx_buf = "From pdc: Type 4 chars"
static int usart_tx_buf_size = 22


Define Documentation

#define USART_ADDR   AVR32_USART2_ADDRESS

Definition at line 20 of file usart_example3.c.


Function Documentation

int main ( void   ) 

Definition at line 47 of file usart_example3.c.

References usart_options_t::baudrate, usart_options_t::channelmode, usart_options_t::charlength, usart_options_t::paritytype, pdc_enable(), pdc_setRxBuf(), pdc_setTxBuf(), pdc_translatePtr(), pio_enable_module(), print(), usart_options_t::stopbits, tick_delay(), USART_1_STOPBIT, USART_ADDR, usart_init_rs232(), usart_int_handler(), USART_NO_PARITY, USART_NORMAL_CHMODE, usart_rx_buf, usart_rx_buf_size, usart_tx_buf, and usart_tx_buf_size.

00048 {
00049   int cpu_hz = 20000000;
00050 
00051   volatile avr32_usart_t *usart = (void *) USART_ADDR;
00052   struct usart_options_t usart_opt;
00053 
00054   avr32_piomap_t usart_piomap = {                               \
00055     {AVR32_USART2_RXD_0_PIN, AVR32_USART2_RXD_0_FUNCTION},      \
00056     {AVR32_USART2_TXD_0_PIN, AVR32_USART2_TXD_0_FUNCTION},      \
00057     {AVR32_USART0_CLK_0_PIN, AVR32_USART0_CLK_0_FUNCTION},      \
00058     {AVR32_USART0_CTS_0_PIN, AVR32_USART0_CTS_0_FUNCTION},      \
00059     {AVR32_USART0_RTS_0_PIN, AVR32_USART0_RTS_0_FUNCTION}       \
00060   };
00061 
00062 
00063   /* Set options for the USART */
00064   usart_opt.baudrate = 57600;
00065   usart_opt.charlength = 8;
00066   usart_opt.paritytype = USART_NO_PARITY;
00067   usart_opt.stopbits = USART_1_STOPBIT;
00068   usart_opt.channelmode = USART_NORMAL_CHMODE;
00069 
00070   pio_enable_module( usart_piomap, 5 );
00071   usart_init_rs232( usart, &usart_opt, cpu_hz);
00072   print(usart, "\n\n.: USART PDC TEST :.\n");
00073 
00074   /* Setup interrupts */
00075   set_interrupts_base( (void *) AVR32_INTC_ADDRESS );
00076   print(usart, "\nInitializing interrupts\n");
00077   register_interrupt( (__int_handler) (usart_int_handler), AVR32_USART2_IRQ/32, AVR32_USART2_IRQ % 32, INT0);
00078   usart->ier = AVR32_USART_IER_ENDRX_MASK;
00079 
00080   //print(usart, "Setting up PDC\n");
00081   pdc_enable( (void *) USART_ADDR );
00082   pdc_setRxBuf((void *) USART_ADDR,
00083                 (void *) pdc_translatePtr(usart_rx_buf),
00084                 usart_rx_buf_size,
00085                 (void *) 0,
00086                 0);
00087   pdc_setTxBuf( (void *) USART_ADDR,
00088                 (void *) usart_tx_buf,
00089                 usart_tx_buf_size,
00090                 (void *) 0,
00091                 0);
00092 
00093   init_interrupts();
00094 
00095   while(1)
00096         tick_delay();
00097 
00098   return 42;
00099 
00100 }

Here is the call graph for this function:

void tick_delay (  ) 

Definition at line 102 of file usart_example3.c.

References print(), and USART_ADDR.

Referenced by main().

00103 {
00104         volatile avr32_usart_t *usart = (void *) USART_ADDR;
00105         int i;
00106 
00107         for(i=0; i<5000000;i++);
00108         print(usart, ".");
00109 }

Here is the call graph for this function:

__int_handler* usart_int_handler (  ) 

Definition at line 30 of file usart_example3.c.

References pdc_flushCache(), pdc_setRxNextBuf(), pdc_translatePtr(), print(), print_hex(), USART_ADDR, usart_rx_buf, and usart_rx_buf_size.

00031 {
00032   volatile avr32_usart_t *usart = (void *) USART_ADDR;
00033 
00034   // RX PDC
00035         print(usart, "\n" );
00036         print_hex(usart, usart->csr);
00037         print(usart, "\n");
00038     print(usart, pdc_translatePtr(usart_rx_buf) );
00039         pdc_flushCache( pdc_translatePtr(usart_rx_buf), usart_rx_buf_size );
00040         pdc_setRxNextBuf( (void *) usart,
00041                         pdc_translatePtr( usart_rx_buf ), usart_rx_buf_size );
00042 
00043   return (void *) 0;
00044 }

Here is the call graph for this function:


Variable Documentation

char* usart_rx_buf = "1234"

Definition at line 23 of file usart_example3.c.

Referenced by main(), and usart_int_handler().

int usart_rx_buf_size = 4 [static]

Definition at line 24 of file usart_example3.c.

Referenced by main(), and usart_int_handler().

char* usart_tx_buf = "From pdc: Type 4 chars"

Definition at line 25 of file usart_example3.c.

Referenced by main().

int usart_tx_buf_size = 22 [static]

Definition at line 26 of file usart_example3.c.

Referenced by main().


Generated on Thu May 10 14:14:49 2007 for AVR321000 Communication with the AVR32 USART by  doxygen 1.5.1