コード例 #1
0
ファイル: main.c プロジェクト: santhoshvlsi/potato
// Handle an exception/interrupt.
// Arguments:
// - cause: exception cause, see potato.h for values
// - epc: exception return address
// - regbase: base of the stored context, can be used for printing all
//            registers with regbase[0] = x1 and upwards.
void exception_handler(uint32_t cause, void * epc, void * regbase)
{
	if(cause == ((1 << CAUSE_INTERRUPT_BIT) | (CAUSE_IRQ_BASE + 5))) // Timer interrupt
	{
		uart_puts(IO_ADDRESS(UART_BASE), "Hashes per second: ");
		uart_puth(IO_ADDRESS(UART_BASE), hashes_per_second);
		uart_puts(IO_ADDRESS(UART_BASE), "\n\r");
		seg7_set_value(IO_ADDRESS(SEG7_BASE), hashes_per_second);

		if(led_status == 0)
		{
			gpio_set_output(IO_ADDRESS(GPIO2_BASE), 1);
			led_status = 1;
		} else {
			gpio_set_output(IO_ADDRESS(GPIO2_BASE), 0);
			led_status = 0;
		}

		hashes_per_second = 0;
		timer_reset(IO_ADDRESS(TIMER_BASE));
	} else {
		uart_puts(IO_ADDRESS(UART_BASE), "Unhandled exception!\n\r");
		uart_puts(IO_ADDRESS(UART_BASE), "Cause: ");
		uart_puth(IO_ADDRESS(UART_BASE), cause);
		uart_puts(IO_ADDRESS(UART_BASE), "\n\r");
		uart_puts(IO_ADDRESS(UART_BASE), "EPC: ");
		uart_puth(IO_ADDRESS(UART_BASE), (uint32_t) epc);
		uart_puts(IO_ADDRESS(UART_BASE), "\n\r");

		while(1) asm volatile("nop\n");
	}
}
コード例 #2
0
ファイル: spi.c プロジェクト: areusch/libAVR
bool spi_init(SPI_t* port,
              bool lsb_first,
              uint8_t spi_mode,
              uint32_t max_clock_speed_hz,
              SpiControl* out_control) {
  if (max_clock_speed_hz < CHIP_SPI_MIN_CLOCK_SPEED_HZ)
        return false;

  chip_spi_enable(false);

  gpio_set_output(chip_spi_mosi_pin(port));
  gpio_set_output(chip_spi_sck_pin(port));
  gpio_set_input(chip_spi_miso_pin(port));

  chip_spi_set_clock_speed(port, max_clock_speed_hz);

  chip_spi_set_operating_params(port, lsb_first, true, spi_mode);

  chip_spi_enable(true);

  out_control->port = port;
  out_control->active_transfer = NULL;

  return true;
}
コード例 #3
0
ファイル: agilefox_leds.c プロジェクト: Liambeguin/openlab
void platform_leds_setup()
{
    // Configure the LEDs
    // Enable port B
    gpio_enable(GPIO_B);

    // Set output pins B10 and B12
    gpio_set_output(GPIO_B, GPIO_PIN_10);
    gpio_set_output(GPIO_B, GPIO_PIN_12);

    // Clear LEDs
    leds_off(LED_0 + LED_1);
}
コード例 #4
0
ファイル: leds-arch.c プロジェクト: AlexandreRio/contiki
void platform_leds_setup(void)
{
    gpio_enable(LED_0_PORT);
    gpio_enable(LED_1_PORT);
    gpio_enable(LED_2_PORT);

    // Set output pins B10 and B12
    gpio_set_output(LED_0_PORT, LED_0_PIN);
    gpio_set_output(LED_1_PORT, LED_1_PIN);
    gpio_set_output(LED_2_PORT, LED_2_PIN);

    // Clear LEDs
    leds_arch_set(0);
}
コード例 #5
0
ファイル: iotlab-cn_periph.c プロジェクト: adjih/openlab
void platform_periph_setup()
{
    // Configure the radio
    radio_setup();

    // Configure the power measurement
    power_setup();

    // Cut power PA11, PB2, PB12
    gpio_set_output(GPIO_A, GPIO_PIN_11);
    gpio_pin_clear(GPIO_A, GPIO_PIN_11); // Battery

    gpio_set_output(GPIO_B, GPIO_PIN_2);
    gpio_pin_clear(GPIO_B, GPIO_PIN_2); // CHARGE

    gpio_set_output(GPIO_B, GPIO_PIN_12);
    gpio_pin_clear(GPIO_B, GPIO_PIN_12); // 5V
}
コード例 #6
0
ファイル: gpio.c プロジェクト: samdolt/diplome-pic32
void gpio_set_direction(const char GPIO[], enum gpio_direction direction) {
    if(direction == OUTPUT) {
        gpio_set_output(GPIO);
    }
    else if(ANALOG){
        gpio_set_analog(GPIO);
    }
    else {
        gpio_set_input(GPIO);
    }
}
コード例 #7
0
ファイル: 1wr.c プロジェクト: Ayesha-N/6lbr
/*----------------------------------------------------------------------------*
write one byte on 1 wire.
Parameters:
   bytes to write.
Returns:
 *----------------------------------------------------------------------------*/
