4.1. USB
4.1.1. Overview
Prerequisite Knowledge Required
This section requires knowledge of the USB protocol. We recommend USB Made Simple if you are unclear on the terminology used in this section.
RP2040 contains a USB 2.0 controller that can operate as either:
- • a Full Speed device (12Mbps)
- • a host that can communicate with both Low Speed (1.5Mbps) and Full Speed devices. This includes multiple downstream devices connected to a USB hub.
There is an integrated USB 1.1 PHY which interfaces the USB controller with the DP and DM pins of the chip.
4.1.1.1. Features
The USB controller hardware handles the low level USB protocol, meaning the main job of the programmer is to configure the controller and then provide / consume data buffers in response to events on the bus. The controller interrupts the processor when it needs attention. The USB controller has 4kB of DPSRAM which is used for configuration and data buffers.
4.1.1.1.1. Device Mode
- • USB 2.0-compatible Full Speed device (12Mbps)
- • Supports up to 32 endpoints (Endpoints 0 → 15 in both in and out directions)
- • Supports Control , Isochronous , Bulk , and Interrupt endpoint types
- • Supports double buffering
- • 3840 bytes of usable buffer space in DPSRAM. This is equivalent to 60 × 64-byte buffers.
4.1.1.1.2. Host Mode
- • Can communicate with Full Speed (12Mbps) devices and Low Speed devices (1.5Mbps)
- • Can communicate with multiple devices via a USB hub, including Low Speed devices connected to a Full Speed hub
- • Can poll up to 15 interrupt endpoints in hardware. (Interrupt endpoints are used by hubs to notify the host of connect/disconnect events, mice to notify the host of movement etc.)
4.1.2. Architecture
4.1.2.1. Clock speed
This controller requires
clk_usb to be running at 48MHz.
NOTE
clk_sys must also be running at > 48MHz. See
RP2040-E16
.
4.1.2.2. Overview
Figure 57. A simplified overview of the USB controller architecture.

