Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -e

DEVS=$(lsusb|grep -E '(2a19|16c0|04b4|1d50|fb9a|1443)' |sed 's/:.*//;s/Bus //;s/Device //;s/ /\//')

if [ -z "$1" ]; then
echo "$0: usage: $0 <file>"
exit 1;
fi

for dev in $DEVS;do
echo "Downloading $1 to $dev"
/sbin/fxload -D /dev/bus/usb/$dev -t fx2lp -I $1
done

exit 0
12 changes: 12 additions & 0 deletions examples/mpsse_gpio/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FX2LIBDIR=../../
BASENAME = ftdi_mpsse
SOURCES=ftdi_mpsse.c mpsse_utils.c
PID=0x1004
CODE_SIZE = --code-size 0x3000
XRAM_LOC = --xram-loc 0x3200
XRAM_SIZE = --xram-size 0x700
INT2JT =-Wl"-b INT2JT=0x3100"
include $(FX2LIBDIR)lib/fx2.mk
include $(FX2LIBDIR)lib/fx2-cdesc.mk
fx2_download:
../download.sh build/$(BASENAME).ihx
216 changes: 216 additions & 0 deletions examples/mpsse_gpio/descriptors.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
/*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.......

The descriptors below setup an FTDI device with a VID
of 0x0403, and PID of 0x6010.In this particular case
endpoint 1 is used to transfer data in and out of the device
since it can be easily accessed by the CPU and is not used
for other purposes(Typically used for transferring small aamount
of data which is what we need)
Bus 003 Device 039: ID 0403:6010
Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
vbDevice Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0403 Future Technology Devices International, Ltd
idProduct 0x6010 FT2232C Dual USB-UART/FIFO IC
bcdDevice 7.00
iManufacturer 1
iProduct 2
iSerial 3
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 55
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 2
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 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 0x0200 1x 512 bytes
bInterval 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 2
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0






*/
#include "descriptors.h"

__code __at(0x3e00) struct usb_descriptors code_descriptors =
{
.device = {
.bLength = USB_DT_DEVICE_SIZE,
.bDescriptorType = USB_DT_DEVICE,
.bcdUSB = USB_BCD_V20,
.bDeviceClass = USB_CLASS_VENDOR_SPEC,
.bDeviceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bDeviceProtocol = 0xff,
.bMaxPacketSize0 = 64,
.idVendor = 0x0403,
.idProduct = 0x6010,
.bcdDevice = 0x0007,
.iManufacturer = USB_STRING_INDEX(0),
.iProduct = USB_STRING_INDEX(1),
.iSerialNumber = USB_STRING_INDEX_NONE,
.bNumConfigurations = 1,
},
.qualifier = {
.bLength = USB_DT_DEVICE_QUALIFIER_SIZE,
.bDescriptorType = USB_DT_DEVICE_QUALIFIER,
.bcdUSB = USB_BCD_V20,
.bDeviceClass = USB_CLASS_VENDOR_SPEC,
.bDeviceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bDeviceProtocol = 0xff,
.bMaxPacketSize0 = 64,
.bNumConfigurations = 1,
.bRESERVED = 0,
},
.highspeed = {
.config = {
.bLength = USB_DT_CONFIG_SIZE,
.bDescriptorType = USB_DT_CONFIG,
.wTotalLength = sizeof(descriptors.highspeed),
.bNumInterfaces = 1,
.bConfigurationValue = 1,
.iConfiguration = 0,
.bmAttributes = USB_CONFIG_ATT_ONE,
.bMaxPower = 0x32, // FIXME: ???
},
.interface = {
.bLength = USB_DT_INTERFACE_SIZE,
.bDescriptorType = USB_DT_INTERFACE,
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = 2,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bInterfaceProtocol = USB_PROTOCOL_VENDOR_SPEC,
.iInterface = USB_STRING_INDEX(2),
},
.endpoints = {
{
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_ENDPOINT_NUMBER(0x2) | USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = 512,
.bInterval = 0,
},
{
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_ENDPOINT_NUMBER(0x1) | USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = 512,
.bInterval = 0,
},
},
},
.fullspeed = {
.config = {
.bLength = USB_DT_CONFIG_SIZE,
.bDescriptorType = USB_DT_CONFIG,
.wTotalLength = sizeof(descriptors.fullspeed),
.bNumInterfaces = 1,
.bConfigurationValue = 1,
.iConfiguration = 0,
.bmAttributes = USB_CONFIG_ATT_ONE,
.bMaxPower = 0x32, // FIXME: ???
},
.interface = {
.bLength = USB_DT_INTERFACE_SIZE,
.bDescriptorType = USB_DT_INTERFACE,
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = 2,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bInterfaceProtocol = 0xff,
.iInterface = 3,
},
.endpoints = {
{
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_ENDPOINT_NUMBER(0x2) | USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = 64,
.bInterval = 0,
},
{
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_ENDPOINT_NUMBER(0x6) | USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = 64,
.bInterval = 0,
},
},
},
#include "build/descriptors_stringtable.inc"
};
33 changes: 33 additions & 0 deletions examples/mpsse_gpio/descriptors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <stddef.h>

#include "build/descriptors_stringtable.h"

#include <linux/ch9.h>
#include <linux/ch9-extra.h>

#ifndef DESCRIPTORS_H_
#define DESCRIPTORS_H_

struct usb_section {
struct usb_config_descriptor config;
struct usb_interface_descriptor interface;
struct usb_endpoint_descriptor endpoints[2];
};

struct usb_descriptors {
struct usb_device_descriptor device;
struct usb_qualifier_descriptor qualifier;
struct usb_section highspeed;
struct usb_section fullspeed;
struct usb_descriptors_stringtable stringtable;
};

__xdata __at(DSCR_AREA) struct usb_descriptors descriptors;

__code __at(DSCR_AREA+offsetof(struct usb_descriptors, device)) WORD dev_dscr;
__code __at(DSCR_AREA+offsetof(struct usb_descriptors, qualifier)) WORD dev_qual_dscr;
__code __at(DSCR_AREA+offsetof(struct usb_descriptors, highspeed)) WORD highspd_dscr;
__code __at(DSCR_AREA+offsetof(struct usb_descriptors, fullspeed)) WORD fullspd_dscr;
__code __at(DSCR_AREA+offsetof(struct usb_descriptors, stringtable)) WORD dev_strings;

#endif // DESCRIPTORS_H_
3 changes: 3 additions & 0 deletions examples/mpsse_gpio/descriptors.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hi
There
iFrame
Loading