pio_example.c File Reference


Detailed Description

This example demonstrates PIO functionality.

This examples demonstrates how to use some pins as input and some as output. It routes the status from a set of pins to other pins. See the documentation for settings and how to deploy this example on target.

Author:
Atmel Corporation: http://www.atmel.com
Support email: avr32@atmel.com

Definition in file pio_example.c.

#include "pio.h"
#include <avr32/io.h>

Go to the source code of this file.

Defines

#define INPUT_MASK   0x000000ff
#define OUTPUT_MASK   0x000000ff
#define SUCCESS   0

Functions

int main (void)


Define Documentation

#define INPUT_MASK   0x000000ff

Definition at line 59 of file pio_example.c.

Referenced by main().

#define OUTPUT_MASK   0x000000ff

Definition at line 60 of file pio_example.c.

Referenced by main().

#define SUCCESS   0

Definition at line 62 of file pio_example.c.


Function Documentation

int main ( void   ) 

This function will read the dip switches on the STK1000 and put the status out on the leds. To get it to work, you must connect the input and output correctly on the STK1000. The input (switches) header marked J25 must be connected to the header labeled J1 (PORTB[0..7]). While the output (leds) header marked J15 must be connected to the header marked J3 (PORTC[0..7])

Returns:
SUCCESS

Definition at line 74 of file pio_example.c.

References INPUT_MASK, and OUTPUT_MASK.

00075 {
00076   volatile avr32_pio_t *piob = &AVR32_PIOB;
00077   volatile avr32_pio_t *pioc = &AVR32_PIOC;
00078   unsigned int input, output;
00079 
00080   pioc->per = OUTPUT_MASK;
00081   piob->per = INPUT_MASK;
00082 
00083   pioc->oer = OUTPUT_MASK;
00084   pioc->puer = OUTPUT_MASK;
00085   pioc->codr = OUTPUT_MASK;
00086   piob->codr = INPUT_MASK;
00087 
00088   while(1){
00089     input = ( piob->pdsr & INPUT_MASK); /* get input */
00090     output = ( pioc->pdsr & OUTPUT_MASK); /* get output */
00091 
00092     if ( output != input){
00093       pioc->codr = OUTPUT_MASK;  /* clear output */
00094       pioc->sodr = (~input & OUTPUT_MASK); /* set output from input */
00095     }
00096 
00097   }
00098 }


Generated on Tue Nov 25 11:16:34 2008 for AVR32 - PIO Driver by  doxygen 1.5.6