[BACK]Return to gpioled.c CVS log [TXT][DIR] Up to [local] / funnyos / arch / sam7s64 / dev

File: [local] / funnyos / arch / sam7s64 / dev / gpioled.c (download)

Revision 1.1, Mon Nov 19 10:51:40 2007 UTC (16 years, 6 months ago) by nbrk
Branch: MAIN

driver for LED sitting on the GPIO pin;
it sets its line (given by 'loc') to pio output with value 1;

/*
 * $Id: gpioled.c,v 1.1 2007/11/19 10:51:40 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 = {
	0,
	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 (PA17)\n");

	/* talk to gpio controller */
	gcp->gc_pinset(gcp->gc_selfdd, pin);

	return(0);
}