Serial interface engine command description, Section 13–11 “serial interface engine command, Description – NXP Semiconductors LPC24XX UM10237 User Manual

Page 363

Advertising
background image

UM10237_4

© NXP B.V. 2009. All rights reserved.

User manual

Rev. 04 — 26 August 2009

363 of 792

NXP Semiconductors

UM10237

Chapter 13: LPC24XX USB device controller

11. Serial interface engine command description

The functions and registers of the Serial Interface Engine (SIE) are accessed using
commands, which consist of a command code followed by optional data bytes (read or
write action). The USBCmdCode (

Table 13–326

) and USBCmdData (

Table 13–327

)

registers are used for these accesses.

A complete access consists of two phases:

1. Command phase: the USBCmdCode register is written with the CMD_PHASE field

set to the value 0x05 (Command), and the CMD_CODE field set to the desired
command code. On completion of the command, the CCEMPTY bit of USBDevIntSt is
set.

2. Data phase (optional): for writes, the USBCmdCode register is written with the

CMD_PHASE field set to the value 0x01 (Write), and the CMD_WDATA field set with
the desired write data. On completion of the write, the CCEMPTY bit of USBDevIntSt
is set. For reads, USBCmdCode register is written with the CMD_PHASE field set to
the value 0x02 (Read), and the CMD_CODE field set with command code the read
corresponds to. On completion of the read, the CDFULL bit of USBDevInSt will be set,
indicating the data is available for reading in the USBCmdData register. In the case of
multi-byte registers, the least significant byte is accessed first.

An overview of the available commands is given in

Table 13–347

.

Here is an example of the Read Current Frame Number command (reading 2 bytes):

USBDevIntClr = 0x30; // Clear both CCEMPTY & CDFULL

USBCmdCode = 0x00F50500; // CMD_CODE=0xF5, CMD_PHASE=0x05(Command)

while (!(USBDevIntSt & 0x10)); // Wait for CCEMPTY.

USBDevIntClr = 0x10; // Clear CCEMPTY interrupt bit.

USBCmdCode = 0x00F50200; // CMD_CODE=0xF5, CMD_PHASE=0x02(Read)

while (!(USBDevIntSt & 0x20)); // Wait for CDFULL.

USBDevIntClr = 0x20; // Clear CDFULL.

CurFrameNum = USBCmdData; // Read Frame number LSB byte.

USBCmdCode = 0x00F50200; // CMD_CODE=0xF5, CMD_PHASE=0x02(Read)

while (!(USBDevIntSt & 0x20)); // Wait for CDFULL.

Temp = USBCmdData; // Read Frame number MSB byte

USBDevIntClr = 0x20; // Clear CDFULL interrupt bit.

CurFrameNum = CurFrameNum | (Temp << 8);

Here is an example of the Set Address command (writing 1 byte):

USBDevIntClr = 0x10; // Clear CCEMPTY.

USBCmdCode = 0x00D00500; // CMD_CODE=0xD0, CMD_PHASE=0x05(Command)

while (!(USBDevIntSt & 0x10)); // Wait for CCEMPTY.

USBDevIntClr = 0x10; // Clear CCEMPTY.

USBCmdCode = 0x008A0100; // CMD_WDATA=0x8A(DEV_EN=1, DEV_ADDR=0xA),

// CMD_PHASE=0x01(Write)

while (!(USBDevIntSt & 0x10)); // Wait for CCEMPTY.

USBDevIntClr = 0x10; // Clear CCEMPTY.

Advertising