The USB controller is an area efficient design that muxes a device controller or host controller onto a common set of components. Each component is detailed below.
4.1.2.3. USB PHY
The USB PHY provides the electrical interface between the USB DP and DM pins and the digital logic of the controller. The DP and DM pins are a differential pair, meaning the values are always the inverse of each other, except to encode a specific line state ( SE0 , etc). The USB PHY drives the DP and DM pins to transmit data, as well as performing a differential receive of any incoming data. The USB PHY provides both single-ended and differential receive data to the line state detection module.
The USB PHY has built in pull-up and pull-down resistors. If the controller is acting as a Full Speed device then the DP pin is pulled up to indicate to the host that a Full Speed device has been connected. In host mode, a weak pull down is applied to DP and DM so that the lines are pulled to a logical zero until the device pulls up DP for Full Speed or DM for Low Speed.
4.1.2.4. Line state detection
The [2] defines several line states (Bus Reset, Connected, Suspend, Resume, Data 1, Data 0, etc) that need to be detected. The line state detection module has several state machines to detect these states and signal events to the other hardware components. There is no shared clock signal in USB, so the RX data must be sampled by an internal clock. The maximum data rate of USB Full Speed is 12Mbps. The RX data is sampled at 48MHz, giving 4 clock cycles to capture and filter the bus state. The line state detection module distributes the filtered RX data to the Serial RX Engine.
4.1.2.5. Serial RX Engine
The serial receive engine decodes receive data captured by the line state detection module. It produces the following information:
- • The PID of the incoming data packet
- • The device address for the incoming data
- • The device endpoint for the incoming data
- • Data bytes
The serial receive engine also detects errors in RX data by performing a CRC check on the incoming data. Any errors are signalled to the other hardware blocks and can raise an interrupt.
i NOTE
If you disconnect the USB cable during a packet in either host or device mode you will see errors raised by the hardware. Your software will need to take this scenario into account if you enable error interrupts.
4.1.2.6. Serial TX Engine
The serial transmit engine is a mirror of the serial receive engine. It is connected to the currently active controller (either device or host). It creates TOKEN and DATA packets, including calculating the CRC, and transmits them on the bus.
4.1.2.7. DPSRAM
The USB controller has 4kB (4096 bytes) of DPSRAM (Dual Port SRAM). The DPSRAM is used to store control registers and data buffers. The DPSRAM is accessible as a 32-bit wide memory at address 0 of the USB controller ( 0x50100000 ).
The DPSRAM has the following characteristics, which are different to most registers on RP2040:
- • Supports 8/16/32-bit accesses. Registers typically support 32-bit accesses only
- • The DPSRAM does not support set / clear aliases. RP2040 registers typically support these
Data Buffers are typically 64 bytes long as this is the max normal packet size for most FS packets. For Isochronous endpoints a maximum buffer size of 1023 bytes is supported. For other packet types the maximum size is 64 bytes per buffer.
4.1.2.7.1. Concurrent access
The DPSRAM in the USB controller should be considered asynchronous and not atomic. It is a dual port SRAM which means the processor has a port to read/write the memory and the USB controller also has a port to read/write the memory. This means that both the processor and the USB controller can access the same memory address at the same time. One could be writing and one could be reading. It is possible to get inconsistent data if the controller is reading the memory while the processor is writing the memory. Care must be taken to avoid this scenario.
The AVAILABLE bit in the buffer control register is used to indicate who has ownership of a buffer. This bit should be set to 1 by the processor to give the controller ownership of the buffer. The controller will set the bit back to 0 when it has used the buffer. The AVAILABLE bit should be set separately to the rest of the data in the buffer control register, so that the rest of the data in the buffer control register is accurate when the AVAILABLE bit is set.
This is necessary because the processor clock clk_sys can be running several times faster than the clk_usb clock. Therefore clk_sys can update the data during a read by the USB controller on a slower clock. The correct process is:
- • Write buffer information (length, etc.) to buffer control register
- •
nopfor someclk_syscycles to ensure that at least oneclk_usbcycle has passed. For example ifclk_syswas running at 125MHz andclk_usbwas running at 48MHz then 125/48 rounded up would be 3nopinstructions - • Set
AVAILABLEbit
If
clk_sys and
clk_usb are running at the same frequency then it is not necessary to set the
AVAILABLE bit separately.
i NOTE
When the controller is writing status back to the DPSRAM it does a 16 bit write to the lower 2 bytes for buffer 0 and the upper 2 bytes for buffer 1. Therefore, if using double buffered mode, it is safest to treat the buffer control register as two 16 bit registers when updating it in software.
4.1.2.7.2. Layout
Addresses
0x0-0xff are used for control registers containing configuration data. The remaining space, addresses
0x100-0xffff(3840 bytes) can be used for data buffers. The controller has control registers that start at address
0x10000.
The memory layout is different depending on if the controller is in Device or Host mode. In device mode, there are multiple endpoints a host can access so there must be endpoint control and buffer control registers for each endpoint. In host mode, the host software running on the processor is deciding which endpoints and which devices to access, so there only needs to be one set of endpoint control and buffer control registers. As well as software driven transfers, the host controller can poll up to 15 interrupt endpoints and has a register for each of these interrupt endpoints.
Table 394. DPSRAM layout
| Offset | Device Function | Host Function |
|---|---|---|
| 0x0 | Setup packet (8 bytes) | |
| 0x8 | EP1 in control | Interrupt endpoint control 1 |
| 0xc | EP1 out control | Spare |
| 0x10 | EP2 in control | Interrupt endpoint control 2 |
| 0x14 | EP2 out control | Spare |
| 0x18 | EP3 in control | Interrupt endpoint control 3 |
| 0x1c | EP3 out control | Spare |
| 0x20 | EP4 in control | Interrupt endpoint control 4 |
| 0x24 | EP4 out control | Spare |
| 0x28 | EP5 in control | Interrupt endpoint control 5 |
| 0x2c | EP5 out control | Spare |
| 0x30 | EP6 in control | Interrupt endpoint control 6 |
| 0x34 | EP6 out control | Spare |
| 0x38 | EP7 in control | Interrupt endpoint control 7 |
| 0x3c | EP7 out control | Spare |
| 0x40 | EP8 in control | Interrupt endpoint control 8 |
| 0x44 | EP8 out control | Spare |
| 0x48 | EP9 in control | Interrupt endpoint control 9 |
| 0x4c | EP9 out control | Spare |
| 0x50 | EP10 in control | Interrupt endpoint control 10 |
| 0x54 | EP10 out control | Spare |
| Offset | Device Function | Host Function |
|---|---|---|
| 0x58 | EP11 in control | Interrupt endpoint control 11 |
| 0x5c | EP11 out control | Spare |
| 0x60 | EP12 in control | Interrupt endpoint control 12 |
| 0x64 | EP12 out control | Spare |
| 0x68 | EP13 in control | Interrupt endpoint control 13 |
| 0x6c | EP13 out control | Spare |
| 0x70 | EP14 in control | Interrupt endpoint control 14 |
| 0x74 | EP14 out control | Spare |
| 0x78 | EP15 in control | Interrupt endpoint control 15 |
| 0x7c | EP15 out control | Spare |
| 0x80 | EP0 in buffer control | EPx buffer control |
| 0x84 | EP0 out buffer control | Spare |
| 0x88 | EP1 in buffer control | Interrupt endpoint buffer control 1 |
| 0x8c | EP1 out buffer control | Spare |
| 0x90 | EP2 in buffer control | Interrupt endpoint buffer control 2 |
| 0x94 | EP2 out buffer control | Spare |
| 0x98 | EP3 in buffer control | Interrupt endpoint buffer control 3 |
| 0x9c | EP3 out buffer control | Spare |
| 0xa0 | EP4 in buffer control | Interrupt endpoint buffer control 4 |
| 0xa4 | EP4 out buffer control | Spare |
| 0xa8 | EP5 in buffer control | Interrupt endpoint buffer control 5 |
| 0xac | EP5 out buffer control | Spare |
| 0xb0 | EP6 in buffer control | Interrupt endpoint buffer control 6 |
| 0xb4 | EP6 out buffer control | Spare |
| 0xb8 | EP7 in buffer control | Interrupt endpoint buffer control 7 |
| 0xbc | EP7 out buffer control | Spare |
| 0xc0 | EP8 in buffer control | Interrupt endpoint buffer control 8 |
| 0xc4 | EP8 out buffer control | Spare |
| 0xc8 | EP9 in buffer control | Interrupt endpoint buffer control 9 |
| 0xcc | EP9 out buffer control | Spare |
| 0xd0 | EP10 in buffer control | Interrupt endpoint buffer control 10 |
| 0xd4 | EP10 out buffer control | Spare |
| 0xd8 | EP11 in buffer control | Interrupt endpoint buffer control 11 |
| 0xdc | EP11 out buffer control | Spare |
| 0xe0 | EP12 in buffer control | Interrupt endpoint buffer control 12 |
| 0xe4 | EP12 out buffer control | Spare |
| clk_sys_busfabric clk_sys_clocks WAKE_EN registers to the • • • stop external clocks Interval Register | SLEEP_EN when the chip is inactive. If the user has not configured the stop unused clock sources such as the PLLs and Crystal Oscillator reduce the frequencies of generated clocks by increasing the clock divisors For maximum power saving when the chip is inactive, the user should consider DORMANT (see test interval. The interval is defined by counting cycles of The user can pick between accuracy and test time using the Test Interval | registers. The intention is to reduce power consumed in the clock distribution networks WAKE_EN and SLEEP_EN registers then system sleep will do Section 2.11.3) mode in clk_ref which must be driven either from XOSC or from a FC0_INTERVAL register. Table 206 shows the trade off. Accuracy |
|---|---|---|
| Offset | Device Function | Host Function |
| 0xe8 | EP13 in buffer control | Interrupt endpoint buffer control 13 |
| 0xec | EP13 out buffer control | Spare |
| 0xf0 | EP14 in buffer control | Interrupt endpoint buffer control 14 |
| 0xf4 | EP14 out buffer control | Spare |
| 0xf8 | EP15 in buffer control | Interrupt endpoint buffer control 15 |
| 0xfc | EP15 out buffer control | Spare |
| 0x100 | EP0 buffer 0 (shared between in and out) | EPx control |
| 0x140 | Optional EP0 buffer 1 | Spare |
| 0x180 0x180 | Data buffers Data buffers | |
| endpoint control register for EP0. Its buffers begin at | 0x100 . All other endpoints can have either single or dual buffers | |
| controls for EP0 come from Table 395. Endpoint Bit(s) control register layout | SIE_CTRL. Device Function | Host Function |
| 31 | Endpoint Enable Endpoint Enable | |
| 30 | Single buffered (64 bytes) = 0, Double buffered (64 bytes x 2) = 1 Single buffered (64 bytes) = 0, Double buffered (64 bytes x 2) = 1 | |
| 29 | Enable Interrupt for every transferred buffer Enable Interrupt for every transferred buffer | |
| 28 | Enable Interrupt for every 2 transferred buffers (valid for double buffered only) | |
| 27:26 27:26 | Endpoint Type: Control = 0, ISO = 1, Bulk = 2, Interrupt = 3 Endpoint Type: Control = 0, ISO = 1, Bulk = 2, Interrupt = 3 | |
| 25:18 | N/A | The interval the host controller should poll this endpoint. Only applicable for interrupt |
| 17 | Interrupt on Stall Interrupt on Stall | |
| 16 | Interrupt on NAK | value of 9 would poll the endpoint every 10ms. |
| 15:6 15:6 | Address base offset in DPSRAM of data buffer(s) Address base offset in DPSRAM of data buffer(s) |
4.1.2.7.3. Endpoint control register
The endpoint control register is used to configure an endpoint. It contains:
- • The endpoint type
- • The base address of its data buffer, or data buffers if double buffered
- • Interrupts events on the endpoint should trigger
A device must support Endpoint 0 so that it can reply to SETUP packets and be enumerated. As a result, there is no endpoint control register for EP0. Its buffers begin at
0x100. All other endpoints can have either single or dual buffers and are mapped at the base address programmed. As EP0 has no endpoint control register, the interrupt enable controls for EP0 come from
SIE_CTRL
.
Table 395. Endpoint control register layout
i NOTE
The data buffer base address must be 64-byte aligned as bits 0-5 are ignored
4.1.2.7.4. Buffer control register
The buffer control register contains information about the state of the data buffers for that endpoint. It is shared between the processor and the controller. If the endpoint is configured to be single buffered, only the first half (bits 0-15) of the buffer are used.
If double buffering, the buffer select starts at buffer 0. From then on, the buffer select flips between buffer 0 and 1 unless the "reset buffer select" bit is set (which resets the buffer select to buffer 0). The value of the buffer select is internal to the controller and not accessible by the processor.
For host interrupt and isochronous packets on EPx, the buffer full bit will be set on completion even if the transfer was unsuccessful. The error bits in the SIE_STATUS register can be read to determine the error.
Table 396. Buffer control register layout
| Bit(s) | Function |
|---|---|
| 31 | Buffer 1 full. Should be set to 1 by the processor for an IN transaction and 0 for an OUT transaction. The controller sets this to 1 for an OUT transaction because it has filled the buffer. The controller sets it to 0 for an IN transaction because it has emptied the buffer. Only valid for double buffered |
| 30 | Last buffer of transfer for buffer 1 - only valid for double buffered |
| 29 | Data PID for buffer 1 - DATA0 = 0, DATA1 = 1 - only valid for double buffered |
| 27:28 | Double buffer offset for Isochronous mode (0 = 128, 1 = 256, 2 = 512, 3 = 1024) |
| 26 | Buffer 1 available. Whether the buffer can be used by the controller for a transfer. The processor sets this to 1 when the buffer is configured. The controller sets to 0 when it has used the buffer. i.e. has sent the data to the host for an IN transaction or has filled the buffer with data from the host for an OUT transaction. Only valid for double buffered. |
| 25:16 | Buffer 1 transfer length - only valid for double buffered |
| 15 | Buffer 0 full. Should be set to 1 by the processor for an IN transaction and 0 for an OUT transaction. The controller sets this to 1 for an OUT transaction because it has filled the buffer. The controller sets it to 0 for an IN transaction because it has emptied the buffer. |
| 14 | Last buffer of transfer for buffer 0 |
| 13 | Data PID for buffer 0 - DATA0 = 0, DATA1 = 1 |
| 12 | Reset buffer select to buffer 0 - cleared at end of transfer. For DEVICE ONLY |
| 11 | Send STALL for device, STALL received for host |
| 10 | Buffer 0 available. Whether the buffer can be used by the controller for a transfer. The processor sets this to 1 when the buffer is configured. The controller sets to 0 when it has used the buffer. i.e. has sent the data to the host for an IN transaction or has filled the buffer with data from the host for an OUT transaction. |
| 9:0 | Buffer 0 transfer length |
⚠ WARNING
If running
clk_sys and
clk_usb at different speeds, the available and stall bits should be set after the other data in the buffer control register. Otherwise the controller may initiate a transaction with data from a previous packet. That is to say, the controller could see the available bit set but get the data pid or length from the previous packet.
4.1.2.8. Device Controller
This section details how the device controller operates when it receives various packet types from the host.
4.1.2.8.1. SETUP
The device controller MUST always accept a setup packet from the host. That is why the first 8 bytes of the DPSRAM has dedicated space for the setup packet.
The [2] states that receiving a setup packet also clears any stall bits on EP0. For this reason, the stall bits for EP0 are gated with two bits in the
EP_STALL_ARM register. These bits are cleared when a setup packet is received. This means that to send a stall on EP0, you have to set both the stall bit in the buffer control register, and the appropriate bit in
EP_STALL_ARM.
Barring any errors, the setup packet will be put into the setup packet buffer at DPSRAM offset
0x0. The device controller will then reply with an ACK.
Finally,
SIE_STATUS.SETUP_REC is set to indicate that a setup packet has been received. This will trigger an interrupt if the programmer has enabled the
SETUP_REC interrupt (see
INTE
).
4.1.2.8.2. IN
From the device's point of view, an IN transfer means transferring data INTO the host. When an IN token is received from the host the request is handled as follows:
TOKEN phase:
- • If
STALL
is set in the buffer control register (and if EP0, the appropriate
EP_STALL_ARMbit is set) then send a STALL response and go back to idle. - • If AVAILABLE and FULL bits are set in buffer control move to the phase
- • Otherwise send NAK unless this is an Isochronous endpoint, in which case go to idle.
DATA phase:
- • Send DATA. If Isochronous go to idle. Otherwise move to ACK phase.
ACK phase:
- • Wait for ACK packet from host. If there is a timeout then raise a timeout error. If ACK is received then the packet is done, so move to status phase.
STATUS phase:
- • If this was the last buffer in the transfer (i.e. if the
LAST_BUFFERbit in the buffer control register was set), setSIE_STATUS.TRANS_COMPLETE. - • If the endpoint is double buffered, flip the buffer select to the other buffer.
- • Set a bit in
BUFF_STATUSto indicate the buffer is done. When handling this event, the programmer should readBUFF_CPU_SHOULD_HANDLEto see if it is buffer 0 or buffer 1 that is finished. If the endpoint is double buffered it is possible to have both buffers done. The clearedBUFF_STATUSbit will be set again, andBUFF_CPU_SHOULD_HANDLEwill change in this instance. - • Update status in the appropriate half of the buffer control register: length, pid, and last_buff are set. Everything else is written to zero.
If a NAK gets sent to the host the host will retry again later.
4.1.2.8.3. OUT
When an OUT token is received from the host, the request is handled as follows:
TOKEN phase:
- • Is the DATA pid what is specified in the buffer control register? If not raise
SIE_STATUS.DATA_SEQ_ERROR. (The data pid for an Isochronous endpoint is not checked because Isochronous data is always sent with a DATA0 pid.) - • Is the AVAILABLE bit set and the FULL bit unset. If so go to the data phase, unless the STALL bit is set in which case the device controller will reply with a STALL .
DATA phase:
- • Store received data in buffer. If Isochronous go to STATUS phase. Otherwise go to ACK phase.
ACK phase:
- • Send ACK. Go to STATUS phase.
STATUS phase:
See status phase from Section 4.1.2.8.2 . The only difference is that the FULL bit is set in the buffer control register to indicate that data has been received whereas in the IN case the FULL bit is cleared to indicate that data has been sent.
4.1.2.8.4. Suspend and Resume
The USB device controller supports both suspend and resume, as well as remote resume (triggered with SIE_CTRL.RESUME ), where the device initiates the resume. There is an interrupt / status bit in SIE_STATUS . It is not necessary to enable the suspend and resume interrupts, as most devices do not need to care about suspend and resume.
The device goes into suspend when it does not see any start of frame packets (transmitted every 1ms) from the host.
i NOTE
If you enable the suspend interrupt, it is likely you will see a suspend interrupt when the device is first connected but the bus is idle. The bus can be idle for a few ms before the host begins sending start of frame packets. You will also see a suspend interrupt when the device is disconnected if you do not have a VBUS detect circuit connected. This is because without VBUS detection, it is impossible to tell the difference between being disconnected and suspended.
4.1.2.8.5. Errata
There are two hardware issues with the device controller, both of which have software workarounds on RP2040B0, RP2040B1, and are fixed in hardware on RP2040B2. See RP2040-E2 and RP2040-E5 for more information.
4.1.2.9. Host Controller
The host controller design is similar to the device controller. All transactions are started by the host, so the host is always dealing with transactions it has started. For this reason there is only one set of endpoint control / endpoint buffer control registers. There is also additional hardware to poll interrupt endpoints in the background when there are no software controlled transactions taking place.
The host needs to send keep-alive packets to the device every 1ms to keep the device from suspending. In Full Speed mode this is done by sending a SOF (start of frame) packet. In Low Speed mode, an EOP (end of packet) is sent. When setting up the controller, SIE_CTRL.KEEP_ALIVE_EN and SIE_CTRL.SOF_EN should be set to enable these packets.
Several bits in SIE_CTRL are used to begin a host transaction:
- • SEND_SETUP - Send a setup packet. This is typically used in conjunction with RECEIVE_TRANS so the setup packet will be sent followed by the additional data transaction expected from the device.
- • SEND_TRANS - This transfer is OUT from the host
- • RECEIVE_TRANS - This transfer is IN to the host
- • START_TRANS - Start the transfer - non-latching
- • STOP_TRANS - Stop the current transfer - non-latching
- • PREAMBLE_ENABLE - Use this to send a packet to a Low Speed device on a Full Speed hub. This will send a PRE token packet before every packet the host sends (i.e. pre, token, pre, data, pre, ack).
- • SOF_SYNC - The SOF Sync bit is used to delay the transaction until after the next SOF. This is useful for interrupt and isochronous endpoints. The Host controller prevents a transaction of 64bytes from clashing with the SOF packets.
For longer Isochronous packet the software is responsible for preventing a collision by using the SOF Sync bit and limiting the number of packets sent in one frame. If a transaction is set up with multiple packets the SOF Sync bit only applies to the first packet.
⚠ WARNING
The
START_TRANS bit is synchronised separately to other control bits in the
SIE_CTRL register. The
START_TRANS bit should be set separately to the rest of the data in the
SIE_CTRL register, so that the register contents are stable when the controller is prompted to start a transfer. This is necessary because the processor clock
clk_sys can be asynchronous to the
clk_usb clock.
- • Write fields in
SIE_CTRLapart fromSTART_TRANS - •
nopfor someclk_syscycles to ensure that at least twoclk_usbcycles have passed. For example ifclk_syswas running at 125MHz andclk_usbwas running at 48MHz then 125/48 rounded up would be 6nopinstructions - • Set the
START_TRANSbit.
4.1.2.9.1. SETUP
The
SETUP packet sent from the host always comes from the dedicated 8 bytes of space at offset
0x0 of the DPSRAM. Like the device controller, there are no control registers associated with the setup packet. The parameters are hard coded and loaded into the hardware when you write to
START_TRANS with the
SEND_SETUP bit set. Once the setup packet has been sent, the host state machine will wait for an
ACK from the device. If there is a timeout then an
RX_TIMEOUT error will be raised. If the
SEND_TRANS bit is set then the host state machine will move to the
OUT phase. Most commonly the
SEND_SETUP packet is used in conjunction with the
RECEIVE_TRANS bit and will therefore move to the
IN phase after sending a setup packet.
4.1.2.9.2. IN
An
IN transfer is triggered with the
RECEIVE_TRANS bit set when the
START_TRANS bit is set. This may be preceded by a
SETUP packet being sent if the
SEND_SETUP bit was set.
CONTROL phase:
- • Read
EPx control
register located at
0x80to get the endpoint information:- ◦ Are we double buffered?
- ◦ What interrupts to enable
- ◦ Base address of the data buffer, or data buffers if in double buffered mode
- ◦ Endpoint type
- • Read
EPx buffer control
register at
0x100to get the endpoint buffer information such as transfer length and data pid. The host state machine still checks for the presence of theAVAILABLEbit, so this needs to be set andFULLneeds to be unset. The transaction will not happen until this is the case.
TOKEN phase:
- • Send the
INtoken packet to the device. The target device address and endpoint come from theADDR_ENDPregister.
DATA phase:
- • Receive the first data packet from the device. Raise RX timeout error if the device doesn't reply. Raise DATA SEQ ERROR if the data packet has wrong DATA PID.
ACK phase:
- • Send ACK to device
STATUS phase:
- • Set BUFF_STATUS bit and update buffer control register. Will set FULL , LAST_BUFF if applicable, DATA_PID , WR_LEN . TRANS_COMPLETE will be set if this is the last buffer in the transfer.
CONTROL phase (pt 2):
- • The host state machine will keep performing IN transactions until LAST_BUFF is seen in the buffer_control register. If the host is in double buffered mode then the host controller will toggle between BUF0 and BUF1 sections of the buffer control register. Otherwise it will keep reading the buffer control register for buffer 0 and wait for the FULL to be unset and AVAILABLE to be set before starting the next IN transaction (i.e. wait in the control phase). The device can send a zero length packet to the host to indicate that it has no more data. In which case the host state machine will stop listening for more data regardless of if the LAST_BUFF flag was set or not. The host software can tell this has happened because BUFF_DONE will be set with a data length of 0 in the buffer control register.
⚠ WARNING
The USB host controller has a bug ( RP2040-E4 ) that means the status written back to the buffer control register can appear in the wrong half of the register. Bits 0-15 are for buffer 0, and bits 16-31 are for buffer 1. The host controller has a buffer selector that is flipped after each transfer is complete. This buffer selector is incorrectly used when writing status information back to the buffer control register even in single buffered mode. The buffer selector is not used when reading the buffer control register. The implication of this is that host software needs to keep track of the buffer selector and shift the buffer control register to the right by 16 bits if the buffer selector is 1.
For more information, see RP2040-E4 .
4.1.2.9.3. OUT
An OUT transfer is triggered with the SEND_TRANS bit set when the START_TRANS bit is set. This may be preceded by a SETUP packet being sent if the SEND_SETUP bit was set.
CONTROL phase:
- • Read EPx control to get endpoint information (same as Section 4.1.2.9.2 )
- • Read EPx buffer control to get the transfer length, data pid. AVAILABLE and FULL must be set for the transfer to start.
TOKEN phase
- • Send OUT packet to the device. The target device address and endpoint come from the ADDR_ENDP register.
DATA phase:
- • Send the first data packet to the device. If the endpoint type is Isochronous then there is no ACK phase so the host controller will go straight to status phase. If
ACK
received then go to status phase. Otherwise:
- ◦ If no reply is received then raise SIE_STATUS.RX_TIMEOUT .
- ◦ If NAK received raise SIE_STATUS.NAK_REC and send the data packet again.
- ◦ If STALL received then raise SIE_STATUS.STALL_REC and go to idle.
STATUS phase:
- • Set BUFF_STATUS bit and update buffer control register. FULL will be set to 0. TRANS_COMPLETE will be set if this is the last buffer in the transfer.
⚠ WARNING
The bug mentioned above ( RP2040-E4 ) in the IN section also applies to the OUT section.
CONTROL phase (pt 2):
If this isn't the last buffer in the transfer then wait for FULL and AVAILABLE to be set in the EPx buffer control register again.
4.1.2.9.4. Interrupt Endpoints
The host controller can poll interrupt endpoints on many devices (up to a maximum of 15 endpoints). To enable these, the programmer must:
- • Pick the next free interrupt endpoint slot on the host controller (starting at 1, to a maximum of 15)
- • Program the appropriate endpoint control register and buffer control register like you would with a normal IN or OUT transfer. Note that interrupt endpoints are only single buffered so the BUF1 part of the buffer control register is invalid.
- • Set the address and endpoint of the device in the appropriate ADDR_ENDP register ( ADDR_ENDP1 to ADDR_ENDP15 ). The preamble bit should be set if the device is Low Speed but attached to a Full Speed hub. The endpoint direction bit should also be set.
- • Set the interrupt endpoint active bit in INT_EP_CTRL (i.e. set bit 1 to 15 of that register)
Typically an interrupt endpoint will be an IN transfer. For example, a USB hub would be polled to see if the state of any of its ports have changed. If there is no change the hub will reply with a NAK to the controller and nothing will happen. Similarly, a mouse will reply with a NAK unless the mouse has been moved since the last time the interrupt endpoint was polled.
Interrupt endpoints are polled by the controller once a SOF packet has been sent by the host controller.
The controller loops from 1 to 15 and will attempt to poll any interrupt endpoint with the EP_ACTIVE bit set to 1 in INT_EP_CTRL . The controller will then read the endpoint control register, and buffer control register to see if there is an available buffer (i.e. FULL + AVAILABLE if an OUT transfer and NOT FULL + AVAILABLE for an IN transfer). If not, the controller will move onto the next interrupt endpoint slot.
If there is an available buffer, then the transfer is dealt with the same as a normal IN or OUT transfer and the BUFF_DONE flag in BUFF_STATUS will be set when the interrupt endpoint has a valid buffer. BUFF_CPU_SHOULD_HANDLE is invalid for interrupt endpoints as there is only a single buffer that can ever be done ( RP2040-E3 ).
4.1.2.10. VBUS Control
The USB controller can be connected up to GPIO pins (see Section 2.19 ) for the purpose of VBUS control:
- • VBUS enable, used to enable VBUS in host mode. VBUS enable is set in SIE_CTRL
- • VBUS detect, used to detect that VBUS is present in device mode. VBUS detect is a bit in SIE_STATUS and can also raise a VBUS_DETECT interrupt (enabled in INTE )
- • VBUS overcurrent, used to detect an overcurrent event. Applicable to both device and host. VBUS overcurrent is a bit in SIE_STATUS .
It is not necessary to connect up any of these pins to GPIO. The host can permanently supply VBUS and detect a device being connected when either the DP or DM pin is pulled high. VBUS detect can be forced in USB_PWR .
4.1.3. Programmer's Model
4.1.3.1. TinyUSB
The RP2040 TinyUSB port should be considered as the reference implementation for this USB controller. This port can be found in:
https://github.com/hathach/tinyusb/blob/master/src/portable/raspberrypi/rp2040/dcd_rp2040.c
https://github.com/hathach/tinyusb/blob/master/src/portable/raspberrypi/rp2040/hcd_rp2040.c
https://github.com/hathach/tinyusb/blob/master/src/portable/raspberrypi/rp2040/rp2040_usb.h
4.1.3.2. Standalone device example
A standalone USB device example,
dev_lowlevel, makes it easier to understand how to interact with the USB controller without needing to understand the TinyUSB abstractions. In addition to endpoint 0, the standalone device has two bulk endpoints: EP1 OUT and EP2 IN. The device is designed to send whatever data it receives on EP1 to EP2. The example comes with a small Python script that writes "Hello World" into EP1 and checks that it is correctly received on EP2.
The code included in this section will walk you through setting up to the USB device controller to receive a setup packet, and then respond to the setup packet.
Figure 58. USB analyser trace of the
dev_lowlevel USB device example. The control transfers are the device enumeration. The first bulk OUT (out from the host) transfer, highlighted in blue, is the host sending "Hello World" to the device. The second bulk transfer IN (in to the host), is the device returning "Hello World" to the host.
| Ch0 | Packet 522 | H | Reset | 15.006 ms | ||||
| Transfer 0 | F | Control | ADDR 0 | ENDP 0 | bRequest GET_DESCRIPTOR | wValue DEVICE type | wIndex 0x0000 | Descriptors |
| Transfer 1 | S | Control | ADDR 7 | ENDP 0 | bRequest SET_ADDRESS | wValue New address 7 | wIndex 0x0000 | wLength 0 |
| Transfer 2 | F | Control | ADDR 7 | ENDP 0 | bRequest GET_DESCRIPTOR | wValue DEVICE type | wIndex 0x0000 | Descriptors |
| Transfer 3 | S | Control | ADDR 7 | ENDP 0 | bRequest GET_DESCRIPTOR | wValue CONFIGURATION type, Index 0 | wIndex 0x0000 | Descriptors |
| Transfer 4 | F | Control | ADDR 7 | ENDP 0 | bRequest GET_DESCRIPTOR | wValue CONFIGURATION type, Index 0 | wIndex 0x0000 | 4 Descriptors |
| Transfer 5 | S | Control | ADDR 7 | ENDP 0 | bRequest GET_DESCRIPTOR | wValue STRING type, LANGID codes requested | wIndex Language ID 0x0000 | Lang Supported |
| Transfer 6 | F | Control | ADDR 7 | ENDP 0 | bRequest GET_DESCRIPTOR | wValue STRING type, Index 2 | wIndex Language ID 0x0409 | Pico Test Device |
| Transfer 7 | S | Control | ADDR 7 | ENDP 0 | bRequest GET_DESCRIPTOR | wValue STRING type, Index 1 | wIndex Language ID 0x0409 | Raspberry Pi |
| Transfer 8 | F | Control | ADDR 7 | ENDP 0 | bRequest SET_CONFIGURATION | wValue New Configuration 1 | wIndex 0x0000 | wLength 0 |
| Transfer 9 | S | Bulk | ADDR 7 | ENDP 1 | Bytes Transferred | 12 | ||
| Transfer 10 | F | Bulk | ADDR 7 | ENDP 2 | Bytes Transferred | 12 | ||
4.1.3.2.1. Device controller initialisation
The following code initialises the USB device.
Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 183 - 217
183 void usb_device_init() {
184 // Reset usb controller
185 reset_unreset_block_num_wait_blocking(RESET_USBCTRL);
186
187 // Clear any previous state in dpram just in case
188 memset(usb_dpram, 0, sizeof(*usb_dpram)); ①
189
190 // Enable USB interrupt at processor
191 irq_set_enabled(USBCTRL_IRQ, true);
192
193 // Mux the controller to the onboard usb phy
194 usb_hw->muxing = USB_USB_MUXING_TO_PHY_BITS | USB_USB_MUXING_SOFTCON_BITS; 195 196 // Force VBUS detect so the device thinks it is plugged into a host 197 usb_hw->pwr = USB_USB_PWR_VBUS_DETECT_BITS | USB_USB_PWR_VBUS_DETECT_OVERRIDE_EN_BITS; 198 199 // Enable the USB controller in device mode. 200 usb_hw->main_ctrl = USB_MAIN_CTRL_CONTROLLER_EN_BITS; 201 202 // Enable an interrupt per EP0 transaction 203 usb_hw->sie_ctrl = USB_SIE_CTRL_EP0_INT_1BUF_BITS; ② 204 205 // Enable interrupts for when a buffer is done, when the bus is reset, 206 // and when a setup packet is received 207 usb_hw->inte = USB_INTS_BUFF_STATUS_BITS | 208 USB_INTS_BUS_RESET_BITS | 209 USB_INTS_SETUP_REQ_BITS; 210 211 // Set up endpoints (endpoint control registers) 212 // described by device configuration 213 usb_setup_endpoints(); 214 215 // Present full speed device by enabling pull up on DP 216 usb_hw_set->sie_ctrl = USB_SIE_CTRL_PULLUP_EN_BITS; 217 }
4.1.3.2.2. Configuring the endpoint control registers for EP1 and EP2
The function
usb_configure_endpoints loops through each endpoint defined in the device configuration (including EP0 in and EP0 out, which don't have an endpoint control register defined) and calls the
usb_configure_endpoint function. This sets up the endpoint control register for that endpoint:
Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 149 - 164
149 void usb_setup_endpoint(const struct usb_endpoint_configuration *ep) {
150 printf("Set up endpoint 0x%x with buffer address 0x%p\n", ep->descriptor-
151 >bEndpointAddress, ep->data_buffer);
152
153 // EP0 doesn't have one so return if that is the case
154 if (!ep->endpoint_control) {
155 return;
156 }
157
158 // Get the data buffer as an offset of the USB controller's DPRAM
159 uint32_t dpram_offset = usb_buffer_offset(ep->data_buffer);
160 uint32_t reg = EP_CTRL_ENABLE_BITS
161 | EP_CTRL_INTERRUPT_PER_BUFFER
162 | (ep->descriptor->bmAttributes << EP_CTRL_BUFFER_TYPE_LSB)
163 | dpram_offset;
164 *ep->endpoint_control = reg;
165 }
4.1.3.2.3. Receiving a setup packet
An interrupt is raised when a setup packet is received, so the interrupt handler must handle this event:
Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 494 - 504
494 void isr_usbctrl(void) {
495 // USB interrupt handler
496 uint32_t status = usb_hw->ints;
497 uint32_t handled = 0;
498
499 // Setup packet received
500 if (status & USB_INTS_SETUP_REQ_BITS) {
501 handled |= USB_INTS_SETUP_REQ_BITS;
502 usb_hw_clear->sie_status = USB_SIE_STATUS_SETUP_REC_BITS;
503 usb_handle_setup_packet();
504 }
The setup packet gets written to the first 8 bytes of the USB ram, so the setup packet handler casts that area of memory to
struct usb_setup_packet *.
Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 383 - 427
383 void usb_handle_setup_packet(void) {
384 volatile struct usb_setup_packet *pkt = (volatile struct usb_setup_packet *) &usb_dpram
->setup_packet;
385 uint8_t req_direction = pkt->bmRequestType;
386 uint8_t req = pkt->bRequest;
387
388 // Reset PID to 1 for EP0 IN
389 usb_get_endpoint_configuration(EP0_IN_ADDR)->next_pid = 1u;
390
391 if (req_direction == USB_DIR_OUT) {
392 if (req == USB_REQUEST_SET_ADDRESS) {
393 usb_set_device_address(pkt);
394 } else if (req == USB_REQUEST_SET_CONFIGURATION) {
395 usb_set_device_configuration(pkt);
396 } else {
397 usb_acknowledge_out_request();
398 printf("Other OUT request (0x%x)\r\n", pkt->bRequest);
399 }
400 } else if (req_direction == USB_DIR_IN) {
401 if (req == USB_REQUEST_GET_DESCRIPTOR) {
402 uint16_t descriptor_type = pkt->wValue >> 8;
403
404 switch (descriptor_type) {
405 case USB_DT_DEVICE:
406 usb_handle_device_descriptor(pkt);
407 printf("GET DEVICE DESCRIPTOR\r\n");
408 break;
409
410 case USB_DT_CONFIG:
411 usb_handle_config_descriptor(pkt);
412 printf("GET CONFIG DESCRIPTOR\r\n");
413 break;
414
415 case USB_DT_STRING:
416 usb_handle_string_descriptor(pkt);
417 printf("GET STRING DESCRIPTOR\r\n");
418 break;
419
420 default:
421 printf("Unhandled GET_DESCRIPTOR type 0x%x\r\n", descriptor_type);
422 }
423 } else {
424 printf("Other IN request (0x%x)\r\n", pkt->bRequest);
425 } 426 } 427 }
4.1.3.2.4. Replying to a setup packet on EP0 IN
The first thing a host will request is the device descriptor, the following code handles that setup request.
Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 266 - 273
266 void usb_handle_device_descriptor(volatile struct usb_setup_packet *pkt) {
267 const struct usb_device_descriptor *d = dev_config.device_descriptor;
268 // EP0 in
269 struct usb_endpoint_configuration *ep = usb_get_endpoint_configuration(EP0_IN_ADDR);
270 // Always respond with pid 1
271 ep->next_pid = 1;
272 usb_start_transfer(ep, (uint8_t *) d, MIN(sizeof(struct usb_device_descriptor), pkt->wLength));
273 }
The
usb_start_transfer function copies the data to send into the appropriate hardware buffer, and configures the buffer control register. Once the buffer control register has been written to, the device controller will respond to the host with the data. Before this point, the device will reply with a
NAK
.
Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/usb/device/dev_lowlevel/dev_lowlevel.c Lines 238 - 260
238 void usb_start_transfer(struct usb_endpoint_configuration *ep, uint8_t *buf, uint16_t len) {
239 // We are asserting that the length is <= 64 bytes for simplicity of the example.
240 // For multi packet transfers see the tinyusb port.
241 assert(len <= 64);
242
243 printf("Start transfer of len %d on ep addr 0x%x\n", len, ep->descriptor->bEndpointAddress);
244
245 // Prepare buffer control register value
246 uint32_t val = len | USB_BUF_CTRL_AVAIL;
247
248 if (ep_is_tx(ep)) {
249 // Need to copy the data from the user buffer to the usb memory
250 memcpy((void *) ep->data_buffer, (void *) buf, len);
251 // Mark as full
252 val |= USB_BUF_CTRL_FULL;
253 }
254
255 // Set pid and flip for next transfer
256 val |= ep->next_pid ? USB_BUF_CTRL_DATA1_PID : USB_BUF_CTRL_DATA0_PID;
257 ep->next_pid ^= 1u;
258
259 *ep->buffer_control = val;
260 }
4.1.4. List of Registers
The USB registers start at a base address of
0x50110000(defined as
USBCTRL_REGS_BASE in SDK).
Table 397. List of USB registers
| Offset | Name | Info |
|---|---|---|
| 0x00 | ADDR_ENDP | Device address and endpoint control |
| 0x04 | ADDR_ENDP1 | Interrupt endpoint 1. Only valid for HOST mode. |
| 0x08 | ADDR_ENDP2 | Interrupt endpoint 2. Only valid for HOST mode. |
| 0x0c | ADDR_ENDP3 | Interrupt endpoint 3. Only valid for HOST mode. |
| 0x10 | ADDR_ENDP4 | Interrupt endpoint 4. Only valid for HOST mode. |
| 0x14 | ADDR_ENDP5 | Interrupt endpoint 5. Only valid for HOST mode. |
| 0x18 | ADDR_ENDP6 | Interrupt endpoint 6. Only valid for HOST mode. |
| 0x1c | ADDR_ENDP7 | Interrupt endpoint 7. Only valid for HOST mode. |
| 0x20 | ADDR_ENDP8 | Interrupt endpoint 8. Only valid for HOST mode. |
| 0x24 | ADDR_ENDP9 | Interrupt endpoint 9. Only valid for HOST mode. |
| 0x28 | ADDR_ENDP10 | Interrupt endpoint 10. Only valid for HOST mode. |
| 0x2c | ADDR_ENDP11 | Interrupt endpoint 11. Only valid for HOST mode. |
| 0x30 | ADDR_ENDP12 | Interrupt endpoint 12. Only valid for HOST mode. |
| 0x34 | ADDR_ENDP13 | Interrupt endpoint 13. Only valid for HOST mode. |
| 0x38 | ADDR_ENDP14 | Interrupt endpoint 14. Only valid for HOST mode. |
| 0x3c | ADDR_ENDP15 | Interrupt endpoint 15. Only valid for HOST mode. |
| 0x40 | MAIN_CTRL | Main control register |
| 0x44 | SOF_WR | Set the SOF (Start of Frame) frame number in the host controller. The SOF packet is sent every 1ms and the host will increment the frame number by 1 each time. |
| 0x48 | SOF_RD | Read the last SOF (Start of Frame) frame number seen. In device mode the last SOF received from the host. In host mode the last SOF sent by the host. |
| 0x4c | SIE_CTRL | SIE control register |
| 0x50 | SIE_STATUS | SIE status register |
| 0x54 | INT_EP_CTRL | interrupt endpoint control register |
| 0x58 | BUFF_STATUS | Buffer status register. A bit set here indicates that a buffer has completed on the endpoint (if the buffer interrupt is enabled). It is possible for 2 buffers to be completed, so clearing the buffer status bit may instantly re set it on the next clock cycle. |
| 0x5c | BUFF_CPU_SHOULD_HANDLE | Which of the double buffers should be handled. Only valid if using an interrupt per buffer (i.e. not per 2 buffers). Not valid for host interrupt endpoint polling because they are only single buffered. |
| 0x60 | EP_ABORT | Device only: Can be set to ignore the buffer control register for this endpoint in case you would like to revoke a buffer. A NAK will be sent for every access to the endpoint until this bit is cleared. A corresponding bit in EP_ABORT_DONE is set when it is safe to modify the buffer control register. |
| Offset | Name | Info |
|---|---|---|
| 0x64 | EP_ABORT_DONE | Device only: Used in conjunction with EP_ABORT . Set once an endpoint is idle so the programmer knows it is safe to modify the buffer control register. |
| 0x68 | EP_STALL_ARM | Device: this bit must be set in conjunction with the STALL bit in the buffer control register to send a STALL on EP0. The device controller clears these bits when a SETUP packet is received because the USB spec requires that a STALL condition is cleared when a SETUP packet is received. |
| 0x6c | NAK_POLL | Used by the host controller. Sets the wait time in microseconds before trying again if the device replies with a NAK. |
| 0x70 | EP_STATUS_STALL_NAK | Device: bits are set when the IRQ_ON_NAK or IRQ_ON_STALL bits are set. For EP0 this comes from SIE_CTRL . For all other endpoints it comes from the endpoint control register. |
| 0x74 | USB_MUXING | Where to connect the USB controller. Should be to_phy by default. |
| 0x78 | USB_PWR | Overrides for the power signals in the event that the VBUS signals are not hooked up to GPIO. Set the value of the override and then the override enable to switch over to the override value. |
| 0x7c | USBPHY_DIRECT | This register allows for direct control of the USB phy. Use in conjunction with usbphy_direct_override register to enable each override bit. |
| 0x80 | USBPHY_DIRECT_OVERRIDE | Override enable for each control in usbphy_direct |
| 0x84 | USBPHY_TRIM | Used to adjust trim values of USB phy pull down resistors. |
| 0x8c | INTR | Raw Interrupts |
| 0x90 | INTE | Interrupt Enable |
| 0x94 | INTF | Interrupt Force |
| 0x98 | INTS | Interrupt status after masking & forcing |
USB: ADDR_ENDP Register
Offset: 0x00
Description
Device address and endpoint control
Table 398.
ADDR_ENDP Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:20 | Reserved. | - | - |
| 19:16 | ENDPOINT: Device endpoint to send data to. Only valid for HOST mode. | RW | 0x0 |
| 15:7 | Reserved. | - | - |
| 6:0 | ADDRESS: In device mode, the address that the device should respond to. Set in response to a SET_ADDR setup packet from the host. In host mode set to the address of the device to communicate with. | RW | 0x00 |
USB: ADDR_ENDP1, ADDR_ENDP2, ..., ADDR_ENDP14, ADDR_ENDP15 Registers
Offsets: 0x04, 0x08, ..., 0x38, 0x3c
Description
Interrupt endpoint N . Only valid for HOST mode.
Table 399.
ADDR_ENDP1,
ADDR_ENDP2, ...,
ADDR_ENDP14,
ADDR_ENDP15
Registers
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:27 | Reserved. | - | - |
| 26 | INTEP_PREAMBLE: Interrupt EP requires preamble (is a low speed device on a full speed hub) | RW | 0x0 |
| 25 | INTEP_DIR: Direction of the interrupt endpoint. In=0, Out=1 | RW | 0x0 |
| 24:20 | Reserved. | - | - |
| 19:16 | ENDPOINT: Endpoint number of the interrupt endpoint | RW | 0x0 |
| 15:7 | Reserved. | - | - |
| 6:0 | ADDRESS: Device address | RW | 0x00 |
USB: MAIN_CTRL Register
Offset: 0x40
Description
Main control register
Table 400.
MAIN_CTRL Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31 | SIM_TIMING: Reduced timings for simulation | RW | 0x0 |
| 30:2 | Reserved. | - | - |
| 1 | HOST_NDEVICE: Device mode = 0, Host mode = 1 | RW | 0x0 |
| 0 | CONTROLLER_EN: Enable controller | RW | 0x0 |
USB: SOF_WR Register
Offset: 0x44
Description
Set the SOF (Start of Frame) frame number in the host controller. The SOF packet is sent every 1ms and the host will increment the frame number by 1 each time.
Table 401. SOF_WR
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:11 | Reserved. | - | - |
| 10:0 | COUNT | WF | 0x000 |
USB: SOF_RD Register
Offset: 0x48
Description
Read the last SOF (Start of Frame) frame number seen. In device mode the last SOF received from the host. In host mode the last SOF sent by the host.
Table 402. SOF_RD
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:11 | Reserved. | - | - |
| Bits 14:10 9:5 4:0 Bits | Description SHIFT Description | MASK_MSB : The most-significant bit allowed to pass by the mask (inclusive) MASK_LSB : The least-significant bit allowed to pass by the mask (inclusive) : Logical right-shift applied to accumulator before masking | Type RW RW RW Type | Reset 0x00 0x00 0x00 Reset |
|---|---|---|---|---|
| 28 | EP0_INT_2BUF on EP0 | : Device: Set bit in BUFF_STATUS for every 2 buffers completed | RW | 0x0 |
| 27 | EP0_INT_NAK NAK | : Device: Set bit in EP_STATUS_STALL_NAK when EP0 sends a | RW | 0x0 |
| 26 | DIRECT_EN | : Direct bus drive enable | RW | 0x0 |
| 25 | DIRECT_DP | : Direct control of DP | RW | 0x0 |
| 24 | DIRECT_DM | : Direct control of DM | RW | 0x0 |
| 23:19 | Reserved. | - | - | |
| 18 | TRANSCEIVER_PD | : Power down bus transceiver | RW | 0x0 |
| 17 | RPU_OPT | : Device: Pull-up strength (0=1K2, 1=2k3) | RW | 0x0 |
| 16 | PULLUP_EN | : Device: Enable pull up resistor | RW | 0x0 |
| 15 | PULLDOWN_EN | : Host: Enable pull down resistors | RW | 0x0 |
| 14 | Reserved. | - | - | |
| 13 | RESET_BUS | : Host: Reset bus | SC | 0x0 |
| 12 | RESUME suspend. | : Device: Remote wakeup. Device can initiate its own resume after | SC | 0x0 |
| 11 | VBUS_EN | : Host: Enable VBUS | RW | 0x0 |
| 10 | KEEP_ALIVE_EN | : Host: Enable keep alive packet (for low speed bus) | RW | 0x0 |
| 9 | SOF_EN | : Host: Enable SOF generation (for full speed bus) | RW | 0x0 |
| 8 | SOF_SYNC | : Host: Delay packet(s) until after SOF | RW | 0x0 |
| 7 | Reserved. | - | - | |
| 6 | PREAMBLE_EN | : Host: Preable enable for LS device on FS hub | RW | 0x0 |
| 5 | Reserved. | - | - | |
| 4 | STOP_TRANS | : Host: Stop transaction | SC | 0x0 |
| 3 | RECEIVE_DATA | : Host: Receive transaction (IN to host) | RW | 0x0 |
| 2 | SEND_DATA | : Host: Send transaction (OUT from host) | RW | 0x0 |
USB: SIE_CTRL Register
Offset: 0x4c
Description
SIE control register
Table 403. SIE_CTRL Register
| Bits 14:10 9:5 4:0 Bits | Description SHIFT Description | MASK_MSB : The most-significant bit allowed to pass by the mask (inclusive) MASK_LSB : The least-significant bit allowed to pass by the mask (inclusive) : Logical right-shift applied to accumulator before masking | Type RW RW RW Type | Reset 0x00 0x00 0x00 Reset |
|---|---|---|---|---|
| 29 | STALL_REC | : Host: STALL received | WC | 0x0 |
| 28 | NAK_REC | : Host: NAK received | WC | 0x0 |
| 27 | RX_TIMEOUT | : RX timeout is raised by both the host and device if an ACK is not received in the maximum time specified by the USB spec. | WC | 0x0 |
| 26 | RX_OVERFLOW | : RX overflow is raised by the Serial RX engine if the incoming data is too fast. | WC | 0x0 |
| 25 | BIT_STUFF_ERROR | : Bit Stuff Error. Raised by the Serial RX engine. | WC | 0x0 |
| 24 | CRC_ERROR | : CRC Error. Raised by the Serial RX engine. | WC | 0x0 |
| 23:20 | Reserved. | - | - | |
| 19 | BUS_RESET | : Device: bus reset received | WC | 0x0 |
| 18 | TRANS_COMPLETE | : Transaction complete. | WC | 0x0 |
| * An IN or OUT packet is sent with the register | LAST_BUFF | bit set in the buffer control | ||
| IN packet is received and the | LAST_BUFF bit is set in the buffer control register * An IN packet is received with zero length * An OUT packet is sent and the | |||
| 17 | LAST_BUFF SETUP_REC | bit is set : Device: Setup packet received | WC | 0x0 |
USB: SIE_STATUS Register
Offset: 0x50
Description
SIE status register
Table 404.
SIE_STATUS Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 16 | CONNECTED: Device: connected | WC | 0x0 |
| 15:12 | Reserved. | - | - |
| 11 | RESUME: Host: Device has initiated a remote resume. Device: host has initiated a resume. | WC | 0x0 |
| 10 | VBUS_OVER_CURR: VBUS over current detected | RO | 0x0 |
| 9:8 | SPEED: Host: device speed. Disconnected = 00, LS = 01, FS = 10 | WC | 0x0 |
| 7:5 | Reserved. | - | - |
| 4 | SUSPENDED: Bus in suspended state. Valid for device and host. Host and device will go into suspend if neither Keep Alive / SOF frames are enabled. | WC | 0x0 |
| 3:2 | LINE_STATE: USB bus line state | RO | 0x0 |
| 1 | Reserved. | - | - |
| 0 | VBUS_DETECTED: Device: VBUS Detected | RO | 0x0 |
USB: INT_EP_CTRL Register
Offset: 0x54
Description
interrupt endpoint control register
Table 405.
INT_EP_CTRL Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:16 | Reserved. | - | - |
| 15:1 | INT_EP_ACTIVE: Host: Enable interrupt endpoint 1 → 15 | RW | 0x0000 |
| 0 | Reserved. | - | - |
USB: BUFF_STATUS Register
Offset: 0x58
Description
Buffer status register. A bit set here indicates that a buffer has completed on the endpoint (if the buffer interrupt is enabled). It is possible for 2 buffers to be completed, so clearing the buffer status bit may instantly re set it on the next clock cycle.
Table 406.
BUFF_STATUS
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31 | EP15_OUT | WC | 0x0 |
| 30 | EP15_IN | WC | 0x0 |
| 29 | EP14_OUT | WC | 0x0 |
| 28 | EP14_IN | WC | 0x0 |
| 27 | EP13_OUT | WC | 0x0 |
| 26 | EP13_IN | WC | 0x0 |
| 25 | EP12_OUT | WC | 0x0 |
| 24 | EP12_IN | WC | 0x0 |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 23 | EP11_OUT | WC | 0x0 |
| 22 | EP11_IN | WC | 0x0 |
| 21 | EP10_OUT | WC | 0x0 |
| 20 | EP10_IN | WC | 0x0 |
| 19 | EP9_OUT | WC | 0x0 |
| 18 | EP9_IN | WC | 0x0 |
| 17 | EP8_OUT | WC | 0x0 |
| 16 | EP8_IN | WC | 0x0 |
| 15 | EP7_OUT | WC | 0x0 |
| 14 | EP7_IN | WC | 0x0 |
| 13 | EP6_OUT | WC | 0x0 |
| 12 | EP6_IN | WC | 0x0 |
| 11 | EP5_OUT | WC | 0x0 |
| 10 | EP5_IN | WC | 0x0 |
| 9 | EP4_OUT | WC | 0x0 |
| 8 | EP4_IN | WC | 0x0 |
| 7 | EP3_OUT | WC | 0x0 |
| 6 | EP3_IN | WC | 0x0 |
| 5 | EP2_OUT | WC | 0x0 |
| 4 | EP2_IN | WC | 0x0 |
| 3 | EP1_OUT | WC | 0x0 |
| 2 | EP1_IN | WC | 0x0 |
| 1 | EP0_OUT | WC | 0x0 |
| 0 | EP0_IN | WC | 0x0 |
USB: BUFF_CPU_SHOULD_HANDLE Register
Offset: 0x5c
Description
Which of the double buffers should be handled. Only valid if using an interrupt per buffer (i.e. not per 2 buffers). Not valid for host interrupt endpoint polling because they are only single buffered.
Table 407.
BUFF_CPU_SHOULD_H
ANDLE Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31 | EP15_OUT | RO | 0x0 |
| 30 | EP15_IN | RO | 0x0 |
| 29 | EP14_OUT | RO | 0x0 |
| 28 | EP14_IN | RO | 0x0 |
| 27 | EP13_OUT | RO | 0x0 |
| 26 | EP13_IN | RO | 0x0 |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 25 | EP12_OUT | RO | 0x0 |
| 24 | EP12_IN | RO | 0x0 |
| 23 | EP11_OUT | RO | 0x0 |
| 22 | EP11_IN | RO | 0x0 |
| 21 | EP10_OUT | RO | 0x0 |
| 20 | EP10_IN | RO | 0x0 |
| 19 | EP9_OUT | RO | 0x0 |
| 18 | EP9_IN | RO | 0x0 |
| 17 | EP8_OUT | RO | 0x0 |
| 16 | EP8_IN | RO | 0x0 |
| 15 | EP7_OUT | RO | 0x0 |
| 14 | EP7_IN | RO | 0x0 |
| 13 | EP6_OUT | RO | 0x0 |
| 12 | EP6_IN | RO | 0x0 |
| 11 | EP5_OUT | RO | 0x0 |
| 10 | EP5_IN | RO | 0x0 |
| 9 | EP4_OUT | RO | 0x0 |
| 8 | EP4_IN | RO | 0x0 |
| 7 | EP3_OUT | RO | 0x0 |
| 6 | EP3_IN | RO | 0x0 |
| 5 | EP2_OUT | RO | 0x0 |
| 4 | EP2_IN | RO | 0x0 |
| 3 | EP1_OUT | RO | 0x0 |
| 2 | EP1_IN | RO | 0x0 |
| 1 | EP0_OUT | RO | 0x0 |
| 0 | EP0_IN | RO | 0x0 |
USB: EP_ABORT Register
Offset: 0x60
Description
Device only: Can be set to ignore the buffer control register for this endpoint in case you would like to revoke a buffer. A NAK will be sent for every access to the endpoint until this bit is cleared. A corresponding bit in EP_ABORT_DONE is set when it is safe to modify the buffer control register.
Table 408. EP_ABORT Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31 | EP15_OUT | RW | 0x0 |
| 30 | EP15_IN | RW | 0x0 |
| 29 | EP14_OUT | RW | 0x0 |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 28 | EP14_IN | RW | 0x0 |
| 27 | EP13_OUT | RW | 0x0 |
| 26 | EP13_IN | RW | 0x0 |
| 25 | EP12_OUT | RW | 0x0 |
| 24 | EP12_IN | RW | 0x0 |
| 23 | EP11_OUT | RW | 0x0 |
| 22 | EP11_IN | RW | 0x0 |
| 21 | EP10_OUT | RW | 0x0 |
| 20 | EP10_IN | RW | 0x0 |
| 19 | EP9_OUT | RW | 0x0 |
| 18 | EP9_IN | RW | 0x0 |
| 17 | EP8_OUT | RW | 0x0 |
| 16 | EP8_IN | RW | 0x0 |
| 15 | EP7_OUT | RW | 0x0 |
| 14 | EP7_IN | RW | 0x0 |
| 13 | EP6_OUT | RW | 0x0 |
| 12 | EP6_IN | RW | 0x0 |
| 11 | EP5_OUT | RW | 0x0 |
| 10 | EP5_IN | RW | 0x0 |
| 9 | EP4_OUT | RW | 0x0 |
| 8 | EP4_IN | RW | 0x0 |
| 7 | EP3_OUT | RW | 0x0 |
| 6 | EP3_IN | RW | 0x0 |
| 5 | EP2_OUT | RW | 0x0 |
| 4 | EP2_IN | RW | 0x0 |
| 3 | EP1_OUT | RW | 0x0 |
| 2 | EP1_IN | RW | 0x0 |
| 1 | EP0_OUT | RW | 0x0 |
| 0 | EP0_IN | RW | 0x0 |
USB: EP_ABORT_DONE Register
Offset: 0x64
Description
Device only: Used in conjunction with EP_ABORT . Set once an endpoint is idle so the programmer knows it is safe to modify the buffer control register.
Table 409.
EP_ABORT_DONE
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31 | EP15_OUT | WC | 0x0 |
| 30 | EP15_IN | WC | 0x0 |
| 29 | EP14_OUT | WC | 0x0 |
| 28 | EP14_IN | WC | 0x0 |
| 27 | EP13_OUT | WC | 0x0 |
| 26 | EP13_IN | WC | 0x0 |
| 25 | EP12_OUT | WC | 0x0 |
| 24 | EP12_IN | WC | 0x0 |
| 23 | EP11_OUT | WC | 0x0 |
| 22 | EP11_IN | WC | 0x0 |
| 21 | EP10_OUT | WC | 0x0 |
| 20 | EP10_IN | WC | 0x0 |
| 19 | EP9_OUT | WC | 0x0 |
| 18 | EP9_IN | WC | 0x0 |
| 17 | EP8_OUT | WC | 0x0 |
| 16 | EP8_IN | WC | 0x0 |
| 15 | EP7_OUT | WC | 0x0 |
| 14 | EP7_IN | WC | 0x0 |
| 13 | EP6_OUT | WC | 0x0 |
| 12 | EP6_IN | WC | 0x0 |
| 11 | EP5_OUT | WC | 0x0 |
| 10 | EP5_IN | WC | 0x0 |
| 9 | EP4_OUT | WC | 0x0 |
| 8 | EP4_IN | WC | 0x0 |
| 7 | EP3_OUT | WC | 0x0 |
| 6 | EP3_IN | WC | 0x0 |
| 5 | EP2_OUT | WC | 0x0 |
| 4 | EP2_IN | WC | 0x0 |
| 3 | EP1_OUT | WC | 0x0 |
| 2 | EP1_IN | WC | 0x0 |
| 1 | EP0_OUT | WC | 0x0 |
| 0 | EP0_IN | WC | 0x0 |
USB: EP_STALL_ARM Register
Offset: 0x68
DescriptionDevice: this bit must be set in conjunction with the STALL bit in the buffer control register to send a STALL on EP0. The device controller clears these bits when a SETUP packet is received because the USB spec requires that a STALL condition is cleared when a SETUP packet is received.
Table 410.
EP_STALL_ARM
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:2 | Reserved. | - | - |
| 1 | EP0_OUT | RW | 0x0 |
| 0 | EP0_IN | RW | 0x0 |
Offset: 0x6c
DescriptionUsed by the host controller. Sets the wait time in microseconds before trying again if the device replies with a NAK.
Table 411. NAK_POLL
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:26 | Reserved. | - | - |
| 25:16 | DELAY_FS: NAK polling interval for a full speed device | RW | 0x010 |
| 15:10 | Reserved. | - | - |
| 9:0 | DELAY_LS: NAK polling interval for a low speed device | RW | 0x010 |
Offset: 0x70
DescriptionDevice: bits are set when the IRQ_ON_NAK or IRQ_ON_STALL bits are set. For EP0 this comes from SIE_CTRL . For all other endpoints it comes from the endpoint control register.
Table 412.
EP_STATUS_STALL_NAK
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31 | EP15_OUT | WC | 0x0 |
| 30 | EP15_IN | WC | 0x0 |
| 29 | EP14_OUT | WC | 0x0 |
| 28 | EP14_IN | WC | 0x0 |
| 27 | EP13_OUT | WC | 0x0 |
| 26 | EP13_IN | WC | 0x0 |
| 25 | EP12_OUT | WC | 0x0 |
| 24 | EP12_IN | WC | 0x0 |
| 23 | EP11_OUT | WC | 0x0 |
| 22 | EP11_IN | WC | 0x0 |
| 21 | EP10_OUT | WC | 0x0 |
| 20 | EP10_IN | WC | 0x0 |
| 19 | EP9_OUT | WC | 0x0 |
| 18 | EP9_IN | WC | 0x0 |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 17 | EP8_OUT | WC | 0x0 |
| 16 | EP8_IN | WC | 0x0 |
| 15 | EP7_OUT | WC | 0x0 |
| 14 | EP7_IN | WC | 0x0 |
| 13 | EP6_OUT | WC | 0x0 |
| 12 | EP6_IN | WC | 0x0 |
| 11 | EP5_OUT | WC | 0x0 |
| 10 | EP5_IN | WC | 0x0 |
| 9 | EP4_OUT | WC | 0x0 |
| 8 | EP4_IN | WC | 0x0 |
| 7 | EP3_OUT | WC | 0x0 |
| 6 | EP3_IN | WC | 0x0 |
| 5 | EP2_OUT | WC | 0x0 |
| 4 | EP2_IN | WC | 0x0 |
| 3 | EP1_OUT | WC | 0x0 |
| 2 | EP1_IN | WC | 0x0 |
| 1 | EP0_OUT | WC | 0x0 |
| 0 | EP0_IN | WC | 0x0 |
USB: USB_MUXING Register
Offset: 0x74
Description
Where to connect the USB controller. Should be to_phy by default.
Table 413.
USB_MUXING Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:4 | Reserved. | - | - |
| 3 | SOFTCON | RW | 0x0 |
| 2 | TO_DIGITAL_PAD | RW | 0x0 |
| 1 | TO_EXTPHY | RW | 0x0 |
| 0 | TO_PHY | RW | 0x0 |
USB: USB_PWR Register
Offset: 0x78
Description
Overrides for the power signals in the event that the VBUS signals are not hooked up to GPIO. Set the value of the override and then the override enable to switch over to the override value.
Table 414. USB_PWR Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:6 | Reserved. | - | - |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 5 | OVERCURR_DETECT_EN | RW | 0x0 |
| 4 | OVERCURR_DETECT | RW | 0x0 |
| 3 | VBUS_DETECT_OVERRIDE_EN | RW | 0x0 |
| 2 | VBUS_DETECT | RW | 0x0 |
| 1 | VBUS_EN_OVERRIDE_EN | RW | 0x0 |
| 0 | VBUS_EN | RW | 0x0 |
USB: USBPHY_DIRECT Register
Offset: 0x7c
Description
This register allows for direct control of the USB phy. Use in conjunction with usbphy_direct_override register to enable each override bit.
Table 415.
USBPHY_DIRECT
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:23 | Reserved. | - | - |
| 22 | DM_OVV : DM over voltage | RO | 0x0 |
| 21 | DP_OVV : DP over voltage | RO | 0x0 |
| 20 | DM_OVCN : DM overcurrent | RO | 0x0 |
| 19 | DP_OVCN : DP overcurrent | RO | 0x0 |
| 18 | RX_DM : DPM pin state | RO | 0x0 |
| 17 | RX_DP : DPP pin state | RO | 0x0 |
| 16 | RX_DD : Differential RX | RO | 0x0 |
| 15 | TX_DIFFMODE
: TX_DIFFMODE=0: Single ended mode TX_DIFFMODE=1: Differential drive mode (TX_DM, TX_DM_OE ignored) | RW | 0x0 |
| 14 | TX_FSSLEW
: TX_FSSLEW=0: Low speed slew rate TX_FSSLEW=1: Full speed slew rate | RW | 0x0 |
| 13 | TX_PD : TX power down override (if override enable is set). 1 = powered down. | RW | 0x0 |
| 12 | RX_PD : RX power down override (if override enable is set). 1 = powered down. | RW | 0x0 |
| 11 | TX_DM
: Output data. TX_DIFFMODE=1, Ignored TX_DIFFMODE=0, Drives DPM only. TX_DM_OE=1 to enable drive. DPM=TX_DM | RW | 0x0 |
| 10 | TX_DP
: Output data. If TX_DIFFMODE=1, Drives DPP/DPM diff pair. TX_DP_OE=1 to enable drive. DPP=TX_DP, DPM=~TX_DP If TX_DIFFMODE=0, Drives DPP only. TX_DP_OE=1 to enable drive. DPP=TX_DP | RW | 0x0 |
| 9 | TX_DM_OE
: Output enable. If TX_DIFFMODE=1, Ignored. If TX_DIFFMODE=0, OE for DPM only. 0 - DPM in Hi-Z state; 1 - DPM driving | RW | 0x0 |
| 8 | TX_DP_OE
: Output enable. If TX_DIFFMODE=1, OE for DPP/DPM diff pair. 0 - DPP/DPM in Hi-Z state; 1 - DPP/DPM driving If TX_DIFFMODE=0, OE for DPP only. 0 - DPP in Hi-Z state; 1 - DPP driving | RW | 0x0 |
| 7 | Reserved. | - | - |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 6 | DM_PULLDN_EN : DM pull down enable | RW | 0x0 |
| 5 | DM_PULLUP_EN : DM pull up enable | RW | 0x0 |
| 4 | DM_PULLUP_HISEL : Enable the second DM pull up resistor. 0 - Pull = Rpu2; 1 - Pull = Rpu1 + Rpu2 | RW | 0x0 |
| 3 | Reserved. | - | - |
| 2 | DP_PULLDN_EN : DP pull down enable | RW | 0x0 |
| 1 | DP_PULLUP_EN : DP pull up enable | RW | 0x0 |
| 0 | DP_PULLUP_HISEL : Enable the second DP pull up resistor. 0 - Pull = Rpu2; 1 - Pull = Rpu1 + Rpu2 | RW | 0x0 |
USB: USBPHY_DIRECT_OVERRIDE Register
Offset: 0x80
Description
Override enable for each control in usbphy_direct
Table 416.
USBPHY_DIRECT_OVERRIDE Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:16 | Reserved. | - | - |
| 15 | TX_DIFFMODE_OVERRIDE_EN | RW | 0x0 |
| 14:13 | Reserved. | - | - |
| 12 | DM_PULLUP_OVERRIDE_EN | RW | 0x0 |
| 11 | TX_FSSLEW_OVERRIDE_EN | RW | 0x0 |
| 10 | TX_PD_OVERRIDE_EN | RW | 0x0 |
| 9 | RX_PD_OVERRIDE_EN | RW | 0x0 |
| 8 | TX_DM_OVERRIDE_EN | RW | 0x0 |
| 7 | TX_DP_OVERRIDE_EN | RW | 0x0 |
| 6 | TX_DM_OE_OVERRIDE_EN | RW | 0x0 |
| 5 | TX_DP_OE_OVERRIDE_EN | RW | 0x0 |
| 4 | DM_PULLDN_EN_OVERRIDE_EN | RW | 0x0 |
| 3 | DP_PULLDN_EN_OVERRIDE_EN | RW | 0x0 |
| 2 | DP_PULLUP_EN_OVERRIDE_EN | RW | 0x0 |
| 1 | DM_PULLUP_HISEL_OVERRIDE_EN | RW | 0x0 |
| 0 | DP_PULLUP_HISEL_OVERRIDE_EN | RW | 0x0 |
USB: USBPHY_TRIM Register
Offset: 0x84
Description
Used to adjust trim values of USB phy pull down resistors.
Table 417.
USBPHY_TRIM
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:13 | Reserved. | - | - |
| 12:8 | DM_PULLDN_TRIM
: Value to drive to USB PHY DM pulldown resistor trim control Experimental data suggests that the reset value will work, but this register allows adjustment if required | RW | 0x1f |
| 7:5 | Reserved. | - | - |
| 4:0 | DP_PULLDN_TRIM
: Value to drive to USB PHY DP pulldown resistor trim control Experimental data suggests that the reset value will work, but this register allows adjustment if required | RW | 0x1f |
USB: INTR Register
Offset: 0x8c
Description
Raw Interrupts
Table 418. INTR
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:20 | Reserved. | - | - |
| 19 | EP_STALL_NAK : Raised when any bit in EP_STATUS_STALL_NAK is set. Clear by clearing all bits in EP_STATUS_STALL_NAK. | RO | 0x0 |
| 18 | ABORT_DONE : Raised when any bit in ABORT_DONE is set. Clear by clearing all bits in ABORT_DONE. | RO | 0x0 |
| 17 | DEV_SOF : Set every time the device receives a SOF (Start of Frame) packet. Cleared by reading SOF_RD | RO | 0x0 |
| 16 | SETUP_REQ : Device. Source: SIE_STATUS.SETUP_REC | RO | 0x0 |
| 15 | DEV_RESUME_FROM_HOST : Set when the device receives a resume from the host. Cleared by writing to SIE_STATUS.RESUME | RO | 0x0 |
| 14 | DEV_SUSPEND : Set when the device suspend state changes. Cleared by writing to SIE_STATUS.SUSPENDED | RO | 0x0 |
| 13 | DEV_CONN_DIS : Set when the device connection state changes. Cleared by writing to SIE_STATUS.CONNECTED | RO | 0x0 |
| 12 | BUS_RESET : Source: SIE_STATUS.BUS_RESET | RO | 0x0 |
| 11 | VBUS_DETECT : Source: SIE_STATUS.VBUS_DETECTED | RO | 0x0 |
| 10 | STALL : Source: SIE_STATUS.STALL_REC | RO | 0x0 |
| 9 | ERROR_CRC : Source: SIE_STATUS.CRC_ERROR | RO | 0x0 |
| 8 | ERROR_BIT_STUFF : Source: SIE_STATUS.BIT_STUFF_ERROR | RO | 0x0 |
| 7 | ERROR_RX_OVERFLOW : Source: SIE_STATUS.RX_OVERFLOW | RO | 0x0 |
| 6 | ERROR_RX_TIMEOUT : Source: SIE_STATUS.RX_TIMEOUT | RO | 0x0 |
| 5 | ERROR_DATA_SEQ : Source: SIE_STATUS.DATA_SEQ_ERROR | RO | 0x0 |
| 4 | BUFF_STATUS : Raised when any bit in BUFF_STATUS is set. Clear by clearing all bits in BUFF_STATUS. | RO | 0x0 |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 3 | TRANS_COMPLETE : Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear by writing to this bit. | RO | 0x0 |
| 2 | HOST_SOF : Host: raised every time the host sends a SOF (Start of Frame). Cleared by reading SOF_RD | RO | 0x0 |
| 1 | HOST_RESUME : Host: raised when a device wakes up the host. Cleared by writing to SIE_STATUS.RESUME | RO | 0x0 |
| 0 | HOST_CONN_DIS : Host: raised when a device is connected or disconnected (i.e. when SIE_STATUS.SPEED changes). Cleared by writing to SIE_STATUS.SPEED | RO | 0x0 |
USB: INTE Register
Offset: 0x90
Description
Interrupt Enable
Table 419. INTE Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:20 | Reserved. | - | - |
| 19 | EP_STALL_NAK : Raised when any bit in EP_STATUS_STALL_NAK is set. Clear by clearing all bits in EP_STATUS_STALL_NAK. | RW | 0x0 |
| 18 | ABORT_DONE : Raised when any bit in ABORT_DONE is set. Clear by clearing all bits in ABORT_DONE. | RW | 0x0 |
| 17 | DEV_SOF : Set every time the device receives a SOF (Start of Frame) packet. Cleared by reading SOF_RD | RW | 0x0 |
| 16 | SETUP_REQ : Device. Source: SIE_STATUS.SETUP_REC | RW | 0x0 |
| 15 | DEV_RESUME_FROM_HOST : Set when the device receives a resume from the host. Cleared by writing to SIE_STATUS.RESUME | RW | 0x0 |
| 14 | DEV_SUSPEND : Set when the device suspend state changes. Cleared by writing to SIE_STATUS.SUSPENDED | RW | 0x0 |
| 13 | DEV_CONN_DIS : Set when the device connection state changes. Cleared by writing to SIE_STATUS.CONNECTED | RW | 0x0 |
| 12 | BUS_RESET : Source: SIE_STATUS.BUS_RESET | RW | 0x0 |
| 11 | VBUS_DETECT : Source: SIE_STATUS.VBUS_DETECTED | RW | 0x0 |
| 10 | STALL : Source: SIE_STATUS.STALL_REC | RW | 0x0 |
| 9 | ERROR_CRC : Source: SIE_STATUS.CRC_ERROR | RW | 0x0 |
| 8 | ERROR_BIT_STUFF : Source: SIE_STATUS.BIT_STUFF_ERROR | RW | 0x0 |
| 7 | ERROR_RX_OVERFLOW : Source: SIE_STATUS.RX_OVERFLOW | RW | 0x0 |
| 6 | ERROR_RX_TIMEOUT : Source: SIE_STATUS.RX_TIMEOUT | RW | 0x0 |
| 5 | ERROR_DATA_SEQ : Source: SIE_STATUS.DATA_SEQ_ERROR | RW | 0x0 |
| 4 | BUFF_STATUS : Raised when any bit in BUFF_STATUS is set. Clear by clearing all bits in BUFF_STATUS. | RW | 0x0 |
| 3 | TRANS_COMPLETE : Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear by writing to this bit. | RW | 0x0 |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 2 | HOST_SOF : Host: raised every time the host sends a SOF (Start of Frame). Cleared by reading SOF_RD | RW | 0x0 |
| 1 | HOST_RESUME : Host: raised when a device wakes up the host. Cleared by writing to SIE_STATUS.RESUME | RW | 0x0 |
| 0 | HOST_CONN_DIS : Host: raised when a device is connected or disconnected (i.e. when SIE_STATUS.SPEED changes). Cleared by writing to SIE_STATUS.SPEED | RW | 0x0 |
USB: INTF Register
Offset: 0x94
Description
Interrupt Force
Table 420. INTF Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:20 | Reserved. | - | - |
| 19 | EP_STALL_NAK : Raised when any bit in EP_STATUS_STALL_NAK is set. Clear by clearing all bits in EP_STATUS_STALL_NAK. | RW | 0x0 |
| 18 | ABORT_DONE : Raised when any bit in ABORT_DONE is set. Clear by clearing all bits in ABORT_DONE. | RW | 0x0 |
| 17 | DEV_SOF : Set every time the device receives a SOF (Start of Frame) packet. Cleared by reading SOF_RD | RW | 0x0 |
| 16 | SETUP_REQ : Device. Source: SIE_STATUS.SETUP_REC | RW | 0x0 |
| 15 | DEV_RESUME_FROM_HOST : Set when the device receives a resume from the host. Cleared by writing to SIE_STATUS.RESUME | RW | 0x0 |
| 14 | DEV_SUSPEND : Set when the device suspend state changes. Cleared by writing to SIE_STATUS.SUSPENDED | RW | 0x0 |
| 13 | DEV_CONN_DIS : Set when the device connection state changes. Cleared by writing to SIE_STATUS.CONNECTED | RW | 0x0 |
| 12 | BUS_RESET : Source: SIE_STATUS.BUS_RESET | RW | 0x0 |
| 11 | VBUS_DETECT : Source: SIE_STATUS.VBUS_DETECTED | RW | 0x0 |
| 10 | STALL : Source: SIE_STATUS.STALL_REC | RW | 0x0 |
| 9 | ERROR_CRC : Source: SIE_STATUS.CRC_ERROR | RW | 0x0 |
| 8 | ERROR_BIT_STUFF : Source: SIE_STATUS.BIT_STUFF_ERROR | RW | 0x0 |
| 7 | ERROR_RX_OVERFLOW : Source: SIE_STATUS.RX_OVERFLOW | RW | 0x0 |
| 6 | ERROR_RX_TIMEOUT : Source: SIE_STATUS.RX_TIMEOUT | RW | 0x0 |
| 5 | ERROR_DATA_SEQ : Source: SIE_STATUS.DATA_SEQ_ERROR | RW | 0x0 |
| 4 | BUFF_STATUS : Raised when any bit in BUFF_STATUS is set. Clear by clearing all bits in BUFF_STATUS. | RW | 0x0 |
| 3 | TRANS_COMPLETE : Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear by writing to this bit. | RW | 0x0 |
| 2 | HOST_SOF : Host: raised every time the host sends a SOF (Start of Frame). Cleared by reading SOF_RD | RW | 0x0 |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 1 | HOST_RESUME : Host: raised when a device wakes up the host. Cleared by writing to SIE_STATUS.RESUME | RW | 0x0 |
| 0 | HOST_CONN_DIS : Host: raised when a device is connected or disconnected (i.e. when SIE_STATUS.SPEED changes). Cleared by writing to SIE_STATUS.SPEED | RW | 0x0 |
USB: INTS Register
Offset: 0x98
Description
Interrupt status after masking & forcing
Table 421. INTS Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:20 | Reserved. | - | - |
| 19 | EP_STALL_NAK : Raised when any bit in EP_STATUS_STALL_NAK is set. Clear by clearing all bits in EP_STATUS_STALL_NAK. | RO | 0x0 |
| 18 | ABORT_DONE : Raised when any bit in ABORT_DONE is set. Clear by clearing all bits in ABORT_DONE. | RO | 0x0 |
| 17 | DEV_SOF : Set every time the device receives a SOF (Start of Frame) packet. Cleared by reading SOF_RD | RO | 0x0 |
| 16 | SETUP_REQ : Device. Source: SIE_STATUS.SETUP_REC | RO | 0x0 |
| 15 | DEV_RESUME_FROM_HOST : Set when the device receives a resume from the host. Cleared by writing to SIE_STATUS.RESUME | RO | 0x0 |
| 14 | DEV_SUSPEND : Set when the device suspend state changes. Cleared by writing to SIE_STATUS.SUSPENDED | RO | 0x0 |
| 13 | DEV_CONN_DIS : Set when the device connection state changes. Cleared by writing to SIE_STATUS.CONNECTED | RO | 0x0 |
| 12 | BUS_RESET : Source: SIE_STATUS.BUS_RESET | RO | 0x0 |
| 11 | VBUS_DETECT : Source: SIE_STATUS.VBUS_DETECTED | RO | 0x0 |
| 10 | STALL : Source: SIE_STATUS.STALL_REC | RO | 0x0 |
| 9 | ERROR_CRC : Source: SIE_STATUS.CRC_ERROR | RO | 0x0 |
| 8 | ERROR_BIT_STUFF : Source: SIE_STATUS.BIT_STUFF_ERROR | RO | 0x0 |
| 7 | ERROR_RX_OVERFLOW : Source: SIE_STATUS.RX_OVERFLOW | RO | 0x0 |
| 6 | ERROR_RX_TIMEOUT : Source: SIE_STATUS.RX_TIMEOUT | RO | 0x0 |
| 5 | ERROR_DATA_SEQ : Source: SIE_STATUS.DATA_SEQ_ERROR | RO | 0x0 |
| 4 | BUFF_STATUS : Raised when any bit in BUFF_STATUS is set. Clear by clearing all bits in BUFF_STATUS. | RO | 0x0 |
| 3 | TRANS_COMPLETE : Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear by writing to this bit. | RO | 0x0 |
| 2 | HOST_SOF : Host: raised every time the host sends a SOF (Start of Frame). Cleared by reading SOF_RD | RO | 0x0 |
| 1 | HOST_RESUME : Host: raised when a device wakes up the host. Cleared by writing to SIE_STATUS.RESUME | RO | 0x0 |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 0 | HOST_CONN_DIS : Host: raised when a device is connected or disconnected (i.e. when SIE_STATUS.SPEED changes). Cleared by writing to SIE_STATUS.SPEED | RO | 0x0 |
References
- ▪ [1] USB Made Simple
- ▪ [2] USB 2.0 Specification