led.h File Reference

#include <avr32/ap7000.h>
#include "../pio/pio.h"

Include dependency graph for led.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define BLACK   0x00
#define BLUE   0x10
#define GREEN   0x04
#define LED_INVALID_ARGUMENT   -1
#define LED_SUCCESS   0
#define LEDPORT_ADDR   AVR32_PIOC_ADDRESS
#define LEDPORT_START   0
#define LEFT   0
#define LIGHT_BLUE   0x14
#define PURPLE   0x11
#define RED   0x01
#define RGBPORT_ADDR   AVR32_PIOC_ADDRESS
#define RGBPORT_START   8
#define RIGHT   1
#define WHITE   0x15
#define YELLOW   0x05

Functions

int led_clear_leds (char mask)
int led_clear_rgb (unsigned int position)
int led_leds_init (void)
int led_rgb_init (void)
int led_set_leds (char mask)
int led_set_rgb (unsigned int position, unsigned char colour)


Define Documentation

#define BLACK   0x00

Definition at line 20 of file led.h.

#define BLUE   0x10

Definition at line 24 of file led.h.

#define GREEN   0x04

Definition at line 22 of file led.h.

#define LED_INVALID_ARGUMENT   -1

Definition at line 13 of file led.h.

Referenced by led_clear_rgb(), and led_set_rgb().

#define LED_SUCCESS   0

Definition at line 12 of file led.h.

Referenced by led_clear_leds(), led_clear_rgb(), led_leds_init(), led_rgb_init(), led_set_leds(), and led_set_rgb().

#define LEDPORT_ADDR   AVR32_PIOC_ADDRESS

Definition at line 7 of file led.h.

Referenced by led_clear_leds(), led_leds_init(), and led_set_leds().

#define LEDPORT_START   0

Definition at line 8 of file led.h.

Referenced by led_clear_leds(), led_leds_init(), and led_set_leds().

#define LEFT   0

Definition at line 16 of file led.h.

Referenced by led_clear_rgb(), and led_set_rgb().

#define LIGHT_BLUE   0x14

Definition at line 26 of file led.h.

#define PURPLE   0x11

Definition at line 25 of file led.h.

#define RED   0x01

Definition at line 21 of file led.h.

#define RGBPORT_ADDR   AVR32_PIOC_ADDRESS

Definition at line 9 of file led.h.

Referenced by led_clear_rgb(), led_rgb_init(), and led_set_rgb().

#define RGBPORT_START   8

Definition at line 10 of file led.h.

Referenced by led_clear_rgb(), led_rgb_init(), and led_set_rgb().

#define RIGHT   1

Definition at line 17 of file led.h.

Referenced by led_clear_rgb(), and led_set_rgb().

#define WHITE   0x15

Definition at line 27 of file led.h.

#define YELLOW   0x05

Definition at line 23 of file led.h.


Function Documentation

int led_clear_leds ( char  mask  ) 

Definition at line 25 of file led.c.

References LED_SUCCESS, LEDPORT_ADDR, and LEDPORT_START.

00026 {
00027         avr32_pio_t *led_port = (void *) LEDPORT_ADDR;
00028         led_port->codr = mask<<LEDPORT_START;
00029 
00030         return LED_SUCCESS;
00031 }

int led_clear_rgb ( unsigned int  position  ) 

Definition at line 60 of file led.c.

References LED_INVALID_ARGUMENT, LED_SUCCESS, LEFT, RGBPORT_ADDR, RGBPORT_START, and RIGHT.

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 }

int led_leds_init ( void   ) 

Definition at line 4 of file led.c.

References LED_SUCCESS, LEDPORT_ADDR, and LEDPORT_START.

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 }

int led_rgb_init ( void   ) 

Definition at line 34 of file led.c.

References LED_SUCCESS, RGBPORT_ADDR, and RGBPORT_START.

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 }

int led_set_leds ( char  mask  ) 

Definition at line 16 of file led.c.

References LED_SUCCESS, LEDPORT_ADDR, and LEDPORT_START.

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 }

int led_set_rgb ( unsigned int  position,
unsigned char  colour 
)

Definition at line 46 of file led.c.

References LED_INVALID_ARGUMENT, LED_SUCCESS, LEFT, RGBPORT_ADDR, RGBPORT_START, and RIGHT.

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 }


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