void
owr_writeb(unsigned byte)
{
  int i;

  for(i = 0; i < 8; i++) {
    if(byte & 0x01) {
      gpio_set_output(GPIO_1WR);
      micro_delay(tW1L);
      gpio_set_input(GPIO_1WR);
      micro_delay(tSLOT - tW1L);
    } else {
      gpio_set_output(GPIO_1WR);
      micro_delay(tW0L);
      gpio_set_input(GPIO_1WR);
      micro_delay(tSLOT - tW0L);
    }
    byte >>= 1;
  }
}
コード例 #8
0
ファイル: leds.c プロジェクト: Liambeguin/openlab
void platform_leds_setup()
{
    // Configure the LEDs
    int i;
    for (i = 0; i < leds_num; i++)
    {
        gpio_set_output(leds_gpio[i], leds_pin[i]);
    }

    // Clear LEDs
    leds_off(0xFF);
}
コード例 #9
0
ファイル: kernel.c プロジェクト: wuxx/sos
s32 os_main(u32 sp)
{
    struct __os_task__ *ptask;

    int_init();
    uart_init();
    dram_init();
    timer_init();
    mmc_init();

    PRINT_INFO("%s\n", sys_banner);

    coretimer_init();
    task_init();
    semaphore_init();

    PRINT_INFO("cpu_mode: %s; lr: 0x%x; sp: 0x%x; cpsr: 0x%x\n",
            get_cpu_mode(NULL), __get_lr(), sp, __get_cpsr());

    gpio_set_function(GPIO_16, OUTPUT);
    gpio_set_output(GPIO_16, 0);

    /* set_log_level(LOG_DEBUG); */

    /* create idle task */
    if ((ptask = tcb_alloc()) == NULL) {
        panic();
    }

    tcb_init(ptask, idle_task, 0, 256);

    /*os_ready_insert(ptask);*/

    current_task = &tcb[IDLE_TASK_ID];  /* assume that this is idle_task */

    /* create main task */
    if ((ptask = tcb_alloc()) == NULL) {
        panic();
    }

    tcb_init(ptask, main_task, 0, 100);

    os_ready_insert(ptask);

    /* 'slip into idle task', cause the os_main() is not a task (it's the god code of system) */
    __set_sp(&(task_stack[0][TASK_STK_SIZE]));
    current_task->state = TASK_RUNNING;
    idle_task(0);

    kassert(0);
    return 0;
}
コード例 #10
0
ファイル: square.c プロジェクト: cvphelps/courseware
void notmain() {
  led_init();
  gpio_init();

  gpio_set_pullup(GPIO_PIN23);
  gpio_set_output(GPIO_PIN23);

  while (1) {
    int i;
    gpio_pin_write(GPIO_PIN23, 0);
    for (i = 0; i < 100; i++) {}
    gpio_pin_write(GPIO_PIN23, 1);
    for (i = 0; i < 100; i++) {}
  } 
}
コード例 #11
0
ファイル: azurelion_periph.c プロジェクト: Liambeguin/openlab
void platform_usb_enable()
{
    // gpio_enable(GPIO_A);
    // gpio_set_alternate_function(GPIO_A, GPIO_PIN_11, GPIO_AF_10);
    // gpio_set_alternate_function(GPIO_A, GPIO_PIN_12, GPIO_AF_10);

    // external pull-up
    gpio_enable(GPIO_B);
    gpio_set_output(GPIO_B, GPIO_PIN_5);
    gpio_pin_set(GPIO_B, GPIO_PIN_5);
    // internal pull-up

    //syscfg_pmc_config(SYSCFG_PMC_USB, 1);

    nvic_enable_interrupt_line(NVIC_IRQ_LINE_USB_LP);
}
コード例 #12
0
ファイル: 1wr.c プロジェクト: Ayesha-N/6lbr
/*----------------------------------------------------------------------------*
 reset the 1 wire.
Parameters:
Returns:
  1 if presence detect.
 *----------------------------------------------------------------------------*/
