在线时间588 小时
UID3469866
注册时间2018-4-19
NXP金币2806
TA的每日心情 | 慵懒 2024-2-8 09:39 |
---|
签到天数: 217 天 [LV.7]常住居民III
版主
- 积分
- 7576
- 最后登录
- 2024-4-17
|
今天集中实验了不少功能,接下来是我们的USB,USB的连线也是与官方一样的(USB的IO是无法复用的)。直接找一个例程,下载试试(SDK_2_10_0_MIMXRT1170-EVK\boards\evkmimxrt1170\usb_examples\usb_host_msd_fatfs)。
下载到芯片里面。
把U盘插到第一个USB上,一切完美。
- mass storage device attached:pid=0x1666vid=0x951 address=1
- ............................fatfs test.....................
- fatfs mount as logiacal driver 1......success
- test f_mkfs......success
- test f_getfree:
- FAT type = FAT32
- bytes per cluster = 32768; number of clusters=944220
- The free size: 30215008KB, the total size:30215040KB
- directory operation:
- list root directory:
- create directory "dir_1"......success
- create directory "dir_2"......success
- create sub directory "dir_2/sub_1"......success
- list root directory:
- dir - ___ - DIR_1 - 0Bytes - 2018-1-1 0:0:0
- dir - ___ - DIR_2 - 0Bytes - 2018-1-1 0:0:0
- list directory "dir_1":
- dir - ___ - SUB_1 - 0Bytes - 2018-1-1 0:0:0
- rename directory "dir_1/sub_1" to "dir_1/sub_2"......success
- delete directory "dir_1/sub_2"......success
- get directory "dir_1" information:
- dir - ___ - DIR_1 - 0Bytes - 2018-1-1 0:0:0
- change "dir_1" timestamp to 2015.10.1, 12:30:0......success
- get directory "dir_1" information:
- dir - ___ - DIR_1 - 0Bytes - 2015-10-1 12:30:0
- file operation:
- create file "f_1.dat"......success
- test f_write......success
- test f_printf......success
- test f_puts......success
- test f_putc......success
- test f_seek......success
- test f_gets......ABCDEFGHI
- test f_read......JKLMNOPQRS
- test f_truncate......success
- test f_close......success
- get file "f_1.dat" information:
- fil - ___ - F_1.DAT - 19Bytes - 2018-1-1 0:0:0
- change "f_1.dat" timestamp to 2015.10.1, 12:30:0......success
- change "f_1.dat" to readonly......success
- get file "f_1.dat" information:
- fil - R__ - F_1.DAT - 19Bytes - 2015-10-1 12:30:0
- remove "f_1.dat" readonly attribute......success
- get file "f_1.dat" information:
- fil - ___ - F_1.DAT - 19Bytes - 2015-10-1 12:30:0
- rename "f_1.dat" to "f_2.dat"......success
- delete "f_2.dat"......success
- ............................test done......................
复制代码 但是,插到第二个的时候,问题来了,不识别。
查了查原理图,没问题啊。
然后电表量一下,没断路。
我去,啥问题,然后我试了一下从机USB的例程,USB1也没问题。一个鼠标中间画方框。但是USB2还是不行。
读了读代码的文档,也没有描述这个例程是开了一个USB还是两个都打开了。
怀揣着对NXP的信任,我抄起了风枪,但是还不行。。。。。。。。。。。。
又仔细读了读文档,没有啥发现,于是看向了代码。。。。。。
好像,就开了一个USB啊。
- void USB_HostIsrEnable(void)
- {
- uint8_t irqNumber;
- uint8_t usbHOSTEhciIrq[] = USBHS_IRQS;
- irqNumber = usbHOSTEhciIrq[CONTROLLER_ID - kUSB_ControllerEhci0];
- /* USB_HOST_CONFIG_EHCI */
- /* Install isr, set priority, and enable IRQ. */
- #if defined(__GIC_PRIO_BITS)
- GIC_SetPriority((IRQn_Type)irqNumber, USB_HOST_INTERRUPT_PRIORITY);
- #else
- NVIC_SetPriority((IRQn_Type)irqNumber, USB_HOST_INTERRUPT_PRIORITY);
- #endif
- EnableIRQ((IRQn_Type)irqNumber);
- }
复制代码 只开了一个中断。
接着看代码。、
- #define CONTROLLER_ID kUSB_ControllerEhci0
复制代码 看起来这里是关键,改成1估计就可以了。但是接下来一句注释把我搞懵了。
- /*! @brief USB controller ID */
- typedef enum _usb_controller_index
- {
- kUSB_ControllerKhci0 = 0U, /*!< KHCI 0U */
- kUSB_ControllerKhci1 = 1U, /*!< KHCI 1U, Currently, there are no platforms which have two KHCI IPs, this is reserved
- to be used in the future. */
- kUSB_ControllerEhci0 = 2U, /*!< EHCI 0U */
- kUSB_ControllerEhci1 = 3U, /*!< EHCI 1U, Currently, there are no platforms which have two EHCI IPs, this is reserved
- to be used in the future. */
- kUSB_ControllerLpcIp3511Fs0 = 4U, /*!< LPC USB IP3511 FS controller 0 */
- kUSB_ControllerLpcIp3511Fs1 = 5U, /*!< LPC USB IP3511 FS controller 1, there are no platforms which have two IP3511
- IPs, this is reserved to be used in the future. */
- kUSB_ControllerLpcIp3511Hs0 = 6U, /*!< LPC USB IP3511 HS controller 0 */
- kUSB_ControllerLpcIp3511Hs1 = 7U, /*!< LPC USB IP3511 HS controller 1, there are no platforms which have two IP3511
- IPs, this is reserved to be used in the future. */
- kUSB_ControllerOhci0 = 8U, /*!< OHCI 0U */
- kUSB_ControllerOhci1 = 9U, /*!< OHCI 1U, Currently, there are no platforms which have two OHCI IPs, this is reserved
- to be used in the future. */
- kUSB_ControllerIp3516Hs0 = 10U, /*!< IP3516HS 0U */
- kUSB_ControllerIp3516Hs1 = 11U, /*!< IP3516HS 1U, Currently, there are no platforms which have two IP3516HS IPs,
- this is reserved to be used in the future. */
- kUSB_ControllerDwc30 = 12U, /*!< DWC3 0U */
- kUSB_ControllerDwc31 = 13U, /*!< DWC3 1U Currently, there are no platforms which have two Dwc IPs, this is reserved
- to be used in the future.*/
- } usb_controller_index_t;
复制代码 没有?预留?为将来准备?小小的心里藏着大大的问号。
绝路了吗?
不死心的我尝试硬改(试试嘛,死马当活马医)
- #define CONTROLLER_ID kUSB_ControllerEhci1
复制代码 然后,USB2可用,但是USB1不可用了。
这证明了USB硬件是没有问题的。
不过这注释,确实要批评一下NXP。这里手动@小恩GG。这一段注释、文档需不需要修改一下,或者是我哪里操作不正确。
|
|