28 USB on-the-go full-speed (OTG_FS)
Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers ที่ the Flash memory density ย่านระหว่าง 16 and 32 Kbytes.
Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers ที่ the Flash memory density ย่านระหว่าง 64 and 128 Kbytes.
High-density devices are STM32F101xx and STM32F103xx microcontrollers ที่ the
Flash memory density ย่านระหว่าง 256 and 512 Kbytes.
XL-density devices are STM32F101xx and STM32F103xx microcontrollers ที่ the
Flash memory density ย่านระหว่าง 768 Kbytes and 1 Mbyte.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
ส่วนนี้ประยุกต์ใช้กับ STM32F105xx and STM32F107xx connectivity line devices เท่านั้น.
28.1 OTG_FS introduction
ลิขสิทธิ์บางส่วน (c) 2004, 2005 Synopsys, Inc. สงวนลิขสิทธิ์ ใช้โดยได้รับอนุญาต
ส่วนนี้นำเสนอ the architecture และ the programming model ของ the OTG_FS controller.
คำย่อต่อไปนี้ถูกใช้ไปตลอด section นี้:
FS Full-speed
LS Low-speed
MAC Media access controller
OTG On-the-go
PFC Packet FIFO controller
PHY Physical layer
USB Universal serial bus
UTMI USB 2.0 transceiver macrocell interface (UTMI)
การอ้างอิงถูกทำถึงเอกสารต่อไปนี้:
• USB On-The-Go Supplement, Revision 1.3
• Universal Serial Bus Revision 2.0 Specification
The OTG_FS เป็น a dual-role device (DRD) controller ที่รองรับทั้ง device and host functions และตรงตามอย่างสมบูรณ์กับ the On-The-Go Supplement to the USB 2.0 Specification. มันสามารถถูกกำหนดค่าเป็น a host-only or device-only controller, ตรงตามอย่างสมบูรณ์กับ the USB 2.0 Specification. ใน host mode, the OTG_FS รองรับ full-speed (FS, 12 Mbits/s) และ low-speed (LS, 1.5 Mbits/s) transfers ในขณะที่ใน device mode, มันรองรับเฉพาะ full-speed (FS, 12 Mbits/s) transfers. The OTG_FS รองรับทั้ง HNP and SRP. อุปกรณ์ภายนอกที่จำเป็นต้องมีเท่านั้นคือ a charge pump สำหรับ VBUS ใน host mode.
28.2 OTG_FS main features
The main features สามารถถูกแบ่งลงในสามประเภท: general, host-mode and device-mode features.
28.2.1 General features
The OTG_FS interface general features เป็นดังต่อไปนี้:
• มันคือ USB-IF ได้รับการรับรองตาม the Universal Serial Bus Specification Rev 2.0
• มันรวมการรับรองอย่างเต็มรูปแบบ (PHY) สำหรับ the optional On-The-Go (OTG) protocol รายละเอียดใน the On-The-Go
Supplement Rev 1.3 specification
– การรองรับแบบองค์รวมสำหรับ A-B Device Identification (ID line)
– การรองรับแบบองค์รวมสำหรับ host Negotiation Protocol (HNP) and Session Request Protocol (SRP)
– มันยอมให้ host ปิด VBUS เพื่อประหยัด battery power ใน OTG applications
– มันรองรับ OTG ตรวจสอบดู VBUS levels ด้วย internal comparators
– มันรองรับ dynamic host-peripheral switch ของหน้าที่
• มันสามารถกำหนดค่าทางซอฟแวร์เพื่อให้ทำงานเป็น:
– SRP มีความสามารถ USB FS Peripheral (B-device)
– SRP มีความสามารถ USB FS/LS host (A-device)
– USB On-The-Go Full-Speed Dual Role device
• รองรับ FS SOF and LS Keep-alives ด้วยth
– SOF pulse PAD connectivity (OTG_FS_SOF)
– SOF pulse internal connection to timer2 (TIM2)
– Configurable framing period
– Configurable end of frame interrupt
• มันรวม power saving features ไว้อย่างเช่น system stop ในระหว่าง USB Suspend, ปิด clock domains internal ไปยัง the
digital core, PHY and DFIFO power management
• มันมีคุณลักษณะ RAM เฉพาะ 1.25 Kbytes พร้อมการควบคุม FIFO ขั้นสูง:
– สามารถกำหนดค่าการแบ่งพาร์ติชั่นของ RAM space ลงใน FIFOs ต่างๆเพื่อความยืดหยุ่นและประสิทธิภาพของการใช้ RAM
– แต่ละ FIFO สามารถถือหลาย packets
– Dynamic memory allocation
– สามารถกำหนดค่า FIFO sizes ที่ไม่เป็นกำลัง 2 เพื่อยอมให้ใช้ contiguous memory locations
• มันรับประกัน max USB bandwidth สำหรับสูงถึง one frame (1ms) โดยปราศจาก system intervention
28.2.2 Host-mode features
The OTG_FS interface main features และ requirements ใน host-mode มีดังต่อไปนี้:
• External charge pump สำหรับ VBUS voltage generation.
• สูงถึง 8 host channels (pipes): แต่ละ channel สามารถกำหนดค่าใหม่ได้แบบไดนามิกเพื่อจัดสรรชนิดใดๆของ USB transfer.
• Built-in hardware scheduler holding:
– สูงถึง 8 interrupt พร้อม isochronous transfer ร้องขอใน the periodic hardware queue
– สูงถึง 8 control พร้อม bulk transfer ร้องขอใน the non-periodic hardware queue
• การจัดการของ a shared RX FIFO, a periodic TX FIFO and a nonperiodic TX FIFO สำหรับการใช้งานอย่างมีประสิทธิ์ภาพของ
the USB data RAM.
28.2.3 Peripheral-mode features
The OTG_FS interface main features ใน peripheral-mode มีดังต่อไปนี้:
• 1 bidirectional control endpoint0
• 3 IN endpoints (EPs) สามารถกำหนดค่าได้เพื่อรองรับ Bulk, Interrupt หรือ Isochronous transfers
• 3 OUT endpoints สามารถกำหนดค่าได้เพื่อรองรับ Bulk, Interrupt หรือ Isochronous transfers
• การจัดการของ a shared Rx FIFO and a Tx-OUT FIFO สำหรับการใช้งานอย่างมีประสิทธิ์ภาพของ the USB data RAM
• การจัดการของสูงถึง 4 dedicated Tx-IN FIFOs (หนึ่งสำหรับแต่ละ active IN EP) เพื่อใส่โหลดน้อยลงบน the application
• รองรับสำหรับ the soft disconnect feature.
28.3 OTG_FS functional description
(https://i.imgur.com/wmeT4Gv.png)
28.3.1 OTG pins
(https://i.imgur.com/O84wnWm.png)
28.3.2 OTG full-speed core
The USB OTG FS รับ the 48 MHz ±0.25% clock จาก the reset and clock controller(RCC), โดยทาง an external quartz. The USB clock ถูกใช้สำหรับการขับ the 48 MHz domain ที่ full-speed(12 Mbit/s) และต้องถูกเปิดใช้งานก่อนการกำหนดค่า the OTG FS core.
The CPU อ่านและเขียนจาก/ถึง the OTG FS core registers ผ่านทาง the AHB peripheral bus. มันถูกแจ้ง USB events ผ่านทาง the single USB OTG interrupt line ที่อธิบายใน Section 28.15: OTG_FS interrupts.
The CPU ส่ง data ผ่าน the USB โดยการเขียน 32-bit words ไปยัง dedicated OTG_FS locations (push registers). The data ดังนั้นถูกเก็บโดยอัตโนมัติลงใน Tx-data FIFOs ที่กำหนดค่าไว้ภายใน the USB data RAM. มี one Tx-FIFO push register สำหรับแต่ละ in-endpoint (peripheral mode) หรือ out-channel (host mode).
The CPU รับ the data จาก the USB โดยการอ่าน 32-bit words จาก dedicated OTG_FS addresses (pop registers). The data ดังนั้นถูกดึงโดยอัตโนมัติจาก a shared Rx-FIFO ที่กำหนดค่าไว้ภายใน the 1.25 KB USB data RAM. มี one Rx-FIFO pop register สำหรับแต่ละ out-endpoint หรือ in-channel.
The USB protocol layer ถูกขับโดย the serial interface engine (SIE) และทำให้เป็นอนุกรมผ่าน the USB โดย the full-/low-speed transceiver module ภายใน the on-chip physical layer (PHY).
28.3.3 Full-speed OTG PHY
The embedded full-speed OTG PHY ถูกควบคุมโดย the OTG FS core และถ่ายทอด USB control & data signals ผ่าน the full-speed subset of the UTMI+ Bus (UTMIFS). มันจัดให้มี the physical รองรับต่อ USB connectivity
The full-speed OTG PHY รวมส่วนประกอบต่อไปนี้:
• FS/LS transceiver module ที่ใช้โดยทั้ง host and device. มันขับ transmission and reception โดยตรงบน the single-
ended USB lines.
• integrated ID pull-up resistor ที่ใช้เพื่อสุ่ม the ID line สำหรับ A/B device identification.
• DP/DM integrated pull-up and pull-down resistors ที่ควบคุมโดย the OTG_FS core ขึ้นอยู่กับบทบาทปัจจุบันของ the
device. เป็น a peripheral, มันเปิดใช้งาน the DP pull-up resistor เพื่อส่งสัญญาณ full-speed peripheral connections ทันที
ที่ VBUS ได้รับสัญญานว่าอยู่ที่ a valid level (B-session valid). ใน host mode, pull-down resistors ถูกเปิดใช้งานบนทั้ง
DP/DM. Pull-up and pull-down resistors ถูกสลับแบบไดนามิกค์เมื่อ the device's role ถูกเปลี่ยนโดยทาง the host
negotiation protocol (HNP).
• Pull-up/pull-down resistor ECN circuit. The DP pull-up ประกอบด้วย 2 resistors ที่ควบคุมแยกกันจาก the OTG_FS ตาม
the resistor Engineering Change Notice ที่ใช้กับ USB Rev2.0. การตัดแต่งแบบไดนามิกของ the DP pull-up strength ยอม
เพื่อ better noise rejection และ Tx/Rx signal quality.
• VBUS sensing comparators ที่มี hysteresis ที่ใช้เพื่อตรวจหา VBUS Valid, A-B Session Valid และ session-end voltage
thresholds(ขอบเขต(บน-ล่าง)). พวกมันถูกใช้เพื่อขับ the session request protocol (SRP), ตรวจหา valid startup และ end-
of-session conditions, มอนิเตอร์ the VBUS supply อย่างคงที่ในระหว่าง USB operations.
• VBUS pulsing method circuit ที่ใช้เพื่อ charge/discharge VBUS ผ่าน resistors ในระหว่าง the SRP (weak drive).
28.4 OTG dual role device (DRD)
(https://i.imgur.com/7nPQuNY.png)
28.4.1 ID line detection
The host หรือ peripheral (ค่าเริ่มต้น) role ถูกถือว่าขึ้นอยู่กับ the ID input pin (OTG_FS_ID). The ID line status ถูกกำหนดเมื่อเสียบ the USB, ขึ้นอยู่กับว่า
ข้างไหนของ the USB cable ถูกเชื่อมต่อกับ the micro-AB receptacle.
• ถ้า the B-side of the USB cable ถูกต่อกับ a floating ID wire, the integrated pull-up resistor ตรวจพบ a high ID level
และ the default Peripheral role ถูกยืนยัน. ในการกำหนดค่านี้ the OTG_FS สอดคล้องกับ the standard FSM ที่อธิบายโดย
section 6.8.2: On-The-Go B-device of the On-The-Go Specification Rev1.3 เสริมสำหรับ the USB2.0.
• ถ้า the A-side of the USB cable ถูกต่อกับ a grounded ID, the OTG_FS ปล่อยออก an ID line status เปลี่ยน interrupt
(CIDSCHG bit in OTG_FS_GINTSTS) สำหรับ host software initialization, และสลับโดยอัตโนมัติไปยัง the host role. ใน
การกำหนดค่านี้ the OTG_FS สอดคล้องกับ the standard FSM ที่อธิบายโดย section 6.8.1: On-The-Go Adevice of the On-
The-Go Specification Rev1.3 เสริมสำหรับ the USB2.0.
28.4.2 HNP dual role device
The HNP capable bit ใน the Global USB configuration register (HNPCAP bit ใน OTG_FS_GUSBCFG) เปิดใช้งาน the OTG_FS core เพื่อเปลี่ยนแบบไดนามิกค์บทบาทของมันจาก A-host ไปเป็น A-peripheral และในทางกลับกัน, หรือจาก B-Peripheral ไปเป็น B-host และในทางกลับกันตรงตาม the host negotiation protocol (HNP). The current device status สามารถถูกอ่านโดยค่าที่รวมกันของ the Connector ID Status bit ใน the Global OTG control and status register (CIDSTS bit ใน OTG_FS_GOTGCTL) และ the current mode of operation bit ใน the global interrupt and status register (CMOD bit in OTG_FS_GINTSTS).
The HNP program model ถูกอธิบายอย่างละเอียดใน Section 28.17.
28.4.3 SRP dual role device
The SRP capable bit ใน the global USB configuration register (SRPCAP bit ใน OTG_FS_GUSBCFG) เปิดใช้งาน the OTG_FS core เพื่อปิดการสร้าง VBUS สำหรับ the A-device เพื่อประหยัดพลังงาน. โปรดทราบว่า the A-device มีหน้าที่ในการขับ VBUS เสมอโดยไม่คำนึงถึง the host or peripheral role of the OTG_FS.
the SRP A/B-device program model ถูกอธิบายอย่างละเอียดใน Section 28.17.
28.5 USB peripheral
section นี้ให้ the functional description of the OTG_FS ใน the USB peripheral mode. The OTG_FS ทำงานเป็น an USB peripheral ในสถานการณ์ต่อไปนี้:
• OTG B-Peripheral
– OTG B-device default state ถ้า B-side of USB cable ถูกเสียบ
• OTG A-Peripheral
– OTG A-device state หลังจาก the HNP สลับ the OTG_FS ไปเป็น peripheral role ของมัน
• B-device
– ถ้า the ID line ปรากฎ, หน้าที่และต่อถึง the B-side of the USB cable, และ the HNP-capable bit in the Global USB
Configuration register (HNPCAP bit in OTG_FS_GUSBCFG) จะถูกเคลียร์ (ดู On-The-Go Rev1.3 par. 6.8.3).
• Peripheral only (ดู Figure 305)
– The force device mode bit ใน the Global USB configuration register (FDMOD in OTG_FS_GUSBCFG) ถูกเซ็ตเป็น
1, บังคับ the OTG_FS core ให้ทำงานเป็น a USB peripheral-only (ดู On-The-Go Rev1.3 par. 6.8.3). ในกรณีนี้, the ID
line จะถูกเพิกเฉยแม้ว่าปรากฎบน the USB connector.
Note: ในการสร้าง a bus-powered device implementation ในกรณีของ the B-device or peripheral-only configuration, an
external regulator ต้องถูกเพิ่มเพื่อสร้าง the VDD chip-supply จาก VBUS.
(https://i.imgur.com/ySyZHNR.png)
28.5.1 SRP-capable peripheral
The SRP capable bit ใน the Global USB configuration register (SRPCAP bit ใน OTG_FS_GUSBCFG) เปิดใช้งาน the OTG_FS เพื่อรองรับ the session request protocol (SRP). ในวิธีนี้, มันยอมให้ the remote A-device ประหยัดพลังงานโดยการปิด VBUS ในขณะที่ the USB session ถูกแขวน.
The SRP peripheral mode program model ถูกอธิบายอย่างละเอียดใน the B-device session request protocol section.
28.5.2 Peripheral states
Powered state
The VBUS input ตรวจพบ the B-Session valid voltage โดยที่ the USB peripheral ถูกอนุญาตให้เข้าสู่ the powered state (see USB2.0 par9.1). จากนั้น The OTG_FS จะเชื่อมต่อโดยอัตโนมัติ the DP pull-up resistor เพื่อให้สัญญาน full-speed device connection ไปยัง the host และสร้าง the session request interrupt (SRQINT bit ใน OTG_FS_GINTSTS) เพื่อแจ้งให้ทราบ the powered state.
The VBUS input ยังช่วยให้แน่ใจว่า valid VBUS levels ถูกจ่ายไฟโดย the host ในระหว่าง USB operations. ถ้าการลดลงของ VBUS ต่ำกว่า B-session valid ที่เกิดขึ้นถูกตรวจพบ (ตัวอย่างเช่นเนื่องจาก a power disturbance หรือ the host port ถูก switched off), the OTG_FS จะตัดการเชื่อมต่อโดยอัตโนมัติและ the session end detected (SEDET bit ใน OTG_FS_GOTGINT) interrupt จะถูกสร้างเพื่อแจ้งให้ทราบว่า the OTG_FS ได้ออกจาก the powered state แล้ว.
ใน the powered state, the OTG_FS คาดว่าจะได้รับ some reset signaling จาก the host. ไม่มี other USB operation สามารถเป็นได้. เมื่อ a reset signaling ถูกรับ the reset detected interrupt (USBRST in OTG_FS_GINTSTS) จะถูกสร้าง. เมื่อ the reset signaling เสร็จสมบูรณ์, the enumeration done interrupt (ENUMDNE bit in OTG_FS_GINTSTS) จะถูกสร้างและ the OTG_FS เข้าสู่ the Default state.
Soft disconnect
The powered state สามารถถูกออกโดย software ด้วย the soft disconnect feature. The DP pullup resistor จะถูกเอาออกโดยการเซ็ต the soft disconnect bit ใน the device control register (SDIS bit ใน OTG_FS_DCTL), เป็นเหตุให้ a device disconnect detection interrupt บน the host side ถึงแม้ว่า the USB cable ไม่ได้ถูกถอดออกจาก the host port จริงๆ.
Default state
ใน the Default state the OTG_FS คาดว่าจะได้รับ a SET_ADDRESS command จาก the host. ไม่มี other USB operation สามารถเป็นไปได้. เมื่อ a valid SET_ADDRESS command ถูกถอดระหัสบน the USB, the application เขียน the corresponding number ลงใน the device address field ใน the device configuration register (DAD bit in OTG_FS_DCFG). จากนั้น The OTG_FS เข้าสู่ the address state และพร้อมที่จะตอบรับ host transactions ที่ theconfigured USB address.
Suspended state
The OTG_FS peripheral ตรวจสอบกิจกรรม USB อย่างต่อเนื่อง. หลังจากการนับ 3 ms of USB idleness, the early suspend interrupt (ESUSP bit ใน OTG_FS_GINTSTS) จะถูกปล่อยออก, และยืนยัน 3 ms ต่อมา, ถ้าเหมาะสม, โดย the suspend interrupt (USBSUSP bit ใน OTG_FS_GINTSTS). จากนั้น The device suspend bit จะถูกเซ็ตโดยอัตโนมัติใน the device status register (SUSPSTS bit in OTG_FS_DSTS) และ the OTG_FS เข้าสู่ the suspended state.
The suspended state อาจมีทางเลือกถูกออกโดย the device ตัวมันเอง. ในกรณีนี้ the application เซ็ต the remote wakeup signaling bit ใน the device control register (RWUSIG bit ใน OTG_FS_DCTL) และเคลียร์มันหลังจาก 1 ถึง 15 ms.
เมื่อ a resume signaling ถูกตรวจพบจาก the host, the resume interrupt (WKUPINT bit ใน OTG_FS_GINTSTS) จะถูกสร้างและ the device suspend bit จะถูกเคลียร์โดยอัตโนมัติ.