advanced_dip_switch_lights.c File Reference

#include "../part.h"
#include "pio_defines.h"

Include dependency graph for advanced_dip_switch_lights.c:

Go to the source code of this file.

Defines

#define BITMASK   0x000000ff
#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 USE_RGB_LEDS   1
#define white   0x15
#define yellow   0x05

Functions

unsigned int log_2 (register unsigned int x)
unsigned int log_2 (unsigned int x)
int main (void)
unsigned int ones32 (register unsigned int x)
unsigned int ones32 (unsigned int x)

Variables

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


Define Documentation

#define BITMASK   0x000000ff

Definition at line 19 of file advanced_dip_switch_lights.c.

Referenced by main().

#define black   0x00

Definition at line 5 of file advanced_dip_switch_lights.c.

#define blue   0x10

Definition at line 9 of file advanced_dip_switch_lights.c.

#define green   0x04

Definition at line 7 of file advanced_dip_switch_lights.c.

#define INPUT_BITMASK   0x0000ff00

Definition at line 17 of file advanced_dip_switch_lights.c.

Referenced by main().

#define light_blue   0x14

Definition at line 11 of file advanced_dip_switch_lights.c.

#define OUTPUT_BITMASK   0x000000ff

Definition at line 18 of file advanced_dip_switch_lights.c.

Referenced by main().

#define purple   0x11

Definition at line 10 of file advanced_dip_switch_lights.c.

#define red   0x01

Definition at line 6 of file advanced_dip_switch_lights.c.

#define USE_RGB_LEDS   1

Definition at line 15 of file advanced_dip_switch_lights.c.

Referenced by main().

#define white   0x15

Definition at line 12 of file advanced_dip_switch_lights.c.

#define yellow   0x05

Definition at line 8 of file advanced_dip_switch_lights.c.


Function Documentation

unsigned int log_2 ( register unsigned int  x  ) 

Definition at line 51 of file advanced_dip_switch_lights.c.

References ones32().

00052 {
00053         x |= (x >> 1);
00054         x |= (x >> 2);
00055         x |= (x >> 4);
00056         x |= (x >> 8);
00057         x |= (x >> 16);
00058 
00059         return(ones32(x >> 1));
00060 }

Here is the call graph for this function:

unsigned int log_2 ( unsigned int  x  ) 

Referenced by main().

int main ( void   ) 

Definition at line 24 of file advanced_dip_switch_lights.c.

References BITMASK, color_array, INPUT_BITMASK, log_2(), OUTPUT_BITMASK, piob, and USE_RGB_LEDS.

00025 {
00026   avr32_pio_t *piob = (void *) AVR32_PIOB_ADDRESS;
00027 
00028   char input, output;
00029 
00030   /* SET PIO */
00031   piob->pdr = 0x00000000;
00032   piob->oer = OUTPUT_BITMASK;
00033   piob->odr = INPUT_BITMASK;
00034   piob->ifer = INPUT_BITMASK;
00035   piob->codr = 0xFFFFffff;
00036 
00037   while(1){
00038     input = (~(piob->pdsr >> 8) & BITMASK);
00039     output = (piob->pdsr) & BITMASK;
00040     if( input != output){
00041       piob->codr = OUTPUT_BITMASK;
00042       if(USE_RGB_LEDS)
00043         piob->sodr = color_array[ log_2(input) ] ;
00044       else
00045           piob->sodr = input;
00046     } //if
00047 
00048   }//while
00049 }//main

Here is the call graph for this function:

unsigned int ones32 ( register unsigned int  x  ) 

Definition at line 62 of file advanced_dip_switch_lights.c.

00063 {
00064 
00065         x -= ((x >> 1) & 0x55555555);
00066         x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
00067         x = (((x >> 4) + x) & 0x0f0f0f0f);
00068         x += (x >> 8);
00069         x += (x >> 16);
00070 
00071         return(x & 0x0000003f);
00072 }

unsigned int ones32 ( unsigned int  x  ) 

Referenced by log_2().


Variable Documentation

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

Definition at line 13 of file advanced_dip_switch_lights.c.

Referenced by main(), and rgb_leds().


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