? build Index: .cvsignore =================================================================== RCS file: /cvs/gnome/libgpio/.cvsignore,v retrieving revision 1.1 diff -u -r1.1 .cvsignore --- .cvsignore 2000/06/11 17:33:57 1.1 +++ .cvsignore 2000/07/20 22:24:00 @@ -21,3 +21,5 @@ gpio-usb.lo gpioConf.sh libgpio.la +Makefile +Makefile.in Index: ChangeLog =================================================================== RCS file: /cvs/gnome/libgpio/ChangeLog,v retrieving revision 1.3 diff -u -r1.3 ChangeLog --- ChangeLog 2000/07/15 18:59:16 1.3 +++ ChangeLog 2000/07/20 22:24:00 @@ -1,3 +1,9 @@ +2000-07-20 Fabrice Bellet + + * .cvsignore : added Makefile and Makefile.in + * gpio-usb.[hc] : changed gpio_usb_clear_halt() so we + can choose which endpoint to reset. + 2000-07-15 Fabrice Bellet * gpio-usb.c : removed useless call to usb_release_interface() Index: gpio-ieee1394.c =================================================================== RCS file: /cvs/gnome/libgpio/gpio-ieee1394.c,v retrieving revision 1.6 diff -u -r1.6 gpio-ieee1394.c --- gpio-ieee1394.c 2000/06/26 22:14:17 1.6 +++ gpio-ieee1394.c 2000/07/20 22:24:00 @@ -40,6 +40,10 @@ int gpio_ieee1394_update (gpio_device *dev); +int gpio_ieee1394_clear_halt (gpio_device *dev); + +/* private */ + int gpio_ieee1394_set_baudrate(gpio_device *dev); @@ -53,8 +57,9 @@ gpio_ieee1394_read, gpio_ieee1394_write, gpio_ieee1394_get_pin, - gpio_iee1394_set_pin, - gpio_ieee1394_update + gpio_iee1394_set_pin, + gpio_ieee1394_update, + gpio_ieee1394_clear_halt }; /* IEEE1394 API functions @@ -104,4 +109,13 @@ int gpio_ieee1394_update (gpio_device *dev) { +} + +/* + * This function does nothing with IEEE1394 + * + */ + +int gpio_ieee1394_clear_halt (gpio_device *dev, int ep) { + return GPIO_OK; } Index: gpio-network.c =================================================================== RCS file: /cvs/gnome/libgpio/gpio-network.c,v retrieving revision 1.1 diff -u -r1.1 gpio-network.c --- gpio-network.c 2000/07/13 22:40:34 1.1 +++ gpio-network.c 2000/07/20 22:24:00 @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ +#include #include "gpio.h" /* network prototypes @@ -40,6 +41,10 @@ int gpio_network_update (gpio_device *dev); +int gpio_network_clear_halt (gpio_device *dev, int ep); + +/* private */ + int gpio_network_set_baudrate(gpio_device *dev); struct gpio_operations gpio_network_operations = @@ -53,7 +58,8 @@ gpio_network_write, gpio_network_get_pin, gpio_network_set_pin, - gpio_network_update + gpio_network_update, + gpio_network_clear_halt }; @@ -104,4 +110,13 @@ int gpio_network_update (gpio_device *dev) { +} + +/* + * This function does nothing for network + * + */ + +int gpio_network_clear_halt (gpio_device *dev, int ep) { + return GPIO_OK; } Index: gpio-parallel.c =================================================================== RCS file: /cvs/gnome/libgpio/gpio-parallel.c,v retrieving revision 1.7 diff -u -r1.7 gpio-parallel.c --- gpio-parallel.c 2000/07/17 17:25:24 1.7 +++ gpio-parallel.c 2000/07/20 22:24:00 @@ -51,6 +51,10 @@ int gpio_parallel_update (gpio_device *dev); +int gpio_parallel_clear_halt (gpio_device *dev, int ep); + +/* private */ + int gpio_parallel_set_baudrate(gpio_device *dev); struct gpio_operations gpio_parallel_operations = @@ -64,7 +68,8 @@ gpio_parallel_write, gpio_parallel_get_pin, gpio_parallel_set_pin, - gpio_parallel_update + gpio_parallel_update, + gpio_parallel_clear_halt }; @@ -134,4 +139,12 @@ int gpio_parallel_update (gpio_device *dev) { +} + +/* + * This function does nothing for parallel + * + */ +int gpio_parallel_clear_halt (gpio_device *dev, int ep) { + return GPIO_OK; } Index: gpio-serial.c =================================================================== RCS file: /cvs/gnome/libgpio/gpio-serial.c,v retrieving revision 1.9 diff -u -r1.9 gpio-serial.c --- gpio-serial.c 2000/07/17 17:25:24 1.9 +++ gpio-serial.c 2000/07/20 22:24:01 @@ -49,6 +49,8 @@ #include "gpio.h" +#define GPIO_SERIAL_DEBUG 1 + #ifdef HAVE_TERMIOS_H static struct termios term_old; #else @@ -68,11 +70,13 @@ int gpio_serial_read(gpio_device *dev, char *bytes, int size); int gpio_serial_write(gpio_device *dev, char *bytes, int size); -int gpio_serial_get_pin(gpio_device *dev, int pin); +int gpio_serial_get_pin(gpio_device *dev, int pin); int gpio_serial_set_pin(gpio_device *dev, int pin, int level); int gpio_serial_update (gpio_device *dev); +int gpio_serial_clear_halt(gpio_device *dev, int ep); + /* private */ int gpio_serial_set_baudrate(gpio_device *dev); static speed_t gpio_serial_baudconv(int rate); @@ -88,7 +92,8 @@ gpio_serial_write, gpio_serial_get_pin, gpio_serial_set_pin, - gpio_serial_update + gpio_serial_update, + gpio_serial_clear_halt }; /* Serial API functions @@ -134,6 +139,9 @@ } int gpio_serial_init (gpio_device *dev) { +#ifdef GPIO_SERIAL_DEBUG + printf ("gpio_serial_init() called\n"); +#endif /* save previous setttings in to dev->settings_saved */ #if HAVE_TERMIOS_H if (tcgetattr(dev->device_fd, &term_old) < 0) { @@ -150,11 +158,13 @@ } int gpio_serial_exit (gpio_device *dev) { - } int gpio_serial_open(gpio_device * dev) { +#ifdef GPIO_SERIAL_DEBUG + printf ("gpio_serial_open() called\n"); +#endif #ifdef __FreeBSD__ dev->device_fd = open(dev->settings.serial.port, O_RDWR | O_NOCTTY | O_NONBLOCK); @@ -175,6 +185,9 @@ int gpio_serial_close(gpio_device * dev) { +#ifdef GPIO_SERIAL_DEBUG + printf ("gpio_serial_close() called\n"); +#endif if (close(dev->device_fd) == -1) { perror("gpio_serial_close: tried closing device file descriptor"); return GPIO_ERROR; @@ -185,6 +198,14 @@ int gpio_serial_write(gpio_device * dev, char *bytes, int size) { int len, ret; +#ifdef GPIO_SERIAL_DEBUG + int i; + + printf ("gpio_serial_write(): "); + for (i=0;itimeout); + for (i=0;isettings, &dev->settings_pending, sizeof(dev->settings)); if (dev->device_fd != 0) { @@ -367,6 +426,15 @@ } /* + * This function does nothing for serial + * + */ +int gpio_serial_clear_halt(gpio_device * dev, int ep) +{ + return GPIO_OK; +} + +/* Serial port specific helper functions ---------------------------------------------------------------- */ @@ -377,6 +445,10 @@ #if HAVE_TERMIOS_H struct termios tio; +#ifdef GPIO_SERIAL_DEBUG + printf ("gpio_serial_set_baudrate(speed=%d) called\n", + dev->settings.serial.speed); +#endif if (tcgetattr(dev->device_fd, &tio) < 0) { perror("tcgetattr"); return GPIO_ERROR; @@ -415,6 +487,10 @@ #else struct sgttyb ttyb; +#ifdef GPIO_SERIAL_DEBUG + printf ("gpio_serial_set_baudrate(speed=%d) called\n", + dev->settings.serial.speed); +#endif if (ioctl(dev->device_fd, TIOCGETP, &ttyb) < 0) { perror("ioctl(TIOCGETP)"); return GPIO_ERROR; Index: gpio-usb.c =================================================================== RCS file: /cvs/gnome/libgpio/gpio-usb.c,v retrieving revision 1.11 diff -u -r1.11 gpio-usb.c --- gpio-usb.c 2000/07/15 18:59:16 1.11 +++ gpio-usb.c 2000/07/20 22:24:01 @@ -47,6 +47,9 @@ int gpio_usb_init(gpio_device *dev) { +#ifdef GPIO_USB_DEBUG + printf ("gpio_usb_init() called\n"); +#endif usb_init(); usb_find_busses(); usb_find_devices(); @@ -114,19 +117,38 @@ } -int gpio_usb_clear_halt (gpio_device * dev) +int gpio_usb_clear_halt (gpio_device * dev,int ep) { - if (usb_clear_halt (dev->device_handle, dev->settings.usb.inep) - || usb_clear_halt (dev->device_handle, dev->settings.usb.outep)) + int ret=0; + +#ifdef GPIO_USB_DEBUG + printf ("gpio_usb_clear_halt() called "); +#endif + switch (ep) { + case GPIO_USB_IN_ENDPOINT : +#ifdef GPIO_USB_DEBUG + printf ("[ep=IN]\n"); +#endif + ret=usb_clear_halt (dev->device_handle,dev->settings.usb.inep); + break; + case GPIO_USB_OUT_ENDPOINT : +#ifdef GPIO_USB_DEBUG + printf ("[ep=OUT]\n"); +#endif + ret=usb_clear_halt (dev->device_handle,dev->settings.usb.outep); + break; + default: + fprintf (stderr,"gpio_usb_clear_halt: bad EndPoint argument\n"); return GPIO_ERROR; - else - return GPIO_OK; + } + return (ret?GPIO_ERROR:GPIO_OK); } int gpio_usb_write(gpio_device * dev, char *bytes, int size) { - int i; #ifdef GPIO_USB_DEBUG + int i; + printf ("gpio_usb_write(): "); for (i=0;iops->set_pin(dev, pin, level); } +int gpio_clear_halt(gpio_device * dev, int ep) +{ + /* Reset an endpoint (USB only) */ + return dev->ops->clear_halt(dev, ep); +} int gpio_set_timeout(gpio_device * dev, int millisec_timeout) { dev->timeout = millisec_timeout; Index: gpio.h.in =================================================================== RCS file: /cvs/gnome/libgpio/gpio.h.in,v retrieving revision 1.15 diff -u -r1.15 gpio.h.in --- gpio.h.in 2000/07/17 17:25:24 1.15 +++ gpio.h.in 2000/07/20 22:24:02 @@ -93,16 +93,17 @@ struct gpio_device; typedef struct gpio_device gpio_device; struct gpio_operations { - int (*list) (gpio_device_info *, int*); - int (*init) (gpio_device *); - int (*exit) (gpio_device *); - int (*open) (gpio_device *); - int (*close) (gpio_device *); - int (*read) (gpio_device *, char *, int); - int (*write) (gpio_device *, char *, int); - int (*get_pin) (gpio_device *, int); - int (*set_pin) (gpio_device *, int, int); - int (*update) (gpio_device *); + int (*list) (gpio_device_info *, int*); + int (*init) (gpio_device *); + int (*exit) (gpio_device *); + int (*open) (gpio_device *); + int (*close) (gpio_device *); + int (*read) (gpio_device *, char *, int); + int (*write) (gpio_device *, char *, int); + int (*get_pin) (gpio_device *, int); + int (*set_pin) (gpio_device *, int, int); + int (*update) (gpio_device *); + int (*clear_halt) (gpio_device *, int); }; /* Specify the device information */ @@ -232,7 +233,7 @@ unsuccessful: GPIO_ERROR */ - int gpio_get_pin (gpio_device *dev, int pin); + int gpio_get_pin (gpio_device *dev, int pin); /* Give the status of pin from dev pin values: see PIN_ constants in the various .h files @@ -242,7 +243,7 @@ not implemented for USB (useful?) */ - int gpio_set_pin (gpio_device *dev, int pin, int level); + int gpio_set_pin (gpio_device *dev, int pin, int level); /* set the status of pin from dev to level pin values: see PIN_ constants in the various .h files @@ -253,6 +254,16 @@ successful: status unsuccessful: GPIO_ERROR not implemented for USB (useful?) + */ + int gpio_clear_halt (gpio_device *dev, int ep); + /* reset an endpoint on USB devices + ep value : + GPIO_USB_IN_ENDPOINT + GPIO_USB_OUT_ENDPOINT + return values: + successful: GPIO_OK + unsuccessful: GPIO_ERROR + only implemented (and useful) for USB */ #endif /* _GPIO_H_ */