Commit 557a945b authored by Dean Camera's avatar Dean Camera
Browse files

Removed all binary constants and replaced with decimal or hexadecimal...

Removed all binary constants and replaced with decimal or hexadecimal constants so that unpatched GCC compilers can still build the code without having to be itself patched and recompiled first.
parent 7d4cccc2
......@@ -20,6 +20,8 @@
* to early-abort
* - Move StdRequestType.h, StreamCallbacks.h, USBMode.h from the LowLevel USB driver directory to the HighLevel USB driver directory,
* where they are more suited
* - Removed all binary constants and replaced with decimal or hexadecimal constants so that unpatched GCC compilers can still build the
* code without having to be itself patched and recompiled first
*
* \section Sec_ChangeLog090401 Version 090401
*
......
......@@ -52,6 +52,11 @@
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared
* with the EP_TYPE_* masks to determine the exact type of the endpoint.
*/
#define EP_TYPE_MASK 0x03
/** Casts a pointer to a descriptor inside the configuration descriptor into a pointer to the given
* descriptor type.
*
......
......@@ -90,39 +90,41 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define DATA_SIZE_MASK 0b00000011
#define TYPE_MASK 0b00001100
#define TAG_MASK 0b11110000
#define DATA_SIZE_0 0b00000000
#define DATA_SIZE_1 0b00000001
#define DATA_SIZE_2 0b00000010
#define DATA_SIZE_4 0b00000011
#define DATA_SIZE_MASK 0x03
#define TYPE_MASK 0x0C
#define TAG_MASK 0xF0
#define DATA_SIZE_0 0x00
#define DATA_SIZE_1 0x01
#define DATA_SIZE_2 0x02
#define DATA_SIZE_4 0x03
#define TYPE_MAIN 0b00000000
#define TYPE_GLOBAL 0b00000100
#define TYPE_LOCAL 0b00001000
#define TYPE_MAIN 0x00
#define TYPE_GLOBAL 0x04
#define TYPE_LOCAL 0x08
#define TAG_MAIN_INPUT 0b10000000
#define TAG_MAIN_OUTPUT 0b10010000
#define TAG_MAIN_COLLECTION 0b10100000
#define TAG_MAIN_FEATURE 0b10110000
#define TAG_MAIN_ENDCOLLECTION 0b11000000
#define TAG_GLOBAL_USAGEPAGE 0b00000000
#define TAG_GLOBAL_LOGICALMIN 0b00010000
#define TAG_GLOBAL_LOGICALMAX 0b00100000
#define TAG_GLOBAL_PHYSMIN 0b00110000
#define TAG_GLOBAL_PHYSMAX 0b01000000
#define TAG_GLOBAL_UNITEXP 0b01010000
#define TAG_GLOBAL_UNIT 0b01100000
#define TAG_GLOBAL_REPORTSIZE 0b01110000
#define TAG_GLOBAL_REPORTID 0b10000000
#define TAG_GLOBAL_REPORTCOUNT 0b10010000
#define TAG_GLOBAL_PUSH 0b10100000
#define TAG_GLOBAL_POP 0b10110000
#define TAG_LOCAL_USAGE 0b00000000
#define TAG_LOCAL_USAGEMIN 0b00010000
#define TAG_LOCAL_USAGEMAX 0b00100000
#define TAG_MAIN_INPUT 0x80
#define TAG_MAIN_OUTPUT 0x90
#define TAG_MAIN_COLLECTION 0xA0
#define TAG_MAIN_FEATURE 0xB0
#define TAG_MAIN_ENDCOLLECTION 0xC0
#define TAG_GLOBAL_USAGEPAGE 0x00
#define TAG_GLOBAL_LOGICALMIN 0x10
#define TAG_GLOBAL_LOGICALMAX 0x20
#define TAG_GLOBAL_PHYSMIN 0x30
#define TAG_GLOBAL_PHYSMAX 0x40
#define TAG_GLOBAL_UNITEXP 0x50
#define TAG_GLOBAL_UNIT 0x60
#define TAG_GLOBAL_REPORTSIZE 0x70
#define TAG_GLOBAL_REPORTID 0x80
#define TAG_GLOBAL_REPORTCOUNT 0x90
#define TAG_GLOBAL_PUSH 0xA0
#define TAG_GLOBAL_POP 0xB0
#define TAG_LOCAL_USAGE 0x00
#define TAG_LOCAL_USAGEMIN 0x10
#define TAG_LOCAL_USAGEMAX 0x20
#endif
#endif
......@@ -108,69 +108,69 @@
* descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
* from the host's VBUS line.
*/
#define USB_CONFIG_ATTR_BUSPOWERED 0b10000000
#define USB_CONFIG_ATTR_BUSPOWERED 0x80
/** Can be masked with other configuration descriptor attributes for a USB_Descriptor_Configuration_Header_t
* descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
* from the device's own power source.
*/
#define USB_CONFIG_ATTR_SELFPOWERED 0b11000000
#define USB_CONFIG_ATTR_SELFPOWERED 0xC0
/** Can be masked with other configuration descriptor attributes for a USB_Descriptor_Configuration_Header_t
* descriptor's ConfigAttributes value to indicate that the specified configuration supports the
* remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
* request.
*/
#define USB_CONFIG_ATTR_REMOTEWAKEUP 0b10100000
#define USB_CONFIG_ATTR_REMOTEWAKEUP 0xA0
/** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's
* Attributes value to indicate that the specified endpoint is not synchronized.
*
* \see The USB specification for more details on the possible Endpoint attributes.
*/
#define ENDPOINT_ATTR_NO_SYNC (0b00 << 2)
#define ENDPOINT_ATTR_NO_SYNC (0 << 2)
/** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's
* Attributes value to indicate that the specified endpoint is asynchronous.
*
* \see The USB specification for more details on the possible Endpoint attributes.
*/
#define ENDPOINT_ATTR_ASYNC (0b01 << 2)
#define ENDPOINT_ATTR_ASYNC (1 << 2)
/** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's
* Attributes value to indicate that the specified endpoint is adaptive.
*
* \see The USB specification for more details on the possible Endpoint attributes.
*/
#define ENDPOINT_ATTR_ADAPTIVE (0b10 << 2)
#define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
/** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's
* Attributes value to indicate that the specified endpoint is synchronized.
*
* \see The USB specification for more details on the possible Endpoint attributes.
*/
#define ENDPOINT_ATTR_SYNC (0b11 << 2)
#define ENDPOINT_ATTR_SYNC (3 << 2)
/** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's
* Attributes value to indicate that the specified endpoint is used for data transfers.
*
* \see The USB specification for more details on the possible Endpoint usage attributes.
*/
#define ENDPOINT_USAGE_DATA (0b00 << 4)
#define ENDPOINT_USAGE_DATA (0 << 4)
/** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's
* Attributes value to indicate that the specified endpoint is used for feedback.
*
* \see The USB specification for more details on the possible Endpoint usage attributes.
*/
#define ENDPOINT_USAGE_FEEDBACK (0b01 << 4)
#define ENDPOINT_USAGE_FEEDBACK (1 << 4)
/** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's
* Attributes value to indicate that the specified endpoint is used for implicit feedback.
*
* \see The USB specification for more details on the possible Endpoint usage attributes.
*/
#define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (0b10 << 4)
#define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
/** Gives a void pointer to the specified descriptor (of any type). */
#define DESCRIPTOR_ADDRESS(Descriptor) ((void*)&Descriptor)
......
......@@ -44,14 +44,14 @@
*
* \see REQDIR_* macros for masks indicating the request data direction.
*/
#define CONTROL_REQTYPE_DIRECTION 0b10000000
#define CONTROL_REQTYPE_DIRECTION 0x80
/** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor
* Specific). The result of this mask should then be compared to the request type masks.
*
* \see REQTYPE_* macros for masks indicating the request type.
*/
#define CONTROL_REQTYPE_TYPE 0b01100000
#define CONTROL_REQTYPE_TYPE 0x60
/** Mask for the request type parameter, to indicate the recipient of the request (Standard, Class
* or Vendor Specific). The result of this mask should then be compared to the request recipient
......@@ -59,7 +59,7 @@
*
* \see REQREC_* macros for masks indicating the request recipient.
*/
#define CONTROL_REQTYPE_RECIPIENT 0b00011111
#define CONTROL_REQTYPE_RECIPIENT 0x1F
/** Request data direction mask, indicating that the request data will flow from host to device.
*
......
......@@ -95,7 +95,7 @@
/** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
* numerical address in the device.
*/
#define ENDPOINT_EPNUM_MASK 0b111
#define ENDPOINT_EPNUM_MASK 0x03
/** Endpoint bank size mask, for masking against endpoint addresses to retrieve the endpoint's
* bank size in the device.
......
......@@ -221,7 +221,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 & 0b01111111); }MACROE
#define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = (addr & 0x7F); }MACROE
/* Enums: */
enum USB_Host_WaitMSErrorCodes_t
......
......@@ -160,32 +160,25 @@
*
* \note See Endpoint.h and Pipe.h headers for endpoint/pipe functions.
*/
#define EP_TYPE_CONTROL 0b00
#define EP_TYPE_CONTROL 0x00
/** Mask for an ISOCHRONOUS type endpoint or pipe.
*
* \note See Endpoint.h and Pipe.h headers for endpoint/pipe functions.
*/
#define EP_TYPE_ISOCHRONOUS 0b01
#define EP_TYPE_ISOCHRONOUS 0x01
/** Mask for a BULK type endpoint or pipe.
*
* \note See Endpoint.h and Pipe.h headers for endpoint/pipe functions.
*/
#define EP_TYPE_BULK 0b10
#define EP_TYPE_BULK 0x02
/** Mask for an INTERRUPT type endpoint or pipe.
*
* \note See Endpoint.h and Pipe.h headers for endpoint/pipe functions.
*/
#define EP_TYPE_INTERRUPT 0b11
/** Mask for determining the type of an endpoint or pipe. This should then be compared with the
* EP_TYPE_* macros elsewhere in this module to determine the exact type of the endpoint or pipe.
*
* \note See Endpoint.h and Pipe.h headers for endpoint/pipe functions.
*/
#define EP_TYPE_MASK 0b11
#define EP_TYPE_INTERRUPT 0x03
#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
/** Returns boolean true if the VBUS line is currently high (i.e. the USB host is supplying power),
......
......@@ -74,17 +74,17 @@
/** Token mask for Pipe_ConfigurePipe(). This sets the pipe as a SETUP token (for CONTROL type pipes),
* which will trigger a control request on the attached device when data is written to the pipe.
*/
#define PIPE_TOKEN_SETUP (0b00 << PTOKEN0)
#define PIPE_TOKEN_SETUP (0 << PTOKEN0)
/** Token mask for Pipe_ConfigurePipe(). This sets the pipe as a IN token (for non-CONTROL type pipes),
* indicating that the pipe data will flow from device to host.
*/
#define PIPE_TOKEN_IN (0b01 << PTOKEN0)
#define PIPE_TOKEN_IN (1 << PTOKEN0)
/** Token mask for Pipe_ConfigurePipe(). This sets the pipe as a IN token (for non-CONTROL type pipes),
* indicating that the pipe data will flow from host to device.
*/
#define PIPE_TOKEN_OUT (0b10 << PTOKEN0)
#define PIPE_TOKEN_OUT (2 << PTOKEN0)
/** Mask for the bank mode selection for the Pipe_ConfigurePipe() macro. This indicates that the pipe
* should have one single bank, which requires less USB FIFO memory but results in slower transfers as
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment