From 180b07871491b9fa9eecffc61bc11f4fec309dbb Mon Sep 17 00:00:00 2001 From: Stefan Krulj Date: Tue, 10 Jul 2012 23:55:31 +0200 Subject: [PATCH] Read works now but uses git statusbusy waitgit status --- char_dev.c | 16 ++++------------ ftdi_daemon.c | 23 +++++++++++++++++------ gpio_callbacks.c | 11 ++++++----- usb_gpio.c | 10 ++++++++++ 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/char_dev.c b/char_dev.c index ad17e6f..ad57e0d 100644 --- a/char_dev.c +++ b/char_dev.c @@ -1,13 +1,4 @@ -static char device_buffer[1]; -static int major; -static uint8_t buff_empty=1; -static uint8_t buff_start; -static uint8_t buff_end; - - -static uint8_t buffer[BUFFER_SIZE]; - static uint8_t readBuffer(void){ uint8_t ret; if(buff_empty){ @@ -59,16 +50,17 @@ static ssize_t device_write(struct file *filp, const char __user *buff, size_t l if(len!=1){ return -EINVAL; } - ret = copy_from_user(device_buffer, buff, len); + ret = copy_from_user(pin_status, buff, len); if( ret<0 ){ printk("<1>%s: Device write error!\n",MOD_NAME); return 0; } + n_written=0; return len; } struct file_operations fops = { - read: device_read, - write: device_write, + read: device_read, + write: device_write, }; diff --git a/ftdi_daemon.c b/ftdi_daemon.c index b92d8f5..770d8c0 100644 --- a/ftdi_daemon.c +++ b/ftdi_daemon.c @@ -41,7 +41,8 @@ static int get_value(unsigned offset){ DEBUG_OUT("%s: GET_VALUE of pin%d\n",MOD_NAME,offset); if( !is_output(offset) ){ - if( ftdi_read_pins(&ftdic,&USB_GPIO_PIN) < 0){ + + if( ftdi_read_pins(&ftdic,&USB_GPIO_PIN) < 0){ LOG("%s: Unable to read pin%d \n",MOD_NAME,offset); } return !!((USB_GPIO_PIN) & (1<%s: GET_VALUE of pin%d ",MOD_NAME,offset); - ret=writeToBuffer(offset); - ret|=writeToBuffer(CMD_READ); + writeToBuffer(offset); + writeToBuffer(CMD_READ); - return -ret; + n_written=1; + while(n_written){}; + + return pin_status[0]; } static void set_value(struct gpio_chip *chip, unsigned offset, int value){ diff --git a/usb_gpio.c b/usb_gpio.c index 806ce40..33b3cb7 100644 --- a/usb_gpio.c +++ b/usb_gpio.c @@ -3,6 +3,16 @@ static struct gpio_chip ft232_chip; static struct subprocess_info *sub_info; +static char pin_status[1]; +static int major; +static uint8_t buff_empty=1; +static uint8_t buff_start; +static uint8_t buff_end; + +static uint8_t buffer[BUFFER_SIZE]; + +static volatile int n_written; + #include "char_dev.c" #include "gpio_callbacks.c"