快要被 Eclipse 搞瘋掉之前, 找到了解決方法, 但是應該不算正解, 不過先記下來, 可以用先.
加入 static library ( .a)
要加入 libcyu3mipicsi.a, 先把它複製到相對應的 debug/release 目錄下, 然後在 project property 的 C/C++ General 下面的 Paths and Symbols 的 Libraies 的地方, 加入去掉前面 lib, 後面 .a 的 cyu3mipicsi, 就可以了
| Offset | Field | Size | Value | Description | |
| 0 | bLength | 1 | Number | Size of Descriptor in bytes | 0x09 |
| 1 | bDescriptorType | 1 | Constant | Interface Association Descriptor | 0x0B |
| 2 | bFirstInterface | 1 | Number | Interface number of the first interface that is associated with this function | |
| 3 | bInterfaceCount | 1 | Number | Number of contiguous interfaces that at associated with this function | |
| 4 | bFunctionClass | 1 | Class | Class Code (assigned by USB-IF) | |
| 5 | bFunctionSubClass | 1 | SubClass | Sub Class Code (asigned by USB-IF) | |
| 6 | bFunctionProtocol | 1 | Protocol | Protocol Code (assigned by USB-IF) | |
| 7 | iFunction | 1 | Index | Index of string descriptor describing this function |
| Offset | Field | Size | Value | Description | |
| 0 | bLength | 1 | Number | Size of Descriptor in bytes | 0x05 |
| 1 | bDescriptorType | 1 | Constant | BOS Descriptor | 0x0F |
| 2 | wTotalLength | 2 | Number | The number of bytes in this descriptor and all of its subordinate descriptors | include all sub desceiptors |
| 4 | bNumDeviceCaps | 1 | Number | The number of device capability descriptors subordinate to this BOS descriptor. |
| Offset | Field | Size | Value | Description | |
| 0 | bLength | 1 | Number | Size of Descriptor in bytes | |
| 1 | bDescriptorType | 1 | Constant | DevCapability Descriptor | 0x10 |
| 2 | bDevCapabilityType | 1 | Number | Device Capability Type | |
| 3 | Capability-Dependent | Var | Variable | Capability-specific data and format |
| Capability Code | Value | Descriptor |
| Wireless_USB | 01H | Defines the set of Wireless USB-specific device level capabilities |
| USB 2.0 Extension | 02H | USB 2.0 Extension Descriptor |
| SUPERSPEED_USB | 03H | Defines the set of SuperSpeed USB specific device level capabilities |
| CONTAINER_ID | 04H | Defines the instance unique ID used to identify the instance across all operating modes |
| PLATFORM | 05H | Defines a device capability specific to a particular platform/operating system |
| POWER_DELIVERY_CAPABILITY | 06H | Defines the various PD Capabilities of this device |
| BATTERY_INFO_CAPABILITY | 07H | Provides information on each battery supported by the device |
| PD_CONSUMER_PORT_CAPABILITY | 08H | The consumer characteristics of a port on the device |
| PD_PROVIDER_PORT_CAPABILITY | 09H | The provider characteristics of a port on the device |
| SUPERSPEED_PLUS | 0AH | Defines the set of SuperSpeed Plus USB specific device level capabilities |
| PRECISION_TIME_MEASUREMENT | 0BH | Precision Time Measurement (PTM) Capability Descriptor |
| Wireless_USB_Ext | 0CH | Defines the set of Wireless USB 1.1-specific device level capabilities |
| Reserved | 00H, 0DH~FFH | Reserved for future use |
Offset | Field | Size | Value | Description | Note |
0 | bLength | 1 | Number | size of the descriptor in bytes | 0x12 |
1 | bDescriptorType | 1 | Constant | DeviceDescriptor (0x01) | 0x01 |
2 | bcdUSB | 2 | BCD | USB Sepcification Number | USB 3.0 0x00, 0x03USB 2.1 0x10, 0x02 |
4 | bDeviceClass | 1 | Class | Class Code: 0x00: each interface specifies it’s own claas code 0xFF: the class code is vendor specified Otherwise: | 0xEF Miscellaneous |
5 | bDeviceSubClass | 1 | SubClass | Assigned by USB ORG | 0x02 |
6 | bDeviceProtocol | 1 | Protocol | Assigned by USB ORG | 0x01 |
7 | bMaxPacketSize | 1 | Number | Maximum Packet Size for Endpoint 0 | 8/16/32/64 |
8 | idVendor | 2 | ID | Assigned by USB ORG | |
10 | idProduct | 2 | ID | Assigned by Manufacturer | |
12 | bcdDevice | 2 | BCD | Device Release Number | |
14 | iManufacturer | 1 | Index | Index of Manufacturer String Descriptor | |
15 | iProduct | 1 | Index | Index of Product String Descriptor | |
16 | iSerialNumber | 1 | Index | Index of Serial Number String Descriptor | |
17 | bNumConfigurations | 1 | Integer | Number of Possible Configurations |
| Offset | Field | Size | Value | Description | |
| 0 | bLength | 1 | Number | Size of Descriptor in bytes | 0x09 |
| 1 | bDescriptorType | 1 | Constant | Configuration Descriptor | 0x02 |
| 2 | wTotalLength | 2 | Number | Total Length of Data returned | include all sub desceiptors |
| 4 | bNumInterfaces | 1 | Number | Number of Interfaces | number of interface in this configuration |
| 5 | bConfigurationValue | 1 | Number | Value to use as an argument to select this configuration | Configuration value to be selected |
| 6 | iConfiguration | 1 | Index | Index of String Descriptor Describing this configuration | |
| 7 | bmAttributes | 1 | Bitmap | D7: Bus Powered D6: Self Powered D5: Remote Wakeup D4..D0 reserved (0) | |
| 8 | bMaxPower | 1 | mA | Maximum Power Consumption |
| Offset | Field | Size | Value | Description | |
| 0 | bLength | 1 | Number | Size of Descriptor in bytes | 0x09 |
| 1 | bDescriptorType | 1 | Constant | Interface Descriptor | 0x04 |
| 2 | bInterefaceNumber | 1 | Number | Number of Interface | zero based interface descriptor |
| 3 | bAlternateSetting | 1 | Number | Value used to select alternative setting | 0: Not alternative 1: alternative |
| 4 | bNumEndpoints | 1 | Number | Number of Endpoints used for this interface | |
| 5 | bInterfaceClass | 1 | Class | Assigned by USB ORG | |
| 6 | bInterfaceSubClass | 1 | SubClass | Assigned by USB ORG | |
| 7 | bInterfaceProtocol | 1 | Protocol | Protocol Code | |
| 8 | iInterface | 1 | Index | Index of String Descriptor |
| Offset | Field | Size | Value | Description | |
| 0 | bLength | 1 | Number | Size of Descriptor in bytes | 0x07 |
| 1 | bDescriptorType | 1 | Constant | End Descriptor | 0x05 |
| 2 | bEndpointAddress | 1 | Endpoint | Endpoint Address 0b..3b Endpoint NUmber 4b..6b Reserved ( Zero) 7b Direction 0 : Out Endpoint 1 : In Endpoint | zero based interface descriptor |
| 3 | bmAttributes | 1 | Bitmap | Bits 0..1 Transfer Type 00 = Control 01 = Isochronous 10 = Bulk 11 = Interrupt Bits 5..2 reserved if not Isochronous. Bits 3..2 Synchronization type 00 = No Synchronization 01 = Asynchronous 10 = Adaptive 11 = Synchronous Bits 5..4 Usage type 00 = Data endpoint 01 = Feedback endpoint 10 = Implicit feedback Data endpoint 11 = Reserved | 0: Not alternative 1: alternative |
| 4 | wMaxPacketSize | 2 | Number | Maximum Packet Size . | |
| 6 | bInterval | 1 | Number | Polling interval in frame count. Bulk & Control Endpoint ignored. Iso must equal 1 Interrupt 1..255 |
| Offset | Field | Size | Value | Description | |
| 0 | bLength | 1 | Number | Size of Descriptor in bytes | |
| 1 | bDescriptorType | 1 | Constant | String Descriptor | 0x03 |
| 2 | wLANGID[0] | 2 | Number | Supported Language Code Zero | ex 0x0409 (English, USA) |
| wLANGID[1] | 2 | Number | Supported Language Code One | ex 0x0C09 (English, Austria) | |
| 4 | wLANGID[2] | 2 | Number | Supported Language Code X | ex 0x0407 (German – Standard) |
| Offset | Field | Size | Value | Description | |
| 0 | bLength | 1 | Number | Size of Descriptor in bytes | |
| 1 | bDescriptorType | 1 | Constant | String Descriptor | 0x03 |
| 2 | bString | n | Unicode | Supported Language Code Zero | Unicode Encoded String |
| Offset | Field | Size | Value | Description | |
| 0 | bLength | 1 | Number | Size of Descriptor in bytes | |
| 1 | bDescriptorType | 1 | Constant | Device Qualifier Type | |
| 2 | bcdUSB | 2 | BCD | USB spec version number. | |
| 4 | bDeviceClass | 1 | Class | Class Code | |
| 5 | bDeviceSubClass | 1 | SubClass | SubClass Code | |
| 6 | bDeviceProtocol | 1 | Protocol | Protocol Code | |
| 7 | bMaxPacketSize0 | 1 | Number | Maximum packet size for other speed | |
| 8 | bNumConfigurations | 1 | Number | Number of Other-speed configurations | |
| 9 | bReserved | 1 | Zero | Reserved for future use, must be zero |
D-TCM 是資料 (data) 用的 TCM. FX3 有 8 K 的 D-TCM. SDK 預設把這一塊記憶體, 分配給系統的堆疊.
modes address size SYS MODE STACK 0x10000000-0x10000800 2 K ABT MODE STACK 0x10000800-0x10000900 256 B UND MODE STACK 0x10000900-0x10000A00 256 B FIQ MODE STACK 0x10000A00-0x10000C00 512 B IRQ MODE STACK 0x10000A00-0x10001000 1 K SVC MODE STACK 0x10000A00-0x10002000 4 K
I-TCM 是 instruction TCM. FX3 有 16 K 的 I-TCM. SDK 預設把這一塊記憶體, SDK 主要分配給 Interrupt Handler, 以及 Exception Vector.
usage address size Execption Vector 0x00000000-0x00000100 256 B Fixed Interrupt Handler 0x00000100-0x00004000 16 K – 256 B
不同的 FX3 型號, system memory 的 size 可能有所不同, 有 256K/512K 的差別. 以下以 512 K 作說明.
usage address size DMA descriptor 0x40000000-0x40003000 12 K Fixed Code Area 0x40003000-0x40030000 180 K Data Area 0x40030000-0x40037000
0x40030000-0x4003800028 K
32 K(with Compiler Heap)
(without Compiler Heap)Compiler Heap 0x40030000-0x40037000 4 K (if used) RTOS Heap 0x40038000-0x40040000 32 K DMA Buffer Area 0x40040000-0x40080000 256 K
/* Initialize the device */
CyU3PSysClockConfig_t clockConfig;
clockConfig.setSysClk400 = CyTrue;
clockConfig.cpuClkDiv = 2;
clockConfig.dmaClkDiv = 2;
clockConfig.mmioClkDiv = 2;
clockConfig.useStandbyClk = CyFalse;
clockConfig.clkSrc = CY_U3P_SYS_CLK;
status = CyU3PDeviceInit (&clockConfig);
FX3 不支援 virtual memory. 實體記憶體是和虛擬記憶體是1對1的對應. 這需要設定 MMU. 另外, MMU 也用來 enable 系統的 cache. /* Initialize the caches. Enable both Instruction and Data caches. */
status = CyU3PDeviceCacheControl (CyTrue, CyTrue, CyTrue);
if (status != CY_U3P_SUCCESS)
{
goto handle_fatal_error;
}
當完成這前述的步驟後, 程式的執行權會交給 RTOS. 也就是透過呼叫 CyU3PKernelEntry (). RTOS 在完成 RTOS 自己的啟始動作後, 會再呼叫 CyFxApplicationDefine 這個 FX3 已經定義的 callback function, application 在這個地方定義自己的 thread, 由 RTOS 分配時間來執行.
將 #include "cyfxbulksrcsink.h" 修改為 #include "CxTest.h"2. 修改 CxTestDscr.c
將 #include "cyfxbulksrcsink.h" 修改為 #include "CxTest.h"3. 修改 .project
將 cyfxbulksrcsink 全部取代成 CxTest4. 修改 .cproject
將 cyfxbulksrcsink 全部取代成 CxTest
Control Transfer 控制傳輸 Interrupt Transfer 中斷傳輸 Isochronous Transfer 同步傳輸 Bulk Transfer 大量傳輸
Control Transfer 是被設計作為 USB Host 向 USB Device 下達命令及狀態查詢. 它的作用主要是在於和應用無關的 USB 系統控制. 所以, 每個 device 都必需至少提供一組 Control Transfer 來對應.
當然, 要自己定義一組 Control Transfer 來使用也是可以的.特徵:
由於是對應 USB Host 的命令, 所以對 device 來說, Control Transfer 是突如其來, 但是它又必需以最高優先權傳送, 所以它可以傳送的資料限制也最大. 通常, 它只能傳送 8/16/32/64 個 bytes 的資料.
相對於 Control Transfer 是被動的和 USB Host 溝通, Interrupt Transfer 是被設計作為USB device 向 USB Host 傳送非週期的資料. 但是在 USB 的架構下, 傳輸的頻寬是由 USB Host 分配, 因此, Interrupt Transfer 實際上是先向 USB Host 發出頻寬分配的請求, 然後在下一次傳輸時, 才真正的傳遞資料.特徵:
Interrupt Transfer 傳送的是非週期性的資料, 這代表這資料的重要性比較高. 因此, Interrupt Transfer 傳送的資料, 可以被保證在一段時間內送達, 而且, 如果傳送錯誤, 它可以在下一個 Host/Device 交換資料的時間內重傳.
Guaranteed Latency Stream Pipe - Unidirectional Error detection and next period retry
同步傳輸用來傳送連續, 定期發生, 對時間敏感的資料. 譬如說, 電話/即時影像/視訊電話等應用. 當中間有一小段資料失誤, 對應用來說, 影響不大, 可能只是很短的一個雜音, 或是畫面破損了一下, 停滯了一下. 由於下一個時間點的資料還是會繼續收到, 因此, 這樣的影響是可以被接受的.特徵:
Isochronous Transfer 的資料, 及時送達比資料的正確性重要.
Isochronous Transfer 保證在傳輸的過程中, 在每一次傳輸時, 保留預先分配的資料頻寬來傳送資料. 因此, 它可以保證在固定時間內傳輸, 它檢查錯誤, 但是不重傳, 也不保證送達.
Guaranteed access to USB bandwidth Bounded latency Stream Pipe - Unidirectional Error detection via CRC, but no retry or guarantee of delivery Full & high speed modes only No data toggling
Bulk Transfer 用來傳送大量突發性, 時間不敏感的資料. 例如外接硬碟, 從 scanner/DSC 接收影像資料. 這些資料, 傳輸錯誤不能容許, 但是慢個一秒也沒有太大的關係.特徵:
Bulk Transfer 的時間優先權是最低的, 因此, 在其他 Transfer mode 作用的情況下, 會延遲較長的時間, 資料才能被送出. 但是在傳輸的頻寬分配完之後, Bulk Transfer 又可以吃光所有剩下的頻寬. 因此, 它又具備最大傳輸能力的可能性.
Bulk Transfer 的時間優先權是最低的, 因此, 在其他 Transfer mode 作用的情況下, 會延遲較長的時間, 資料才能被送出. 但是在傳輸的頻寬分配完之後, Bulk Transfer 又可以吃光所有剩下的頻寬. 因此, 它又具備最大傳輸能力的可能性.
Used to transfer large bursty data Error detection via CRC, with guarantee of delivery No guarantee of bandwidth or minimum latency Stream Pipe-Unidirectional Full & high speed modes only