-
December 29th, 2009, 06:01 PM
#1
"Rom" / "rom byte" keywords?
I'm trying to program a microcontroller in C to communicate with my laptop over a USB connection. The code examples that I've been able to find have the descriptors written either like this:
Code:
ROM USB_DEVICE_DESCRIPTOR device_dsc=
{
0x12, // Size of this descriptor in bytes
USB_DESCRIPTOR_DEVICE, // DEVICE descriptor type
0x0200, // USB Spec Release Number in BCD format
0x00, // Class Code
0x00, // Subclass code
0x00, // Protocol code
USB_EP0_BUFF_SIZE, // Max packet size for EP0, see usb_config.h
0x04D8, // Vendor ID
0x003F, // Product ID: Mouse in a circle fw demo
0x0002, // Device release number in BCD format
0x01, // Manufacturer string index
0x02, // Product string index
0x00, // Device serial number string index
0x01 // Number of possible configurations
};
Or this:
Code:
rom byte deviceDescriptor[] =
{
0x12, 0x01, // bLength, bDescriptorType
0x00, 0x02, // bcdUSB (low byte), bcdUSB (high byte)
0x00, 0x00, // bDeviceClass, bDeviceSubClass
0x00, E0SZ, // bDeviceProtocl, bMaxPacketSize
0xD8, 0x04, // idVendor (low byte), idVendor (high byte)
0xFF, 0x01, // idProduct (low byte), idProduct (high byte)
0x01, 0x00, // bcdDevice (low byte), bcdDevice (high byte)
0x01, 0x02, // iManufacturer, iProduct
0x00, 0x01 // iSerialNumber (none), bNumConfigurations
};
The problem is, I have no idea what the "rom" and "rom byte" words mean. I've looked through my C programming book and have searched Google but have come up with nothing. Can anyone point me in the right direction?
Thanks
Last edited by Robotics Guy; December 29th, 2009 at 06:03 PM.
-
December 29th, 2009, 07:33 PM
#2
Re: "Rom" / "rom byte" keywords?
Info from a USB manual...
Information about a USB device is stored in segments of its ROM (read-only
memory). These segments are called descriptors. An interface descriptor can
identify a device as belonging to one of a finite number of classes.
-
December 29th, 2009, 07:54 PM
#3
Re: "Rom" / "rom byte" keywords?
I believe the answer to my question lies in one for the example project's included files:
Code:
typedef union
{
UINT16 Val;
UINT8 v[2] __PACKED;
struct __PACKED
{
UINT8 LB;
UINT8 HB;
} byte;
struct __PACKED
{
__EXTENSION UINT8 b0:1;
__EXTENSION UINT8 b1:1;
__EXTENSION UINT8 b2:1;
__EXTENSION UINT8 b3:1;
__EXTENSION UINT8 b4:1;
__EXTENSION UINT8 b5:1;
__EXTENSION UINT8 b6:1;
__EXTENSION UINT8 b7:1;
__EXTENSION UINT8 b8:1;
__EXTENSION UINT8 b9:1;
__EXTENSION UINT8 b10:1;
__EXTENSION UINT8 b11:1;
__EXTENSION UINT8 b12:1;
__EXTENSION UINT8 b13:1;
__EXTENSION UINT8 b14:1;
__EXTENSION UINT8 b15:1;
} bits;
} UINT16_VAL, UINT16_BITS;
So it looks like ROM really just means "const." But the structure which I believe corresponds to the "byte" keyword totally confuses me. Can anyone shed some light on the above structure?
-
December 29th, 2009, 08:22 PM
#4
Re: "Rom" / "rom byte" keywords?
It's a union so all members point to the same memory location. Within the union there is a bit field structure, a word and a struct of 2 bytes. It's sort-of a shortcut to access individual bits or individual bytes in a 16 bit word.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|