From 0f35fd7a47583f9435e62a19acb797719d09ca65 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Sat, 4 Dec 2010 07:25:17 +0300 Subject: [PATCH] Add bulk receive code to USB abstraction. --- usbdev.c | 11 ++++++++++- usbdev.h | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/usbdev.c b/usbdev.c index d8b10a5..ebda583 100644 --- a/usbdev.c +++ b/usbdev.c @@ -1,6 +1,7 @@ /* * JzBoot: an USB bootloader for JZ series of Ingenic(R) microprocessors. - * Copyright (C) 2010 Sergey Gridassov + * Copyright (C) 2010 Sergey Gridassov , + * Peter Zotov * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -143,6 +144,14 @@ int usbdev_sendbulk(void *hndl, void *data, int size) { return translate_libusb(libusb_bulk_transfer(hndl, ENDPOINT_OUT, data, size, &trans, CONTROL_TIMEOUT)); } +int usbdev_recvbulk(void *hndl, void *data, int size) { + int trans; + + debug(LEVEL_DEBUG, "Bulk: reading data %p, size %d\n", data, size); + + return translate_libusb(libusb_bulk_transfer(hndl, ENDPOINT_IN, data, size, &trans, CONTROL_TIMEOUT)); +} + static int translate_libusb(int code) { switch(code) { case LIBUSB_SUCCESS: diff --git a/usbdev.h b/usbdev.h index 772308e..6bc24d1 100644 --- a/usbdev.h +++ b/usbdev.h @@ -1,6 +1,7 @@ /* * JzBoot: an USB bootloader for JZ series of Ingenic(R) microprocessors. - * Copyright (C) 2010 Sergey Gridassov + * Copyright (C) 2010 Sergey Gridassov , + * Peter Zotov * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,5 +33,6 @@ void *usbdev_open(void *dev); void usbdev_close(void *hndl); int usbdev_vendor(void *hndl, int direction, uint8_t req, uint16_t value, uint16_t index, void *data, uint16_t size); int usbdev_sendbulk(void *hndl, void *data, int size); +int usbdev_recvbulk(void *hndl, void *data, int size); #endif