int
owr_reset(void)
{
  int result;

  cli();
  gpio_set_output(GPIO_1WR);
  gpio_set_off(GPIO_1WR);
  micro_delay(tRSTL);
  gpio_set_input(GPIO_1WR);
  micro_delay(tMSP);
  result = gpio_get(GPIO_1WR);
  micro_delay(tRSTL);
  sei();
  return !result;
}
コード例 #13
0
ファイル: 1wr.c プロジェクト: Ayesha-N/6lbr
/*----------------------------------------------------------------------------*
read one byte on 1 wire
Parameters:
Returns:
  value.
 *----------------------------------------------------------------------------*/
unsigned
owr_readb(void)
{
  unsigned result = 0;
  int i;

  for(i = 0; i < 8; i++) {
    result >>= 1;
    gpio_set_output(GPIO_1WR);
    micro_delay(tRL);
    gpio_set_input(GPIO_1WR);
    micro_delay(tMSR);
    if(gpio_get(GPIO_1WR)) {
      result |= 0x80;
    }
    micro_delay(tSLOT - tRL);
  }
  return result;
}
コード例 #14
0
void keyboard_emulator_init() {
    gpio_set_output(CLK);
    gpio_set_output(DATA);
}
コード例 #15
0
ファイル: dht22.c プロジェクト: frankgalynsky/meteo-zone2
bool dht22_read_data(struct dht22 *dht, float *temp, float *hum, struct error *err)
{
    uint32_t count = 0;
    uint32_t threshold = 0;
    uint32_t pulseCounts[DHT_PULSES*2] = {0};

    gpio_set_output(dht->pin);
    gpio_max_priority();
    gpio_set_high(dht->pin);
    gpio_sleep_millis(500);
    gpio_set_low(dht->pin);
    gpio_wait_millis(20);
    gpio_set_input(dht->pin);

    /*
     * Need a very short delay before reading pins or else value
     * is sometimes still low.
     */
    for (volatile uint8_t i = 0; i < 50; ++i) {}

    /* Wait for DHT to pull pin low. */
    while (gpio_read(dht->pin))
        if (++count >= DHT_MAXCOUNT) {
            gpio_default_priority();
            strcpy(err->message, "Error timeout.");
            return false;
        }

    /* Record pulse widths for the expected result bits. */
    for (uint8_t i = 0; i < DHT_PULSES*2; i += 2) {
        while (!gpio_read(dht->pin))
            if (++pulseCounts[i] >= DHT_MAXCOUNT) {
                gpio_default_priority();
                strcpy(err->message, "Error timeout.");
                return false;
            }

        while (gpio_read(dht->pin))
            if (++pulseCounts[i+1] >= DHT_MAXCOUNT) {
                gpio_default_priority();
                strcpy(err->message, "Error timeout.");
                return false;
            }
    }
    gpio_default_priority();

    for (uint8_t i = 2; i < DHT_PULSES*2; i += 2)
        threshold += pulseCounts[i];

    threshold /= DHT_PULSES-1;

    /* Interpret each high pulse as a 0 or 1 by comparing it to the 50us reference.
     * If the count is less than 50us it must be a ~28us 0 pulse, and if it's higher
     * then it must be a ~70us 1 pulse.
     */
    for (uint8_t i = 3; i < DHT_PULSES*2; i += 2) {
        uint8_t index = (i-3)/16;

        dht->data[index] <<= 1;
        if (pulseCounts[i] >= threshold)
            dht->data[index] |= 1;
    }

    if (dht->data[4] == ((dht->data[0] + dht->data[1] + dht->data[2] + dht->data[3]) & 0xFF)) {
        *hum = (dht->data[0] * 256 + dht->data[1]) / 10.0f;
        *temp = ((dht->data[2] & 0x7F) * 256 + dht->data[3]) / 10.0f;
        if (dht->data[2] & 0x80)
            *temp *= -1.0f;
    } else
        strcpy(err->message, "Can not read data.");
    strcpy(err->message, "");
    return true;
}
コード例 #16
0
ファイル: oled.c プロジェクト: Lambros2014/spi
void LCD_Init(void){
	
	GPIO->GPIO_PORT[OLED1_DISPLAY_MOSI_PIN/32].GPIO_GPERC = OELD1_DISPLAY_MOSI_GPIO;
	GPIO->GPIO_PORT[OLED1_DISPLAY_SCK_PIN/32].GPIO_GPERC = OLED1_DISPLAY_SCK_GPIO;
	
	gpio_set_mux(OELD1_DISPLAY_MOSI_GPIO, OLED1_DISPLAY_MOSI_PIN, MUX_PERIPHERAL_A);
	gpio_set_mux(OLED1_DISPLAY_SCK_GPIO, OLED1_DISPLAY_SCK_PIN, MUX_PERIPHERAL_B);
	
	// CS pin as output
	gpio_set_output(OLED1_DISPLAY_SS_GPIO, OLED1_DISPLAY_SS_PIN);
	GPIO->GPIO_PORT[OLED1_DISPLAY_SS_PIN/32].GPIO_OVRS = OLED1_DISPLAY_SS_GPIO;
	
	// OLED reset pin as output
	gpio_set_output(OLED1_DISPLAY_RESET_GPIO, OLED1_DISPLAY_RESET_PIN);
	GPIO->GPIO_PORT[OLED1_DISPLAY_RESET_PIN/32].GPIO_OVRS = OLED1_DISPLAY_RESET_GPIO;
	
	// OLED data/cmd pin as output
	gpio_set_output(OLED1_DATACMD_GPIO, OLED1_DATACMD_PIN);
	GPIO->GPIO_PORT[OLED1_DATACMD_PIN/32].GPIO_OVRS = OLED1_DATACMD_GPIO;

	// Enable SPI clock.
	PM->PM_UNLOCK = PM_UNLOCK_KEY(0xAA) | PM_UNLOCK_ADDR(0x028);
	PM->PM_PBAMASK |= PM_PBAMASK_SPI;
	
	// Set up SPI mode
	SPI->SPI_MR |= SPI_MR_MSTR | SPI_MR_MODFDIS | SPI_MR_PCS(0b1011);
	
	// Configure NPCS2
	SPI->SPI_CSR[2] |= SPI_CSR_SCBR(1) | SPI_CSR_DLYBCT(0x01) | SPI_CSR_CPOL;
	
	//Enable the SPI module.
	SPI->SPI_CR |= SPI_CR_SPIEN;
	
	LCD_Poweron_Reset();
	#if 1 //128x32
	//Set Display off
	LCD_buffer[0] = OLED_SET_DISPLAY_OFF;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);
	
	//Set Display clock Div Ration
	LCD_buffer[0] = OLED_SET_FREQUENCY;
	LCD_buffer[1] = 0x80;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);
	
	//Set Display mux ratio
	LCD_buffer[0] = OLED_SET_MUX_RATIO;
	LCD_buffer[1] = 0x1F;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);
	
	//Set Display offset
	LCD_buffer[0] = OLED_SET_DISP_OFFSET;
	LCD_buffer[1] = 0x00;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);
	
	//Set Display Start line
	LCD_buffer[0] = OLED_SET_START_LINE(0);
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);

	//Enable charge pump
	LCD_buffer[0] = 0x8D;
	LCD_buffer[1] = 0x14;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);

	//Set Display Segment remap
	LCD_buffer[0] = OLED_SET_SEG_REMAP_REW;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);

	//Set Display COM Scan Direction
	LCD_buffer[0] = OLED_SET_COM_SCAN_DIR_REW;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);

	//Set COM pins HW Config
	LCD_buffer[0] = OLED_SET_COM_HW_CONF;
	LCD_buffer[1] = 0x02;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);

	//Set Contrast
	LCD_buffer[0] = OLED_SET_CONTRAST;
	LCD_buffer[1] = 0x8F;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);

	//Set Precharge
	LCD_buffer[0] = OLED_SET_PRECHARGE;
	LCD_buffer[1] = 0x22;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);

	//Set VCOMH Deselect Level
	LCD_buffer[0] = OLED_SET_VCOM_DESELECT;
	LCD_buffer[1] = 0x40;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);

	//Set Display On/Off
	LCD_buffer[0] = OLED_ENTIRE_DISPLAY_OFF;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);

	//Set Display Normal/Inverse
	LCD_buffer[0] = OLED_SET_DISPLAY_NORMAL;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);

	//Set Display On
	LCD_buffer[0] = OLED_SET_DISPLAY_ON;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);
	#else //128x64

	//Set Display off
	LCD_buffer[0] = OLED_SET_DISPLAY_OFF;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);
	
	//Set Display clock Div Ration
	LCD_buffer[0] = OLED_SET_FREQUENCY;
	LCD_buffer[1] = 0x80;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);
	
	//Set Display mux ratio
	LCD_buffer[0] = OLED_SET_MUX_RATIO;
	LCD_buffer[1] = 0x1F;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);
	
	//Set Display offset
	LCD_buffer[0] = OLED_SET_DISP_OFFSET;
	LCD_buffer[1] = 0x00;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);
	
	//Set Display Start line
	LCD_buffer[0] = OLED_SET_START_LINE(0);
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);

	//Enable charge pump
	LCD_buffer[0] = 0x8D;
	LCD_buffer[1] = 0x14;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);

	//Set Display Segment remap
	LCD_buffer[0] = OLED_SET_SEG_REMAP_REW;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);

	//Set Display COM Scan Direction
	LCD_buffer[0] = OLED_SET_COM_SCAN_DIR_REW;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);

	//Set COM pins HW Config
	LCD_buffer[0] = OLED_SET_COM_HW_CONF;
	LCD_buffer[1] = 0x12;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);

	//Set Contrast
	LCD_buffer[0] = OLED_SET_CONTRAST;
	LCD_buffer[1] = 0x9F;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);

	//Set Precharge
	LCD_buffer[0] = OLED_SET_PRECHARGE;
	LCD_buffer[1] = 0x22;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);

	//Set VCOMH Deselect Level
	LCD_buffer[0] = OLED_SET_VCOM_DESELECT;
	LCD_buffer[1] = 0x30;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);

	//Set Display On/Off
	LCD_buffer[0] = OLED_ENTIRE_DISPLAY_OFF;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);

	//Set Display Normal/Inverse
	LCD_buffer[0] = OLED_SET_DISPLAY_NORMAL;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);

	//Set Display On
	LCD_buffer[0] = OLED_SET_DISPLAY_ON;
	SPI_Send_Buffer(&LCD_buffer[0], 1, LCD_COMMAND);
	#endif

	//Clear all RAM
	for(uint8_t page = 0; page<8; page++) {
		SPI_Send_Byte(LCD_COMMAND, OLED_SET_START_PAGE(page));
		for(uint8_t col = 0; col<128; col++){
			SPI_Send_Byte(LCD_DATA, 0x00);
		}
	}

	SPI_Send_Byte(LCD_COMMAND, OLED_SET_START_PAGE(0));

	LCD_buffer[0] = 0x22;
	LCD_buffer[1] = 0;
	LCD_buffer[2] = 3;
	SPI_Send_Buffer(&LCD_buffer[0], 3, LCD_COMMAND);

	LCD_buffer[0] = OLED_SET_ADDRESS_MODE;
	LCD_buffer[1] = 0x00;
	SPI_Send_Buffer(&LCD_buffer[0], 2, LCD_COMMAND);
}
コード例 #17
0
ファイル: gpio.c プロジェクト: ElvishArtisan/gpio
int gpio_ioctl(struct inode *inode,struct file *filp,
	       unsigned cmd,unsigned long arg)
{
  struct gpio_line out;
  struct gpio_mask mask;
  int mode;
  unsigned minor;

#ifdef KERNEL_2_4
  minor=MINOR(inode->i_rdev);
#else
  minor=iminor(inode);
#endif  // KERNEL_2_4

  switch(cmd) {
      case GPIO_GETINFO:
	if(copy_to_user((unsigned long *)arg,&boards[minor],
			sizeof(struct gpio_info))) {
	  return -EFAULT;
	}
	return 0;
	break;

      case GPIO_SETMODE:
	if(boards[minor].mode==GPIO_MODE_AUTO) {
	  return -EINVAL;
	}
	if(copy_from_user(&mode,(unsigned long *)arg,sizeof(unsigned))) {
	  return -EFAULT;
	}
       	if(boards[minor].mode==mode) {
	  return 0;
	}
	gpio_set_mode(mode,minor);
	return 0;
	break;

      case GPIO_GET_INPUTS:
	memset(&mask,0,sizeof(struct gpio_mask));
	mask.mask[0]=gpio_get_inputs(minor);
	if(copy_to_user((unsigned long *)arg,&mask,sizeof(struct gpio_mask))) {
	  return -EFAULT;
	}
	return 0;
	break;

      case GPIO_GET_OUTPUTS:
	memset(&mask,0,sizeof(struct gpio_mask));
	spin_lock(&gpio_spinlock);
	mask.mask[0]=board_state[minor];
	spin_unlock(&gpio_spinlock);
	if(copy_to_user((unsigned long *)arg,&mask,sizeof(struct gpio_mask))) {
	  return -EFAULT;
	}
	return 0;
	break;

      case GPIO_GET_FILTERS:
	memset(&mask,0,sizeof(struct gpio_mask));
	spin_lock(&gpio_spinlock);
	mask.mask[0]=board_filter[minor];
	spin_unlock(&gpio_spinlock);
	if(copy_to_user((unsigned long *)arg,&mask,sizeof(struct gpio_mask))) {
	  return -EFAULT;
	}
	return 0;
	break;

      case GPIO_SET_OUTPUT:
	if(copy_from_user(&out,(unsigned long *)arg,
			  sizeof(struct gpio_line))) {
	  return -EFAULT;
	}
	gpio_set_output(&out,minor);
	return 0;
	break;

      case GPIO_SET_FILTER:
	if(copy_from_user(&out,(unsigned long *)arg,
			  sizeof(struct gpio_line))) {
	  return -EFAULT;
	}
	gpio_set_filter(&out,minor);
	return 0;
	break;

      case GPIO_SET_OUTPUTS:
	if(copy_from_user(&mask,(unsigned long *)arg,
			  sizeof(struct gpio_mask))) {
	  return -EFAULT;
	}
	gpio_set_outputs(&mask,minor);
	return 0;
	break;

      case GPIO_SET_FILTERS:
	if(copy_from_user(&mask,(unsigned long *)arg,
			  sizeof(struct gpio_mask))) {
	  return -EFAULT;
	}
	if(gpio_set_filters(&mask,minor)==1) {
	  return -EINVAL;
	}
	return 0;
	break;
  }
  return -ENOTTY;
}