This example uses the PIO driver to toggle the RGB leds on the STK1000. See the documentation or comments in this file for jumper settings on your STK1000.
Definition in file pio_example1_rainbow_lights.c.
#include "pio.h"
Include dependency graph for pio_example1_rainbow_lights.c:

Go to the source code of this file.
Defines | |
| #define | BLACK 0x00 |
| #define | BLUE 0x10 |
| #define | CPU_HZ 20000000 |
| #define | GREEN 0x04 |
| #define | LEFT 0 |
| #define | NUMBER_OF_COLORS 4 |
| #define | RED 0x01 |
| #define | RIGHT 1 |
| #define | SUCCESS 0; |
Functions | |
| void | delay (void) |
| int | main (void) |
|
|
Definition at line 79 of file pio_example1_rainbow_lights.c. Referenced by main(). |
|
|
Definition at line 82 of file pio_example1_rainbow_lights.c. Referenced by main(). |
|
|
Definition at line 71 of file pio_example1_rainbow_lights.c. Referenced by delay(). |
|
|
Definition at line 81 of file pio_example1_rainbow_lights.c. Referenced by main(). |
|
|
Definition at line 75 of file pio_example1_rainbow_lights.c. |
|
|
Definition at line 72 of file pio_example1_rainbow_lights.c. Referenced by main(). |
|
|
Definition at line 80 of file pio_example1_rainbow_lights.c. Referenced by main(). |
|
|
Definition at line 76 of file pio_example1_rainbow_lights.c. |
|
|
Definition at line 69 of file pio_example1_rainbow_lights.c. Referenced by main(). |
|
|
A delay functions that delays the chip for CPU_HZ / 4.
Definition at line 155 of file pio_example1_rainbow_lights.c. References CPU_HZ. Referenced by main(). 00156 { 00157 int i; 00158 00159 for (i=0; i<CPU_HZ/4; i++); 00160 }
|
|
|
This function toggles your RGB-leds
Definition at line 121 of file pio_example1_rainbow_lights.c. References BLACK, BLUE, delay(), GREEN, NUMBER_OF_COLORS, and RED. 00122 { 00123 int i; 00124 int color_array[NUMBER_OF_COLORS]={RED,GREEN,BLUE,BLACK}; 00125 00126 /* Set up a pio structure to point at PIOC's base address */ 00127 volatile avr32_pio_t *pioc = &AVR32_PIOC; 00128 00129 pioc->per = 0x000000ff; /* Set pio enable for 16 LSBs of PORTB */ 00130 pioc->oer = 0x000000ff; /* Make them output ports */ 00131 pioc->idr = 0x000000ff; /* Disable interrupts on these pins */ 00132 pioc->puer = 0x00000ff; /* Enable pull-ups */ 00133 00134 00135 00136 while(1){ 00137 for(i=0; i<NUMBER_OF_COLORS; i++){ 00138 00139 /* Clear the RGB-color for the right/left RGB led*/ 00140 pioc->codr = 0x000000ff; 00141 00142 /* Set the current RGB-color to the left and right RGB led*/ 00143 pioc->sodr = color_array[i] | color_array[i]<<1; 00144 delay(); 00145 } 00146 } 00147 00148 return SUCCESS; 00149 }
Here is the call graph for this function: ![]() |
1.4.6