ui_led.h

00001 /*
00002   ui_led.h
00003   
00004   Nicolas Williamson - July 2009
00005 */
00006 
00007 #ifndef __UI_LED_H__
00008 #define __UI_LED_H__
00009 
00010 //Only for use in RGB
00011 #define UI_LED_RED 100,0,0
00012 #define UI_LED_ORANGE 100,50,0
00013 #define UI_LED_YELLOW 50,100,0
00014 #define UI_LED_GREEN 0,100,0
00015 #define UI_LED_BLUE 0,0,100
00016 #define UI_LED_PURPLE 75,0,75
00017 #define UI_LED_WHITE 200,200,200
00018 #define UI_LED_OFF 0,0,0
00019 
00020 //Functions
00021 void ui_led_init(void);
00022 void ui_led_register_write(unsigned int device, unsigned int address, unsigned int w_data);
00023 void ui_led_pwm(unsigned int led_num, unsigned int color, unsigned int pwm);
00024 void ui_led_rgb(unsigned int led_num, unsigned int red_level, unsigned int green_level, unsigned int blue_level);
00025 
00026 
00027 /* HARDWARE SETUP
00028 
00029   // *******************************************************************************
00030   // Initialize SSP/SPI1 for LED Control
00031   // *******************************************************************************
00032   PCONP &= ~(1<<10);    // power setting: disable SPI1  (bit 10)
00033   PCONP |= (1<<21);   // power setting: enable SSP (bit 21!!!!!!!!!!!!!!!!!!!!!!)
00034   SSPCR1 = 0;       // Disable SSP to allow setting changes
00035   SSPCR0 = 0;
00036   SSPCR0 |= (15<<0);    // data size: 16 bits (bits 0-3 = 15 means 16bit data)
00037   SSPCR0 &= ~(3<<4);    // SPI mode (bits 4-5 = 0)
00038   SSPCR0 &= ~(1<<6);    //sclk low when idle - Motorola format
00039   SSPCR0 &= ~(1<<7);    //sample on the first edge (rising edge)
00040 //  SSPCPSR &= ~(3<<0);   //clear prescale divider
00041   SSPCPSR |= 2;   // prescale divider
00042   SSPCR0 |= (1<<8);   // bit frequency = PCLK/(CPSDVSR*(SCR+1)) = 15 Mbits/sec
00043   PINSEL1 &= ~0x3FC;    // clear P0.17~P0.20;
00044   PINSEL1 |= (2<<2)|(2<<4)|(2<<6);    // P0.17: SCK1, P0.18: MISO1, P0.19: MOSI1, P0.20: Manual SSEL 
00045 //  PINSEL1 |= (2<<2)|(2<<4)|(2<<6)|(2<<8); // P0.17: SCK1, P0.18: MISO1, P0.19: MOSI1, P0.20: auto SSEL
00046   FIO0DIR |= (1<<20);   //SSEL is output
00047   FIO0SET = (1<<20);    //SSEL high
00048   SSPCR1 |= (1<<1);   // enable SSP/SPI1   
00049   
00050 */
00051 
00052 
00053 #endif /* __UI_LED_H__ */
Generated on Tue Jun 29 16:36:14 2010 by  doxygen 1.6.3