00001 /*This file has been prepared for Doxygen automatic documentation generation.*/ 00024 /* ************************************************************************ *\ 00025 00026 Copyright (c) 2006, Atmel Corporation All rights reserved. 00027 00028 Redistribution and use in source and binary forms, with or without 00029 modification, are permitted provided that the following conditions are met: 00030 00031 1. Redistributions of source code must retain the above copyright notice, 00032 this list of conditions and the 00033 following disclaimer. 00034 00035 2. Redistributions in binary form must reproduce the above copyright notice, 00036 this list of conditions and the following disclaimer in the documentation 00037 and/or other materials provided with the distribution. 00038 00039 3. The name of ATMEL may not be used to endorse or promote products 00040 derived from this software without specific prior written permission. 00041 00042 THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS 00043 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00044 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00045 PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY 00046 DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, 00047 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00048 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00049 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00050 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00051 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00052 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 00053 WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00054 00055 POSSIBILITY OF SUCH DAMAGE. 00056 00057 \* ************************************************************************ */ 00058 00059 #ifdef __GNUC__ 00060 #include <avr32/io.h> 00061 #elif __ICCAVR32__ 00062 #include <avr32/ioap7000.h> 00063 #else 00064 #error No known compiler used 00065 #endif 00066 00067 #include "pio.h" 00068 00069 #define SUCCESS 0; 00070 00071 #define CPU_HZ 20000000 00072 #define NUMBER_OF_COLORS 4 00073 00074 /* leds */ 00075 #define LEFT 0 00076 #define RIGHT 1 00077 00078 /* colors */ 00079 #define BLACK 0x00 00080 #define RED 0x01 00081 #define GREEN 0x04 00082 #define BLUE 0x10 00083 00084 00085 00086 /* 00087 PORTC[7..0] controls the RGB-leds in the following way: 00088 00089 PIN CONNECTION 00090 7 X 00091 6 X 00092 5 Right led 00093 4 Left led 00094 3 Right led 00095 2 Left led 00096 1 Right led 00097 0 Left led 00098 00099 Where: 00100 X - No connection 00101 R - Right 00102 L - Left 00103 00104 That means that the color of the left RGB-led is driven by the pins 00105 0, 2 & 4, while the right one is driven by 1, 3 & 5. The combination of 00106 these 3 bits puts out a color on the RGB-leds. These 3 bits can be 00107 combined to create additional colors. 00108 00109 This example will run a set of colors on the rgb-leds on the STK1000. 00110 To get it to work, connect a cable from J3 to J20 on the STK1000. 00111 00112 */ 00113 00114 /* prototype */ 00115 void delay( void ); 00116 00121 int main( void ) 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 } 00150 00155 void delay( void ) 00156 { 00157 int i; 00158 00159 for (i=0; i<CPU_HZ/4; i++); 00160 }
1.4.6