Commit 00d9a3537a7a460b85447bdda9ee9d564b625cfa
1 parent
28da8e7b
UPDATE
Showing
5 changed files
with
16 additions
and
17 deletions
Show diff stats
Moteur/Moteur.c
USB/usb_driver
No preview for this file type
USB/usb_driver.c
1 | #include <libusb-1.0/libusb.h> //bibliothèque USB | 1 | #include <libusb-1.0/libusb.h> //bibliothèque USB |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | -#include <termios.h> | 4 | + |
5 | #include <fcntl.h> | 5 | #include <fcntl.h> |
6 | #include <strings.h> | 6 | #include <strings.h> |
7 | #include <unistd.h> | 7 | #include <unistd.h> |
@@ -150,7 +150,7 @@ void enumeration(libusb_context *context) //Enumération des périphériques USB | @@ -150,7 +150,7 @@ void enumeration(libusb_context *context) //Enumération des périphériques USB | ||
150 | 150 | ||
151 | 151 | ||
152 | 152 | ||
153 | -void envoie(unsigned char c) | 153 | +void envoi(unsigned char c) |
154 | { | 154 | { |
155 | /* To send a char to the device simply initiate a bulk_transfer to the | 155 | /* To send a char to the device simply initiate a bulk_transfer to the |
156 | * Endpoint with address ep_out_addr. | 156 | * Endpoint with address ep_out_addr. |
@@ -187,7 +187,7 @@ int main() | @@ -187,7 +187,7 @@ int main() | ||
187 | { | 187 | { |
188 | //Initialisation de la bibliotheque libusb | 188 | //Initialisation de la bibliotheque libusb |
189 | libusb_context *context; | 189 | libusb_context *context; |
190 | - unsigned char * buf; | 190 | + unsigned char buf[65]; |
191 | int len; | 191 | int len; |
192 | 192 | ||
193 | int status=libusb_init(&context); | 193 | int status=libusb_init(&context); |
@@ -208,9 +208,7 @@ int main() | @@ -208,9 +208,7 @@ int main() | ||
208 | } | 208 | } |
209 | 209 | ||
210 | 210 | ||
211 | -/* - set line encoding: here 9600 8N1 | ||
212 | - * 9600 = 0x2580 ~> 0x80, 0x25 in little endian | ||
213 | - */ | 211 | + |
214 | //Configuration du port série. | 212 | //Configuration du port série. |
215 | unsigned char encoding[] = { 0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08 }; | 213 | unsigned char encoding[] = { 0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08 }; |
216 | status = libusb_control_transfer(handle, 0x21, 0x20, 0, 0, encoding, | 214 | status = libusb_control_transfer(handle, 0x21, 0x20, 0, 0, encoding, |
@@ -239,33 +237,33 @@ int main() | @@ -239,33 +237,33 @@ int main() | ||
239 | return 0; | 237 | return 0; |
240 | break; | 238 | break; |
241 | case 'd': | 239 | case 'd': |
242 | - envoie(LED_ON); | 240 | + envoi(LED_ON); |
243 | sleep(1); | 241 | sleep(1); |
244 | - //len = read_chars(buf, 1); | ||
245 | - | 242 | + |
246 | break; | 243 | break; |
247 | case 'g': | 244 | case 'g': |
248 | - envoie(LED_OFF); | 245 | + envoi(LED_OFF); |
249 | sleep(1); | 246 | sleep(1); |
250 | break; | 247 | break; |
251 | case 'h': | 248 | case 'h': |
252 | - envoie(MOVE_LEFT); | 249 | + envoi(MOVE_LEFT); |
253 | sleep(1); | 250 | sleep(1); |
254 | break; | 251 | break; |
255 | case 'b': | 252 | case 'b': |
256 | - envoie(MOVE_RIGHT); | 253 | + envoi(MOVE_RIGHT); |
257 | sleep(1); | 254 | sleep(1); |
258 | break; | 255 | break; |
259 | case 't' : | 256 | case 't' : |
260 | - envoie(MOVE_STOP); | 257 | + envoi(MOVE_STOP); |
261 | sleep(1); | 258 | sleep(1); |
262 | break; | 259 | break; |
263 | default : | 260 | default : |
264 | printf("Commande invalide ! Retaper :\n"); | 261 | printf("Commande invalide ! Retaper :\n"); |
265 | break; | 262 | break; |
266 | } | 263 | } |
267 | - } | ||
268 | - | 264 | + |
265 | + sleep(1); | ||
266 | +} | ||
269 | 267 | ||
270 | return 0; | 268 | return 0; |
271 | } | 269 | } |
No preview for this file type
gadget/Descriptors.c
@@ -185,13 +185,13 @@ const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARR | @@ -185,13 +185,13 @@ const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARR | ||
185 | * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | 185 | * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device |
186 | * Descriptor. | 186 | * Descriptor. |
187 | */ | 187 | */ |
188 | -const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"Dean Camera"); | 188 | +const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"Djamil MOHAMED"); |
189 | 189 | ||
190 | /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | 190 | /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, |
191 | * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | 191 | * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device |
192 | * Descriptor. | 192 | * Descriptor. |
193 | */ | 193 | */ |
194 | -const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"LUFA USB-RS232 Adapter"); | 194 | +const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"USB gadget"); |
195 | 195 | ||
196 | /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | 196 | /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" |
197 | * documentation) by the application code so that the address and size of a requested descriptor can be given | 197 | * documentation) by the application code so that the address and size of a requested descriptor can be given |