在开发FX3的时候,觉得赛普拉斯的库注释太少,很多时候无法理解代码含义。由于使用DMA,需要理解DMA生产者消费者代表的含义,经过多方查找,决定记录下来。
在cyu3dma.h中对SocketID进行了枚举,以下是其具体代码。
1 typedef enum CyU3PDmaSocketId_t 2 { 3 CY_U3P_LPP_SOCKET_I2S_LEFT = 0x0000, /**< Left channel output to I2S port. */ 4 CY_U3P_LPP_SOCKET_I2S_RIGHT, /**< Right channel output to I2S port. */ 5 CY_U3P_LPP_SOCKET_I2C_CONS, /**< Outgoing data to I2C slave. */ 6 CY_U3P_LPP_SOCKET_UART_CONS, /**< Outgoing data to UART peer. */ 7 CY_U3P_LPP_SOCKET_SPI_CONS, /**< Outgoing data to SPI slave. */ 8 CY_U3P_LPP_SOCKET_I2C_PROD, /**< Incoming data from I2C slave. */ 9 CY_U3P_LPP_SOCKET_UART_PROD, /**< Incoming data from UART peer. */ 10 CY_U3P_LPP_SOCKET_SPI_PROD, /**< Incoming data from SPI slave. */ 11 12 13 14 CY_U3P_PIB_SOCKET_0 = 0x0100, /**< P-port socket number 0. */ 15 CY_U3P_PIB_SOCKET_1, /**< P-port socket number 1. */ 16 CY_U3P_PIB_SOCKET_2, /**< P-port socket number 2. */ 17 CY_U3P_PIB_SOCKET_3, /**< P-port socket number 3. */ 18 CY_U3P_PIB_SOCKET_4, /**< P-port socket number 4. */ 19 CY_U3P_PIB_SOCKET_5, /**< P-port socket number 5. */ 20 CY_U3P_PIB_SOCKET_6, /**< P-port socket number 6. */ 21 CY_U3P_PIB_SOCKET_7, /**< P-port socket number 7. */ 22 CY_U3P_PIB_SOCKET_8, /**< P-port socket number 8. */ 23 CY_U3P_PIB_SOCKET_9, /**< P-port socket number 9. */ 24 CY_U3P_PIB_SOCKET_10, /**< P-port socket number 10. */ 25 CY_U3P_PIB_SOCKET_11, /**< P-port socket number 11. */ 26 CY_U3P_PIB_SOCKET_12, /**< P-port socket number 12. */ 27 CY_U3P_PIB_SOCKET_13, /**< P-port socket number 13. */ 28 CY_U3P_PIB_SOCKET_14, /**< P-port socket number 14. */ 29 CY_U3P_PIB_SOCKET_15, /**< P-port socket number 15. */ 30 CY_U3P_PIB_SOCKET_16, /**< P-port socket number 16. */ 31 CY_U3P_PIB_SOCKET_17, /**< P-port socket number 17. */ 32 CY_U3P_PIB_SOCKET_18, /**< P-port socket number 18. */ 33 CY_U3P_PIB_SOCKET_19, /**< P-port socket number 19. */ 34 CY_U3P_PIB_SOCKET_20, /**< P-port socket number 20. */ 35 CY_U3P_PIB_SOCKET_21, /**< P-port socket number 21. */ 36 CY_U3P_PIB_SOCKET_22, /**< P-port socket number 22. */ 37 CY_U3P_PIB_SOCKET_23, /**< P-port socket number 23. */ 38 CY_U3P_PIB_SOCKET_24, /**< P-port socket number 24. */ 39 CY_U3P_PIB_SOCKET_25, /**< P-port socket number 25. */ 40 CY_U3P_PIB_SOCKET_26, /**< P-port socket number 26. */ 41 CY_U3P_PIB_SOCKET_27, /**< P-port socket number 27. */ 42 CY_U3P_PIB_SOCKET_28, /**< P-port socket number 28. */ 43 CY_U3P_PIB_SOCKET_29, /**< P-port socket number 29. */ 44 CY_U3P_PIB_SOCKET_30, /**< P-port socket number 30. */ 45 CY_U3P_PIB_SOCKET_31, /**< P-port socket number 31. */ 46 47 48 49 CY_U3P_SIB_SOCKET_0 = 0x0200, /**< S-port socket number 0. */ 50 CY_U3P_SIB_SOCKET_1, /**< S-port socket number 1. */ 51 CY_U3P_SIB_SOCKET_2, /**< S-port socket number 2. */ 52 CY_U3P_SIB_SOCKET_3, /**< S-port socket number 3. */ 53 CY_U3P_SIB_SOCKET_4, /**< S-port socket number 4. */ 54 CY_U3P_SIB_SOCKET_5, /**< S-port socket number 5. */ 55 56 //U-port是指endpoint socket 57 CY_U3P_UIB_SOCKET_CONS_0 = 0x0300, /**< U-port output socket number 0. */ 58 CY_U3P_UIB_SOCKET_CONS_1, /**< U-port output socket number 1. */ 59 CY_U3P_UIB_SOCKET_CONS_2, /**< U-port output socket number 2. */ 60 CY_U3P_UIB_SOCKET_CONS_3, /**< U-port output socket number 3. */ 61 CY_U3P_UIB_SOCKET_CONS_4, /**< U-port output socket number 4. */ 62 CY_U3P_UIB_SOCKET_CONS_5, /**< U-port output socket number 5. */ 63 CY_U3P_UIB_SOCKET_CONS_6, /**< U-port output socket number 6. */ 64 CY_U3P_UIB_SOCKET_CONS_7, /**< U-port output socket number 7. */ 65 CY_U3P_UIB_SOCKET_CONS_8, /**< U-port output socket number 8. */ 66 CY_U3P_UIB_SOCKET_CONS_9, /**< U-port output socket number 9. */ 67 CY_U3P_UIB_SOCKET_CONS_10, /**< U-port output socket number 10. */ 68 CY_U3P_UIB_SOCKET_CONS_11, /**< U-port output socket number 11. */ 69 CY_U3P_UIB_SOCKET_CONS_12, /**< U-port output socket number 12. */ 70 CY_U3P_UIB_SOCKET_CONS_13, /**< U-port output socket number 13. */ 71 CY_U3P_UIB_SOCKET_CONS_14, /**< U-port output socket number 14. */ 72 CY_U3P_UIB_SOCKET_CONS_15, /**< U-port output socket number 15. */ 73 74 75 CY_U3P_UIB_SOCKET_PROD_0 = 0x400, /**< U-port input socket number 0. */ 76 CY_U3P_UIB_SOCKET_PROD_1, /**< U-port input socket number 1. */ 77 CY_U3P_UIB_SOCKET_PROD_2, /**< U-port input socket number 2. */ 78 CY_U3P_UIB_SOCKET_PROD_3, /**< U-port input socket number 3. */ 79 CY_U3P_UIB_SOCKET_PROD_4, /**< U-port input socket number 4. */ 80 CY_U3P_UIB_SOCKET_PROD_5, /**< U-port input socket number 5. */ 81 CY_U3P_UIB_SOCKET_PROD_6, /**< U-port input socket number 6. */ 82 CY_U3P_UIB_SOCKET_PROD_7, /**< U-port input socket number 7. */ 83 CY_U3P_UIB_SOCKET_PROD_8, /**< U-port input socket number 8. */ 84 CY_U3P_UIB_SOCKET_PROD_9, /**< U-port input socket number 9. */ 85 CY_U3P_UIB_SOCKET_PROD_10, /**< U-port input socket number 10. */ 86 CY_U3P_UIB_SOCKET_PROD_11, /**< U-port input socket number 11. */ 87 CY_U3P_UIB_SOCKET_PROD_12, /**< U-port input socket number 12. */ 88 CY_U3P_UIB_SOCKET_PROD_13, /**< U-port input socket number 13. */ 89 CY_U3P_UIB_SOCKET_PROD_14, /**< U-port input socket number 14. */ 90 CY_U3P_UIB_SOCKET_PROD_15, /**< U-port input socket number 15. */ 91 92 93 CY_U3P_CPU_SOCKET_CONS = 0x3F00, /**< Socket through which the FX3 CPU receives data. */ 94 CY_U3P_CPU_SOCKET_PROD /**< Socket through which the FX3 CPU produces data. */ 95 96 } CyU3PDmaSocketId_t;
其中:
LPP_SOCKET是指 外设硬件端口,如CY_U3P_LPP_SOCKET_UART_PROD就代表UART的 RX 端口,而CY_U3P_LPP_SOCKET_UART_CONS就代表TX,因为数据要从TX端口发送。
P-PORT 是指FX3中的GPIF端口
S-PORT 是指FX3专门为SD/MMC卡准备的端口
U-PORT 是指USB端口,或者说是Endpoint Socket端口
CPU_SOCKET是指 FX3的CPU所收到的数据储存的端口