Ok, now the second part of this cypress story. The source which is provided by cypress contains some demo projects, for my test design which should put the board into a peripheral mode, the demo “de2″ is a good starting point. After some browsing through the code I saw that this demo puts SIE1 (Serial Interface Engine) into a simple loopback/FIFO mode where the usb driver could write some data with a bulk transfer into a buffer and read it back. This is a good starting point to implement a simple driver under Linux with libusb. But this needs some easy modification to the code, because the ml50x board has the peripheral port connected to the SIE2. After mapping SIE1 functionality to SIE2 and remove some unused code the driver implementation can be started. The driver just write some data into the cypress chip and reads it back.
Now the next step. This step includes includes the communication with the fpga. The fpga is connected with 16 data, 2 address and some control signals to the cypress chip. To transfer data to/from the fpga just use a simple protocol with a and write/read enable signals. For this implementation the original SIE2 implementation of the demo program is our friend. Again remove some unused/not needed code from the implementation and add app_task implementation. This application task function will be called from the main loop. This function have to compare the control entries of the bulk transfer endpoints and execute the needed functionality like writing or reading to/from the fpga. The lsusb print out looks like:
Bus 004 Device 003: ID 04b4:4224 Cypress Semiconductor Corp. Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 255 Vendor Specific Class bDeviceSubClass 0 bDeviceProtocol 255 bMaxPacketSize0 8 idVendor 0x04b4 Cypress Semiconductor Corp. idProduct 0x4224 bcdDevice 0.04 iManufacturer 1 codiert.org iProduct 2 FPGA - ML505 control iSerial 3 42-24 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 46 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xc0 Self Powered MaxPower 0mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 0 bInterfaceProtocol 255 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0
After scanning the USB bus and opening the device it can be written/read by the following codes:
usb_bulk_write(hd, 2, &buf, 2, 10000); usb_bulk_read(hd, 1, &rec, 2, 10000);
Code can be requested by mail — cheers