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.
Definition in file pio_example2_dip_switch_lights.c.
#include "pio.h"
Include dependency graph for pio_example2_dip_switch_lights.c:

Go to the source code of this file.
Defines | |
| #define | INPUT_MASK 0x000000ff |
| #define | OUTPUT_MASK 0x000000ff |
| #define | SUCCESS 0 |
Functions | |
| int | main (void) |
|
|
Definition at line 70 of file pio_example2_dip_switch_lights.c. Referenced by main(). |
|
|
Definition at line 71 of file pio_example2_dip_switch_lights.c. Referenced by main(). |
|
|
Definition at line 73 of file pio_example2_dip_switch_lights.c. |
|
|
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])
Definition at line 85 of file pio_example2_dip_switch_lights.c. References INPUT_MASK, OUTPUT_MASK, and SUCCESS. 00086 { 00087 volatile avr32_pio_t *piob = &AVR32_PIOB; 00088 volatile avr32_pio_t *pioc = &AVR32_PIOC; 00089 unsigned int input, output; 00090 00091 pioc->per = OUTPUT_MASK; 00092 piob->per = INPUT_MASK; 00093 00094 pioc->oer = OUTPUT_MASK; 00095 pioc->puer = OUTPUT_MASK; 00096 pioc->codr = OUTPUT_MASK; 00097 piob->codr = INPUT_MASK; 00098 00099 while(1){ 00100 input = ( piob->pdsr & INPUT_MASK); /* get input */ 00101 output = ( pioc->pdsr & OUTPUT_MASK); /* get output */ 00102 00103 if ( output != input){ 00104 pioc->codr = OUTPUT_MASK; /* clear output */ 00105 pioc->sodr = (~input & OUTPUT_MASK); /* set output from input */ 00106 } 00107 00108 } 00109 return SUCCESS; 00110 }
|
1.4.6