pio_example2_dip_switch_lights.c File Reference

#include <avr32/morgan.h>
#include <avr32/pio.h>

Include dependency graph for pio_example2_dip_switch_lights.c:

Go to the source code of this file.

Defines

#define black   0x00
#define blue   0x10
#define green   0x04
#define INPUT_BITMASK   0x0000ff00
#define light_blue   0x14
#define OUTPUT_BITMASK   0x000000ff
#define purple   0x11
#define red   0x01
#define white   0x15
#define yellow   0x05

Functions

int main (void)

Variables

char color_array [8] = {black,purple,blue,light_blue,green,yellow,red,white}


Define Documentation

#define black   0x00

Definition at line 5 of file pio_example2_dip_switch_lights.c.

#define blue   0x10

Definition at line 9 of file pio_example2_dip_switch_lights.c.

#define green   0x04

Definition at line 7 of file pio_example2_dip_switch_lights.c.

#define INPUT_BITMASK   0x0000ff00

Definition at line 16 of file pio_example2_dip_switch_lights.c.

#define light_blue   0x14

Definition at line 11 of file pio_example2_dip_switch_lights.c.

#define OUTPUT_BITMASK   0x000000ff

Definition at line 17 of file pio_example2_dip_switch_lights.c.

#define purple   0x11

Definition at line 10 of file pio_example2_dip_switch_lights.c.

#define red   0x01

Definition at line 6 of file pio_example2_dip_switch_lights.c.

#define white   0x15

Definition at line 12 of file pio_example2_dip_switch_lights.c.

#define yellow   0x05

Definition at line 8 of file pio_example2_dip_switch_lights.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 J2 (PORTB[15..8]). While the output (leds) header marked J15 must be connected to the header marked J1 (PORTB[7..])

Parameters:
none 
Returns:
none

Definition at line 28 of file pio_example2_dip_switch_lights.c.

References INPUT_BITMASK, OUTPUT_BITMASK, and piob.

00029 {
00030   avr32_pio_t *piob = (void *) AVR32_PIOB;
00031   char input, output;
00032 
00033   /* SET PIO */
00034   piob->pdr = 0x00000000; /* Enable entire PORTB for PIO controlled operation */
00035   piob->oer = OUTPUT_BITMASK; /* Use PORTB[15..8] as output */
00036   piob->odr = INPUT_BITMASK; /* Use PORTB[7..0] as input */
00037   piob->ifer = INPUT_BITMASK; /*Glitch enable on input */
00038   piob->codr = 0xFFFFffff; /* Clear all appropriate pins */
00039 
00040   while(1){
00041         /* read input and output */
00042         input = (~(piob->pdsr >> 8) & OUTPUT_BITMASK);
00043     output = (piob->pdsr) & OUTPUT_BITMASK;
00044 
00045         /* check if a change has occured */
00046     if( input != output){
00047                 /* Clear the output data */
00048                 piob->codr = OUTPUT_BITMASK;
00049                 /* Set output data according to the input */
00050                 piob->sodr = input;
00051     } //if
00052   }//while
00053 }//main


Variable Documentation

char color_array[8] = {black,purple,blue,light_blue,green,yellow,red,white}

Definition at line 14 of file pio_example2_dip_switch_lights.c.


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