diff --git a/Demos/Host/ClassDriver/CDCHost/CDCHost.c b/Demos/Host/ClassDriver/CDCHost/CDCHost.c index 99c0c81727ba567f9c539b0959b8091ef61507a3..ded3e4c109928b85ac3fef54179bce83703d2e26 100644 --- a/Demos/Host/ClassDriver/CDCHost/CDCHost.c +++ b/Demos/Host/ClassDriver/CDCHost/CDCHost.c @@ -44,9 +44,14 @@ USB_ClassInfo_CDC_Host_t VirtualSerial_CDC_Interface = { .Config = { - .DataINPipeNumber = 1, - .DataOUTPipeNumber = 2, - .NotificationPipeNumber = 3, + .DataINPipeNumber = 1, + .DataINPipeDoubleBank = false, + + .DataOUTPipeNumber = 2, + .DataOUTPipeDoubleBank = false, + + .NotificationPipeNumber = 3, + .NotificationPipeDoubleBank = false, }, }; diff --git a/LUFA/Drivers/Peripheral/Serial.h b/LUFA/Drivers/Peripheral/Serial.h index bde1449e8980a74142e54b47a8ed7e3ce1d9db1c..4009331bd41cb24b0f8bfebb9c830617d9ffc379 100644 --- a/LUFA/Drivers/Peripheral/Serial.h +++ b/LUFA/Drivers/Peripheral/Serial.h @@ -68,12 +68,12 @@ /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is * not set. */ - #define SERIAL_UBBRVAL(baud) (((F_CPU / 16) / baud) - 1) + #define SERIAL_UBBRVAL(baud) (((F_CPU / 16) / (baud)) - 1) /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is * set. */ - #define SERIAL_2X_UBBRVAL(baud) (((F_CPU / 8) / baud) - 1) + #define SERIAL_2X_UBBRVAL(baud) (((F_CPU / 8) / (baud)) - 1) /* Pseudo-Function Macros: */ #if defined(__DOXYGEN__) diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c index 0bf1f70200ea27393216f9807365002ee96e1cad..a9f1c9c817cb7d6b8518fbda56a70a75b3eb07f6 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.c +++ b/LUFA/Drivers/USB/Class/Device/HID.c @@ -95,7 +95,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter { Endpoint_ClearSETUP(); - HIDInterfaceInfo->State.UsingReportProtocol = (USB_ControlRequest.wValue != 0x0000); + HIDInterfaceInfo->State.UsingReportProtocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00); Endpoint_ClearStatusStage(); } diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c index 88d4156141dfe480b04fdce4465abdfa88cc77d8..aac0931b1c07caea001ce057f54f9d36e5971567 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.c +++ b/LUFA/Drivers/USB/Class/Host/CDC.c @@ -97,7 +97,8 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) { Pipe_ConfigurePipe(CDCInterfaceInfo->Config.NotificationPipeNumber, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, - EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE); + EndpointData->EndpointAddress, EndpointData->EndpointSize, + CDCInterfaceInfo->Config.NotificationPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); CDCInterfaceInfo->State.NotificationPipeSize = EndpointData->EndpointSize; Pipe_SetInterruptPeriod(EndpointData->PollingIntervalMS); @@ -110,7 +111,8 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) { Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN, - EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE); + EndpointData->EndpointAddress, EndpointData->EndpointSize, + CDCInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); CDCInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize; FoundEndpoints |= CDC_FOUND_DATAPIPE_IN; @@ -118,7 +120,8 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo else { Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT, - EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE); + EndpointData->EndpointAddress, EndpointData->EndpointSize, + CDCInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); CDCInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize; FoundEndpoints |= CDC_FOUND_DATAPIPE_OUT; diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h index c0ebe09567287e93a6b1201a59f98db8ac4cdb42..9af0f6052455408631c8a18f21a397f8149c3bdc 100644 --- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h +++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h @@ -78,7 +78,7 @@ * // Can now access elements of the configuration header struct using the -> indirection operator * \endcode */ - #define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)DescriptorPtr) + #define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)(DescriptorPtr)) /** Casts a pointer to a descriptor inside the configuration descriptor into the given descriptor * type (as an actual struct instance rather than a pointer to a struct). diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index 4dfa1ef9b66c37affd516f8bced55c7567307146..5bbbb87b537d5120e724773ddd057469640a1862 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -351,12 +351,12 @@ #endif #if !defined(CONTROL_ONLY_DEVICE) - #define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = epnum; }MACROE + #define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = (epnum); }MACROE #else #define Endpoint_SelectEndpoint(epnum) (void)epnum #endif - #define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << epnum); UERST = 0; }MACROE + #define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << (epnum)); UERST = 0; }MACROE #define Endpoint_EnableEndpoint() MACROS{ UECONX |= (1 << EPEN); }MACROE @@ -372,7 +372,7 @@ #define Endpoint_GetEndpointInterrupts() UEINT - #define Endpoint_HasEndpointInterrupted(n) ((UEINT & (1 << n)) ? true : false) + #define Endpoint_HasEndpointInterrupted(n) ((UEINT & (1 << (n))) ? true : false) #define Endpoint_IsINReady() ((UEINTX & (1 << TXINI)) ? true : false) @@ -406,7 +406,7 @@ #define Endpoint_GetEndpointDirection() (UECFG0X & ENDPOINT_DIR_IN) - #define Endpoint_SetEndpointDirection(dir) MACROS{ UECFG0X = ((UECFG0X & ~ENDPOINT_DIR_IN) | dir); }MACROE + #define Endpoint_SetEndpointDirection(dir) MACROS{ UECFG0X = ((UECFG0X & ~ENDPOINT_DIR_IN) | (dir)); }MACROE #endif /* Enums: */ @@ -1179,11 +1179,11 @@ #endif #define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks) \ - Endpoint_ConfigureEndpoint_Prv(Number, \ - ((Type << EPTYPE0) | Direction), \ - ((1 << ALLOC) | Banks | \ + Endpoint_ConfigureEndpoint_Prv((Number), \ + (((Type) << EPTYPE0) | (Direction)), \ + ((1 << ALLOC) | (Banks) | \ (__builtin_constant_p(Size) ? \ - Endpoint_BytesToEPSizeMask(Size) : \ + Endpoint_BytesToEPSizeMask(Size) : \ Endpoint_BytesToEPSizeMaskDynamic(Size)))) /* Function Prototypes: */ diff --git a/LUFA/Drivers/USB/LowLevel/Host.h b/LUFA/Drivers/USB/LowLevel/Host.h index 50912ad7dc77e1a86bb5b271394523407eeba228..8cf1fe04741da4122e71b860320733dde7b6d272 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.h +++ b/LUFA/Drivers/USB/LowLevel/Host.h @@ -366,7 +366,7 @@ #define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE #define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE - #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = (addr & 0x7F); }MACROE + #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = ((addr) & 0x7F); }MACROE /* Enums: */ enum USB_Host_WaitMSErrorCodes_t diff --git a/LUFA/Drivers/USB/LowLevel/OTG.h b/LUFA/Drivers/USB/LowLevel/OTG.h index d95488e3ce9eab06dd11b9a51404df180db24974..a5ad6bad771ab3c23c457ffbdd120bcd83062668 100644 --- a/LUFA/Drivers/USB/LowLevel/OTG.h +++ b/LUFA/Drivers/USB/LowLevel/OTG.h @@ -118,7 +118,7 @@ #define USB_OTG_Host_IsHNPReceived() ((OTGCON & (1 << HNPREQ)) ? true : false) - #define USB_OTG_Device_InitiateSRP(type) MACROS{ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (type | (1 << SRPREQ))); }MACROE + #define USB_OTG_Device_InitiateSRP(type) MACROS{ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | ((type) | (1 << SRPREQ))); }MACROE #endif #endif diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index 4b7b900e917076d58979953ebf3fa987c1d25419..6e643778bb35d03a30b9560b05925757278d5490 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -420,9 +420,9 @@ #define Pipe_GetCurrentPipe() (UPNUM & PIPE_PIPENUM_MASK) - #define Pipe_SelectPipe(pipenum) MACROS{ UPNUM = pipenum; }MACROE + #define Pipe_SelectPipe(pipenum) MACROS{ UPNUM = (pipenum); }MACROE - #define Pipe_ResetPipe(pipenum) MACROS{ UPRST = (1 << pipenum); UPRST = 0; }MACROE + #define Pipe_ResetPipe(pipenum) MACROS{ UPRST = (1 << (pipenum)); UPRST = 0; }MACROE #define Pipe_EnablePipe() MACROS{ UPCONX |= (1 << PEN); }MACROE @@ -432,21 +432,21 @@ #define Pipe_GetPipeToken() (UPCFG0X & PIPE_TOKEN_MASK) - #define Pipe_SetToken(token) MACROS{ UPCFG0X = ((UPCFG0X & ~PIPE_TOKEN_MASK) | token); }MACROE + #define Pipe_SetToken(token) MACROS{ UPCFG0X = ((UPCFG0X & ~PIPE_TOKEN_MASK) | (token)); }MACROE #define Pipe_SetInfiniteINRequests() MACROS{ UPCONX |= (1 << INMODE); }MACROE - #define Pipe_SetFiniteINRequests(n) MACROS{ UPCONX &= ~(1 << INMODE); UPINRQX = n; }MACROE + #define Pipe_SetFiniteINRequests(n) MACROS{ UPCONX &= ~(1 << INMODE); UPINRQX = (n); }MACROE #define Pipe_IsConfigured() ((UPSTAX & (1 << CFGOK)) ? true : false) #define Pipe_BoundEndpointNumber() ((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK) - #define Pipe_SetInterruptPeriod(ms) MACROS{ UPCFG2X = ms; }MACROE + #define Pipe_SetInterruptPeriod(ms) MACROS{ UPCFG2X = (ms); }MACROE #define Pipe_GetPipeInterrupts() UPINT - #define Pipe_HasPipeInterrupted(n) ((UPINT & (1 << n)) ? true : false) + #define Pipe_HasPipeInterrupted(n) ((UPINT & (1 << (n))) ? true : false) #define Pipe_Unfreeze() MACROS{ UPCONX &= ~(1 << PFREEZE); }MACROE diff --git a/Projects/AVRISP/AVRISP.c b/Projects/AVRISP/AVRISP.c index 016d74ce8ddda9ae1b499a9b86b8de0257ac898e..44b8356cd2dac206fc1953b4dd9c22d06d9ed4b2 100644 --- a/Projects/AVRISP/AVRISP.c +++ b/Projects/AVRISP/AVRISP.c @@ -34,9 +34,6 @@ * the project and is responsible for the initial application hardware configuration. */ -// TODO: Add in software SPI for lower programming speeds below 125KHz -// TODO: Add reversed/shorted target connector checks - #include "AVRISP.h" /** Main program entry point. This routine contains the overall program flow, including initial diff --git a/Projects/Benito/Benito.c b/Projects/Benito/Benito.c index 2ee24dac77f34ccd466fd95fe823d0bd9a3dd952..5b81a54d173a02b9de989f71e0426a0d5e15682f 100644 --- a/Projects/Benito/Benito.c +++ b/Projects/Benito/Benito.c @@ -56,16 +56,19 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = { .Config = { - .ControlInterfaceNumber = 0, + .ControlInterfaceNumber = 0, - .DataINEndpointNumber = CDC_TX_EPNUM, - .DataINEndpointSize = CDC_TXRX_EPSIZE, + .DataINEndpointNumber = CDC_TX_EPNUM, + .DataINEndpointSize = CDC_TXRX_EPSIZE, + .DataINEndpointDoubleBank = false, - .DataOUTEndpointNumber = CDC_RX_EPNUM, - .DataOUTEndpointSize = CDC_TXRX_EPSIZE, + .DataOUTEndpointNumber = CDC_RX_EPNUM, + .DataOUTEndpointSize = CDC_TXRX_EPSIZE, + .DataOUTEndpointDoubleBank = false, - .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, - .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, + .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, + .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, + .NotificationEndpointDoubleBank = false, }, }; diff --git a/Projects/Magstripe/Magstripe.c b/Projects/Magstripe/Magstripe.c index 7b3f0be39aaa174bbd237088f4ce711f275f8c7a..69f17c7593ddf529267a3ebd2f06a9abfcd2b7c8 100644 --- a/Projects/Magstripe/Magstripe.c +++ b/Projects/Magstripe/Magstripe.c @@ -56,13 +56,14 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface = { .Config = { - .InterfaceNumber = 0, + .InterfaceNumber = 0, - .ReportINEndpointNumber = KEYBOARD_EPNUM, - .ReportINEndpointSize = KEYBOARD_EPSIZE, + .ReportINEndpointNumber = KEYBOARD_EPNUM, + .ReportINEndpointSize = KEYBOARD_EPSIZE, + .ReportINEndpointDoubleBank = KEYBOARD_EPSIZE, - .PrevReportINBuffer = PrevKeyboardHIDReportBuffer, - .PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer), + .PrevReportINBuffer = PrevKeyboardHIDReportBuffer, + .PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer), }, }; diff --git a/Projects/USBtoSerial/USBtoSerial.c b/Projects/USBtoSerial/USBtoSerial.c index a4a4625cea5cdaf0f0cfd7f75881ed66e5abd84d..747e027fe567926e75724ea2d3f77f82ef1d9e4f 100644 --- a/Projects/USBtoSerial/USBtoSerial.c +++ b/Projects/USBtoSerial/USBtoSerial.c @@ -50,16 +50,19 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = { .Config = { - .ControlInterfaceNumber = 0, + .ControlInterfaceNumber = 0, - .DataINEndpointNumber = CDC_TX_EPNUM, - .DataINEndpointSize = CDC_TXRX_EPSIZE, + .DataINEndpointNumber = CDC_TX_EPNUM, + .DataINEndpointSize = CDC_TXRX_EPSIZE, + .DataINEndpointDoubleBank = false, - .DataOUTEndpointNumber = CDC_RX_EPNUM, - .DataOUTEndpointSize = CDC_TXRX_EPSIZE, + .DataOUTEndpointNumber = CDC_RX_EPNUM, + .DataOUTEndpointSize = CDC_TXRX_EPSIZE, + .DataOUTEndpointDoubleBank = false, - .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, - .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, + .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, + .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, + .NotificationEndpointDoubleBank = false, }, };