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

Diff for /funnyos/arch/sam7s64/dev/gpioled.c between version 1.4 and 1.5

version 1.4, 2007/11/24 19:04:42 version 1.5, 2007/12/16 23:10:08
Line 4 
Line 4 
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/device.h>  #include <sys/device.h>
 #include <sys/gpio.h>  #include <sys/gpio.h>
   #include <sys/devctl.h>
   
   #include <arch/sam7s64/dev/gpioledvar.h>
   #include <libkern/printf.h>
 /*  /*
  * GPIO LED found on my SAM7-P64 development board.   * GPIO LED found on my SAM7-P64 development board.
  */   */
   
 int     gpioled_attach(struct device *, uint32_t, uint8_t);  int     gpioled_attach(struct device *, uint32_t, uint8_t);
   int     gpioled_devctl(struct device *self, uint32_t ctlcmd, void *ctldata);
   
   
 struct driver gpioled_dr = {  struct driver gpioled_dr = {
         1,          sizeof(struct gpioled_dd),
         gpioled_attach,          gpioled_attach,
         NULL,          NULL,
         NULL          NULL
Line 22 
Line 27 
 int  int
 gpioled_attach(struct device *self, uint32_t loc, uint8_t flags)  gpioled_attach(struct device *self, uint32_t loc, uint8_t flags)
 {  {
           struct gpioled_dd *ddp = self->dv_devdata;
         /* grab parent's gpio_controller */          /* grab parent's gpio_controller */
         struct gpio_controller *gcp = self->dv_parent->dv_aux;          ddp->gld_gcp = self->dv_parent->dv_aux;
         struct gpio_pin pin;  
   
         pin.gp_pinno = loc;     /* PA17 or PA18 please */          ddp->gld_pin.gp_pinno = loc;    /* PA17 or PA18 please */
         pin.gp_pio = 1;         /* PIO mode */          ddp->gld_pin.gp_pio = 1;        /* PIO mode */
         pin.gp_flags = GPIO_PIN_OUTPUT;          ddp->gld_pin.gp_flags = GPIO_PIN_OUTPUT;
         pin.gp_value = 0;       /* LED on */          ddp->gld_pin.gp_value = 0;      /* LED on */
   
         printf("p64 onboard LED (pin %d)\n", pin.gp_pinno);          printf("p64 onboard LED (pio pin %d)\n", ddp->gld_pin.gp_pinno);
   
         /* talk to gpio controller */          /* talk to gpio controller */
         gcp->gc_pinset(gcp->gc_selfdd, pin);          ddp->gld_gcp->gc_pinset(ddp->gld_gcp->gc_selfdd, ddp->gld_pin);
   
           devctl_register(self, gpioled_devctl);
           return(0);
   }
   
   
   int
   gpioled_devctl(struct device *self, uint32_t ctlcmd, void *ctldata)
   {
           struct gpioled_dd *ddp;
   
           ddp = self->dv_devdata;
   
           switch(ctlcmd) {
                   case(DCGPIOLED_TOGGLE):
                           /* toggle LED */
                           ddp->gld_pin.gp_value = ~ddp->gld_pin.gp_value & 0x01;
   
                           /* update us using our gpio controller */
                           ddp->gld_gcp->gc_pinset(ddp->gld_gcp->gc_selfdd, ddp->gld_pin);
                   default:
                           break;
           }
   
         return(0);          return(0);
 }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

CVSweb