File: [local] / funnyos / arch / sam7s64 / dev / gpioled.c (download)
Revision 1.3, Sat Nov 24 17:43:15 2007 UTC (16 years, 7 months ago) by nbrk
Branch: MAIN
Changes since 1.2: +2 -2 lines
correctly print pin number on attachment (instead if hardcoding it *cough*)
|
/*
* $Id: gpioled.c,v 1.3 2007/11/24 17:43:15 nbrk Exp $
*/
#include <sys/types.h>
#include <sys/device.h>
#include <sys/gpio.h>
/*
* GPIO LED found on my SAM7-P64 development board.
*/
int gpioled_attach(struct device *, uint32_t, uint8_t);
struct driver gpioled_dr = {
1,
gpioled_attach,
NULL,
NULL
};
int
gpioled_attach(struct device *self, uint32_t loc, uint8_t flags)
{
/* grab parent's gpio_controller */
struct gpio_controller *gcp = self->dv_parent->dv_aux;
struct gpio_pin pin;
pin.gp_pinno = loc; /* PA17 or PA18 please */
pin.gp_pio = 1; /* PIO mode */
pin.gp_flags = GPIO_PIN_OUTPUT;
pin.gp_value = 1; /* LED on */
printf("p64 onboard LED (pin %d)\n", pin.gp_pinno);
/* talk to gpio controller */
gcp->gc_pinset(gcp->gc_selfdd, pin);
return(0);
}