Hi! I am working on a project that requires bulk data transfer. I was trying to use the given examples to learn how to use the usbd_rom_cdc_vcom and usbd_rom_libusb examples, but am not able to figure out how to read the data that is sent by the host/controller, or how to connect the device to the host. I am just starting with using NXP processors for programming, would be really helpful if someone could assist me with this.
Hi,
Is this issue the same than the following thread?
https://community.nxp.com/thread/417095
Regards
Sol
Does the 4370 have a ROM API?
Sorry, I didn't see the device you are using. No, The USB ROM API is available on parts LPC4350/30/20 and LPC43S50/S30/S20.
I am using this program on the MCU side:
while (1) {
/* wait until host is connected */
while (libusbdev_Connected() == 0) {
/* Sleep until next IRQ happens */
__WFI(); ------------------> This is where the program gets stuck, I don't understand what kind of interrupt it is expecting. I am using pyusb from the host end and it gives the error following this code. soledad
}
while (libusbdev_Connected()) {
if (libusbdev_QueueReadDone() != -1) {
/* Dummy process read data ......*/
/* requeue read request */
libusbdev_QueueReadReq(g_rxBuff, PACKET_BUFFER_SIZE);
}
if (libusbdev_QueueSendDone() == 0) {
/* Queue send request */
libusbdev_QueueSendReq(g_rxBuff, PACKET_BUFFER_SIZE);
}
}
}
HOST SIDE: ON PYTHON (using pyusb)
OUTPUT:
dev1 = usb.core.find(idVendor = 0x1fc9, idProduct = 0x0090)
>>> print(dev1)
OUTPUT:
DEVICE ID 1fc9:0090 on Bus 001 Address 027 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x200 USB 2.0
bDeviceClass : 0xef Miscellaneous
bDeviceSubClass : 0x2
bDeviceProtocol : 0x1
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x1fc9
idProduct : 0x0090
bcdDevice : 0x100 Device 1.0
iManufacturer : 0x1 NXP Semiconductors
iProduct : 0x2 LPC-LINK2 DATA PORT
iSerialNumber : 0x3 I3FWNUOV
bNumConfigurations : 0x1
CONFIGURATION 1: 500 mA ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0xab (171 bytes)
bNumInterfaces : 0x5
bConfigurationValue : 0x1
iConfiguration : 0x0
bmAttributes : 0x80 Bus Powered
bMaxPower : 0xfa (500 mA)
INTERFACE 0: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x4 Error Accessing String
ENDPOINT 0x81: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x4
ENDPOINT 0x1: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x1 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x4
INTERFACE 4: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x4
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x7 Error Accessing String
ENDPOINT 0x84: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x84 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x1
ENDPOINT 0x4: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x4 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x1
INTERFACE 1: CDC Communication =========================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x1
bAlternateSetting : 0x0
bNumEndpoints : 0x1
bInterfaceClass : 0x2 CDC Communication
bInterfaceSubClass : 0x2
bInterfaceProtocol : 0x0
iInterface : 0x5 Error Accessing String
ENDPOINT 0x83: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x83 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x10 (16 bytes)
bInterval : 0x4
INTERFACE 2: CDC Data ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x2
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0xa CDC Data
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x5 Error Accessing String
ENDPOINT 0x2: Bulk OUT ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x2 OUT
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0x0
ENDPOINT 0x82: Bulk IN ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x82 IN
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0x0
INTERFACE 3: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x3
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x6 Error Accessing String
ENDPOINT 0x85: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x85 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x40 (64 bytes)
bInterval : 0x2
ENDPOINT 0x5: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x5 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x40 (64 bytes)
bInterval : 0x2
>>> cfg =devs.set_configuration() -> Sets the configuration to active mode.
>>> intf = cfg[(0,0)] -> This is the interface, here interface 0.
>>> print(intf)
OUTPUT:
INTERFACE 0: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x4 Error Accessing String
ENDPOINT 0x81: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x4
ENDPOINT 0x1: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x1 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x4
>>> ep = usb.util.find_descriptor( intf, custom_match = lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_OUT)
>>> print(ep)
ENDPOINT 0x1: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x1 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x4
>>> ep.write('test')
ERROR:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\viswe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\usb\core.py", line 387, in write
return self.device.write(self, data, timeout)
File "C:\Users\viswe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\usb\core.py", line 948, in write
self.__get_timeout(timeout)
File "C:\Users\viswe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\usb\backend\libusb1.py", line 842, in intr_write
timeout)
File "C:\Users\viswe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\usb\backend\libusb1.py", line 920, in __write
_check(retval)
File "C:\Users\viswe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\usb\backend\libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 5] Input/Output Error