From d491a2d57eb4ef99b7a356de15f7a75766ff643d Mon Sep 17 00:00:00 2001 From: gperson Date: Tue, 8 Dec 2020 13:10:25 +0100 Subject: [PATCH] correction de l'ajout des interfaces pour les leds et vibreurs, les interfaces ont leur id definie, leur taille aussi, et sont bien definis dans le descriptors.h aussi. correction de certaines erreurs de typo (qui me semblauient avoir ete corrigees precedemment mais apparemment pas ) --- src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Buttons.h | 2 +- src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Joystick.h | 8 ++++---- src/lufa-LUFA-170418/PolytechLille/Manette/Descriptors.c | 14 +++++++------- src/lufa-LUFA-170418/PolytechLille/Manette/Descriptors.h | 14 +++++++++++--- src/lufa-LUFA-170418/PolytechLille/Manette/Manette.c | 4 ++-- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Buttons.h b/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Buttons.h index 2861a44..187560b 100644 --- a/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Buttons.h +++ b/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Buttons.h @@ -168,7 +168,7 @@ { DDRF &= ~BUTTONS_HAUT; - PORTF |= BUTTONS_HAUT; + //PORTF |= BUTTONS_HAUT; pas besoin, ne sert que pour le port b apparemment faudrait enlever cette ligne pour tous les boutons sauf pour le port B } static inline void Buttons_Disable_HAUT(void) diff --git a/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Joystick.h b/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Joystick.h index d91ef2a..9da2ade 100644 --- a/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Joystick.h +++ b/src/lufa-LUFA-170418/LUFA/Drivers/Board/AVR8/PINGUI/Joystick.h @@ -139,12 +139,12 @@ static inline uint8_t Joystick_GetStatus(void) { adc_init(joy_X_ADC); - uinit8_t Xquatrebits = adc_read(); + uint8_t Xquatrebits = adc_read(); Xquatrebits&=0xF0; //pour les quatres bits de poids fort pour axe X - adc_init(joy_Y_ADC); - uinit8_t Yquatrebits = adc_read(); + adc_int(joy_Y_ADC); + uint8_t Yquatrebits = adc_read(); Yquatrebits&=0xF0; - Yquatrebits=Yquatrebits>>4 //pour les quatres bits de poids faible pour axe Y, on place en fort et on decale de 4 bits into le poids faible + Yquatrebits=Yquatrebits>>4; //pour les quatres bits de poids faible pour axe Y, on place en fort et on decale de 4 bits into le poids faible return (uint8_t)(Xquatrebits+Yquatrebits); } #endif diff --git a/src/lufa-LUFA-170418/PolytechLille/Manette/Descriptors.c b/src/lufa-LUFA-170418/PolytechLille/Manette/Descriptors.c index 961c14a..a96047e 100644 --- a/src/lufa-LUFA-170418/PolytechLille/Manette/Descriptors.c +++ b/src/lufa-LUFA-170418/PolytechLille/Manette/Descriptors.c @@ -139,12 +139,12 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = JOYSTICK_EPSIZE, .PollingIntervalMS = 0x05 - } -/* .HID_Interface1 = + }, + .HID_Interface1 = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, - .InterfaceNumber = INTERFACE_ID_Joystick, + .InterfaceNumber = INTERFACE_ID_LEDS, .AlternateSetting = 0x00, .TotalEndpoints = 1, @@ -160,7 +160,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - .EndpointAddress = JOYSTICK_EPADDR, + .EndpointAddress = LEDS_EPADDR, .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = JOYSTICK_EPSIZE, .PollingIntervalMS = 0x05 @@ -172,7 +172,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, - .InterfaceNumber = INTERFACE_ID_Joystick, + .InterfaceNumber = INTERFACE_ID_VIBRATORS, .AlternateSetting = 0x00, .TotalEndpoints = 1, @@ -188,14 +188,14 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - .EndpointAddress = JOYSTICK_EPADDR, + .EndpointAddress = VIBRATORS_EPADDR, .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = JOYSTICK_EPSIZE, .PollingIntervalMS = 0x05 }, -*/ + }; /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests diff --git a/src/lufa-LUFA-170418/PolytechLille/Manette/Descriptors.h b/src/lufa-LUFA-170418/PolytechLille/Manette/Descriptors.h index 468642c..2f4d22b 100644 --- a/src/lufa-LUFA-170418/PolytechLille/Manette/Descriptors.h +++ b/src/lufa-LUFA-170418/PolytechLille/Manette/Descriptors.h @@ -54,8 +54,11 @@ USB_Descriptor_Interface_t HID_Interface; USB_HID_Descriptor_HID_t HID_JoystickHID; USB_Descriptor_Endpoint_t HID_ReportINEndpoint; - // HID_Interface1;HID_ReportOUTEndpoint1; - // HID_Interface2;HID_ReportOUTEndpoint2; + USB_Descriptor_Interface_t HID_Interface1; + USB_Descriptor_Endpoint_t HID_ReportOUTEndpoint1; + USB_Descriptor_Interface_t HID_Interface2; + USB_Descriptor_Endpoint_t HID_ReportOUTEndpoint2; + } USB_Descriptor_Configuration_t; /** Enum for the device interface descriptor IDs within the device. Each interface descriptor @@ -65,6 +68,8 @@ enum InterfaceDescriptors_t { INTERFACE_ID_Joystick = 0, /**< Joystick interface desciptor ID */ + INTERFACE_ID_LEDS = 6, + INTERFACE_ID_VIBRATORS = 7, }; /** Enum for the device string descriptor IDs within the device. Each string descriptor should @@ -81,9 +86,12 @@ /* Macros: */ /** Endpoint address of the Joystick HID reporting IN endpoint. */ #define JOYSTICK_EPADDR (ENDPOINT_DIR_IN | 1) - + #define LEDS_EPADDR (ENDPOINT_DIR_IN | 6) + #define VIBRATORS_EPADDR (ENDPOINT_DIR_IN | 7) /** Size in bytes of the Joystick HID reporting IN endpoint. */ #define JOYSTICK_EPSIZE 8 + #define LEDS_EPSIZE 2 + #define VIBRATORS_EPSIZE 1 /* Function Prototypes: */ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, diff --git a/src/lufa-LUFA-170418/PolytechLille/Manette/Manette.c b/src/lufa-LUFA-170418/PolytechLille/Manette/Manette.c index 28ba1a9..fda194c 100644 --- a/src/lufa-LUFA-170418/PolytechLille/Manette/Manette.c +++ b/src/lufa-LUFA-170418/PolytechLille/Manette/Manette.c @@ -171,8 +171,8 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn JoystickReport->X = JoyStatus_LCL & 0xF0; JoystickReport->Y = JoyStatus_LCL & 0x0F; - if (JoyStatus_LCL & BUTTONS_SEL) - { JoystickReport->Button |= ( 1<<1);} + if (JoyStatus_LCL & BUTTONS_HAUT) + { JoystickReport->Button |= ( 1<<0);} // if (JoyStatus_LCL & JOY_LEFT) -- libgit2 0.21.2