From 4dcf881007757711016db70a54aa4a7d289cb54f Mon Sep 17 00:00:00 2001 From: rguillom Date: Tue, 14 Jan 2020 20:07:15 +0100 Subject: [PATCH] Descripteurs au propre --- lufa-master/PolytechLille/PAD/Descriptors.c | 185 +++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------ lufa-master/PolytechLille/PAD/Descriptors.h | 11 ++++++++--- 2 files changed, 43 insertions(+), 153 deletions(-) diff --git a/lufa-master/PolytechLille/PAD/Descriptors.c b/lufa-master/PolytechLille/PAD/Descriptors.c index 547b872..bd72ec7 100644 --- a/lufa-master/PolytechLille/PAD/Descriptors.c +++ b/lufa-master/PolytechLille/PAD/Descriptors.c @@ -29,7 +29,6 @@ this software. */ - /** \file * * USB Device Descriptors, for library use when in USB device mode. Descriptors are special @@ -39,13 +38,10 @@ #include "Descriptors.h" -////////////////////////////////////////////////////////////////////////// - - -/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage - * of the device in one of its supported configurations, including information about any device interfaces - * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting - * a configuration so that the host may correctly communicate with the USB device. +/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall + * device characteristics, including the supported USB version, control endpoint size and the + * number of device configurations. The descriptor is read out by the USB host when the enumeration + * process begins. */ const USB_Descriptor_Device_t PROGMEM RelayBoard_DeviceDescriptor = { @@ -58,8 +54,8 @@ const USB_Descriptor_Device_t PROGMEM RelayBoard_DeviceDescriptor = .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, - .VendorID = 0x04B4, - .ProductID = 0xFD11, + .VendorID = 0x04B4, //A MODIFIER avec VendorID Carte + .ProductID = 0xFD11, //A MODIFIER .ReleaseNumber = VERSION_BCD(2,0,0), .ManufacturerStrIndex = STRING_ID_Manufacturer, @@ -67,50 +63,58 @@ const USB_Descriptor_Device_t PROGMEM RelayBoard_DeviceDescriptor = .SerialNumStrIndex = STRING_ID_Serial, .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS - - -//////////////////////////////////////////////////////////////////////////// - - +}; /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage * of the device in one of its supported configurations, including information about any device interfaces * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting * a configuration so that the host may correctly communicate with the USB device. */ -const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = +const USB_Descriptor_Configuration_t PROGMEM RelayBoard_ConfigurationDescriptor = { .Config = { .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), - .TotalInterfaces = 2,// MODIF ICI (1 au début) + .TotalInterfaces = 2, .ConfigurationNumber = 1, .ConfigurationStrIndex = NO_DESCRIPTOR, - .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED), + .ConfigAttributes = USB_CONFIG_ATTR_RESERVED, - .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) + .MaxPowerConsumption = USB_CONFIG_POWER_MA(500) }, -////////////////////////////////////////////////////////////////////////////// AJOUT - .InterfaceOUT = + + /* Description Interface SORTIE (LED)*/ + .InferfaceOUT = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, - .InterfaceNumber = INTERFACE_ID_InterfaceOUT, //pas sur mais presque - .AlternateSetting = 0x00, + .InterfaceNumber = INTERFACE_ID_InterfaceOUT, + .AlternateSetting = 0, .TotalEndpoints = 1, - .Class = HID_CSCP_HIDClass, - .SubClass = HID_CSCP_BootSubclass, - .Protocol = HID_CSCP_KeyboardBootProtocol, + .Class = USB_CSCP_VendorSpecificClass, + .SubClass = 0x00, + .Protocol = 0x00, .InterfaceStrIndex = NO_DESCRIPTOR }, + + .HID_KeyboardHID = + { + .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, + .HIDSpec = VERSION_BCD(1,1,1), + .CountryCode = 0x00, + .TotalReportDescriptors = 1, + .HIDReportType = HID_DTYPE_Report, + .HIDReportLength = sizeof(KeyboardReport) + }, + .ReportOUTEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, @@ -120,7 +124,9 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .EndpointSize = KEYBOARD_EPSIZE, .PollingIntervalMS = 0x05 }, -////////////////////////////////////////////////////////////////////////////// FIN AJOUT + + + /* Description interface IN (Boutons)*/ .InterfaceIN = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, @@ -137,7 +143,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .InterfaceStrIndex = NO_DESCRIPTOR }, - .ReportINEndpoint1 = + .ReportINEndpointBoutons = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, @@ -147,7 +153,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .PollingIntervalMS = 0x05 }, - .ReportINEndpoint2 = + .ReportINEndpointJoysticks = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, @@ -158,36 +164,6 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = } }; -//////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests - * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate - * via the language ID table available at USB.org what languages the device supports for its string descriptors. - */ -const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARRAY(LANGUAGE_ID_ENG); - -/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer'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 ManufacturerString = USB_STRING_DESCRIPTOR(L"LUFA Library"); - -/** 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 Keyboard Demo"); - -/** 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 - * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function - * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the - * USB host. - */ - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate * via the language ID table available at USB.org what languages the device supports for its string descriptors. @@ -222,12 +198,6 @@ const USB_Descriptor_String_t PROGMEM RelayBoard_SerialString = USB_STRING_DESCR * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the * USB host. */ - - - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////////////////// uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress) @@ -241,67 +211,6 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, switch (DescriptorType) { case DTYPE_Device: - Address = &DeviceDescriptor; - Size = sizeof(USB_Descriptor_Device_t); - break; - case DTYPE_Configuration: - Address = &ConfigurationDescriptor; - Size = sizeof(USB_Descriptor_Configuration_t); - break; - case DTYPE_String: - switch (DescriptorNumber) - { - case STRING_ID_Language: - Address = &LanguageString; - Size = pgm_read_byte(&LanguageString.Header.Size); - break; - case STRING_ID_Manufacturer: - Address = &ManufacturerString; - Size = pgm_read_byte(&ManufacturerString.Header.Size); - break; - case STRING_ID_Product: - Address = &ProductString; - Size = pgm_read_byte(&ProductString.Header.Size); - break; - } - - break; - case HID_DTYPE_HID: - Address = &ConfigurationDescriptor.HID_KeyboardHID; - Size = sizeof(USB_HID_Descriptor_HID_t); - break; - case HID_DTYPE_Report: - Address = &KeyboardReport; - Size = sizeof(KeyboardReport); - break; - } - - *DescriptorAddress = Address; - return Size; -} - - -///////////////////////////////////////////////////////////////////////////////// - - -uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, - const uint16_t wIndex, - const void** const DescriptorAddress) -{ - cons -/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage - * of the device in one of its supported configurations, including information about any device interfaces - * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting - * a configuration so that the host may correctly communicate with the USB device. - */t uint8_t DescriptorType = (wValue >> 8); - const uint8_t DescriptorNumber = (wValue & 0xFF); - - const void* Address = NULL; - uint16_t Size = NO_DESCRIPTOR; - - switch (DescriptorType) - { - case DTYPE_Device: Address = &RelayBoard_DeviceDescriptor; Size = sizeof(USB_Descriptor_Device_t); break; @@ -337,27 +246,3 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, return Size; } - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lufa-master/PolytechLille/PAD/Descriptors.h b/lufa-master/PolytechLille/PAD/Descriptors.h index 3b25d00..46cfbad 100644 --- a/lufa-master/PolytechLille/PAD/Descriptors.h +++ b/lufa-master/PolytechLille/PAD/Descriptors.h @@ -51,7 +51,13 @@ USB_Descriptor_Configuration_Header_t Config; // Relay Board Interface - USB_Descriptor_Interface_t RelayBoardInterface; + USB_Descriptor_Interface_t InterfaceOUT; + USB_HID_Descriptor_HID_t HID_KeyboardHID; //UTILE ? + USB_Descriptor_Endpoint_t HID_ReportOUTEndpoint; + + USB_Descriptor_Interface_t InterfaceIN; + USB_Descriptor_Endpoint_t HID_ReportINEndpointBoutons; + USB_Descriptor_Endpoint_t HID_ReportOUTEndpointJoysticks; } USB_Descriptor_Configuration_t; /** Enum for the device interface descriptor IDs within the device. Each interface descriptor @@ -60,8 +66,7 @@ */ enum InterfaceDescriptors_t { - INTERFACE_ID_InterfaceOUT = 0, - INTERFACE_ID_InterfaceIN = 1,/**< Relay board interface descriptor ID */ + INTERFACE_ID_RelayBoard = 0, /**< Relay board interface descriptor ID */ }; /** Enum for the device string descriptor IDs within the device. Each string descriptor should -- libgit2 0.21.2