00001 #include "led.h" 00002 00003 /* leds functions */ 00004 int led_leds_init( void ) 00005 { 00006 avr32_pio_t *led_port = (void *) LEDPORT_ADDR; 00007 char led_mask = 0xFF; 00008 00009 led_port->per = led_mask<<LEDPORT_START; 00010 led_port->oer = led_mask<<LEDPORT_START; 00011 led_port->idr = led_mask<<LEDPORT_START; 00012 00013 return LED_SUCCESS; 00014 } 00015 00016 int led_set_leds(char mask) 00017 { 00018 avr32_pio_t *led_port = (void *) LEDPORT_ADDR; 00019 led_port->codr = 0xFF<<LEDPORT_START; 00020 led_port->sodr = mask<<LEDPORT_START; 00021 00022 return LED_SUCCESS; 00023 } 00024 00025 int led_clear_leds(char mask) 00026 { 00027 avr32_pio_t *led_port = (void *) LEDPORT_ADDR; 00028 led_port->codr = mask<<LEDPORT_START; 00029 00030 return LED_SUCCESS; 00031 } 00032 00033 /* rgb leds functions */ 00034 int led_rgb_init( void ) 00035 { 00036 avr32_pio_t *rgb_port = (void *) RGBPORT_ADDR; 00037 char led_mask = 0x3F; 00038 00039 rgb_port->per = led_mask<<RGBPORT_START; 00040 rgb_port->oer = led_mask<<RGBPORT_START; 00041 rgb_port->idr = led_mask<<RGBPORT_START; 00042 00043 return LED_SUCCESS; 00044 } 00045 00046 int led_set_rgb(unsigned int position, unsigned char colour) 00047 { 00048 avr32_pio_t *rgb_port = (void *) RGBPORT_ADDR; 00049 char rgb_mask = 0x3F; 00050 00051 if( (position!=LEFT) | (position!=RIGHT) ) 00052 return LED_INVALID_ARGUMENT; 00053 00054 rgb_port->codr = rgb_mask<<(position+RGBPORT_START); 00055 rgb_port->sodr = colour<<(position+RGBPORT_START); 00056 00057 return LED_SUCCESS; 00058 } 00059 00060 int led_clear_rgb( unsigned int position) 00061 { 00062 avr32_pio_t *rgb_port = (void *) RGBPORT_ADDR; 00063 char rgb_mask = 0x15; 00064 00065 if( (position!=LEFT) | (position!=RIGHT) ) 00066 return LED_INVALID_ARGUMENT; 00067 00068 rgb_port->codr = rgb_mask<<(position+RGBPORT_START); 00069 00070 return LED_SUCCESS; 00071 }
1.5.1