Line 1... |
Line 1... |
/*!
|
/*!
|
ZTEX Firmware Kit for EZ-USB Microcontrollers
|
ZTEX Firmware Kit for EZ-USB FX2 Microcontrollers
|
Copyright (C) 2009-2010 ZTEX e.K.
|
Copyright (C) 2009-2011 ZTEX GmbH.
|
http://www.ztex.de
|
http://www.ztex.de
|
|
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
it under the terms of the GNU General Public License version 3 as
|
it under the terms of the GNU General Public License version 3 as
|
published by the Free Software Foundation.
|
published by the Free Software Foundation.
|
Line 24... |
Line 24... |
#define[ZTEX_DESCRIPTORS_H]
|
#define[ZTEX_DESCRIPTORS_H]
|
|
|
#define[ZTEX_DESCRIPTOR_OFFS][0x06c]
|
#define[ZTEX_DESCRIPTOR_OFFS][0x06c]
|
#define[ZTEX_DESCRIPTOR_LEN][40]
|
#define[ZTEX_DESCRIPTOR_LEN][40]
|
|
|
xdata at ZTEX_DESCRIPTOR_OFFS BYTE ZTEX_DESCRIPTOR;
|
__xdata __at ZTEX_DESCRIPTOR_OFFS BYTE ZTEX_DESCRIPTOR;
|
|
|
/* ZTEX descriptor version. Must be 1. */
|
/* ZTEX descriptor version. Must be 1. */
|
xdata at ZTEX_DESCRIPTOR_OFFS+1 BYTE ZTEX_DESCRIPTOR_VERSION;
|
__xdata __at ZTEX_DESCRIPTOR_OFFS+1 BYTE ZTEX_DESCRIPTOR_VERSION;
|
|
|
/* Must not be modified, ID="ZTEX" */
|
/* Must not be modified, ID="ZTEX" */
|
xdata at ZTEX_DESCRIPTOR_OFFS+2 BYTE ZTEXID[4];
|
__xdata __at ZTEX_DESCRIPTOR_OFFS+2 BYTE ZTEXID[4];
|
|
|
/*
|
/*
|
Product ID and firmware compatibility information.
|
Product ID and firmware compatibility information.
|
|
|
A firmware can overwrite an installed one if
|
A firmware can overwrite an installed one if
|
Line 48... |
Line 48... |
0.0.0.0 // default Product ID (no product specified)
|
0.0.0.0 // default Product ID (no product specified)
|
1.*.*.* // may be used for experimental purposes
|
1.*.*.* // may be used for experimental purposes
|
10.*.*.* // used for ZTEX products
|
10.*.*.* // used for ZTEX products
|
10.11.*.* // ZTEX USB-FPGA-Module 1.2
|
10.11.*.* // ZTEX USB-FPGA-Module 1.2
|
10.12.*.* // ZTEX USB-FPGA-Module 1.11
|
10.12.*.* // ZTEX USB-FPGA-Module 1.11
|
|
10.13.*.* // ZTEX USB-FPGA-Module 1.15
|
10.20.*.* // ZTEX USB-Module 1.0
|
10.20.*.* // ZTEX USB-Module 1.0
|
10.30.*.* // ZTEX USB-XMEGA-Module 1.0
|
10.30.*.* // ZTEX USB-XMEGA-Module 1.0
|
|
|
Please contact me (http://www.ztex.de --> Impressum/Kontakt) if you want to register/reserve a Product ID (range).
|
Please contact me (http://www.ztex.de --> Impressum/Kontakt) if you want to register/reserve a Product ID (range).
|
*/
|
*/
|
xdata at ZTEX_DESCRIPTOR_OFFS+6 BYTE PRODUCT_ID[4];
|
__xdata __at ZTEX_DESCRIPTOR_OFFS+6 BYTE PRODUCT_ID[4];
|
|
|
/* Firmware version, may be used to distinguish seveveral firmware versions */
|
/* Firmware version, may be used to distinguish seveveral firmware versions */
|
xdata at ZTEX_DESCRIPTOR_OFFS+10 BYTE FW_VERSION;
|
__xdata __at ZTEX_DESCRIPTOR_OFFS+10 BYTE FW_VERSION;
|
|
|
/* Interface version. Must be 1. */
|
/* Interface version. Must be 1. */
|
xdata at ZTEX_DESCRIPTOR_OFFS+11 BYTE INTERFACE_VERSION;
|
__xdata __at ZTEX_DESCRIPTOR_OFFS+11 BYTE INTERFACE_VERSION;
|
|
|
/*
|
/*
|
Standard interface capabilities:
|
Standard interface capabilities:
|
0.0 : EEPROM read/write, see ztex-eeprom.h
|
0.0 : EEPROM read/write, see ztex-eeprom.h
|
0.1 : FPGA configuration, see ztex-fpga.h
|
0.1 : FPGA configuration, see ztex-fpga.h
|
0.2 : Flash memory support, see ztex-flash1.h
|
0.2 : Flash memory support, see ztex-flash1.h
|
0.3 : Debug helper, see ztex-debug.h
|
0.3 : Debug helper, see ztex-debug.h
|
0.4 : AVR XMEGA support, see ztex-xmega.h
|
0.4 : AVR XMEGA support, see ztex-xmega.h
|
*/
|
*/
|
xdata at ZTEX_DESCRIPTOR_OFFS+12 BYTE INTERFACE_CAPABILITIES[6];
|
__xdata __at ZTEX_DESCRIPTOR_OFFS+12 BYTE INTERFACE_CAPABILITIES[6];
|
|
|
/* Space for settings which depends on PRODUCT_ID, e.g extra capabilities */
|
/* Space for settings which depends on PRODUCT_ID, e.g extra capabilities */
|
xdata at ZTEX_DESCRIPTOR_OFFS+18 BYTE MODULE_RESERVED[12];
|
__xdata __at ZTEX_DESCRIPTOR_OFFS+18 BYTE MODULE_RESERVED[12];
|
|
|
/*
|
/*
|
Serial number string
|
Serial number string
|
default: "0000000000"
|
default: "0000000000"
|
Should only be modified by the the firmware upload software
|
Should only be modified by the the firmware upload software
|
*/
|
*/
|
xdata at ZTEX_DESCRIPTOR_OFFS+30 BYTE SN_STRING[10];
|
__xdata __at ZTEX_DESCRIPTOR_OFFS+30 BYTE SN_STRING[10];
|
|
|
/* Are Vendor ID and Product ID defined? */
|
/* Are Vendor ID and Product ID defined? */
|
#ifndef[USB_VENDOR_ID]
|
#ifndef[USB_VENDOR_ID]
|
#error[No USB Vendor ID defined]
|
#error[No USB Vendor ID defined]
|
#endif
|
#endif
|
Line 113... |
Line 114... |
CONFIGURE_INTERFACE(1);
|
CONFIGURE_INTERFACE(1);
|
CONFIGURE_INTERFACE(2);
|
CONFIGURE_INTERFACE(2);
|
CONFIGURE_INTERFACE(3);
|
CONFIGURE_INTERFACE(3);
|
|
|
/* define the ZTEX descriptor */
|
/* define the ZTEX descriptor */
|
void abscode_identity() _naked
|
void abscode_identity()// _naked
|
{
|
{
|
_asm
|
__asm
|
.area ABSCODE (ABS,CODE)
|
.area ABSCODE (ABS,CODE)
|
|
|
.org ZTEX_DESCRIPTOR_OFFS
|
.org ZTEX_DESCRIPTOR_OFFS
|
.db ZTEX_DESCRIPTOR_LEN
|
.db ZTEX_DESCRIPTOR_LEN
|
|
|
Line 161... |
Line 162... |
#endif
|
#endif
|
#ifdef[@CAPABILITY_XMEGA;]
|
#ifdef[@CAPABILITY_XMEGA;]
|
#nolf
|
#nolf
|
+ 16
|
+ 16
|
#endif
|
#endif
|
|
#ifdef[@CAPABILITY_HS_FPGA;]
|
|
#nolf
|
|
+ 32
|
|
#endif
|
|
#ifdef[@CAPABILITY_MAC_EEPROM;]
|
|
#nolf
|
|
+ 64
|
|
#endif
|
.db 0
|
.db 0
|
.db 0
|
.db 0
|
.db 0
|
.db 0
|
.db 0
|
.db 0
|
.db 0
|
.db 0
|
Line 185... |
Line 194... |
|
|
.org _SN_STRING
|
.org _SN_STRING
|
.ascii "0000000000"
|
.ascii "0000000000"
|
|
|
.area CSEG (CODE)
|
.area CSEG (CODE)
|
_endasm;
|
__endasm;
|
}
|
}
|
|
|
/* *********************************************************************
|
/* *********************************************************************
|
***** strings *******************************************************
|
***** strings *******************************************************
|
********************************************************************* */
|
********************************************************************* */
|
code char manufacturerString[] = MANUFACTURER_STRING;
|
__code char manufacturerString[] = MANUFACTURER_STRING;
|
code char productString[] = PRODUCT_STRING;
|
__code char productString[] = PRODUCT_STRING;
|
code char configurationString[] = CONFIGURATION_STRING;
|
__code char configurationString[] = CONFIGURATION_STRING;
|
|
|
|
|
/* *********************************************************************
|
/* *********************************************************************
|
***** descriptors ***************************************************
|
***** descriptors ***************************************************
|
********************************************************************* */
|
********************************************************************* */
|
Line 306... |
Line 315... |
#ifeq[EP8_INTERFACE][$0]
|
#ifeq[EP8_INTERFACE][$0]
|
EP_DESCRIPTOR(8);
|
EP_DESCRIPTOR(8);
|
#endif
|
#endif
|
]
|
]
|
|
|
#define[APPEND_PADBYTE(][);][code BYTE $0_PadByte[2-(sizeof($0) & 1)] = { 0 };]
|
#define[APPEND_PADBYTE(][);][__code BYTE $0_PadByte[2-(sizeof($0) & 1)] = { 0 };]
|
|
|
#ifdef[PAD_BYTE] // to ensure word alignment of the descriptors; PAD_BYTE is defined automatically by bmpsdcc script
|
#ifdef[PAD_BYTE] // to ensure word alignment of the descriptors; PAD_BYTE is defined automatically by bmpsdcc script
|
code BYTE PadByte = 0;
|
__code BYTE PadByte = 0;
|
#endif
|
#endif
|
|
|
code BYTE DeviceDescriptor[] =
|
__code BYTE DeviceDescriptor[] =
|
{
|
{
|
18, // 0, Descriptor length
|
18, // 0, Descriptor length
|
0x01, // 1, Descriptor type
|
0x01, // 1, Descriptor type
|
0x00, // 2, Specification Version (L)
|
0x00, // 2, Specification Version (L)
|
0x02, // 3, Specification Version (H)
|
0x02, // 3, Specification Version (H)
|
Line 334... |
Line 343... |
2, // 15, Product string index
|
2, // 15, Product string index
|
3, // 16, Serial number string index
|
3, // 16, Serial number string index
|
1 // 17, Number of configurations
|
1 // 17, Number of configurations
|
};
|
};
|
|
|
code BYTE DeviceQualifierDescriptor[] =
|
__code BYTE DeviceQualifierDescriptor[] =
|
{
|
{
|
10, // 0, Descriptor length
|
10, // 0, Descriptor length
|
0x06, // 1, Decriptor type
|
0x06, // 1, Decriptor type
|
0x00, // 2, Specification Version (L)
|
0x00, // 2, Specification Version (L)
|
0x02, // 3, Specification Version (H)
|
0x02, // 3, Specification Version (H)
|
Line 348... |
Line 357... |
64, // 7, Maximum packet size (EP0?)
|
64, // 7, Maximum packet size (EP0?)
|
1, // 8, Number of configurations
|
1, // 8, Number of configurations
|
0, // 9, Reserved, must be zero
|
0, // 9, Reserved, must be zero
|
};
|
};
|
|
|
code BYTE HighSpeedConfigDescriptor[] =
|
__code BYTE HighSpeedConfigDescriptor[] =
|
{
|
{
|
#define[HIGH_SPEED]
|
#define[HIGH_SPEED]
|
9 // 0, Descriptor length
|
9 // 0, Descriptor length
|
,0x02 // 1, Decriptor type
|
,0x02 // 1, Decriptor type
|
,sizeof(HighSpeedConfigDescriptor) & 0xff // 2, Total length (LSB)
|
,sizeof(HighSpeedConfigDescriptor) & 0xff // 2, Total length (LSB)
|
Line 390... |
Line 399... |
#endif
|
#endif
|
#udefine[HIGH_SPEED]
|
#udefine[HIGH_SPEED]
|
};
|
};
|
APPEND_PADBYTE(HighSpeedConfigDescriptor);
|
APPEND_PADBYTE(HighSpeedConfigDescriptor);
|
|
|
code BYTE FullSpeedConfigDescriptor[] =
|
__code BYTE FullSpeedConfigDescriptor[] =
|
{
|
{
|
9 // 0, Descriptor length
|
9 // 0, Descriptor length
|
,0x02 // 1, Decriptor type
|
,0x02 // 1, Decriptor type
|
,sizeof(FullSpeedConfigDescriptor) & 0xff // 2, Total length (LSB)
|
,sizeof(FullSpeedConfigDescriptor) & 0xff // 2, Total length (LSB)
|
// ,sizeof(FullSpeedConfigDescriptor) >> 8 // 3, Total length (MSB)
|
// ,sizeof(FullSpeedConfigDescriptor) >> 8 // 3, Total length (MSB)
|
Line 430... |
Line 439... |
INTERFACE_DESCRIPTOR(3);
|
INTERFACE_DESCRIPTOR(3);
|
#endif
|
#endif
|
};
|
};
|
APPEND_PADBYTE(FullSpeedConfigDescriptor);
|
APPEND_PADBYTE(FullSpeedConfigDescriptor);
|
|
|
code BYTE EmptyStringDescriptor[] =
|
__code BYTE EmptyStringDescriptor[] =
|
{
|
{
|
sizeof(EmptyStringDescriptor), // Length
|
sizeof(EmptyStringDescriptor), // Length
|
0x03, // Descriptor type
|
0x03, // Descriptor type
|
0, 0
|
0, 0
|
};
|
};
|