How I can turn-on word alignment in Keil C51? I have such definition of USB-descriptors for Cypress EZ-USB chip CY7C68013:
const DEVICEDSCR code TestSyncSlave_DeviceDescriptor = { // Device descriptor sizeof(DEVICEDSCR), // 0x00 Length of this descriptor DEVICE_DSCR, // 0x01 Descriptor type USBSPEC, // 0x02 USB Specification Release Number VENDOR_SPECIFIC, // 0x04 Class Code 0x00, // 0x05 Sub Class Code 0x00, // 0x06 Protocol EP0_MAX_PACKET_SIZE, // 0x07 Maximum Endpoint 0 Packet Size VID_EPOS, // 0x08 Vendor ID PID_ANALYSER, // 0x0a Product ID DID_ANALYSER, // 0x0c DeviceBCD Device Release Number STRING_INDEX_MANUFACTURER, // 0x0e Index of string descriptor describing manufacturer STRING_INDEX_PRODUCT, // 0x0f Index of string descriptor describing product 0x00, // 0x10 Index of string descriptor describing serial number 0x01 // 0x11 Number of configurations }; /////////////////////////////////////////////////////////////////////////////// const DEVICEQUALDSCR code TestSyncSlave_DeviceQualifierDescriptor = { // Device Qualifier descriptor sizeof(DEVICEQUALDSCR), // 0x00 Length of this descriptor DEVQUAL_DSCR, // 0x01 Descriptor type USBSPEC, // 0x02 USB Specification Release Number VENDOR_SPECIFIC, // 0x04 Class Code 0x00, // 0x05 Sub Class Code 0x00, // 0x06 Protocol EP0_MAX_PACKET_SIZE, // 0x07 Maximum Endpoint 0 Packet Size 0x01, // 0x08 Number of configurations 0x00 // 0x09 Reserve }; /////////////////////////////////////////////////////////////////////////////// const DEVICECONFG code TestSyncSlave_HS_Config = { // Configuration when connected to a High Speed host { // Configuration Descriptor sizeof(CONFIGDSCR), // 0x00 bLength: Length of this descriptor CONFIG_DSCR, // 0x01 Type (CONFIGURATION_DESC or CONFIGURATION_DESC) LSB(sizeof(DEVICECONFG)), // 0x02 wTotalLength: Total length for this configuration MSB(sizeof(DEVICECONFG)), // 0x02 wTotalLength: Total length for this configuration NUM_INTERFACES, // 0x04 bNumInterfaces: Number of Interfaces 0x01, // 0x05 bConfigurationValue: Number of this configuration 0x00, // 0x06 iConfiguration: Index of string descriptor describing this configuration CONFIG_ATTRIBUTES, // 0x07 bmAttributes: 7:AlwaysSet|6:SelfPowered|5:RemoteWakeup 150 // 0x08 bMaxPower: Max USB power (in 2mA units) }, { // Interface Descriptor: sizeof(INTRFCDSCR), // 0x00 Size of this descriptor INTRFC_DSCR, // 0x01 Type 0x00, // 0x02 Number of this interface 0x00, // 0x03 Alternate interface ENDPOINT_COUNT, // 0x04 Number of endpoints in this interface (without EP0) VENDOR_SPECIFIC, // 0x05 Class Code 0x00, // 0x06 Sub Class Code 0x00, // 0x07 Device Protocol 0x00, // 0x08 Index of string descriptor describing this interface }, { // Endpoint Descriptors: Type Dir MaxPkt UsbEp Poll {MAKE_ENDPOINT_DESCRIPTOR( EP_BULK, EP_IN, 512, 0x86, 0 )}, {MAKE_ENDPOINT_DESCRIPTOR( EP_BULK, EP_OUT, 64, 0x01, 0 )}, {MAKE_ENDPOINT_DESCRIPTOR( EP_BULK, EP_IN, 64, 0x81, 0 )} } }; //In such definition last structure is missalignment, so I must align it... /////////////////////////////////////////////////////////////////////////////// const DEVICECONFG code TestSyncSlave_FS_Config = { // Configuration when connected to a Full Speed host { // Configuration descriptor sizeof(CONFIGDSCR), // 0x00 Length of this descriptor CONFIG_DSCR, // 0x01 Type (CONFIGURATION_DESC or OTHER_SPEED_CONFIGURATION_DESC) LSB(sizeof(DEVICECONFG)), // 0x02 wTotalLength: Total length for this configuration MSB(sizeof(DEVICECONFG)), // 0x02 wTotalLength: Total length for this configuration NUM_INTERFACES, // 0x04 Number of Interfaces 0x01, // 0x05 Number of this configuration 0x00, // 0x06 Index of string descriptor describing this configuration CONFIG_ATTRIBUTES, // 0x07 bmAttributes: 7:AlwaysSet|6:SelfPowered|5:RemoteWakeup 150 // 0x08 Max USB power (in 2mA units) }, { // Interface Descriptor: sizeof(INTRFCDSCR), // 0x00 Size of this descriptor INTRFC_DSCR, // 0x01 Type 0x00, // 0x02 Number of this interface 0x00, // 0x03 Alternate interface ENDPOINT_COUNT, // 0x04 Number of endpoints in this interface (without EP0) VENDOR_SPECIFIC, // 0x05 Class Code 0x00, // 0x06 Sub Class Code 0x00, // 0x07 Device Protocol 0x00, // 0x08 Index of string descriptor describing this interface }, { // Endpoint Descriptors: Type Dir MaxPkt UsbEp Poll {MAKE_ENDPOINT_DESCRIPTOR( EP_BULK, EP_IN, 64, 0x86, 0 )}, {MAKE_ENDPOINT_DESCRIPTOR( EP_BULK, EP_OUT, 64, 0x01, 0 )}, {MAKE_ENDPOINT_DESCRIPTOR( EP_BULK, EP_IN, 64, 0x81, 0 )} } };
EZ-USB needs that each USB-descriptor was word alignment. How can I do this in Keil C51(any directive such as #pragma pack)?
Sorry, I misunderstood the question. It's not about structure padding, it's about placing variables in memory. It does appear that Keil 8051 tools don't have settings for word alignment of data. But you can always place your sections manually. I believe this is how it's done: http://www.keil.com/support/man/docs/c51/c51_ap_linkerloc.htm