From 00d9a3537a7a460b85447bdda9ee9d564b625cfa Mon Sep 17 00:00:00 2001 From: dmohamed Date: Tue, 4 Jul 2017 23:59:37 +0200 Subject: [PATCH] UPDATE --- Moteur/Moteur.c | 1 + USB/usb_driver | Bin 14512 -> 0 bytes USB/usb_driver.c | 28 +++++++++++++--------------- USB/usb_driver.o | Bin 0 -> 9160 bytes gadget/Descriptors.c | 4 ++-- 5 files changed, 16 insertions(+), 17 deletions(-) create mode 100644 USB/usb_driver.o diff --git a/Moteur/Moteur.c b/Moteur/Moteur.c index ae36c4e..c2438e6 100644 --- a/Moteur/Moteur.c +++ b/Moteur/Moteur.c @@ -84,6 +84,7 @@ int main(void) break; case MOVE_RIGHT: motor_right(); + send_serial('a'); send_ack(); break; case MOVE_LEFT: diff --git a/USB/usb_driver b/USB/usb_driver index 00ca27a..664dc22 100755 Binary files a/USB/usb_driver and b/USB/usb_driver differ diff --git a/USB/usb_driver.c b/USB/usb_driver.c index c6e7975..595ea36 100644 --- a/USB/usb_driver.c +++ b/USB/usb_driver.c @@ -1,7 +1,7 @@ #include //bibliothèque USB #include #include -#include + #include #include #include @@ -150,7 +150,7 @@ void enumeration(libusb_context *context) //Enumération des périphériques USB -void envoie(unsigned char c) +void envoi(unsigned char c) { /* To send a char to the device simply initiate a bulk_transfer to the * Endpoint with address ep_out_addr. @@ -187,7 +187,7 @@ int main() { //Initialisation de la bibliotheque libusb libusb_context *context; - unsigned char * buf; + unsigned char buf[65]; int len; int status=libusb_init(&context); @@ -208,9 +208,7 @@ int main() } -/* - set line encoding: here 9600 8N1 - * 9600 = 0x2580 ~> 0x80, 0x25 in little endian - */ + //Configuration du port série. unsigned char encoding[] = { 0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08 }; status = libusb_control_transfer(handle, 0x21, 0x20, 0, 0, encoding, @@ -239,33 +237,33 @@ int main() return 0; break; case 'd': - envoie(LED_ON); + envoi(LED_ON); sleep(1); - //len = read_chars(buf, 1); - + break; case 'g': - envoie(LED_OFF); + envoi(LED_OFF); sleep(1); break; case 'h': - envoie(MOVE_LEFT); + envoi(MOVE_LEFT); sleep(1); break; case 'b': - envoie(MOVE_RIGHT); + envoi(MOVE_RIGHT); sleep(1); break; case 't' : - envoie(MOVE_STOP); + envoi(MOVE_STOP); sleep(1); break; default : printf("Commande invalide ! Retaper :\n"); break; } - } - + + sleep(1); +} return 0; } diff --git a/USB/usb_driver.o b/USB/usb_driver.o new file mode 100644 index 0000000..0693752 Binary files /dev/null and b/USB/usb_driver.o differ diff --git a/gadget/Descriptors.c b/gadget/Descriptors.c index c8a13df..32f983c 100644 --- a/gadget/Descriptors.c +++ b/gadget/Descriptors.c @@ -185,13 +185,13 @@ const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARR * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device * Descriptor. */ -const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"Dean Camera"); +const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"Djamil MOHAMED"); /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device * Descriptor. */ -const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"LUFA USB-RS232 Adapter"); +const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"USB gadget"); /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" * documentation) by the application code so that the address and size of a requested descriptor can be given -- libgit2 0.21.2