In the SETUP interrupt handler:
switch (bRequest)
{
/* GET_DESCRIPTOR */
case 0x6:
switch (wValueUpper)
{
/* Device Descriptor */
case 0x1:
/* DADR = 0 for Device Descriptor */
MCF_USB_DRAMCR = (0
| wLength << 16
| iDevDesc);
MCF_USB_DRAMCR |= MCF_USB_DRAMCR_START;
break;
...
-mn
Message Edited by MH on 04-10-200612:01 PM
The manual isn't clear about how much of the control transaction required for the GET_DESCRIPTOR request is performed automatically. For example, the USB spec states that "The function receiving a SETUP must accept the SETUP data and respond with ACK.".
Can I assume that the USB module responds with ACK automatically since I can't see a way of initiating an ACK response myself?
Is it correct that the only response required to a request for the device descriptor is to set up the start address and descriptor size in DRAMCR followed by setting DRAMCR[START]? This is what is shown in the code snippets above but I don't know what has been omitted from the example. When DRAMCR[START] is set, DRAMCR[BSY] goes high. Should the BSY bit clear a short time later to indicate that the GET_DESCRIPTOR handler has finished without any further action from the firmware? If, as in my case, the BSY bit does not clear, what are the likely causes (RAMEN is set)?
Thank you.
To write a byte, you just address the register as an 8-bit address. For example, EP0 FIFO data register (address MBAR + 0xB450) could be accessed as follows in C (assuming __MBAR is defined as a byte array that points to the start of the internal module memory map):
uint8 data8 = 0xAB;
uint16 data16 = 0xABCD;
uint32 data32 = 0xABCD0123;
*(uint8*)(&__MBAR[0x00B450]) = data8;
*(uint16*)(&__MBAR[0x00B450]) = data16;
*(uint32*)(&__MBAR[0x00B450]) = data32;
Internally, the byte accesses will use the upper byte lane (31:24) to transfer the data for byte accesses, but you don't really need to worry about that. Just access it at the base address no matter what the transfer size is.
Note that the C header files provide macros for the different accesses, so the above could be:
MCF_USB_EP0FDR_8 = data8;
MCF_USB_EP0FDR_16 = data16;
MCF_USB_EP0FDR_32 = data32;
Message Edited by mnorman on 04-19-2006 01:45 PM