From 0ddab5ef2e13570bae3a6a02b67a9c14ae3144d5 Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 24 Feb 2024 23:55:50 +0100 Subject: [PATCH] refactoring; move firmware code out of python module Signed-off-by: Martin --- CHANGELOG | 1 + .../Firmware => Firmware}/DDS120/Makefile | 0 Firmware/DDS120/dds120-firmware.hex | 288 ++++++++ .../Firmware => Firmware}/DDS120/dds120.c | 0 .../DDS120/descriptor.asm | 0 .../Firmware => Firmware}/DDS120/fl_fw.sh | 0 .../Firmware => Firmware}/DSO6021/Makefile | 0 .../DSO6021/descriptor.asm | 0 Firmware/DSO6021/dso6021-firmware.hex | 285 ++++++++ .../Firmware => Firmware}/DSO6021/dso6021.c | 0 .../Firmware => Firmware}/DSO6021/fl_fw.sh | 0 .../Firmware => Firmware}/DSO6022BE/Makefile | 0 .../DSO6022BE/descriptor.asm | 0 .../DSO6022BE/descriptor.inc | 0 Firmware/DSO6022BE/dso6022be-firmware.hex | 287 ++++++++ .../DSO6022BE/dso6022be.c | 0 .../Firmware => Firmware}/DSO6022BE/fl_fw.sh | 0 .../Firmware => Firmware}/DSO6022BE/fx2.mk | 0 .../DSO6022BE/scope6022.inc | 28 +- .../DSO6022BE/waveforms.inc | 0 .../DSO6022BE/waveforms/COMPILE_GPIF.sh | 0 .../DSO6022BE/waveforms/gpif_1.inc | 0 .../DSO6022BE/waveforms/gpif_1.wvf | 0 .../DSO6022BE/waveforms/gpif_10.inc | 0 .../DSO6022BE/waveforms/gpif_10.wvf | 0 .../DSO6022BE/waveforms/gpif_102.inc | 0 .../DSO6022BE/waveforms/gpif_102.wvf | 0 .../DSO6022BE/waveforms/gpif_103.inc | 0 .../DSO6022BE/waveforms/gpif_103.wvf | 0 .../DSO6022BE/waveforms/gpif_104.inc | 0 .../DSO6022BE/waveforms/gpif_104.wvf | 0 .../DSO6022BE/waveforms/gpif_105.inc | 0 .../DSO6022BE/waveforms/gpif_105.wvf | 0 .../DSO6022BE/waveforms/gpif_106.inc | 0 .../DSO6022BE/waveforms/gpif_106.wvf | 0 .../DSO6022BE/waveforms/gpif_110.inc | 0 .../DSO6022BE/waveforms/gpif_110.wvf | 0 .../DSO6022BE/waveforms/gpif_113.inc | 0 .../DSO6022BE/waveforms/gpif_113.wvf | 0 .../DSO6022BE/waveforms/gpif_12.inc | 0 .../DSO6022BE/waveforms/gpif_12.wvf | 0 .../DSO6022BE/waveforms/gpif_120.inc | 0 .../DSO6022BE/waveforms/gpif_120.wvf | 0 .../DSO6022BE/waveforms/gpif_140.inc | 0 .../DSO6022BE/waveforms/gpif_140.wvf | 0 .../DSO6022BE/waveforms/gpif_15.inc | 0 .../DSO6022BE/waveforms/gpif_15.wvf | 0 .../DSO6022BE/waveforms/gpif_150.inc | 0 .../DSO6022BE/waveforms/gpif_150.wvf | 0 .../DSO6022BE/waveforms/gpif_16.inc | 0 .../DSO6022BE/waveforms/gpif_16.wvf | 0 .../DSO6022BE/waveforms/gpif_164.inc | 0 .../DSO6022BE/waveforms/gpif_164.wvf | 0 .../DSO6022BE/waveforms/gpif_2.inc | 0 .../DSO6022BE/waveforms/gpif_2.wvf | 0 .../DSO6022BE/waveforms/gpif_24.inc | 0 .../DSO6022BE/waveforms/gpif_24.wvf | 0 .../DSO6022BE/waveforms/gpif_3.inc | 0 .../DSO6022BE/waveforms/gpif_3.wvf | 0 .../DSO6022BE/waveforms/gpif_30.inc | 0 .../DSO6022BE/waveforms/gpif_30.wvf | 0 .../DSO6022BE/waveforms/gpif_4.inc | 0 .../DSO6022BE/waveforms/gpif_4.wvf | 0 .../DSO6022BE/waveforms/gpif_48.inc | 0 .../DSO6022BE/waveforms/gpif_48.wvf | 0 .../DSO6022BE/waveforms/gpif_5.inc | 0 .../DSO6022BE/waveforms/gpif_5.wvf | 0 .../DSO6022BE/waveforms/gpif_6.inc | 0 .../DSO6022BE/waveforms/gpif_6.wvf | 0 .../DSO6022BE/waveforms/gpif_8.inc | 0 .../DSO6022BE/waveforms/gpif_8.wvf | 0 .../DSO6022BE/waveforms/waveforms.inc | 0 .../Firmware => Firmware}/DSO6022BL/Makefile | 0 .../DSO6022BL/descriptor.asm | 0 Firmware/DSO6022BL/dso6022bl-firmware.hex | 287 ++++++++ .../DSO6022BL/dso6022bl.c | 0 .../Firmware => Firmware}/DSO6022BL/fl_fw.sh | 0 Firmware/README.md | 29 + .../Firmware => Firmware}/custom/Makefile | 0 .../Firmware => Firmware}/custom/device.c | 0 .../Firmware => Firmware}/custom/dscr.a51 | 0 {PyHT6022/Firmware => Firmware}/custom/fw.c | 0 .../custom/lsusb_custom.lst | 0 .../dso602x_fw_version.h | 4 +- Firmware/fx2lib/.gitignore | 21 + Firmware/fx2lib/CHANGELOG | 32 + Firmware/fx2lib/COPYING | 674 ++++++++++++++++++ Firmware/fx2lib/COPYING.LESSER | 165 +++++ Firmware/fx2lib/Makefile | 29 + Firmware/fx2lib/NOTES | 42 ++ Firmware/fx2lib/README | 41 ++ Firmware/fx2lib/appveyor.yml | 16 + Firmware/fx2lib/docs/intro/.gitignore | 6 + Firmware/fx2lib/docs/intro/Makefile | 11 + Firmware/fx2lib/docs/intro/intro.tex | 80 +++ Firmware/fx2lib/examples/Makefile | 10 + Firmware/fx2lib/examples/NOTES | 88 +++ Firmware/fx2lib/examples/bulkloop/Makefile | 12 + Firmware/fx2lib/examples/bulkloop/bulkloop.c | 227 ++++++ Firmware/fx2lib/examples/bulkloop/dscr.a51 | 225 ++++++ Firmware/fx2lib/examples/bulkloop/load.py | 5 + Firmware/fx2lib/examples/bulkloop/test.cpp | 54 ++ Firmware/fx2lib/examples/bulkloop/test.py | 39 + Firmware/fx2lib/examples/debugdevice/Makefile | 8 + .../fx2lib/examples/debugdevice/debugdev.c | 236 ++++++ Firmware/fx2lib/examples/debugdevice/dscr.a51 | 259 +++++++ .../debugdevice_full_duplex/.gitignore | 2 + .../examples/debugdevice_full_duplex/Makefile | 22 + .../debugdevice_full_duplex/debugdev.c | 331 +++++++++ .../debugdevice_full_duplex/download.sh | 15 + .../examples/debugdevice_full_duplex/dscr.a51 | 356 +++++++++ .../debugdevice_full_duplex/terminal.c | 153 ++++ .../examples/debugdevice_full_duplex/test.cpp | 110 +++ Firmware/fx2lib/examples/eeprom/Makefile | 10 + Firmware/fx2lib/examples/eeprom/client.py | 92 +++ .../fx2lib/examples/eeprom/firmware/Makefile | 6 + .../fx2lib/examples/eeprom/firmware/dscr.a51 | 277 +++++++ .../fx2lib/examples/eeprom/firmware/eeprom.c | 172 +++++ Firmware/fx2lib/examples/fx2/.gitignore | 2 + Firmware/fx2lib/examples/fx2/cpp/.gitignore | 2 + Firmware/fx2lib/examples/fx2/cpp/__init__.py | 0 Firmware/fx2lib/examples/fx2/cpp/fx2.cpp | 161 +++++ Firmware/fx2lib/examples/fx2/cpp/fx2.h | 61 ++ Firmware/fx2lib/examples/fx2/cpp/fx2.i | 30 + .../fx2lib/examples/fx2/fx2load/__init__.py | 59 ++ Firmware/fx2lib/examples/fx2/scripts/fx2load | 34 + Firmware/fx2lib/examples/fx2/setup.py | 19 + Firmware/fx2lib/examples/i2c/Makefile | 8 + Firmware/fx2lib/examples/i2c/i2c.c | 92 +++ Firmware/fx2lib/examples/i2c/load.py | 20 + Firmware/fx2lib/examples/lights/.gitignore | 1 + Firmware/fx2lib/examples/lights/Makefile | 8 + Firmware/fx2lib/examples/lights/lights.c | 37 + Firmware/fx2lib/examples/reset/Makefile | 8 + Firmware/fx2lib/examples/reset/fx2_c0.c | 4 + Firmware/fx2lib/examples/reset/reset.c | 82 +++ Firmware/fx2lib/examples/serial/Makefile | 8 + Firmware/fx2lib/examples/serial/serial.c | 81 +++ Firmware/fx2lib/examples/timers/.gitignore | 1 + Firmware/fx2lib/examples/timers/Makefile | 8 + Firmware/fx2lib/examples/timers/timers.c | 79 ++ Firmware/fx2lib/examples/usbmon_c/Makefile | 19 + Firmware/fx2lib/examples/usbmon_c/download.sh | 15 + Firmware/fx2lib/examples/usbmon_c/dscr.a51 | 241 +++++++ Firmware/fx2lib/examples/usbmon_c/test.c | 88 +++ Firmware/fx2lib/examples/usbmon_c/usbmon.c | 226 ++++++ Firmware/fx2lib/fw/.gitignore | 9 + Firmware/fx2lib/fw/Makefile | 26 + Firmware/fx2lib/fw/device.c | 98 +++ Firmware/fx2lib/fw/dscr.a51 | 256 +++++++ Firmware/fx2lib/fw/fw.c | 135 ++++ Firmware/fx2lib/fw/readme.txt | 20 + Firmware/fx2lib/include/autovector.h | 227 ++++++ Firmware/fx2lib/include/delay.h | 109 +++ Firmware/fx2lib/include/eputils.h | 92 +++ Firmware/fx2lib/include/fx2ints.h | 116 +++ Firmware/fx2lib/include/fx2macros.h | 127 ++++ Firmware/fx2lib/include/fx2regs.h | 646 +++++++++++++++++ Firmware/fx2lib/include/fx2types.h | 50 ++ Firmware/fx2lib/include/gpif.h | 110 +++ Firmware/fx2lib/include/i2c.h | 97 +++ Firmware/fx2lib/include/lights.h | 96 +++ Firmware/fx2lib/include/serial.h | 55 ++ Firmware/fx2lib/include/setupdat.h | 224 ++++++ Firmware/fx2lib/utils/gpif2dat | 20 + Firmware/fx2lib/utils/ihx2iic.py | 186 +++++ Firmware/fx2lib/utils/ihx2iic_2.py | 186 +++++ .../Firmware => Firmware}/modded/dis51lst.sh | 0 .../modded/fixfiforeset.asm | 0 .../modded/fixfiforeset.hex | 0 .../Firmware => Firmware}/modded/isodiff.asm | 0 .../Firmware => Firmware}/modded/isodiff.hex | 0 .../modded/lsusb_mod.lst | 0 .../modded/mod_fw_01.a51 | 0 .../modded/mod_fw_01.ihex | 0 .../modded/mod_fw_01.lst | 0 .../modded/mod_fw_01.map | 0 .../modded/mod_fw_iso.ihex | 0 .../modded/samplerates.asm | 0 .../modded/samplerates.hex | 0 .../Firmware => Firmware}/stock/dis51lst.sh | 0 .../Firmware => Firmware}/stock/stock_fw.a51 | 0 .../Firmware => Firmware}/stock/stock_fw.ihex | 0 .../Firmware => Firmware}/stock/stock_fw.lst | 0 .../Firmware => Firmware}/stock/stock_fw.md | 0 MANIFEST.in | 7 +- MK_FW_VERSION.sh | 4 +- Makefile | 33 +- PyHT6022/Firmware/DDS120/dds120-firmware.hex | 288 -------- .../Firmware/DSO6021/dso6021-firmware.hex | 285 -------- .../Firmware/DSO6022BE/dso6022be-firmware.hex | 286 -------- .../Firmware/DSO6022BL/dso6022bl-firmware.hex | 286 -------- PyHT6022/Firmware/HEX/dds120-firmware.hex | 288 ++++++++ PyHT6022/Firmware/HEX/dso6021-firmware.hex | 285 ++++++++ PyHT6022/Firmware/HEX/dso6022be-firmware.hex | 287 ++++++++ PyHT6022/Firmware/HEX/dso6022bl-firmware.hex | 287 ++++++++ PyHT6022/Firmware/HEX/mod_fw_01.ihex | 405 +++++++++++ PyHT6022/Firmware/HEX/mod_fw_iso.ihex | 420 +++++++++++ PyHT6022/Firmware/HEX/stock_fw.ihex | 451 ++++++++++++ PyHT6022/Firmware/README.md | 29 +- PyHT6022/Firmware/__init__.py | 14 +- PyHT6022/Firmware/firmware_packet_dump.csv | 459 ------------ PyHT6022/Firmware/fx2lib | 1 - PyHT6022/Firmware/modded/dis51-0.5.diff | 51 -- examples/upload_6022BL_firmware_to_6022BE.py | 20 + setup.cfg | 2 + setup.py | 22 +- 207 files changed, 11804 insertions(+), 1720 deletions(-) rename {PyHT6022/Firmware => Firmware}/DDS120/Makefile (100%) create mode 100644 Firmware/DDS120/dds120-firmware.hex rename {PyHT6022/Firmware => Firmware}/DDS120/dds120.c (100%) rename {PyHT6022/Firmware => Firmware}/DDS120/descriptor.asm (100%) rename {PyHT6022/Firmware => Firmware}/DDS120/fl_fw.sh (100%) rename {PyHT6022/Firmware => Firmware}/DSO6021/Makefile (100%) rename {PyHT6022/Firmware => Firmware}/DSO6021/descriptor.asm (100%) create mode 100644 Firmware/DSO6021/dso6021-firmware.hex rename {PyHT6022/Firmware => Firmware}/DSO6021/dso6021.c (100%) rename {PyHT6022/Firmware => Firmware}/DSO6021/fl_fw.sh (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/Makefile (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/descriptor.asm (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/descriptor.inc (100%) create mode 100644 Firmware/DSO6022BE/dso6022be-firmware.hex rename {PyHT6022/Firmware => Firmware}/DSO6022BE/dso6022be.c (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/fl_fw.sh (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/fx2.mk (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/scope6022.inc (95%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/COMPILE_GPIF.sh (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_1.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_1.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_10.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_10.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_102.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_102.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_103.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_103.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_104.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_104.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_105.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_105.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_106.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_106.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_110.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_110.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_113.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_113.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_12.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_12.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_120.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_120.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_140.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_140.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_15.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_15.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_150.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_150.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_16.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_16.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_164.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_164.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_2.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_2.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_24.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_24.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_3.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_3.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_30.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_30.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_4.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_4.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_48.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_48.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_5.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_5.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_6.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_6.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_8.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/gpif_8.wvf (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BE/waveforms/waveforms.inc (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BL/Makefile (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BL/descriptor.asm (100%) create mode 100644 Firmware/DSO6022BL/dso6022bl-firmware.hex rename {PyHT6022/Firmware => Firmware}/DSO6022BL/dso6022bl.c (100%) rename {PyHT6022/Firmware => Firmware}/DSO6022BL/fl_fw.sh (100%) create mode 100644 Firmware/README.md rename {PyHT6022/Firmware => Firmware}/custom/Makefile (100%) rename {PyHT6022/Firmware => Firmware}/custom/device.c (100%) rename {PyHT6022/Firmware => Firmware}/custom/dscr.a51 (100%) rename {PyHT6022/Firmware => Firmware}/custom/fw.c (100%) rename {PyHT6022/Firmware => Firmware}/custom/lsusb_custom.lst (100%) rename {PyHT6022/Firmware => Firmware}/dso602x_fw_version.h (61%) create mode 100644 Firmware/fx2lib/.gitignore create mode 100644 Firmware/fx2lib/CHANGELOG create mode 100644 Firmware/fx2lib/COPYING create mode 100644 Firmware/fx2lib/COPYING.LESSER create mode 100644 Firmware/fx2lib/Makefile create mode 100644 Firmware/fx2lib/NOTES create mode 100644 Firmware/fx2lib/README create mode 100644 Firmware/fx2lib/appveyor.yml create mode 100644 Firmware/fx2lib/docs/intro/.gitignore create mode 100644 Firmware/fx2lib/docs/intro/Makefile create mode 100644 Firmware/fx2lib/docs/intro/intro.tex create mode 100644 Firmware/fx2lib/examples/Makefile create mode 100644 Firmware/fx2lib/examples/NOTES create mode 100644 Firmware/fx2lib/examples/bulkloop/Makefile create mode 100644 Firmware/fx2lib/examples/bulkloop/bulkloop.c create mode 100644 Firmware/fx2lib/examples/bulkloop/dscr.a51 create mode 100644 Firmware/fx2lib/examples/bulkloop/load.py create mode 100644 Firmware/fx2lib/examples/bulkloop/test.cpp create mode 100644 Firmware/fx2lib/examples/bulkloop/test.py create mode 100644 Firmware/fx2lib/examples/debugdevice/Makefile create mode 100644 Firmware/fx2lib/examples/debugdevice/debugdev.c create mode 100644 Firmware/fx2lib/examples/debugdevice/dscr.a51 create mode 100644 Firmware/fx2lib/examples/debugdevice_full_duplex/.gitignore create mode 100644 Firmware/fx2lib/examples/debugdevice_full_duplex/Makefile create mode 100644 Firmware/fx2lib/examples/debugdevice_full_duplex/debugdev.c create mode 100755 Firmware/fx2lib/examples/debugdevice_full_duplex/download.sh create mode 100644 Firmware/fx2lib/examples/debugdevice_full_duplex/dscr.a51 create mode 100644 Firmware/fx2lib/examples/debugdevice_full_duplex/terminal.c create mode 100644 Firmware/fx2lib/examples/debugdevice_full_duplex/test.cpp create mode 100644 Firmware/fx2lib/examples/eeprom/Makefile create mode 100644 Firmware/fx2lib/examples/eeprom/client.py create mode 100644 Firmware/fx2lib/examples/eeprom/firmware/Makefile create mode 100644 Firmware/fx2lib/examples/eeprom/firmware/dscr.a51 create mode 100644 Firmware/fx2lib/examples/eeprom/firmware/eeprom.c create mode 100644 Firmware/fx2lib/examples/fx2/.gitignore create mode 100644 Firmware/fx2lib/examples/fx2/cpp/.gitignore create mode 100644 Firmware/fx2lib/examples/fx2/cpp/__init__.py create mode 100644 Firmware/fx2lib/examples/fx2/cpp/fx2.cpp create mode 100644 Firmware/fx2lib/examples/fx2/cpp/fx2.h create mode 100644 Firmware/fx2lib/examples/fx2/cpp/fx2.i create mode 100644 Firmware/fx2lib/examples/fx2/fx2load/__init__.py create mode 100755 Firmware/fx2lib/examples/fx2/scripts/fx2load create mode 100644 Firmware/fx2lib/examples/fx2/setup.py create mode 100644 Firmware/fx2lib/examples/i2c/Makefile create mode 100644 Firmware/fx2lib/examples/i2c/i2c.c create mode 100644 Firmware/fx2lib/examples/i2c/load.py create mode 100644 Firmware/fx2lib/examples/lights/.gitignore create mode 100644 Firmware/fx2lib/examples/lights/Makefile create mode 100644 Firmware/fx2lib/examples/lights/lights.c create mode 100644 Firmware/fx2lib/examples/reset/Makefile create mode 100644 Firmware/fx2lib/examples/reset/fx2_c0.c create mode 100644 Firmware/fx2lib/examples/reset/reset.c create mode 100644 Firmware/fx2lib/examples/serial/Makefile create mode 100644 Firmware/fx2lib/examples/serial/serial.c create mode 100644 Firmware/fx2lib/examples/timers/.gitignore create mode 100644 Firmware/fx2lib/examples/timers/Makefile create mode 100644 Firmware/fx2lib/examples/timers/timers.c create mode 100644 Firmware/fx2lib/examples/usbmon_c/Makefile create mode 100755 Firmware/fx2lib/examples/usbmon_c/download.sh create mode 100644 Firmware/fx2lib/examples/usbmon_c/dscr.a51 create mode 100644 Firmware/fx2lib/examples/usbmon_c/test.c create mode 100644 Firmware/fx2lib/examples/usbmon_c/usbmon.c create mode 100644 Firmware/fx2lib/fw/.gitignore create mode 100644 Firmware/fx2lib/fw/Makefile create mode 100644 Firmware/fx2lib/fw/device.c create mode 100644 Firmware/fx2lib/fw/dscr.a51 create mode 100644 Firmware/fx2lib/fw/fw.c create mode 100644 Firmware/fx2lib/fw/readme.txt create mode 100644 Firmware/fx2lib/include/autovector.h create mode 100644 Firmware/fx2lib/include/delay.h create mode 100644 Firmware/fx2lib/include/eputils.h create mode 100644 Firmware/fx2lib/include/fx2ints.h create mode 100644 Firmware/fx2lib/include/fx2macros.h create mode 100644 Firmware/fx2lib/include/fx2regs.h create mode 100644 Firmware/fx2lib/include/fx2types.h create mode 100644 Firmware/fx2lib/include/gpif.h create mode 100644 Firmware/fx2lib/include/i2c.h create mode 100644 Firmware/fx2lib/include/lights.h create mode 100644 Firmware/fx2lib/include/serial.h create mode 100644 Firmware/fx2lib/include/setupdat.h create mode 100755 Firmware/fx2lib/utils/gpif2dat create mode 100755 Firmware/fx2lib/utils/ihx2iic.py create mode 100755 Firmware/fx2lib/utils/ihx2iic_2.py rename {PyHT6022/Firmware => Firmware}/modded/dis51lst.sh (100%) rename {PyHT6022/Firmware => Firmware}/modded/fixfiforeset.asm (100%) rename {PyHT6022/Firmware => Firmware}/modded/fixfiforeset.hex (100%) rename {PyHT6022/Firmware => Firmware}/modded/isodiff.asm (100%) rename {PyHT6022/Firmware => Firmware}/modded/isodiff.hex (100%) rename {PyHT6022/Firmware => Firmware}/modded/lsusb_mod.lst (100%) rename {PyHT6022/Firmware => Firmware}/modded/mod_fw_01.a51 (100%) rename {PyHT6022/Firmware => Firmware}/modded/mod_fw_01.ihex (100%) rename {PyHT6022/Firmware => Firmware}/modded/mod_fw_01.lst (100%) rename {PyHT6022/Firmware => Firmware}/modded/mod_fw_01.map (100%) rename {PyHT6022/Firmware => Firmware}/modded/mod_fw_iso.ihex (100%) rename {PyHT6022/Firmware => Firmware}/modded/samplerates.asm (100%) rename {PyHT6022/Firmware => Firmware}/modded/samplerates.hex (100%) rename {PyHT6022/Firmware => Firmware}/stock/dis51lst.sh (100%) rename {PyHT6022/Firmware => Firmware}/stock/stock_fw.a51 (100%) rename {PyHT6022/Firmware => Firmware}/stock/stock_fw.ihex (100%) rename {PyHT6022/Firmware => Firmware}/stock/stock_fw.lst (100%) rename {PyHT6022/Firmware => Firmware}/stock/stock_fw.md (100%) delete mode 100644 PyHT6022/Firmware/DDS120/dds120-firmware.hex delete mode 100644 PyHT6022/Firmware/DSO6021/dso6021-firmware.hex delete mode 100644 PyHT6022/Firmware/DSO6022BE/dso6022be-firmware.hex delete mode 100644 PyHT6022/Firmware/DSO6022BL/dso6022bl-firmware.hex create mode 100644 PyHT6022/Firmware/HEX/dds120-firmware.hex create mode 100644 PyHT6022/Firmware/HEX/dso6021-firmware.hex create mode 100644 PyHT6022/Firmware/HEX/dso6022be-firmware.hex create mode 100644 PyHT6022/Firmware/HEX/dso6022bl-firmware.hex create mode 100644 PyHT6022/Firmware/HEX/mod_fw_01.ihex create mode 100644 PyHT6022/Firmware/HEX/mod_fw_iso.ihex create mode 100644 PyHT6022/Firmware/HEX/stock_fw.ihex delete mode 100644 PyHT6022/Firmware/firmware_packet_dump.csv delete mode 160000 PyHT6022/Firmware/fx2lib delete mode 100644 PyHT6022/Firmware/modded/dis51-0.5.diff create mode 100755 examples/upload_6022BL_firmware_to_6022BE.py create mode 100644 setup.cfg diff --git a/CHANGELOG b/CHANGELOG index 0276122..73b6088 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +2024-02-23: rework the serial number routine [1c46ba5] 2024-02-20: Merge branch 'main' of github.com:Ho-Ro/Hantek6022API [c8cee4c] 2024-02-20: add warning to dangerous example program reset_eeprom_6022.py [d1ad1a0] 2023-11-05: Merge pull request #22 from BMecke/main [cde80ef] diff --git a/PyHT6022/Firmware/DDS120/Makefile b/Firmware/DDS120/Makefile similarity index 100% rename from PyHT6022/Firmware/DDS120/Makefile rename to Firmware/DDS120/Makefile diff --git a/Firmware/DDS120/dds120-firmware.hex b/Firmware/DDS120/dds120-firmware.hex new file mode 100644 index 0000000..d144b96 --- /dev/null +++ b/Firmware/DDS120/dds120-firmware.hex @@ -0,0 +1,288 @@ +:04000000020059326F +:01000B0032C2 +:0100130032BA +:01001B0032B2 +:0100230032AA +:03002B0002027B53 +:030033000201B215 +:01003B003292 +:03004300023F0079 +:01004B003282 +:03005300023F0069 +:1C00B200750800750900750A02750B00750CF4750D01750EF4750F01C200C201BD +:0300E000020056C5 +:030056000208811C +:2000E300E582FF30E00543B108800353B1F7EF30E40543B101800353B1FE75820122E58205 +:20010300FF70407E0EE4FDFC7401B51802801C7402B5180280197405B518028016740AB5F5 +:20012300180280137414B5181680107B0280647B0680607B00805C7B0480587B08805475D8 +:20014300820022BF01497E307D027401B51802801C7402B51802801B7405B51802801A74AC +:200163000AB5180280197414B5182080187B007C0280207B107C02801A7B007C0080147BBB +:20018300107C00800E7B207C0080087582002275820022EEF4FFE5A05207EE5B4FF5A0ED98 +:2001A300F4FFE5B15207ED5C4FF5B175820122C2DC32C0E0C082C083D2005391EF90E65D95 +:2001C3007401F0D083D082D0E032C021C0E0C0F0C082C083C007C006C005C004C003C002DF +:2001E300C001C000C0D075D0007582001211BA5391EF90E65D7410F0D0D0D000D001D002A5 +:20020300D003D004D005D006D007D083D082D0F0D0E0D02132C021C0E0C0F0C082C083C004 +:2002230007C006C005C004C003C002C001C000C0D075D0007582011211BA5391EF90E65D0F +:200243007420F0D0D0D000D001D002D003D004D005D006D007D083D082D0F0D0E0D02132A3 +:20026300C0E0C082C083D2015391EF90E65D7408F0D083D082D0E03263B104C2CF32850A80 +:2002830018751900905DC012157DAE82AF83AC097D00C3EC9EED64808FF063F08095F0409B +:2002A3000990E640E053E07FF02290E640E043E080F02285820A7401B50A0280057402B596 +:2002C3000A18AF0A74072FF50B90E618F090E61AE50BF0120281758201227582002290E66A +:2002E300F574FFF000000000E5BB30E7FB90E6047480F00000000090E618E4F00000000031 +:2003030090E61AE4F00000000090E6047402F00000000090E6047406F00000000090E61824 +:20032300E50BF00000000090E61AE50BF00000000090E604E4F02290E6F574FFF00000002C +:2003430000E50870057E06FF80047E027F0090E648EEF022D2871202E17EE87F031EBEFF63 +:20036300011FEE4F70F7E5BB30E7FB0000000090E6D07428F00000000090E6D1E4F0E5082A +:2003830070057E06FF80047E047F008EBB22AF8290E680E030E7067D1C7E3D80047DA67ED5 +:2003A3003DEF75F010A42416FBE435F0FCEB2DFDEC3EFC7E80EFF508703590E612E4F09005 +:2003C300E61474E0F090E6E27401F08D828C838EF012156090E625F074012DFAE43CFB8E2C +:2003E300078A828B838FF012156090E624F02290E61274D8F090E614E4F090E6D204F08D3C +:20040300828C838EF012156090E621F00DBD00010C8D828C838EF0121560FF90E6207407B2 +:200423005FF08D828C838EF0121560C423541F90E64004F0020281AF827E00EE75F005A413 +:20044300FCADF02489F582ED3419F583E493FBB5070280080EBE19E375820022EC2489FCFC +:20046300ED3419FD8C828D83A3A3A3A3E49390E601F08C828D83A3E493FDA3E493FEA3E4E6 +:2004830093FF75AF07759DE4759E007C208C031CEB60168D828E838FF0121560FBA3AD82F8 +:2004A300AE8390E67CEBF080E47F608F061FEE600790E67CE4F080F375820122E582FF70C6 +:2004C300087B64FCFDFE02054CEF249B401D8F18751900751A00751B009003E8E4F5F01233 +:2004E30012FAAB82AC83ADF0FE805EBF670A7B207C007D007E008051EF243740288F017A49 +:2005030000E9249CF9EA34FF8918F5193395E0F51AF51B90000AE4F5F01212FAAB82AC83C6 +:20052300ADF0FE80247A00EF2438FFEA34FF8F18F5193395E0F51AF51B900064E4F5F0124D +:2005430012FAAB82AC83ADF0FEC3EB9420EC9400ED9400EE64809480401474A09B74869CB3 +:2005630074019D74808EF063F08095F0500475820022751802E4F519F51AF51B8B828C8373 +:200583008DF0EEC006C005C004C003121398A882A983D003D004D005D006880C890D8B823F +:2005A3008C838DF0EE120DDDAC82AD83AEF0FFC004C005C006C00790240075F0F474C91255 +:2005C300149DAC82AD83AEF0FFE58124FCF5818C828D838EF0EF120E0AAC82AD838CCA8D7A +:2005E300CB75820122AD18AE19AF1A8D828E838FF0E5081212DC75820122E58270068510A6 +:200603008212039175820122758200227582012290E6BBE0FE7F0090E6BAE07C004207EC13 +:20062300420690E6BFE0FC7D0090E6BEE07A004205EA420490E6A0E020E1F990E6B8E0FBE3 +:20064300BB40028073BBC0028003020714ED4C7003020718C374409DE49C50067A407B009E +:2006630080048D028C0390E6A0E020E1F98A457546007547407548E77549008F438E4475E4 +:200683008251C007C006C005C004C002120D14D002D004D005D006D00790E68AE4F000007D +:2006A300000090E68BEAF07B00EDC39AFDEC9BFCEA2FFFEB3EFE8095ED4C605990E68BE4EC +:2006C300F090E6A0E020E1F990E68BE0FB8B38753900753A40753BE7753C008F368E3775B4 +:2006E3008251C007C006C005C004C003120C7FE582D003D004D005D006D0077003F5822212 +:200703007A00EB2FFFEA3EFEEDC39BFDEC9AFC80A7758200227582012275820022AF82C0EF +:200723000712033AD00700850C0E850D0FBFE0004015EF2419401090E68AE4F090E68BF014 +:2007430090E6A0E020E1F9BFA2028023BFE0028021BFE1028028BFE202802FBFE30280336B +:20076300BFE4028043BFE5028047BFE656804B02061390E740E0F51875820002010190E7AA +:2007830040E0F51875820102010190E740E0F58202043A90E740E0FFBF010900E4F50EF5A4 +:2007A3000F1203577582012290E740E0F5820202B690E740E0F5820200E390E740E0F582D8 +:2007C3000204BF7582002290E613E4F090E615F0D28790E6C2E4F090E6C37480F090E6C0A8 +:2007E300E4F090E6F4F012033A751801758200120101751801758201120101758201120438 +:200803003A7582021202B675820002039174022408FEE4343EFF7D068D041DEC605FED2469 +:2008230007F582E434E5F583E0FC53040F7B00EC2406F582EB341AF583E4938E828F83F03E +:2008430074012EFBE43FFC8B828C83E4F00BBB00010CED2407F582E434E5F583E0C4540F0A +:20086300901A0693FA8B828C83F00BBB00010C8B828C83E4F0042BFEE43CFF809B2290E66A +:2008830000E054E74410F01208101207CAD2E890E668E043E008F090E65CE043E001F09000 +:2008A300E65CE043E010F090E65CE043E020F090E65CE043E008F0D2DDD2AF75CA3075CB5F +:2008C300F875C800D2ADD2CA90E680E043E00AF09005DC1213F790E680E053E0F7F090E6DF +:2008E30072E4F090E671F090E670F075B109F5A0F58075B6FF75B4FF75B2FF0010000280BF +:2009030003120E6510010280F390E682E043E0C0F090E6817401F0438701000000000000F4 +:2009230000E513701C90E682E030E60790E682E020E0D690E682E030E70790E682E020E1BE +:20094300C890E682E030E60790E682E020E00E90E682E030E7A690E682E030E19F9000053F +:1C0963001213F790E680E043E001F090000F1213F790E680E053E0FEF00208FFB7 +:201669000F0E00000000000002000100000000005055550000000000000000000000000047 +:20168900010100000000000002000100000000005055550000000000000000000000000042 +:2016A900FAFAFAFAFAF90000020000000000010050555555555555000000000000000000F5 +:2016C900FAFAFAFAFAF90000020000000000010050555555555555000000000000000000D5 +:2016E900FAFAF90000000000020000010000000050555555000000000000000000000000A2 +:20170900C8C8C7000000000002000001000000005055555500000000000000000000000017 +:20172900FAFAF9000000000002000001000000005055555500000000000000000000000061 +:20174900969500000000000002000100000000005055550000000000000000000000000058 +:20176900BBBB000000000000020001000000000050555500000000000000000000000000ED +:20178900020100000000000002000100000000005055550000000000000000000000000040 +:2017A9004B4A0000000000000200010000000000505555000000000000000000000000008E +:2017C9002525000000000000020001000000000050555500000000000000000000000000B9 +:2017E900010000000000000002010000000000005055000000000000000000000000000037 +:201809001E1D00000000000002000100000000005055550000000000000000000000000087 +:201829000101000000000000020001000000000050555500000000000000000000000000A0 +:20184900252500000000000002000100000000005055550000000000000000000000000038 +:20186900070700000000000002000100000000005055550000000000000000000000000054 +:20188900010000000000000002010000000000005055000000000000000000000000000096 +:2018A900050400000000000002000100000000005055550000000000000000000000000019 +:2018C90080000000000000000300000000000000000000000000000000000000000000007C +:2018E9000605000000000000020001000000000050555500000000000000000000000000D7 +:2019090080000000000000000300000000000000000000000000000000000000000000003B +:2019290003020000000000000200010000000000505555000000000000000000000000009C +:2019490002020000000000000200010000000000505555000000000000000000000000007D +:2019690003020000000000000200010000000000505555000000000000000000000000005C +:2019890030091980EA1EC91880AA18891880CA10291880CA0FE917808A0C891780CA0A8919 +:2019A90016808A08691980CA064919808A052919808A04E91880CA03A918808A0269188047 +:2019C9008A016916808AA44918808A960918808A8CC917808A78A917808A71691780CA6EB9 +:2019E9004917808A6A291780CA690917808A68E916808A67C91680CA66A916808A3031322A +:0D1A090033343536373839414243444546C1 +:203D000012010002FFFFFF40B50420011002010203010A0600020000004001000902890077 +:203D200001010080FA0904000001FF000000070586020002000904000101FF000100070549 +:203D400082010014010904000201FF00010007058201000C010904000301FF000100070502 +:203D600082010004010904000401FF000100070582010004020904000501FF0001000705F5 +:203D800082010004030904000601FF000100070582010004040904000701FF0001000705CD +:053DA000820100020495 +:203DA6000902390002010080FA0904000001FF000000070586024000000904000101FF004D +:193DC600010007058201FF03010904000201FF00010007058201000201AF +:203DE0000403090416034F00700065006E00480061006E00740065006B000E034400440010 +:203E000053003100320030001A03300030003000300030003000300030003000300030008F +:043E2000300000006E +:20097F0085822CE5272522FDE5283523FE752D02903C00E4F0903C00E06004758200229075 +:20099F00E678E0FB7A0043038090E678EBF0E030E21090000AC006C0051213F7D005D00608 +:2009BF0080D3E52C25E0FB90E679F090E678E020E006903C00E060F3903C00E060047582FB +:2009DF00002290E678E020E2AC90E678E020E14090E678E0FB43034090E678EBF090E67845 +:2009FF00E030E606903C00E060F3903C00E0600475820022E52D14FB8B2D7003F58222903F +:200A1F00000AC006C0051213F7D005D0060209947A007B00C3EA9DEB9E4003020AC9C3EA2F +:200A3F009522EB95235016EA2524F8EB3525F9AC26888289838CF0121560FC801DEAC395A8 +:200A5F0022F8EB9523F9E82529F8E9352AF9AF2B888289838FF0121560FC90E679ECF00A8B +:200A7F00BA00010B90E678E020E006903C00E060F3903C00E060047582002290E678E03097 +:200A9F00E20302099490E678E020E18890E678E0FF43074090E678EFF090E678E030E6064E +:200ABF00903C00E060F37582002290E678E0FF43074090E678EFF090E678E030E606903C25 +:200ADF0000E060F3903C00E060047582002275820122858233903C00E4F004B52E0814B5EF +:200AFF002F0474018001E4FE903C00E06004758200227C007D0090E678E0FB43038090E6A5 +:200B1F0078EBF0E030E20C90000AC0061213F7D00680D5E53325E0FB3395E0FA430301902D +:200B3F00E679EBF090E678E020E006903C00E060F3903C00E060047582002290E678E02072 +:200B5F00E2A690E678E020E11E90E678E0FB43034090E678EBF090E678E030E606903C0033 +:200B7F00E060F375820022EE600F90E678E0FB7A0043032090E678EBF090E679E0E4F5345F +:200B9F00F53574012534F8E43535F9C3E8952EE9952F506C90E678E020E006903C00E06048 +:200BBF00F3903C00E060047582002290E678E030E203020B0774022534F8E43535F9E8B558 +:200BDF002E13E9B52F0F90E678E0F8790043002090E678E8F0A834A9350534E4B5340205AA +:200BFF0035AC34AD35E82530F8E93531F9AF3290E679E0FB888289838FF01212DC020BA174 +:200C1F0090E678E020E006903C00E060F3903C00E060047582002290E678E030E203020BC9 +:200C3F000790E678E0FF43074090E678EFF0EC2530FCED3531FDAF3290E679E08C828D830F +:200C5F008FF01212DC90E678E030E606903C00E060F3903C00E060047582002275820122CA +:200C7F0085823DE4F541F542AB36AC37C3E5419538E54295394003020D107A0090E678E0A7 +:200C9F0030E4067A018C078F3EEA04FFEA243EF98B02A702EF04FAEF243EF9AE41AF4205BC +:200CBF0041E4B541020542EE253AFEEF353BFFAD3C8E828F838DF0121560F78A22752300BE +:200CDF0075243E752500752640E4F527F528F529F52AF52B853D82C004C00312097FE58263 +:200CFF00D003D0047003F582220BBB00010C020C8B75820122AF827E0090E678E030E40605 +:200D1F007E01AD448D4AEE04FDEE244AF9AE43A7068D2275230075244A752500752640E408 +:200D3F00F527F528F529F52AF52B8F82C00712097FE582D0077003F5822285452E85462F50 +:190D5F008547308548318549328F82120AF1E5827003F5822275820122D6 +:200D7800FB7A20E4FCFDFEFFE5822582F582E58333F583E5F033F5F0EB33FB4017DAE980B4 +:200D980042E5822582F582E58333F583E5F033F5F0EB33FBEC33FCED33FDEE33FEEF33FFE3 +:200DB800EC9518ED9519EE951AEF951B4013EC9518FCED9519FDEE951AFEEF951BFF43822D +:050DD80001DABEEB2270 +:06008800E478FFF6D8FD4C +:200DDD00FCABF0AA83A982749EF582C2D1EC30E716D2D1E9F42401F9EAF43400FAEBF43415 +:0D0DFD0000FBECF43400FC12162E02144D25 +:200E0A001212CAC3749E9582403979001215EB30D126E9F42401F582EAF43400F583EBF4E1 +:200E2A003400F5F0ECF43400700AE582458345F0700122E430E70F22EC20E71489828A83BF +:1B0E4A008BF02230D10AE4F582F583F5F074802274FFF582F583F5F0747F22BB +:1200CE007512007513007514A675153D75161C75173DAB +:200E650090E6B9E0FF24F45003020F93EF240A83F582EF241083F583E47397B393CF9393F2 +:200E8500EB93FB12346E0E0E0F0E0F0F0E0F0E0F0F0F121015E5826003020FAF90E6A0E0BA +:200EA500FF7E0043070190E6A0EFF0020FAF1210A9E5826003020FAF90E6A0E0FF7E0043A5 +:200EC500070190E6A0EFF0020FAF121124E5826003020FAF90E6A0E0FF7E0043070190E64B +:200EE500A0EFF0020FAF12071CE5826003020FAF1211E5020FAF12060BAF8290E740EFF03D +:200F050090E68AE4F090E68B04F0020FAF90E6BAE0F58212060FE5826003020FAF90E6A0F5 +:200F2500E0FF7E0043070190E6A0EFF0020FAF90E6BCE0FF751811751900751A408F821220 +:200F450005E8E582701190E6A0E0FF7E0043070190E6A0EFF0805390E740E511F090E68A94 +:200F6500E4F090E68B04F0804190E6BCE0FF90E6BAE0F5108F821205FDE582702D90E6A07D +:200F8500E0FF7E0043070190E6A0EFF0801C90E6B9E0F582120720E582700F90E6A0E0FF79 +:200FA5007E0043070190E6A0EFF090E6A0E0FF43078090E6A0EFF022AF82747F5FFE24F7FC +:200FC5005003021011EE240A83F582EE240D83F583E473EAEE0111051109110D0F0F1010AA +:200FE500101010101090E6A022EF30E7067EA27FE680047EA17FE68E828F832290E6A3224C +:2010050090E6A42290E6A52290E6A6229000002290E6B8E0FFBF80028022BF81028008BFE9 +:20102500820280370210A190E740E4F090E741F090E68AF090E68B7402F08064E51325E052 +:20104500FFE512420790E740EFF090E741E4F090E68AF090E68B7402F0804590E6BCE0F507 +:2010650082120FBDAE82AF838E048F05EE4F7003F582228C828D83E0FC30E0067E017F002C +:2010850080047E007F0090E740EEF090E741E4F090E68AF090E68B7402F0800475820022B5 +:2010A5007582012290E6B8E0FF6005BF0264801B90E6BAE0FFBF0105751300805E90E6BA75 +:2010C500E0FFBF060280547582002290E6BAE0703D90E6BCE0F582120FBDAE82AF83E0FD15 +:2010E5005305FE8E828F83EDF090E6BCE0FF30E7098F057E004305108D0753071F90E683F5 +:20110500EFF07E0043072090E683EFF0800D7582002290E6B9E0F58202072075820122902C +:20112500E6B8E0FF6008BF020280290211AD90E6BAE0FFBF02030211B690E6BAE0FFBF012E +:2011450005751301806B90E6BAE0FFBF060280617582002290E6BAE0704A90E6BCE0F582EE +:20116500120FBDAE82AF83EE4F7003F582228E828F83E0FD7C004305018E828F83EDF0908E +:20118500E6BCE0FF30E7098F057E004305108D0753071F90E683EFF07E0043072090E68379 +:2011A500EFF0800D7582002290E6B9E0F58202072075820122AF827E0110AF027E00EF609E +:2011C5000E75141C75153D7516A675173D800C7514A675153D75161C75173DEE1392AF2240 +:2011E50090E6BBE0FFBF01028019BF02028024BF0302802CBF060302129FBF07030212AFA1 +:201205000212BC7E007F3D90E6B3EFF090E6B47400F02290E6B3E515F090E6B4E514F022BF +:201225007DE07E3D7F8090E6BAE0F5187B008B020BEAB5180280428D008E018F028D828E9D +:20124500838FF012156028F8E439F9880589068A0774012DF9E43EFA8F0489828A838CF03F +:20126500121560F9B9030280067D007E007F00ED4E6006C3E5189B50B5ED4E600F8D038E62 +:201285000490E6B3ECF090E6B4EDF02290E6A0E0FF43070190E6A0EFF0227E127F3D90E6FE +:2012A500B3EFF090E6B47412F02290E6B3E517F090E6B4E516F02290E6A0E0FF43070190B9 +:0512C500E6A0EFF0229D +:200066007900E94400601B7A00901A16780175923CE493F2A308B800020592D9F4DAF275F0 +:0200860092FFE7 +:1212CA00AA82AB83A2F73392D1F5826002D2F7ACF02229 +:1B12DC0020F71130F6138883A88220F509F6A8837583002280FEF280F5F02211 +:203F00000201B500021667000215B800020263000201CD00020218000215B5000213EB007C +:203F20000213ED000213EE000213EF000213F20002166600021668000212F7000212F9005B +:203F40000215BA000213EB0002157C000215B6000215B7000215B9000215BB000215EA00BF +:203F600002149C000213EB000213EB000213EB000213EC000213F0000213F3000213F50077 +:203F80000213F1000213F4000213F60002144C00021368000213930002139500021397002A +:183FA0000213690002139400021396000213EA000212F80002166500AF +:0112F70032C4 +:0112F80032C3 +:0112F90032C2 +:2012FA00AAF0FBE5828518F0A4FCADF0E5838518F0A42DFDE435F0FEE5828519F0A42DFD81 +:20131A00E5F03EFEE433FFEA8518F0A42EFEE5F03FFFE5838519F0A42EFEE5F03FFFE582F2 +:20133A00851AF0A42EFEE5F03FFFEB8518F0A42FFFEA8519F0A42FFFE583851AF0A42FFFC4 +:0E135A00E582851BF0A42F8EF08D838C8222FD +:011368003252 +:011369003251 +:20008E007800E84400600A790075923CE4F309D8FC7801E84400600C7901903C00E4F0A306 +:0400AE00D8FCD9FAA7 +:20136A007A10E4FBFCE58225E0F582E58333F583EB33FBEC33FCEB9518F5F0EC9519400677 +:09138A00FCABF0438201DADD2224 +:011393003227 +:011394003226 +:011395003225 +:011396003224 +:011397003223 +:20139800FBC2D530E715D2D5E4C39582F582E49583F583E495F0F5F0E49BFBE51B30E71731 +:2013B800B2D5E4C39518F518E49519F519E4951AF51AE4951BF51BEB120D7830D513FBE4CE +:1213D800C39582F582E49583F583E495F0F5F0E49B224F +:0113EA0032D0 +:0113EB0032CF +:0113EC0032CE +:0113ED0032CD +:0113EE0032CC +:0113EF0032CB +:0113F00032CA +:0113F10032C9 +:0113F20032C8 +:0113F30032C7 +:0113F40032C6 +:0113F50032C5 +:0113F60032C4 +:2013F700AE82AF8390E600E05418C423541F70057CB1FD801C90E600E05418C423541FFB06 +:20141700BB01067A617B0180047AC27B028A048B058C188D19151874FFB518021519E5185D +:15143700451970F1EE24FFFAEF34FFFB8A068B07EA4B70DD22F3 +:01144C00326D +:20144D00B98003EA13B34010EA2401FAE43BFBE43CFC50047C800582BC000EBB000BBA00E3 +:20146D0008E4F5F0F583F58222A2D1E582138CF092F78B838A8222E4F583F58275F080F4A3 +:0F148D00A2D11322E4F583F58275F0C0747F229B +:01149C00321D +:20149D001215BC30D502B2D1BF0009BC0003021491021484BC000302146EE583B4FF0BE5AC +:2014BD0082B4FF0302149102146EE582B4FF03021484C395835007247F400B02146E2480AD +:2014DD00145003021484F582C3ED9AEE9BEF9C40111582C3EA33F9EB33FAEC33FBE433FC13 +:2014FD008005E4CCCBCAF9C08275F019C3E99DEA9EEB9FEC9400D5F002802D400EE99DF930 +:20151D00EA9EFAEB9FFBEC9400FCC3B3E833F8E58233F582E58333F583C3E933F9EA33FA8F +:20153D00EB33FBEC33FC80C4B3E4F938FAE43582FBE43583FCD082500405827C8012162EA7 +:03155D0002146510 +:0D00590075814B121661E5826003020056AE +:1C15600020F71430F6148883A88220F507E6A88375830022E280F7E49322E0229A +:01157C00323C +:20157D00C2D5E58330E70DD2D5E4C39582F582E49583F583E51930E70DB2D5E4C39518F5E9 +:18159D0018E49519F51912136A30D50BE4C39582F582E49583F5832214 +:0115B5003203 +:0115B6003202 +:0115B7003201 +:0115B8003200 +:0115B90032FF +:0115BA0032FE +:0115BB0032FD +:2015BC00AA82AB83A2F73392D1F5826002D2F7ACF0E58124F9F8E6FD08E6FE0886F008E692 +:0E15DC00A2F73392D5F5836002D2F7AFF0226A +:0115EA0032CE +:2015EB006040F82582500274FFF582E824F8501ECCCBCAF9E4CC24F85014CBCAF9E4CB2408 +:20160B00F8500BCAF9E4CA24F8500379002224086010F8C3EC13FCEB13FBEA13FAE913F9BA +:03162B00D8F122D1 +:20162E007804EC7011E58224F8500AF582E4C9CACBFCD8EF22EC7820058220E713D58201BB +:13164E0022C3E933F9EA33FAEB33FBEC33FCD8EA158222C9 +:04166100758200226C +:011665003252 +:011666003251 +:011667003250 +:01166800324F +:00000001FF diff --git a/PyHT6022/Firmware/DDS120/dds120.c b/Firmware/DDS120/dds120.c similarity index 100% rename from PyHT6022/Firmware/DDS120/dds120.c rename to Firmware/DDS120/dds120.c diff --git a/PyHT6022/Firmware/DDS120/descriptor.asm b/Firmware/DDS120/descriptor.asm similarity index 100% rename from PyHT6022/Firmware/DDS120/descriptor.asm rename to Firmware/DDS120/descriptor.asm diff --git a/PyHT6022/Firmware/DDS120/fl_fw.sh b/Firmware/DDS120/fl_fw.sh similarity index 100% rename from PyHT6022/Firmware/DDS120/fl_fw.sh rename to Firmware/DDS120/fl_fw.sh diff --git a/PyHT6022/Firmware/DSO6021/Makefile b/Firmware/DSO6021/Makefile similarity index 100% rename from PyHT6022/Firmware/DSO6021/Makefile rename to Firmware/DSO6021/Makefile diff --git a/PyHT6022/Firmware/DSO6021/descriptor.asm b/Firmware/DSO6021/descriptor.asm similarity index 100% rename from PyHT6022/Firmware/DSO6021/descriptor.asm rename to Firmware/DSO6021/descriptor.asm diff --git a/Firmware/DSO6021/dso6021-firmware.hex b/Firmware/DSO6021/dso6021-firmware.hex new file mode 100644 index 0000000..752f4d1 --- /dev/null +++ b/Firmware/DSO6021/dso6021-firmware.hex @@ -0,0 +1,285 @@ +:04000000020059326F +:01000B0032C2 +:0100130032BA +:01001B0032B2 +:0100230032AA +:03002B00020219B5 +:0300330002015077 +:01003B003292 +:03004300023F0079 +:01004B003282 +:03005300023F0069 +:1C00B200750800750900750A02750B00750CF4750D01750EF4750F01C200C201BD +:0300E000020056C5 +:0300560002081984 +:2000E300E582FF30E0055380FB8003438004EF30E4055380BF800343804075820122AF82FF +:200103007401B5180280157402B5180280127405B51802800F740AB51812800C7E2280103C +:200123007E11800C7E0080087E33800475820022EF60067D307F0080047D037F00EDF4FF69 +:20014300E5805207ED5E4FF58075820122C2DC32C0E0C082C083D2005391EF90E65D7401D3 +:20016300F0D083D082D0E032C021C0E0C0F0C082C083C007C006C005C004C003C002C001F3 +:20018300C000C0D075D00075820012114E5391EF90E65D7410F0D0D0D000D001D002D0035F +:2001A300D004D005D006D007D083D082D0F0D0E0D02132C021C0E0C0F0C082C083C007C071 +:2001C30006C005C004C003C002C001C000C0D075D00075820112114E5391EF90E65D74200F +:2001E300F0D0D0D000D001D002D003D004D005D006D007D083D082D0F0D0E0D02132C0E0F8 +:20020300C082C083D2015391EF90E65D7408F0D083D082D0E032B287C2CF32850A187519B9 +:2002230000905DC0121511AE82AF83AC097D00C3EC9EED64808FF063F08095F0400990E68E +:2002430040E053E07FF02290E640E043E080F02285820A7401B50A0280057402B50A18AFA4 +:200263000A74072FF50B90E618F090E61AE50BF012021E758201227582002290E6F574FF96 +:20028300F000000000E5BB30E7FB90E6047480F00000000090E618E4F00000000090E61A69 +:2002A300E4F00000000090E6047402F00000000090E6047406F00000000090E618E50BF035 +:2002C3000000000090E61AE50BF00000000090E604E4F02290E6F574FFF000000000E50880 +:2002E30070057E06FF80047E027F0090E648EEF02212027E7EE87F031EBEFF011FEE4F70A0 +:20030300F7E5BB30E7FB0000000090E6D07428F00000000090E6D1E4F0E50870057E06FF5F +:2003230080047E047F008EBB22AF8290E680E030E7067D1C7E3D80047DA67E3DEF75F0108C +:20034300A42416FBE435F0FCEB2DFDEC3EFC7E80EFF508703590E612E4F090E61474E0F0C8 +:2003630090E6E27401F08D828C838EF01214F490E625F074012DFAE43CFB8E078A828B8316 +:200383008FF01214F490E624F02290E61274D8F090E614E4F090E6D204F08D828C838EF01B +:2003A3001214F490E621F00DBD00010C8D828C838EF01214F4FF90E62074075FF08D828C12 +:2003C300838EF01214F4C423541F90E64004F002021EAF827E00EE75F005A4FCADF0241D54 +:2003E300F582ED3419F583E493FBB5070280080EBE19E375820022EC241DFCED3419FD8C4C +:20040300828D83A3A3A3A3E49390E601F08C828D83A3E493FDA3E493FEA3E493FF75AF074C +:20042300759DE4759E007C208C031CEB60168D828E838FF01214F4FBA3AD82AE8390E67C5F +:20044300EBF080E47F608F061FEE600790E67CE4F080F375820122E582FF70087B64FCFD69 +:20046300FE0204E7EF249B401D8F18751900751A00751B009003E8E4F5F012128EAB82AC60 +:2004830083ADF0FE805EBF670A7B207C007D007E008051EF243740288F017A00E9249CF9EC +:2004A300EA34FF8918F5193395E0F51AF51B90000AE4F5F012128EAB82AC83ADF0FE8024F6 +:2004C3007A00EF2438FFEA34FF8F18F5193395E0F51AF51B900064E4F5F012128EAB82AC74 +:2004E30083ADF0FEC3EB9420EC9400ED9400EE64809480401474A09B74869C74019D7480F3 +:200503008EF063F08095F0500475820022751802E4F519F51AF51B8B828C838DF0EEC006A8 +:20052300C005C004C00312132CA882A983D003D004D005D006880C890D8B828C838DF0EEC2 +:20054300120D71AC82AD83AEF0FFC004C005C006C00790240075F0F474C9121431AC82AD7B +:2005630083AEF0FFE58124FCF5818C828D838EF0EF120D9EAC82AD838CCA8DCB75820122EE +:20058300AD18AE19AF1A8D828E838FF0E50812127075820122E582700685108212032C751F +:2005A300820122758200227582012290E6BBE0FE7F0090E6BAE07C004207EC420690E6BF94 +:2005C300E0FC7D0090E6BEE07A004205EA420490E6A0E020E1F990E6B8E0FBBB40028073D1 +:2005E300BBC00280030206AFED4C70030206B3C374409DE49C50067A407B0080048D028C1C +:200603000390E6A0E020E1F98A457546007547407548E77549008F438E44758251C007C089 +:2006230006C005C004C002120CA8D002D004D005D006D00790E68AE4F00000000090E68BA3 +:20064300EAF07B00EDC39AFDEC9BFCEA2FFFEB3EFE8095ED4C605990E68BE4F090E6A0E067 +:2006630020E1F990E68BE0FB8B38753900753A40753BE7753C008F368E37758251C007C0A0 +:2006830006C005C004C003120C13E582D003D004D005D006D0077003F582227A00EB2FFFA5 +:2006A300EA3EFEEDC39BFDEC9AFC80A7758200227582012275820022AF82C0071202D7D021 +:2006C30007850C0E850D0FBFE0004015EF2419401090E68AE4F090E68BF090E6A0E020E1A4 +:2006E300F9BFA2028023BFE0028021BFE1028028BFE202802FBFE3028033BFE4028044BF9B +:20070300E5028048BFE657804C0205AE90E740E0F51875820002010190E740E0F518758270 +:200723000102010190E740E0F5820203D590E740E0FFBF010AD283E4F50EF50F1202F475AC +:2007430082012290E740E0F58202025390E740E0F5820200E390E740E0F58202045A758234 +:20076300002290E613E4F090E615F090E6C2F090E6C37480F090E6C0E4F090E6F4F01202BF +:20078300D77518017582001201017518017582011201017582011203D57582021202537595 +:2007A300820002032C7402240CFEE4343EFF7D068D041DEC605FED2407F582E434E5F583AA +:2007C300E0FC53040F7B00EC249AF582EB3419F583E4938E828F83F074012EFBE43FFC8BB7 +:2007E300828C83E4F00BBB00010CED2407F582E434E5F583E0C4540F90199A93FA8B828C4A +:2008030083F00BBB00010C8B828C83E4F0042BFEE43CFF809B2290E600E054E74410F0122F +:2008230007A8120765D2E890E668E043E008F090E65CE043E001F090E65CE043E010F090CA +:20084300E65CE043E020F090E65CE043E008F0D2DDD2AF75CA3075CBF875C800D2ADD2CA44 +:2008630090E680E043E00AF09005DC12138B90E680E053E0F7F090E672E4F090E671F0904E +:20088300E670F0F5B1F5A0F580F5B6F5B475B2FF1000028003120DF910010280F390E682BA +:2008A300E043E0C0F090E6817401F043870100000000000000E513701C90E682E030E607E2 +:2008C30090E682E020E0D690E682E030E70790E682E020E1C890E682E030E60790E682E003 +:2008E30020E00E90E682E030E7A690E682E030E19F90000512138B90E680E043E001F0900B +:10090300000F12138B90E680E053E0FEF002089391 +:2015FD000F0E000000000000020001000000000050555500000000000000000000000000B4 +:20161D000101000000000000020001000000000050555500000000000000000000000000AE +:20163D00FAFAFAFAFAF9000002000000000001005055555555555500000000000000000061 +:20165D00FAFAFAFAFAF9000002000000000001005055555555555500000000000000000041 +:20167D00FAFAF900000000000200000100000000505555550000000000000000000000000E +:20169D00C8C8C7000000000002000001000000005055555500000000000000000000000084 +:2016BD00FAFAF90000000000020000010000000050555555000000000000000000000000CE +:2016DD009695000000000000020001000000000050555500000000000000000000000000C5 +:2016FD00BBBB0000000000000200010000000000505555000000000000000000000000005A +:20171D000201000000000000020001000000000050555500000000000000000000000000AC +:20173D004B4A000000000000020001000000000050555500000000000000000000000000FA +:20175D00252500000000000002000100000000005055550000000000000000000000000025 +:20177D000100000000000000020100000000000050550000000000000000000000000000A3 +:20179D001E1D000000000000020001000000000050555500000000000000000000000000F4 +:2017BD0001010000000000000200010000000000505555000000000000000000000000000D +:2017DD002525000000000000020001000000000050555500000000000000000000000000A5 +:2017FD000707000000000000020001000000000050555500000000000000000000000000C1 +:20181D00010000000000000002010000000000005055000000000000000000000000000002 +:20183D00050400000000000002000100000000005055550000000000000000000000000085 +:20185D008000000000000000030000000000000000000000000000000000000000000000E8 +:20187D00060500000000000002000100000000005055550000000000000000000000000043 +:20189D008000000000000000030000000000000000000000000000000000000000000000A8 +:2018BD00030200000000000002000100000000005055550000000000000000000000000009 +:2018DD000202000000000000020001000000000050555500000000000000000000000000EA +:2018FD000302000000000000020001000000000050555500000000000000000000000000C9 +:20191D00309D1880EA1E5D1880AA181D1880CA10BD1780CA0F7D17808A0C1D1780CA0A1D7B +:20193D0016808A08FD1880CA06DD18808A05BD18808A047D1880CA033D18808A02FD17803F +:20195D008A01FD15808AA4DD17808A969D17808A8C5D17808A783D17808A71FD1680CA6EB1 +:20197D00DD16808A6ABD1680CA699D16808A687D16808A675D1680CA663D16808A30313221 +:0D199D00333435363738394142434445462E +:203D000012010002FFFFFF40B50421601002010203010A0600020000004001000902890017 +:203D200001010080FA0904000001FF000000070586020002000904000101FF000100070549 +:203D400082010014010904000201FF00010007058201000C010904000301FF000100070502 +:203D600082010004010904000401FF000100070582010004020904000501FF0001000705F5 +:203D800082010004030904000601FF000100070582010004040904000701FF0001000705CD +:053DA000820100020495 +:203DA6000902390002010080FA0904000001FF000000070586024000000904000101FF004D +:193DC600010007058201FF03010904000201FF00010007058201000201AF +:203DE0000403090416034F00700065006E00480061006E00740065006B00120344005300FD +:203E00004F002D0036003000320031001A0330003000300030003000300030003000300090 +:083E200030003000300000000A +:2009130085822CE5272522FDE5283523FE752D02903C00E4F0903C00E060047582002290E1 +:20093300E678E0FB7A0043038090E678EBF0E030E21090000AC006C00512138BD005D006E0 +:2009530080D3E52C25E0FB90E679F090E678E020E006903C00E060F3903C00E06004758267 +:20097300002290E678E020E2AC90E678E020E14090E678E0FB43034090E678EBF090E678B1 +:20099300E030E606903C00E060F3903C00E0600475820022E52D14FB8B2D7003F5822290AB +:2009B300000AC006C00512138BD005D0060209287A007B00C3EA9DEB9E4003020A5DC3EAE0 +:2009D3009522EB95235016EA2524F8EB3525F9AC26888289838CF01214F4FC801DEAC39582 +:2009F30022F8EB9523F9E82529F8E9352AF9AF2B888289838FF01214F4FC90E679ECF00A65 +:200A1300BA00010B90E678E020E006903C00E060F3903C00E060047582002290E678E03003 +:200A3300E20302092890E678E020E18890E678E0FF43074090E678EFF090E678E030E60626 +:200A5300903C00E060F37582002290E678E0FF43074090E678EFF090E678E030E606903C91 +:200A730000E060F3903C00E060047582002275820122858233903C00E4F004B52E0814B55B +:200A93002F0474018001E4FE903C00E06004758200227C007D0090E678E0FB43038090E611 +:200AB30078EBF0E030E20C90000AC00612138BD00680D5E53325E0FB3395E0FA4303019006 +:200AD300E679EBF090E678E020E006903C00E060F3903C00E060047582002290E678E020DF +:200AF300E2A690E678E020E11E90E678E0FB43034090E678EBF090E678E030E606903C00A0 +:200B1300E060F375820022EE600F90E678E0FB7A0043032090E678EBF090E679E0E4F534CB +:200B3300F53574012534F8E43535F9C3E8952EE9952F506C90E678E020E006903C00E060B4 +:200B5300F3903C00E060047582002290E678E030E203020A9B74022534F8E43535F9E8B531 +:200B73002E13E9B52F0F90E678E0F8790043002090E678E8F0A834A9350534E4B534020516 +:200B930035AC34AD35E82530F8E93531F9AF3290E679E0FB888289838FF0121270020B35B8 +:200BB30090E678E020E006903C00E060F3903C00E060047582002290E678E030E203020A37 +:200BD3009B90E678E0FF43074090E678EFF0EC2530FCED3531FDAF3290E679E08C828D83E8 +:200BF3008FF012127090E678E030E606903C00E060F3903C00E060047582002275820122A3 +:200C130085823DE4F541F542AB36AC37C3E5419538E54295394003020CA47A0090E678E080 +:200C330030E4067A018C078F3EEA04FFEA243EF98B02A702EF04FAEF243EF9AE41AF420528 +:200C530041E4B541020542EE253AFEEF353BFFAD3C8E828F838DF01214F4F78A2275230097 +:200C730075243E752500752640E4F527F528F529F52AF52B853D82C004C003120913E5823B +:200C9300D003D0047003F582220BBB00010C020C1F75820122AF827E0090E678E030E406DD +:200CB3007E01AD448D4AEE04FDEE244AF9AE43A7068D2275230075244A752500752640E475 +:200CD300F527F528F529F52AF52B8F82C007120913E582D0077003F5822285452E85462F29 +:190CF3008547308548318549328F82120A85E5827003F5822275820122AF +:200D0C00FB7A20E4FCFDFEFFE5822582F582E58333F583E5F033F5F0EB33FB4017DAE98020 +:200D2C0042E5822582F582E58333F583E5F033F5F0EB33FBEC33FCED33FDEE33FEEF33FF4F +:200D4C00EC9518ED9519EE951AEF951B4013EC9518FCED9519FDEE951AFEEF951BFF438299 +:050D6C0001DABEEB22DC +:06008800E478FFF6D8FD4C +:200D7100FCABF0AA83A982749EF582C2D1EC30E716D2D1E9F42401F9EAF43400FAEBF43481 +:0D0D910000FBECF43400FC1215C20213E16B +:200D9E0012125EC3749E95824039790012157F30D126E9F42401F582EAF43400F583EBF426 +:200DBE003400F5F0ECF43400700AE582458345F0700122E430E70F22EC20E71489828A832C +:1B0DDE008BF02230D10AE4F582F583F5F074802274FFF582F583F5F0747F2228 +:1200CE007512007513007514A675153D75161C75173DAB +:200DF90090E6B9E0FF24F45003020F27EF240A83F582EF241083F583E4732B472763272753 +:200E19007F278FA6C8020E0E0F0E0F0F0E0F0E0E0E0F120FA9E5826003020F4390E6A0E089 +:200E3900FF7E0043070190E6A0EFF0020F4312103DE5826003020F4390E6A0E0FF7E004355 +:200E5900070190E6A0EFF0020F431210B8E5826003020F4390E6A0E0FF7E0043070190E6FC +:200E7900A0EFF0020F431206B7E5826003020F43121179020F431205A6AF8290E740EFF025 +:200E990090E68AE4F090E68B04F0020F4390E6BAE0F5821205AAE5826003020F4390E6A0A0 +:200EB900E0FF7E0043070190E6A0EFF0020F4390E6BCE0FF751811751900751A408F8212F9 +:200ED9000583E582701190E6A0E0FF7E0043070190E6A0EFF0805390E740E511F090E68A66 +:200EF900E4F090E68B04F0804190E6BCE0FF90E6BAE0F5108F82120598E582702D90E6A04F +:200F1900E0FF7E0043070190E6A0EFF0801C90E6B9E0F5821206BBE582700F90E6A0E0FF4B +:200F39007E0043070190E6A0EFF090E6A0E0FF43078090E6A0EFF022AF82747F5FFE24F768 +:200F59005003020FA5EE240A83F582EE240D83F583E4737E8295A599A59DA5A10F0F0F0F51 +:200F79000F0F0F0F0F90E6A022EF30E7067EA27FE680047EA17FE68E828F832290E6A322BD +:200F990090E6A42290E6A52290E6A6229000002290E6B8E0FFBF80028022BF81028008BF56 +:200FB9008202803702103590E740E4F090E741F090E68AF090E68B7402F08064E51325E02B +:200FD900FFE512420790E740EFF090E741E4F090E68AF090E68B7402F0804590E6BCE0F574 +:200FF90082120F51AE82AF838E048F05EE4F7003F582228C828D83E0FC30E0067E017F0005 +:2010190080047E007F0090E740EEF090E741E4F090E68AF090E68B7402F080047582002221 +:201039007582012290E6B8E0FF6005BF0264801B90E6BAE0FFBF0105751300805E90E6BAE1 +:20105900E0FFBF060280547582002290E6BAE0703D90E6BCE0F582120F51AE82AF83E0FDED +:201079005305FE8E828F83EDF090E6BCE0FF30E7098F057E004305108D0753071F90E68361 +:20109900EFF07E0043072090E683EFF0800D7582002290E6B9E0F5820206BB7582012290FF +:2010B900E6B8E0FF6008BF0202802902114190E6BAE0FFBF020302114A90E6BAE0FFBF0173 +:2010D90005751301806B90E6BAE0FFBF060280617582002290E6BAE0704A90E6BCE0F5825B +:2010F900120F51AE82AF83EE4F7003F582228E828F83E0FD7C004305018E828F83EDF09067 +:20111900E6BCE0FF30E7098F057E004305108D0753071F90E683EFF07E0043072090E683E5 +:20113900EFF0800D7582002290E6B9E0F5820206BB75820122AF827E0110AF027E00EF6070 +:201159000E75141C75153D7516A675173D800C7514A675153D75161C75173DEE1392AF22AC +:2011790090E6BBE0FFBF01028019BF02028024BF0302802CBF0603021233BF0703021243E5 +:201199000212507E007F3D90E6B3EFF090E6B47400F02290E6B3E515F090E6B4E514F02298 +:2011B9007DE07E3D7F8090E6BAE0F5187B008B020BEAB5180280428D008E018F028D828E0A +:2011D900838FF01214F428F8E439F9880589068A0774012DF9E43EFA8F0489828A838CF019 +:2011F9001214F4F9B9030280067D007E007F00ED4E6006C3E5189B50B5ED4E600F8D038E3C +:201219000490E6B3ECF090E6B4EDF02290E6A0E0FF43070190E6A0EFF0227E127F3D90E66A +:20123900B3EFF090E6B47412F02290E6B3E517F090E6B4E516F02290E6A0E0FF4307019025 +:05125900E6A0EFF02209 +:200066007900E94400601B7A009019AA780175923CE493F2A308B800020592D9F4DAF2755D +:0200860092FFE7 +:12125E00AA82AB83A2F73392D1F5826002D2F7ACF02295 +:1B12700020F71130F6138883A88220F509F6A8837583002280FEF280F5F0227D +:203F0000020153000215FB0002154C000202010002016B000201B6000215490002137F00B6 +:203F2000021381000213820002138300021386000215FA000215FC0002128B0002128D00BD +:203F400002154E0002137F000215100002154A0002154B0002154D0002154F0002157E001F +:203F60000214300002137F0002137F0002137F0002138000021384000213870002138900D7 +:203F8000021385000213880002138A000213E0000212FC00021327000213290002132B008C +:183FA0000212FD000213280002132A0002137E0002128C000215F90039 +:01128B003230 +:01128C00322F +:01128D00322E +:20128E00AAF0FBE5828518F0A4FCADF0E5838518F0A42DFDE435F0FEE5828519F0A42DFDED +:2012AE00E5F03EFEE433FFEA8518F0A42EFEE5F03FFFE5838519F0A42EFEE5F03FFFE5825F +:2012CE00851AF0A42EFEE5F03FFFEB8518F0A42FFFEA8519F0A42FFFE583851AF0A42FFF31 +:0E12EE00E582851BF0A42F8EF08D838C82226A +:0112FC0032BF +:0112FD0032BE +:20008E007800E84400600A790075923CE4F309D8FC7801E84400600C7901903C00E4F0A306 +:0400AE00D8FCD9FAA7 +:2012FE007A10E4FBFCE58225E0F582E58333F583EB33FBEC33FCEB9518F5F0EC95194006E4 +:09131E00FCABF0438201DADD2290 +:011327003293 +:011328003292 +:011329003291 +:01132A003290 +:01132B00328F +:20132C00FBC2D530E715D2D5E4C39582F582E49583F583E495F0F5F0E49BFBE51B30E7179D +:20134C00B2D5E4C39518F518E49519F519E4951AF51AE4951BF51BEB120D0C30D513FBE4A6 +:12136C00C39582F582E49583F583E495F0F5F0E49B22BB +:01137E00323C +:01137F00323B +:01138000323A +:011381003239 +:011382003238 +:011383003237 +:011384003236 +:011385003235 +:011386003234 +:011387003233 +:011388003232 +:011389003231 +:01138A003230 +:20138B00AE82AF8390E600E05418C423541F70057CB1FD801C90E600E05418C423541FFB72 +:2013AB00BB01067A617B0180047AC27B028A048B058C188D19151874FFB518021519E518CA +:1513CB00451970F1EE24FFFAEF34FFFB8A068B07EA4B70DD2260 +:0113E00032DA +:2013E100B98003EA13B34010EA2401FAE43BFBE43CFC50047C800582BC000EBB000BBA0050 +:2014010008E4F5F0F583F58222A2D1E582138CF092F78B838A8222E4F583F58275F080F40F +:0F142100A2D11322E4F583F58275F0C0747F2207 +:011430003289 +:2014310012155030D502B2D1BF0009BC0003021425021418BC0003021402E583B4FF0BE5C8 +:2014510082B4FF03021425021402E582B4FF03021418C395835007247F400B0214022480C9 +:20147100145003021418F582C3ED9AEE9BEF9C40111582C3EA33F9EB33FAEC33FBE433FCEB +:201491008005E4CCCBCAF9C08275F019C3E99DEA9EEB9FEC9400D5F002802D400EE99DF99C +:2014B100EA9EFAEB9FFBEC9400FCC3B3E833F8E58233F582E58333F583C3E933F9EA33FAFC +:2014D100EB33FBEC33FC80C4B3E4F938FAE43582FBE43583FCD082500405827C801215C281 +:0314F1000213F9EA +:0D00590075814B1215F5E58260030200561B +:1C14F40020F71430F6148883A88220F507E6A88375830022E280F7E49322E02207 +:0115100032A8 +:20151100C2D5E58330E70DD2D5E4C39582F582E49583F583E51930E70DB2D5E4C39518F555 +:1815310018E49519F5191212FE30D50BE4C39582F582E49583F58322ED +:01154900326F +:01154A00326E +:01154B00326D +:01154C00326C +:01154D00326B +:01154E00326A +:01154F003269 +:20155000AA82AB83A2F73392D1F5826002D2F7ACF0E58124F9F8E6FD08E6FE0886F008E6FE +:0E157000A2F73392D5F5836002D2F7AFF022D6 +:01157E00323A +:20157F006040F82582500274FFF582E824F8501ECCCBCAF9E4CC24F85014CBCAF9E4CB2474 +:20159F00F8500BCAF9E4CA24F8500379002224086010F8C3EC13FCEB13FBEA13FAE913F927 +:0315BF00D8F1223E +:2015C2007804EC7011E58224F8500AF582E4C9CACBFCD8EF22EC7820058220E713D5820128 +:1315E20022C3E933F9EA33FAEB33FBEC33FCD8EA15822236 +:0415F50075820022D9 +:0115F90032BF +:0115FA0032BE +:0115FB0032BD +:0115FC0032BC +:00000001FF diff --git a/PyHT6022/Firmware/DSO6021/dso6021.c b/Firmware/DSO6021/dso6021.c similarity index 100% rename from PyHT6022/Firmware/DSO6021/dso6021.c rename to Firmware/DSO6021/dso6021.c diff --git a/PyHT6022/Firmware/DSO6021/fl_fw.sh b/Firmware/DSO6021/fl_fw.sh similarity index 100% rename from PyHT6022/Firmware/DSO6021/fl_fw.sh rename to Firmware/DSO6021/fl_fw.sh diff --git a/PyHT6022/Firmware/DSO6022BE/Makefile b/Firmware/DSO6022BE/Makefile similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/Makefile rename to Firmware/DSO6022BE/Makefile diff --git a/PyHT6022/Firmware/DSO6022BE/descriptor.asm b/Firmware/DSO6022BE/descriptor.asm similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/descriptor.asm rename to Firmware/DSO6022BE/descriptor.asm diff --git a/PyHT6022/Firmware/DSO6022BE/descriptor.inc b/Firmware/DSO6022BE/descriptor.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/descriptor.inc rename to Firmware/DSO6022BE/descriptor.inc diff --git a/Firmware/DSO6022BE/dso6022be-firmware.hex b/Firmware/DSO6022BE/dso6022be-firmware.hex new file mode 100644 index 0000000..7072c0d --- /dev/null +++ b/Firmware/DSO6022BE/dso6022be-firmware.hex @@ -0,0 +1,287 @@ +:04000000020059326F +:01000B0032C2 +:0100130032BA +:01001B0032B2 +:0100230032AA +:03002B00020219B5 +:0300330002015077 +:01003B003292 +:03004300023F0079 +:01004B003282 +:03005300023F0069 +:1C00B200750800750900750A02750B00750CF4750D01750EF4750F01C200C201BD +:0300E000020056C5 +:0300560002084657 +:2000E300E582FF30E00543B108800353B1F7EF30E40543B101800353B1FE75820122AF823B +:200103007401B5180280157402B5180280127405B51802800F740AB51812800C7E48801016 +:200123007E24800C7E0080087E6C800475820022EF60067DE07F0080047D1C7F00EDF4FF54 +:20014300E5A05207ED5E4FF5A075820122C2DC32C0E0C082C083D2005391EF90E65D740193 +:20016300F0D083D082D0E032C021C0E0C0F0C082C083C007C006C005C004C003C002C001F3 +:20018300C000C0D075D0007582001211845391EF90E65D7410F0D0D0D000D001D002D00329 +:2001A300D004D005D006D007D083D082D0F0D0E0D02132C021C0E0C0F0C082C083C007C071 +:2001C30006C005C004C003C002C001C000C0D075D0007582011211845391EF90E65D7420D9 +:2001E300F0D0D0D000D001D002D003D004D005D006D007D083D082D0F0D0E0D02132C0E0F8 +:20020300C082C083D2015391EF90E65D7408F0D083D082D0E032C0E0C0D0B287E50E450F3A +:200223006019150E74FFB50E02150FE50E450F700A850C0E850D0FB2A0D2A1C2CFD0D0D0FC +:20024300E032850A18751900905DC0121547AE82AF83AC097D00C3EC9EED64808FF063F0B5 +:200263008095F0400990E640E053E07FF02290E640E043E080F02285820A7401B50A0280C1 +:20028300057402B50A18AF0A74072FF50B90E618F090E61AE50BF01202457582012275824E +:2002A300002290E6F574FFF000000000E5BB30E7FB90E6047480F00000000090E618E4F0D9 +:2002C3000000000090E61AE4F00000000090E6047402F00000000090E6047406F0000000F3 +:2002E3000090E618E50BF00000000090E61AE50BF00000000090E604E4F02290E6F574FFCF +:20030300F000000000E50870057E06FF80047E027F0090E648EEF0221202A57EE87F031E05 +:20032300BEFF011FEE4F70F7E5BB30E7FB0000000090E6D07428F00000000090E6D1E4F09A +:20034300E50870057E06FF80047E047F008EBB22AF8290E680E030E7067D1C7E3D80047D4C +:20036300A67E3DEF75F010A42416FBE435F0FCEB2DFDEC3EFC7E80EFF508703590E612E4A1 +:20038300F090E61474E0F090E6E27401F08D828C838EF012152A90E625F074012DFAE43CAB +:2003A300FB8E078A828B838FF012152A90E624F02290E61274D8F090E614E4F090E6D204A6 +:2003C300F08D828C838EF012152A90E621F00DBD00010C8D828C838EF012152AFF90E6205D +:2003E30074075FF08D828C838EF012152AC423541F90E64004F0020245AF827E00EE75F0F4 +:2004030005A4FCADF02453F582ED3419F583E493FBB5070280080EBE19E375820022EC244E +:2004230053FCED3419FD8C828D83A3A3A3A3E49390E601F08C828D83A3E493FDA3E493FE5E +:20044300A3E493FF75AF07759DE4759E007C208C031CEB60168D828E838FF012152AFBA316 +:20046300AD82AE8390E67CEBF080E47F608F061FEE600790E67CE4F080F375820122E58246 +:20048300FF70087B64FCFDFE02050EEF249B401D8F18751900751A00751B009003E8E4F544 +:2004A300F01212C4AB82AC83ADF0FE805EBF670A7B207C007D007E008051EF243740288F38 +:2004C300017A00E9249CF9EA34FF8918F5193395E0F51AF51B90000AE4F5F01212C4AB82F1 +:2004E300AC83ADF0FE80247A00EF2438FFEA34FF8F18F5193395E0F51AF51B900064E4F561 +:20050300F01212C4AB82AC83ADF0FEC3EB9420EC9400ED9400EE64809480401474A09B7449 +:20052300869C74019D74808EF063F08095F0500475820022751802E4F519F51AF51B8B82A0 +:200543008C838DF0EEC006C005C004C003121362A882A983D003D004D005D006880C890DB3 +:200563008B828C838DF0EE120DA7AC82AD83AEF0FFC004C005C006C00790240075F0F47499 +:20058300C9121467AC82AD83AEF0FFE58124FCF5818C828D838EF0EF120DD4AC82AD838CA3 +:2005A300CA8DCB75820122AD18AE19AF1A8D828E838FF0E5081212A675820122E58270065A +:2005C30085108212035375820122758200227582012290E6BBE0FE7F0090E6BAE07C0042F0 +:2005E30007EC420690E6BFE0FC7D0090E6BEE07A004205EA420490E6A0E020E1F990E6B80C +:20060300E0FBBB40028073BBC00280030206D6ED4C70030206DAC374409DE49C50067A40FC +:200623007B0080048D028C0390E6A0E020E1F98A457546007547407548E77549008F438E62 +:2006430044758251C007C006C005C004C002120CDED002D004D005D006D00790E68AE4F03B +:200663000000000090E68BEAF07B00EDC39AFDEC9BFCEA2FFFEB3EFE8095ED4C605990E69B +:200683008BE4F090E6A0E020E1F990E68BE0FB8B38753900753A40753BE7753C008F368E31 +:2006A30037758251C007C006C005C004C003120C49E582D003D004D005D006D0077003F580 +:2006C30082227A00EB2FFFEA3EFEEDC39BFDEC9AFC80A7758200227582012275820022AFCE +:2006E30082C0071202FED007C2A0D2A1850C0E850D0FBFE0004015EF2419401090E68AE45C +:20070300F090E68BF090E6A0E020E1F9BFA2028023BFE0028021BFE1028028BFE202802F21 +:20072300BFE3028033BFE4028046BFE502804ABFE659804E0205D590E740E0F51875820041 +:2007430002010190E740E0F51875820102010190E740E0F5820203FC90E740E0FFBF010C81 +:20076300D2A0C2A1E4F50EF50F12031B7582012290E740E0F58202027A90E740E0F58202D0 +:2007830000E390E740E0F5820204817582002290E613E4F090E615F090E6C2F090E6C37418 +:2007A30080F090E6C0E4F090E6F4F01202FE7518017582001201017518017582011201011D +:2007C3007582011203FC75820212027A75820002035374022410FEE4343EFF7D068D041D09 +:2007E300EC605FED2407F582E434E5F583E0FC53040F7B00EC24D0F582EB3419F583E4930C +:200803008E828F83F074012EFBE43FFC8B828C83E4F00BBB00010CED2407F582E434E5F5C2 +:2008230083E0C4540F9019D093FA8B828C83F00BBB00010C8B828C83E4F0042BFEE43CFF0A +:20084300809B2290E600E054E74410F01207D5120792D2E890E668E043E008F090E65CE0A5 +:2008630043E001F090E65CE043E010F090E65CE043E020F090E65CE043E008F0D2DDD2AFAA +:2008830075CA3075CBF875C800D2ADD2CA90E680E043E00AF09005DC1213C190E680E053E3 +:2008A300E0F7F090E6727404F090E671E4F090E670F075B109F5A0F58075B6FF75B4FF758D +:2008C300B2FFC2A0D2A11000028003120E2F10010280F390E682E043E0C0F090E68174010E +:2008E300F043870100000000000000E513701C90E682E030E60790E682E020E0D690E6821B +:20090300E030E70790E682E020E1C890E682E030E60790E682E020E00E90E682E030E7A6C5 +:2009230090E682E030E19F9000051213C190E680E043E001F090000F1213C190E680E05319 +:06094300E0FEF00208C90D +:201633000F0E0000000000000200010000000000505555000000000000000000000000007D +:20165300010100000000000002000100000000005055550000000000000000000000000078 +:20167300FAFAFAFAFAF900000200000000000100505555555555550000000000000000002B +:20169300FAFAFAFAFAF900000200000000000100505555555555550000000000000000000B +:2016B300FAFAF90000000000020000010000000050555555000000000000000000000000D8 +:2016D300C8C8C700000000000200000100000000505555550000000000000000000000004E +:2016F300FAFAF9000000000002000001000000005055555500000000000000000000000098 +:2017130096950000000000000200010000000000505555000000000000000000000000008E +:20173300BBBB00000000000002000100000000005055550000000000000000000000000023 +:20175300020100000000000002000100000000005055550000000000000000000000000076 +:201773004B4A000000000000020001000000000050555500000000000000000000000000C4 +:201793002525000000000000020001000000000050555500000000000000000000000000EF +:2017B30001000000000000000201000000000000505500000000000000000000000000006D +:2017D3001E1D000000000000020001000000000050555500000000000000000000000000BE +:2017F3000101000000000000020001000000000050555500000000000000000000000000D7 +:2018130025250000000000000200010000000000505555000000000000000000000000006E +:2018330007070000000000000200010000000000505555000000000000000000000000008A +:201853000100000000000000020100000000000050550000000000000000000000000000CC +:2018730005040000000000000200010000000000505555000000000000000000000000004F +:201893008000000000000000030000000000000000000000000000000000000000000000B2 +:2018B30006050000000000000200010000000000505555000000000000000000000000000D +:2018D300800000000000000003000000000000000000000000000000000000000000000072 +:2018F3000302000000000000020001000000000050555500000000000000000000000000D3 +:201913000202000000000000020001000000000050555500000000000000000000000000B3 +:20193300030200000000000002000100000000005055550000000000000000000000000092 +:2019530030D31880EA1E931880AA18531880CA10F31780CA0FB317808A0C531780CA0A53CB +:2019730016808A08331980CA061319808A05F318808A04B31880CA037318808A02331880C2 +:201993008A013316808AA41318808A96D317808A8C9317808A787317808A71331780CA6E34 +:2019B3001317808A6AF31680CA69D316808A68B316808A67931680CA667316808A303132A6 +:0D19D30033343536373839414243444546F8 +:203D000012010002FFFFFF40B50422601002010203010A0600020000004001000902890016 +:203D200001010080FA0904000001FF000000070586020002000904000101FF000100070549 +:203D400082010014010904000201FF00010007058201000C010904000301FF000100070502 +:203D600082010004010904000401FF000100070582010004020904000501FF0001000705F5 +:203D800082010004030904000601FF000100070582010004040904000701FF0001000705CD +:053DA000820100020495 +:203DA6000902390002010080FA0904000001FF000000070586024000000904000101FF004D +:193DC600010007058201FF03010904000201FF00010007058201000201AF +:203DE0000403090416034F00700065006E00480061006E00740065006B00160344005300F9 +:203E00004F002D003600300032003200420045001A03300030003000300030003000300068 +:0C3E2000300030003000300030000000A6 +:2009490085822CE5272522FDE5283523FE752D02903C00E4F0903C00E060047582002290AB +:20096900E678E0FB7A0043038090E678EBF0E030E21090000AC006C0051213C1D005D00674 +:2009890080D3E52C25E0FB90E679F090E678E020E006903C00E060F3903C00E06004758231 +:2009A900002290E678E020E2AC90E678E020E14090E678E0FB43034090E678EBF090E6787B +:2009C900E030E606903C00E060F3903C00E0600475820022E52D14FB8B2D7003F582229075 +:2009E900000AC006C0051213C1D005D00602095E7A007B00C3EA9DEB9E4003020A93C3EA08 +:200A09009522EB95235016EA2524F8EB3525F9AC26888289838CF012152AFC801DEAC39514 +:200A290022F8EB9523F9E82529F8E9352AF9AF2B888289838FF012152AFC90E679ECF00AF7 +:200A4900BA00010B90E678E020E006903C00E060F3903C00E060047582002290E678E030CD +:200A6900E20302095E90E678E020E18890E678E0FF43074090E678EFF090E678E030E606BA +:200A8900903C00E060F37582002290E678E0FF43074090E678EFF090E678E030E606903C5B +:200AA90000E060F3903C00E060047582002275820122858233903C00E4F004B52E0814B525 +:200AC9002F0474018001E4FE903C00E06004758200227C007D0090E678E0FB43038090E6DB +:200AE90078EBF0E030E20C90000AC0061213C1D00680D5E53325E0FB3395E0FA430301909A +:200B0900E679EBF090E678E020E006903C00E060F3903C00E060047582002290E678E020A8 +:200B2900E2A690E678E020E11E90E678E0FB43034090E678EBF090E678E030E606903C0069 +:200B4900E060F375820022EE600F90E678E0FB7A0043032090E678EBF090E679E0E4F53495 +:200B6900F53574012534F8E43535F9C3E8952EE9952F506C90E678E020E006903C00E0607E +:200B8900F3903C00E060047582002290E678E030E203020AD174022534F8E43535F9E8B5C5 +:200BA9002E13E9B52F0F90E678E0F8790043002090E678E8F0A834A9350534E4B5340205E0 +:200BC90035AC34AD35E82530F8E93531F9AF3290E679E0FB888289838FF01212A6020B6B16 +:200BE90090E678E020E006903C00E060F3903C00E060047582002290E678E030E203020A01 +:200C0900D190E678E0FF43074090E678EFF0EC2530FCED3531FDAF3290E679E08C828D837B +:200C29008FF01212A690E678E030E606903C00E060F3903C00E06004758200227582012236 +:200C490085823DE4F541F542AB36AC37C3E5419538E54295394003020CDA7A0090E678E014 +:200C690030E4067A018C078F3EEA04FFEA243EF98B02A702EF04FAEF243EF9AE41AF4205F2 +:200C890041E4B541020542EE253AFEEF353BFFAD3C8E828F838DF012152AF78A227523002A +:200CA90075243E752500752640E4F527F528F529F52AF52B853D82C004C003120949E582CF +:200CC900D003D0047003F582220BBB00010C020C5575820122AF827E0090E678E030E40671 +:200CE9007E01AD448D4AEE04FDEE244AF9AE43A7068D2275230075244A752500752640E43F +:200D0900F527F528F529F52AF52B8F82C007120949E582D0077003F5822285452E85462FBC +:190D29008547308548318549328F82120ABBE5827003F582227582012242 +:200D4200FB7A20E4FCFDFEFFE5822582F582E58333F583E5F033F5F0EB33FB4017DAE980EA +:200D620042E5822582F582E58333F583E5F033F5F0EB33FBEC33FCED33FDEE33FEEF33FF19 +:200D8200EC9518ED9519EE951AEF951B4013EC9518FCED9519FDEE951AFEEF951BFF438263 +:050DA20001DABEEB22A6 +:06008800E478FFF6D8FD4C +:200DA700FCABF0AA83A982749EF582C2D1EC30E716D2D1E9F42401F9EAF43400FAEBF4344B +:0D0DC70000FBECF43400FC1215F8021417C8 +:200DD400121294C3749E9582403979001215B530D126E9F42401F582EAF43400F583EBF484 +:200DF4003400F5F0ECF43400700AE582458345F0700122E430E70F22EC20E71489828A83F6 +:1B0E14008BF02230D10AE4F582F583F5F074802274FFF582F583F5F0747F22F1 +:1200CE007512007513007514A675153D75161C75173DAB +:200E2F0090E6B9E0FF24F45003020F5DEF240A83F582EF241083F583E473617D5D995D5DA2 +:200E4F00B55DC5DCFE380E0E0F0E0F0F0E0F0E0E0E0F120FDFE5826003020F7990E6A0E0A3 +:200E6F00FF7E0043070190E6A0EFF0020F79121073E5826003020F7990E6A0E0FF7E00437D +:200E8F00070190E6A0EFF0020F791210EEE5826003020F7990E6A0E0FF7E0043070190E624 +:200EAF00A0EFF0020F791206DEE5826003020F791211AF020F791205CDAF8290E740EFF0C9 +:200ECF0090E68AE4F090E68B04F0020F7990E6BAE0F5821205D1E5826003020F7990E6A0D7 +:200EEF00E0FF7E0043070190E6A0EFF0020F7990E6BCE0FF751811751900751A408F82128D +:200F0F0005AAE582701190E6A0E0FF7E0043070190E6A0EFF0805390E740E511F090E68A08 +:200F2F00E4F090E68B04F0804190E6BCE0FF90E6BAE0F5108F821205BFE582702D90E6A0F1 +:200F4F00E0FF7E0043070190E6A0EFF0801C90E6B9E0F5821206E2E582700F90E6A0E0FFEE +:200F6F007E0043070190E6A0EFF090E6A0E0FF43078090E6A0EFF022AF82747F5FFE24F732 +:200F8F005003020FDBEE240A83F582EE240D83F583E473B4B8CBDBCFDBD3DBD70F0F0F0FFF +:200FAF000F0F0F0F0F90E6A022EF30E7067EA27FE680047EA17FE68E828F832290E6A32287 +:200FCF0090E6A42290E6A52290E6A6229000002290E6B8E0FFBF80028022BF81028008BF20 +:200FEF008202803702106B90E740E4F090E741F090E68AF090E68B7402F08064E51325E0BF +:20100F00FFE512420790E740EFF090E741E4F090E68AF090E68B7402F0804590E6BCE0F53D +:20102F0082120F87AE82AF838E048F05EE4F7003F582228C828D83E0FC30E0067E017F0098 +:20104F0080047E007F0090E740EEF090E741E4F090E68AF090E68B7402F0800475820022EB +:20106F007582012290E6B8E0FF6005BF0264801B90E6BAE0FFBF0105751300805E90E6BAAB +:20108F00E0FFBF060280547582002290E6BAE0703D90E6BCE0F582120F87AE82AF83E0FD81 +:2010AF005305FE8E828F83EDF090E6BCE0FF30E7098F057E004305108D0753071F90E6832B +:2010CF00EFF07E0043072090E683EFF0800D7582002290E6B9E0F5820206E27582012290A2 +:2010EF00E6B8E0FF6008BF0202802902117790E6BAE0FFBF020302118090E6BAE0FFBF01D1 +:20110F0005751301806B90E6BAE0FFBF060280617582002290E6BAE0704A90E6BCE0F58224 +:20112F00120F87AE82AF83EE4F7003F582228E828F83E0FD7C004305018E828F83EDF090FA +:20114F00E6BCE0FF30E7098F057E004305108D0753071F90E683EFF07E0043072090E683AF +:20116F00EFF0800D7582002290E6B9E0F5820206E275820122AF827E0110AF027E00EF6013 +:20118F000E75141C75153D7516A675173D800C7514A675153D75161C75173DEE1392AF2276 +:2011AF0090E6BBE0FFBF01028019BF02028024BF0302802CBF0603021269BF070302127943 +:2011CF000212867E007F3D90E6B3EFF090E6B47400F02290E6B3E515F090E6B4E514F0222C +:2011EF007DE07E3D7F8090E6BAE0F5187B008B020BEAB5180280428D008E018F028D828ED4 +:20120F00838FF012152A28F8E439F9880589068A0774012DF9E43EFA8F0489828A838CF0AB +:20122F0012152AF9B9030280067D007E007F00ED4E6006C3E5189B50B5ED4E600F8D038ECE +:20124F000490E6B3ECF090E6B4EDF02290E6A0E0FF43070190E6A0EFF0227E127F3D90E634 +:20126F00B3EFF090E6B47412F02290E6B3E517F090E6B4E516F02290E6A0E0FF43070190EF +:05128F00E6A0EFF022D3 +:200066007900E94400601B7A009019E0780175923CE493F2A308B800020592D9F4DAF27527 +:0200860092FFE7 +:12129400AA82AB83A2F73392D1F5826002D2F7ACF0225F +:1B12A60020F71130F6138883A88220F509F6A8837583002280FEF280F5F02247 +:203F00000201530002163100021582000202010002016B000201B60002157F000213B500DD +:203F20000213B7000213B8000213B9000213BC0002163000021632000212C1000212C3000B +:203F4000021584000213B50002154600021580000215810002158300021585000215B4006F +:203F6000021466000213B5000213B5000213B5000213B6000213BA000213BD000213BF0027 +:203F80000213BB000213BE000213C000021416000213320002135D0002135F0002136100DA +:183FA0000213330002135E00021360000213B4000212C20002162F00F3 +:0112C10032FA +:0112C20032F9 +:0112C30032F8 +:2012C400AAF0FBE5828518F0A4FCADF0E5838518F0A42DFDE435F0FEE5828519F0A42DFDB7 +:2012E400E5F03EFEE433FFEA8518F0A42EFEE5F03FFFE5838519F0A42EFEE5F03FFFE58229 +:20130400851AF0A42EFEE5F03FFFEB8518F0A42FFFEA8519F0A42FFFE583851AF0A42FFFFA +:0E132400E582851BF0A42F8EF08D838C822233 +:011332003288 +:011333003287 +:20008E007800E84400600A790075923CE4F309D8FC7801E84400600C7901903C00E4F0A306 +:0400AE00D8FCD9FAA7 +:201334007A10E4FBFCE58225E0F582E58333F583EB33FBEC33FCEB9518F5F0EC95194006AD +:09135400FCABF0438201DADD225A +:01135D00325D +:01135E00325C +:01135F00325B +:01136000325A +:011361003259 +:20136200FBC2D530E715D2D5E4C39582F582E49583F583E495F0F5F0E49BFBE51B30E71767 +:20138200B2D5E4C39518F518E49519F519E4951AF51AE4951BF51BEB120D4230D513FBE43A +:1213A200C39582F582E49583F583E495F0F5F0E49B2285 +:0113B4003206 +:0113B5003205 +:0113B6003204 +:0113B7003203 +:0113B8003202 +:0113B9003201 +:0113BA003200 +:0113BB0032FF +:0113BC0032FE +:0113BD0032FD +:0113BE0032FC +:0113BF0032FB +:0113C00032FA +:2013C100AE82AF8390E600E05418C423541F70057CB1FD801C90E600E05418C423541FFB3C +:2013E100BB01067A617B0180047AC27B028A048B058C188D19151874FFB518021519E51894 +:15140100451970F1EE24FFFAEF34FFFB8A068B07EA4B70DD2229 +:0114160032A3 +:20141700B98003EA13B34010EA2401FAE43BFBE43CFC50047C800582BC000EBB000BBA0019 +:2014370008E4F5F0F583F58222A2D1E582138CF092F78B838A8222E4F583F58275F080F4D9 +:0F145700A2D11322E4F583F58275F0C0747F22D1 +:011466003253 +:2014670012158630D502B2D1BF0009BC000302145B02144EBC0003021438E583B4FF0BE5BA +:2014870082B4FF0302145B021438E582B4FF0302144EC395835007247F400B0214382480BB +:2014A70014500302144EF582C3ED9AEE9BEF9C40111582C3EA33F9EB33FAEC33FBE433FC7F +:2014C7008005E4CCCBCAF9C08275F019C3E99DEA9EEB9FEC9400D5F002802D400EE99DF966 +:2014E700EA9EFAEB9FFBEC9400FCC3B3E833F8E58233F582E58333F583C3E933F9EA33FAC6 +:20150700EB33FBEC33FC80C4B3E4F938FAE43582FBE43583FCD082500405827C801215F814 +:0315270002142F7C +:0D00590075814B12162BE5826003020056E4 +:1C152A0020F71430F6148883A88220F507E6A88375830022E280F7E49322E022D0 +:011546003272 +:20154700C2D5E58330E70DD2D5E4C39582F582E49583F583E51930E70DB2D5E4C39518F51F +:1815670018E49519F51912133430D50BE4C39582F582E49583F5832280 +:01157F003239 +:011580003238 +:011581003237 +:011582003236 +:011583003235 +:011584003234 +:011585003233 +:20158600AA82AB83A2F73392D1F5826002D2F7ACF0E58124F9F8E6FD08E6FE0886F008E6C8 +:0E15A600A2F73392D5F5836002D2F7AFF022A0 +:0115B4003204 +:2015B5006040F82582500274FFF582E824F8501ECCCBCAF9E4CC24F85014CBCAF9E4CB243E +:2015D500F8500BCAF9E4CA24F8500379002224086010F8C3EC13FCEB13FBEA13FAE913F9F1 +:0315F500D8F12208 +:2015F8007804EC7011E58224F8500AF582E4C9CACBFCD8EF22EC7820058220E713D58201F2 +:1316180022C3E933F9EA33FAEB33FBEC33FCD8EA158222FF +:04162B0075820022A2 +:01162F003288 +:011630003287 +:011631003286 +:011632003285 +:00000001FF diff --git a/PyHT6022/Firmware/DSO6022BE/dso6022be.c b/Firmware/DSO6022BE/dso6022be.c similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/dso6022be.c rename to Firmware/DSO6022BE/dso6022be.c diff --git a/PyHT6022/Firmware/DSO6022BE/fl_fw.sh b/Firmware/DSO6022BE/fl_fw.sh similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/fl_fw.sh rename to Firmware/DSO6022BE/fl_fw.sh diff --git a/PyHT6022/Firmware/DSO6022BE/fx2.mk b/Firmware/DSO6022BE/fx2.mk similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/fx2.mk rename to Firmware/DSO6022BE/fx2.mk diff --git a/PyHT6022/Firmware/DSO6022BE/scope6022.inc b/Firmware/DSO6022BE/scope6022.inc similarity index 95% rename from PyHT6022/Firmware/DSO6022BE/scope6022.inc rename to Firmware/DSO6022BE/scope6022.inc index ed1f8f5..bc4fd59 100644 --- a/PyHT6022/Firmware/DSO6022BE/scope6022.inc +++ b/Firmware/DSO6022BE/scope6022.inc @@ -3,6 +3,7 @@ * * Copyright (C) 2009 Ubixum, Inc. * Copyright (C) 2015 Jochen Hoenicke + * Copyright (C) 2019-2024 Martin Homuth-Rosemann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,10 +19,13 @@ * License along with this library; if not, see . */ + // CLK_12M; CLK_24M; CLK_48M #define CPU_FREQ CLK_48M + // 12 MHz: 500; 24 MHz: 1000; 48 MHz: 2000 #define TIMER2_VAL 2000 + // CLK_48M & IFCLK30 -> 4 delays #define SYNCDELAY SYNCDELAY4 @@ -94,7 +98,7 @@ void timer2_isr( void ) __interrupt TF2_ISR { } -void set_aadj() { +static void set_aadj() { if ( samplerate >= 24000 / numchannels ) { EP2ISOINPKTS &= 0x7f; } else { @@ -191,6 +195,7 @@ static void select_interface( BYTE alt ) { } } + #include "waveforms.inc" struct samplerate_info { @@ -228,6 +233,7 @@ static const struct samplerate_info samplerates[] = { { 102, waveform_102, ifconfig_102 }, // 20 kS/s }; + static BOOL set_samplerate( BYTE rate ) { BYTE i = 0; const BYTE *waveform; @@ -257,6 +263,7 @@ static BOOL set_samplerate( BYTE rate ) { return TRUE; } + // new functon to set the calibration pulse frequency that allows // to set all possible frequencies between 32 Hz and 100 kHz // integer dividers of 2MHz will be exact @@ -330,7 +337,7 @@ BOOL handle_set_configuration( BYTE cfg ) { // handle reading and writing EEPROM data -BOOL eeprom() { +static BOOL eeprom() { WORD addr = SETUP_VALUE(), len = SETUP_LENGTH(); // 24C02 (small adr mode) recognizes i2c adresses 0x50..0x57 // 24C128 (large adr mode) must be wired to address 0x51 @@ -448,6 +455,7 @@ static void init( void ) { select_interface( 0 ); } + // EZ-USB® FX2LP™ Unique ID Registers – KBA89285 // Question: // Is there a die ID or a unique ID on each EZ-USB® FX2LP™ chip @@ -468,20 +476,22 @@ extern __code BYTE serial_num; // defined in descriptor.asm file for the serial static const char hex2Ascii[ 16 ] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; static void insert_serial_number() { - WORD p_serial_num = (WORD)&serial_num; - - // IMPORTANT: be compatible with previous (wrong) implementation - // write lower nibble before upper nibble to get same serial number + // string starts at position 2 of string_descriptor + BYTE __xdata * p_serial_num = (BYTE __xdata *)&serial_num + 2; BYTE bbb = 6; // start with MSB while ( bbb-- ) { - *( (BYTE __xdata *)( p_serial_num += 2 ) ) = hex2Ascii[ UNIQID[ bbb ] & 0x0F ]; // 1. lower nibble - *( (BYTE __xdata *)( p_serial_num += 2 ) ) = hex2Ascii[ UNIQID[ bbb ] >> 4 ]; // 2. upper nibble + // IMPORTANT: be compatible with previous (wrong) implementation + // write lower nibble before upper nibble to get same serial number + *p_serial_num++ = hex2Ascii[ UNIQID[ bbb ] & 0x0F ]; // 1. lower nibble + *p_serial_num++ = 0; // (UTF-16 coding) + *p_serial_num++ = hex2Ascii[ UNIQID[ bbb ] >> 4 ]; // 2. upper nibble + *p_serial_num++ = 0; // (UTF-16 coding) } } -static void main( void ) { +void main( void ) { /* set to 48 MHz */ SETCPUFREQ( CPU_FREQ ); diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms.inc b/Firmware/DSO6022BE/waveforms.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms.inc rename to Firmware/DSO6022BE/waveforms.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/COMPILE_GPIF.sh b/Firmware/DSO6022BE/waveforms/COMPILE_GPIF.sh similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/COMPILE_GPIF.sh rename to Firmware/DSO6022BE/waveforms/COMPILE_GPIF.sh diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_1.inc b/Firmware/DSO6022BE/waveforms/gpif_1.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_1.inc rename to Firmware/DSO6022BE/waveforms/gpif_1.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_1.wvf b/Firmware/DSO6022BE/waveforms/gpif_1.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_1.wvf rename to Firmware/DSO6022BE/waveforms/gpif_1.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_10.inc b/Firmware/DSO6022BE/waveforms/gpif_10.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_10.inc rename to Firmware/DSO6022BE/waveforms/gpif_10.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_10.wvf b/Firmware/DSO6022BE/waveforms/gpif_10.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_10.wvf rename to Firmware/DSO6022BE/waveforms/gpif_10.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_102.inc b/Firmware/DSO6022BE/waveforms/gpif_102.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_102.inc rename to Firmware/DSO6022BE/waveforms/gpif_102.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_102.wvf b/Firmware/DSO6022BE/waveforms/gpif_102.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_102.wvf rename to Firmware/DSO6022BE/waveforms/gpif_102.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_103.inc b/Firmware/DSO6022BE/waveforms/gpif_103.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_103.inc rename to Firmware/DSO6022BE/waveforms/gpif_103.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_103.wvf b/Firmware/DSO6022BE/waveforms/gpif_103.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_103.wvf rename to Firmware/DSO6022BE/waveforms/gpif_103.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_104.inc b/Firmware/DSO6022BE/waveforms/gpif_104.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_104.inc rename to Firmware/DSO6022BE/waveforms/gpif_104.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_104.wvf b/Firmware/DSO6022BE/waveforms/gpif_104.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_104.wvf rename to Firmware/DSO6022BE/waveforms/gpif_104.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_105.inc b/Firmware/DSO6022BE/waveforms/gpif_105.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_105.inc rename to Firmware/DSO6022BE/waveforms/gpif_105.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_105.wvf b/Firmware/DSO6022BE/waveforms/gpif_105.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_105.wvf rename to Firmware/DSO6022BE/waveforms/gpif_105.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_106.inc b/Firmware/DSO6022BE/waveforms/gpif_106.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_106.inc rename to Firmware/DSO6022BE/waveforms/gpif_106.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_106.wvf b/Firmware/DSO6022BE/waveforms/gpif_106.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_106.wvf rename to Firmware/DSO6022BE/waveforms/gpif_106.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_110.inc b/Firmware/DSO6022BE/waveforms/gpif_110.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_110.inc rename to Firmware/DSO6022BE/waveforms/gpif_110.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_110.wvf b/Firmware/DSO6022BE/waveforms/gpif_110.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_110.wvf rename to Firmware/DSO6022BE/waveforms/gpif_110.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_113.inc b/Firmware/DSO6022BE/waveforms/gpif_113.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_113.inc rename to Firmware/DSO6022BE/waveforms/gpif_113.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_113.wvf b/Firmware/DSO6022BE/waveforms/gpif_113.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_113.wvf rename to Firmware/DSO6022BE/waveforms/gpif_113.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_12.inc b/Firmware/DSO6022BE/waveforms/gpif_12.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_12.inc rename to Firmware/DSO6022BE/waveforms/gpif_12.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_12.wvf b/Firmware/DSO6022BE/waveforms/gpif_12.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_12.wvf rename to Firmware/DSO6022BE/waveforms/gpif_12.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_120.inc b/Firmware/DSO6022BE/waveforms/gpif_120.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_120.inc rename to Firmware/DSO6022BE/waveforms/gpif_120.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_120.wvf b/Firmware/DSO6022BE/waveforms/gpif_120.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_120.wvf rename to Firmware/DSO6022BE/waveforms/gpif_120.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_140.inc b/Firmware/DSO6022BE/waveforms/gpif_140.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_140.inc rename to Firmware/DSO6022BE/waveforms/gpif_140.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_140.wvf b/Firmware/DSO6022BE/waveforms/gpif_140.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_140.wvf rename to Firmware/DSO6022BE/waveforms/gpif_140.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_15.inc b/Firmware/DSO6022BE/waveforms/gpif_15.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_15.inc rename to Firmware/DSO6022BE/waveforms/gpif_15.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_15.wvf b/Firmware/DSO6022BE/waveforms/gpif_15.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_15.wvf rename to Firmware/DSO6022BE/waveforms/gpif_15.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_150.inc b/Firmware/DSO6022BE/waveforms/gpif_150.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_150.inc rename to Firmware/DSO6022BE/waveforms/gpif_150.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_150.wvf b/Firmware/DSO6022BE/waveforms/gpif_150.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_150.wvf rename to Firmware/DSO6022BE/waveforms/gpif_150.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_16.inc b/Firmware/DSO6022BE/waveforms/gpif_16.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_16.inc rename to Firmware/DSO6022BE/waveforms/gpif_16.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_16.wvf b/Firmware/DSO6022BE/waveforms/gpif_16.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_16.wvf rename to Firmware/DSO6022BE/waveforms/gpif_16.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_164.inc b/Firmware/DSO6022BE/waveforms/gpif_164.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_164.inc rename to Firmware/DSO6022BE/waveforms/gpif_164.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_164.wvf b/Firmware/DSO6022BE/waveforms/gpif_164.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_164.wvf rename to Firmware/DSO6022BE/waveforms/gpif_164.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_2.inc b/Firmware/DSO6022BE/waveforms/gpif_2.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_2.inc rename to Firmware/DSO6022BE/waveforms/gpif_2.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_2.wvf b/Firmware/DSO6022BE/waveforms/gpif_2.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_2.wvf rename to Firmware/DSO6022BE/waveforms/gpif_2.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_24.inc b/Firmware/DSO6022BE/waveforms/gpif_24.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_24.inc rename to Firmware/DSO6022BE/waveforms/gpif_24.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_24.wvf b/Firmware/DSO6022BE/waveforms/gpif_24.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_24.wvf rename to Firmware/DSO6022BE/waveforms/gpif_24.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_3.inc b/Firmware/DSO6022BE/waveforms/gpif_3.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_3.inc rename to Firmware/DSO6022BE/waveforms/gpif_3.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_3.wvf b/Firmware/DSO6022BE/waveforms/gpif_3.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_3.wvf rename to Firmware/DSO6022BE/waveforms/gpif_3.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_30.inc b/Firmware/DSO6022BE/waveforms/gpif_30.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_30.inc rename to Firmware/DSO6022BE/waveforms/gpif_30.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_30.wvf b/Firmware/DSO6022BE/waveforms/gpif_30.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_30.wvf rename to Firmware/DSO6022BE/waveforms/gpif_30.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_4.inc b/Firmware/DSO6022BE/waveforms/gpif_4.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_4.inc rename to Firmware/DSO6022BE/waveforms/gpif_4.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_4.wvf b/Firmware/DSO6022BE/waveforms/gpif_4.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_4.wvf rename to Firmware/DSO6022BE/waveforms/gpif_4.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_48.inc b/Firmware/DSO6022BE/waveforms/gpif_48.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_48.inc rename to Firmware/DSO6022BE/waveforms/gpif_48.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_48.wvf b/Firmware/DSO6022BE/waveforms/gpif_48.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_48.wvf rename to Firmware/DSO6022BE/waveforms/gpif_48.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_5.inc b/Firmware/DSO6022BE/waveforms/gpif_5.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_5.inc rename to Firmware/DSO6022BE/waveforms/gpif_5.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_5.wvf b/Firmware/DSO6022BE/waveforms/gpif_5.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_5.wvf rename to Firmware/DSO6022BE/waveforms/gpif_5.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_6.inc b/Firmware/DSO6022BE/waveforms/gpif_6.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_6.inc rename to Firmware/DSO6022BE/waveforms/gpif_6.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_6.wvf b/Firmware/DSO6022BE/waveforms/gpif_6.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_6.wvf rename to Firmware/DSO6022BE/waveforms/gpif_6.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_8.inc b/Firmware/DSO6022BE/waveforms/gpif_8.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_8.inc rename to Firmware/DSO6022BE/waveforms/gpif_8.inc diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/gpif_8.wvf b/Firmware/DSO6022BE/waveforms/gpif_8.wvf similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/gpif_8.wvf rename to Firmware/DSO6022BE/waveforms/gpif_8.wvf diff --git a/PyHT6022/Firmware/DSO6022BE/waveforms/waveforms.inc b/Firmware/DSO6022BE/waveforms/waveforms.inc similarity index 100% rename from PyHT6022/Firmware/DSO6022BE/waveforms/waveforms.inc rename to Firmware/DSO6022BE/waveforms/waveforms.inc diff --git a/PyHT6022/Firmware/DSO6022BL/Makefile b/Firmware/DSO6022BL/Makefile similarity index 100% rename from PyHT6022/Firmware/DSO6022BL/Makefile rename to Firmware/DSO6022BL/Makefile diff --git a/PyHT6022/Firmware/DSO6022BL/descriptor.asm b/Firmware/DSO6022BL/descriptor.asm similarity index 100% rename from PyHT6022/Firmware/DSO6022BL/descriptor.asm rename to Firmware/DSO6022BL/descriptor.asm diff --git a/Firmware/DSO6022BL/dso6022bl-firmware.hex b/Firmware/DSO6022BL/dso6022bl-firmware.hex new file mode 100644 index 0000000..e9718df --- /dev/null +++ b/Firmware/DSO6022BL/dso6022bl-firmware.hex @@ -0,0 +1,287 @@ +:04000000020059326F +:01000B0032C2 +:0100130032BA +:01001B0032B2 +:0100230032AA +:03002B00020219B5 +:0300330002015077 +:01003B003292 +:03004300023F0079 +:01004B003282 +:03005300023F0069 +:1C00B200750800750900750A02750B00750CF4750D01750EF4750F01C200C201BD +:0300E000020056C5 +:0300560002084B52 +:2000E300E582FF30E00543B10A800353B1F5EF30E40543B101800353B1FE75820122AF823B +:200103007401B5180280157402B5180280127405B51802800F740AB51812800C7E2480103A +:200123007E12800C7E0080087E36800475820022EF60067D707F0080047D0E7F00EDF4FF1A +:20014300E5805207ED5E4FF58075820122C2DC32C0E0C082C083D2005391EF90E65D7401D3 +:20016300F0D083D082D0E032C021C0E0C0F0C082C083C007C006C005C004C003C002C001F3 +:20018300C000C0D075D0007582001211895391EF90E65D7410F0D0D0D000D001D002D00324 +:2001A300D004D005D006D007D083D082D0F0D0E0D02132C021C0E0C0F0C082C083C007C071 +:2001C30006C005C004C003C002C001C000C0D075D0007582011211895391EF90E65D7420D4 +:2001E300F0D0D0D000D001D002D003D004D005D006D007D083D082D0F0D0E0D02132C0E0F8 +:20020300C082C083D2015391EF90E65D7408F0D083D082D0E032C0E0C0D0B2A2E50E450F1F +:200223006019150E74FFB50E02150FE50E450F700A850C0E850D0FB2A0D2A1C2CFD0D0D0FC +:20024300E032850A18751900905DC012154CAE82AF83AC097D00C3EC9EED64808FF063F0B0 +:200263008095F0400990E640E053E07FF02290E640E043E080F02285820A7401B50A0280C1 +:20028300057402B50A18AF0A74072FF50B90E618F090E61AE50BF01202457582012275824E +:2002A300002290E6F574FFF000000000E5BB30E7FB90E6047480F00000000090E618E4F0D9 +:2002C3000000000090E61AE4F00000000090E6047402F00000000090E6047406F0000000F3 +:2002E3000090E618E50BF00000000090E61AE50BF00000000090E604E4F02290E6F574FFCF +:20030300F000000000E50870057E06FF80047E027F0090E648EEF022D2871202A57EE87FCD +:20032300031EBEFF011FEE4F70F7E5BB30E7FB0000000090E6D07428F00000000090E6D14D +:20034300E4F0E50870057E06FF80047E047F008EBB22AF8290E680E030E7067D1C7E3D80F9 +:20036300047DA67E3DEF75F010A42416FBE435F0FCEB2DFDEC3EFC7E80EFF508703590E616 +:2003830012E4F090E61474E0F090E6E27401F08D828C838EF012152F90E625F074012DFAD0 +:2003A300E43CFB8E078A828B838FF012152F90E624F02290E61274D8F090E614E4F090E657 +:2003C300D204F08D828C838EF012152F90E621F00DBD00010C8D828C838EF012152FFF9083 +:2003E300E62074075FF08D828C838EF012152FC423541F90E64004F0020245AF827E00EE4E +:2004030075F005A4FCADF02458F582ED3419F583E493FBB5070280080EBE19E375820022F4 +:20042300EC2458FCED3419FD8C828D83A3A3A3A3E49390E601F08C828D83A3E493FDA3E4DA +:2004430093FEA3E493FF75AF07759DE4759E007C208C031CEB60168D828E838FF012152F1E +:20046300FBA3AD82AE8390E67CEBF080E47F608F061FEE600790E67CE4F080F3758201220F +:20048300E582FF70087B64FCFDFE020510EF249B401D8F18751900751A00751B009003E8B4 +:2004A300E4F5F01212C9AB82AC83ADF0FE805EBF670A7B207C007D007E008051EF24374011 +:2004C300288F017A00E9249CF9EA34FF8918F5193395E0F51AF51B90000AE4F5F01212C962 +:2004E300AB82AC83ADF0FE80247A00EF2438FFEA34FF8F18F5193395E0F51AF51B9000640D +:20050300E4F5F01212C9AB82AC83ADF0FEC3EB9420EC9400ED9400EE64809480401474A07A +:200523009B74869C74019D74808EF063F08095F0500475820022751802E4F519F51AF51B9E +:200543008B828C838DF0EEC006C005C004C003121367A882A983D003D004D005D006880C37 +:20056300890D8B828C838DF0EE120DACAC82AD83AEF0FFC004C005C006C00790240075F066 +:20058300F474C912146CAC82AD83AEF0FFE58124FCF5818C828D838EF0EF120DD9AC82AD40 +:2005A300838CCA8DCB75820122AD18AE19AF1A8D828E838FF0E5081212AB75820122E582BC +:2005C300700685108212035575820122758200227582012290E6BBE0FE7F0090E6BAE07CBA +:2005E300004207EC420690E6BFE0FC7D0090E6BEE07A004205EA420490E6A0E020E1F99068 +:20060300E6B8E0FBBB40028073BBC00280030206D8ED4C70030206DCC374409DE49C500614 +:200623007A407B0080048D028C0390E6A0E020E1F98A457546007547407548E77549008F79 +:20064300438E44758251C007C006C005C004C002120CE3D002D004D005D006D00790E68A39 +:20066300E4F00000000090E68BEAF07B00EDC39AFDEC9BFCEA2FFFEB3EFE8095ED4C60593D +:2006830090E68BE4F090E6A0E020E1F990E68BE0FB8B38753900753A40753BE7753C008F7F +:2006A300368E37758251C007C006C005C004C003120C4EE582D003D004D005D006D00770AF +:2006C30003F582227A00EB2FFFEA3EFEEDC39BFDEC9AFC80A77582002275820122758200A7 +:2006E30022AF82C0071202FED007C2A0D2A1850C0E850D0FBFE0004015EF2419401090E6F9 +:200703008AE4F090E68BF090E6A0E020E1F9BFA2028023BFE0028021BFE1028028BFE20262 +:20072300802FBFE3028033BFE4028046BFE502804ABFE659804E0205D790E740E0F5187512 +:20074300820002010190E740E0F51875820102010190E740E0F5820203FE90E740E0FFBF0A +:20076300010CD2A0C2A1E4F50EF50F12031B7582012290E740E0F58202027A90E740E0F547 +:20078300820200E390E740E0F5820204837582002290E613E4F090E615F0D28790E6C2E4F2 +:2007A300F090E6C37480F090E6C0E4F090E6F4F01202FE7518017582001201017518017517 +:2007C30082011201017582011203FE75820212027A75820002035574022410FEE4343EFF9F +:2007E3007D068D041DEC605FED2407F582E434E5F583E0FC53040F7B00EC24D5F582EB34DE +:2008030019F583E4938E828F83F074012EFBE43FFC8B828C83E4F00BBB00010CED2407F52E +:2008230082E434E5F583E0C4540F9019D593FA8B828C83F00BBB00010C8B828C83E4F004D9 +:200843002BFEE43CFF809B2290E600E054E74410F01207DA120794D2E890E668E043E008F8 +:20086300F090E65CE043E001F090E65CE043E010F090E65CE043E020F090E65CE043E00828 +:20088300F0D2DDD2AF75CA3075CBF875C800D2ADD2CA90E680E043E00AF09005DC1213C6E7 +:2008A30090E680E053E0F7F090E6727404F090E671E4F090E670F075B10BF5A0F58075B6FE +:2008C300FF75B4FF75B2FFC2A0D2A11000028003120E3410010280F390E682E043E0C0F0D9 +:2008E30090E6817401F043870100000000000000E513701C90E682E030E60790E682E0205D +:20090300E0D690E682E030E70790E682E020E1C890E682E030E60790E682E020E00E90E636 +:2009230082E030E7A690E682E030E19F9000051213C690E680E043E001F090000F1213C619 +:0B09430090E680E053E0FEF00208CEDA +:201638000F0E00000000000002000100000000005055550000000000000000000000000078 +:20165800010100000000000002000100000000005055550000000000000000000000000073 +:20167800FAFAFAFAFAF9000002000000000001005055555555555500000000000000000026 +:20169800FAFAFAFAFAF9000002000000000001005055555555555500000000000000000006 +:2016B800FAFAF90000000000020000010000000050555555000000000000000000000000D3 +:2016D800C8C8C7000000000002000001000000005055555500000000000000000000000049 +:2016F800FAFAF9000000000002000001000000005055555500000000000000000000000093 +:20171800969500000000000002000100000000005055550000000000000000000000000089 +:20173800BBBB0000000000000200010000000000505555000000000000000000000000001E +:20175800020100000000000002000100000000005055550000000000000000000000000071 +:201778004B4A000000000000020001000000000050555500000000000000000000000000BF +:201798002525000000000000020001000000000050555500000000000000000000000000EA +:2017B800010000000000000002010000000000005055000000000000000000000000000068 +:2017D8001E1D000000000000020001000000000050555500000000000000000000000000B9 +:2017F8000101000000000000020001000000000050555500000000000000000000000000D2 +:20181800252500000000000002000100000000005055550000000000000000000000000069 +:20183800070700000000000002000100000000005055550000000000000000000000000085 +:201858000100000000000000020100000000000050550000000000000000000000000000C7 +:2018780005040000000000000200010000000000505555000000000000000000000000004A +:201898008000000000000000030000000000000000000000000000000000000000000000AD +:2018B800060500000000000002000100000000005055550000000000000000000000000008 +:2018D80080000000000000000300000000000000000000000000000000000000000000006D +:2018F8000302000000000000020001000000000050555500000000000000000000000000CE +:201918000202000000000000020001000000000050555500000000000000000000000000AE +:2019380003020000000000000200010000000000505555000000000000000000000000008D +:2019580030D81880EA1E981880AA18581880CA10F81780CA0FB817808A0C581780CA0A58A3 +:2019780016808A08381980CA061819808A05F818808A04B81880CA037818808A023818809F +:201998008A013816808AA41818808A96D817808A8C9817808A787817808A71381780CA6E11 +:2019B8001817808A6AF81680CA69D816808A68B816808A67981680CA667816808A30313283 +:0D19D80033343536373839414243444546F3 +:203D000012010002FFFFFF40B5042A601002010203010A060002000000400100090289000E +:203D200001010080FA0904000001FF000000070586020002000904000101FF000100070549 +:203D400082010014010904000201FF00010007058201000C010904000301FF000100070502 +:203D600082010004010904000401FF000100070582010004020904000501FF0001000705F5 +:203D800082010004030904000601FF000100070582010004040904000701FF0001000705CD +:053DA000820100020495 +:203DA6000902390002010080FA0904000001FF000000070586024000000904000101FF004D +:193DC600010007058201FF03010904000201FF00010007058201000201AF +:203DE0000403090416034F00700065006E00480061006E00740065006B00160344005300F9 +:203E00004F002D00360030003200320042004C001A03300030003000300030003000300061 +:0C3E2000300030003000300030000000A6 +:20094E0085822CE5272522FDE5283523FE752D02903C00E4F0903C00E060047582002290A6 +:20096E00E678E0FB7A0043038090E678EBF0E030E21090000AC006C0051213C6D005D0066A +:20098E0080D3E52C25E0FB90E679F090E678E020E006903C00E060F3903C00E0600475822C +:2009AE00002290E678E020E2AC90E678E020E14090E678E0FB43034090E678EBF090E67876 +:2009CE00E030E606903C00E060F3903C00E0600475820022E52D14FB8B2D7003F582229070 +:2009EE00000AC006C0051213C6D005D0060209637A007B00C3EA9DEB9E4003020A98C3EAF4 +:200A0E009522EB95235016EA2524F8EB3525F9AC26888289838CF012152FFC801DEAC3950A +:200A2E0022F8EB9523F9E82529F8E9352AF9AF2B888289838FF012152FFC90E679ECF00AED +:200A4E00BA00010B90E678E020E006903C00E060F3903C00E060047582002290E678E030C8 +:200A6E00E20302096390E678E020E18890E678E0FF43074090E678EFF090E678E030E606B0 +:200A8E00903C00E060F37582002290E678E0FF43074090E678EFF090E678E030E606903C56 +:200AAE0000E060F3903C00E060047582002275820122858233903C00E4F004B52E0814B520 +:200ACE002F0474018001E4FE903C00E06004758200227C007D0090E678E0FB43038090E6D6 +:200AEE0078EBF0E030E20C90000AC0061213C6D00680D5E53325E0FB3395E0FA4303019090 +:200B0E00E679EBF090E678E020E006903C00E060F3903C00E060047582002290E678E020A3 +:200B2E00E2A690E678E020E11E90E678E0FB43034090E678EBF090E678E030E606903C0064 +:200B4E00E060F375820022EE600F90E678E0FB7A0043032090E678EBF090E679E0E4F53490 +:200B6E00F53574012534F8E43535F9C3E8952EE9952F506C90E678E020E006903C00E06079 +:200B8E00F3903C00E060047582002290E678E030E203020AD674022534F8E43535F9E8B5BB +:200BAE002E13E9B52F0F90E678E0F8790043002090E678E8F0A834A9350534E4B5340205DB +:200BCE0035AC34AD35E82530F8E93531F9AF3290E679E0FB888289838FF01212AB020B7007 +:200BEE0090E678E020E006903C00E060F3903C00E060047582002290E678E030E203020AFC +:200C0E00D690E678E0FF43074090E678EFF0EC2530FCED3531FDAF3290E679E08C828D8371 +:200C2E008FF01212AB90E678E030E606903C00E060F3903C00E0600475820022758201222C +:200C4E0085823DE4F541F542AB36AC37C3E5419538E54295394003020CDF7A0090E678E00A +:200C6E0030E4067A018C078F3EEA04FFEA243EF98B02A702EF04FAEF243EF9AE41AF4205ED +:200C8E0041E4B541020542EE253AFEEF353BFFAD3C8E828F838DF012152FF78A2275230020 +:200CAE0075243E752500752640E4F527F528F529F52AF52B853D82C004C00312094EE582C5 +:200CCE00D003D0047003F582220BBB00010C020C5A75820122AF827E0090E678E030E40667 +:200CEE007E01AD448D4AEE04FDEE244AF9AE43A7068D2275230075244A752500752640E43A +:200D0E00F527F528F529F52AF52B8F82C00712094EE582D0077003F5822285452E85462FB2 +:190D2E008547308548318549328F82120AC0E5827003F582227582012238 +:200D4700FB7A20E4FCFDFEFFE5822582F582E58333F583E5F033F5F0EB33FB4017DAE980E5 +:200D670042E5822582F582E58333F583E5F033F5F0EB33FBEC33FCED33FDEE33FEEF33FF14 +:200D8700EC9518ED9519EE951AEF951B4013EC9518FCED9519FDEE951AFEEF951BFF43825E +:050DA70001DABEEB22A1 +:06008800E478FFF6D8FD4C +:200DAC00FCABF0AA83A982749EF582C2D1EC30E716D2D1E9F42401F9EAF43400FAEBF43446 +:0D0DCC0000FBECF43400FC1215FD02141CB9 +:200DD900121299C3749E9582403979001215BA30D126E9F42401F582EAF43400F583EBF475 +:200DF9003400F5F0ECF43400700AE582458345F0700122E430E70F22EC20E71489828A83F1 +:1B0E19008BF02230D10AE4F582F583F5F074802274FFF582F583F5F0747F22EC +:1200CE007512007513007514A675153D75161C75173DAB +:200E340090E6B9E0FF24F45003020F62EF240A83F582EF241083F583E4736682629E62627A +:200E5400BA62CAE1033D0E0E0F0E0F0F0E0F0E0E0F0F120FE4E5826003020F7E90E6A0E075 +:200E7400FF7E0043070190E6A0EFF0020F7E121078E5826003020F7E90E6A0E0FF7E004369 +:200E9400070190E6A0EFF0020F7E1210F3E5826003020F7E90E6A0E0FF7E0043070190E610 +:200EB400A0EFF0020F7E1206E0E5826003020F7E1211B4020F7E1205CFAF8290E740EFF0AC +:200ED40090E68AE4F090E68B04F0020F7E90E6BAE0F5821205D3E5826003020F7E90E6A0C6 +:200EF400E0FF7E0043070190E6A0EFF0020F7E90E6BCE0FF751811751900751A408F821283 +:200F140005ACE582701190E6A0E0FF7E0043070190E6A0EFF0805390E740E511F090E68A01 +:200F3400E4F090E68B04F0804190E6BCE0FF90E6BAE0F5108F821205C1E582702D90E6A0EA +:200F5400E0FF7E0043070190E6A0EFF0801C90E6B9E0F5821206E4E582700F90E6A0E0FFE7 +:200F74007E0043070190E6A0EFF090E6A0E0FF43078090E6A0EFF022AF82747F5FFE24F72D +:200F94005003020FE0EE240A83F582EE240D83F583E473B9BDD0E0D4E0D8E0DC0F0F0F0FC8 +:200FB4000F0F0F0F0F90E6A022EF30E7067EA27FE680047EA17FE68E828F832290E6A32282 +:200FD40090E6A42290E6A52290E6A6229000002290E6B8E0FFBF80028022BF81028008BF1B +:200FF4008202803702107090E740E4F090E741F090E68AF090E68B7402F08064E51325E0B5 +:20101400FFE512420790E740EFF090E741E4F090E68AF090E68B7402F0804590E6BCE0F538 +:2010340082120F8CAE82AF838E048F05EE4F7003F582228C828D83E0FC30E0067E017F008E +:2010540080047E007F0090E740EEF090E741E4F090E68AF090E68B7402F0800475820022E6 +:201074007582012290E6B8E0FF6005BF0264801B90E6BAE0FFBF0105751300805E90E6BAA6 +:20109400E0FFBF060280547582002290E6BAE0703D90E6BCE0F582120F8CAE82AF83E0FD77 +:2010B4005305FE8E828F83EDF090E6BCE0FF30E7098F057E004305108D0753071F90E68326 +:2010D400EFF07E0043072090E683EFF0800D7582002290E6B9E0F5820206E475820122909B +:2010F400E6B8E0FF6008BF0202802902117C90E6BAE0FFBF020302118590E6BAE0FFBF01C2 +:2011140005751301806B90E6BAE0FFBF060280617582002290E6BAE0704A90E6BCE0F5821F +:20113400120F8CAE82AF83EE4F7003F582228E828F83E0FD7C004305018E828F83EDF090F0 +:20115400E6BCE0FF30E7098F057E004305108D0753071F90E683EFF07E0043072090E683AA +:20117400EFF0800D7582002290E6B9E0F5820206E475820122AF827E0110AF027E00EF600C +:201194000E75141C75153D7516A675173D800C7514A675153D75161C75173DEE1392AF2271 +:2011B40090E6BBE0FFBF01028019BF02028024BF0302802CBF060302126EBF070302127E34 +:2011D40002128B7E007F3D90E6B3EFF090E6B47400F02290E6B3E515F090E6B4E514F02222 +:2011F4007DE07E3D7F8090E6BAE0F5187B008B020BEAB5180280428D008E018F028D828ECF +:20121400838FF012152F28F8E439F9880589068A0774012DF9E43EFA8F0489828A838CF0A1 +:2012340012152FF9B9030280067D007E007F00ED4E6006C3E5189B50B5ED4E600F8D038EC4 +:201254000490E6B3ECF090E6B4EDF02290E6A0E0FF43070190E6A0EFF0227E127F3D90E62F +:20127400B3EFF090E6B47412F02290E6B3E517F090E6B4E516F02290E6A0E0FF43070190EA +:05129400E6A0EFF022CE +:200066007900E94400601B7A009019E5780175923CE493F2A308B800020592D9F4DAF27522 +:0200860092FFE7 +:12129900AA82AB83A2F73392D1F5826002D2F7ACF0225A +:1B12AB0020F71130F6138883A88220F509F6A8837583002280FEF280F5F02242 +:203F00000201530002163600021587000202010002016B000201B600021584000213BA00C9 +:203F20000213BC000213BD000213BE000213C10002163500021637000212C6000212C800E3 +:203F4000021589000213BA0002154B0002158500021586000215880002158A000215B90047 +:203F600002146B000213BA000213BA000213BA000213BB000213BF000213C2000213C400FF +:203F80000213C0000213C3000213C50002141B0002133700021362000213640002136600B2 +:183FA0000213380002136300021365000213B9000212C70002163400D5 +:0112C60032F5 +:0112C70032F4 +:0112C80032F3 +:2012C900AAF0FBE5828518F0A4FCADF0E5838518F0A42DFDE435F0FEE5828519F0A42DFDB2 +:2012E900E5F03EFEE433FFEA8518F0A42EFEE5F03FFFE5838519F0A42EFEE5F03FFFE58224 +:20130900851AF0A42EFEE5F03FFFEB8518F0A42FFFEA8519F0A42FFFE583851AF0A42FFFF5 +:0E132900E582851BF0A42F8EF08D838C82222E +:011337003283 +:011338003282 +:20008E007800E84400600A790075923CE4F309D8FC7801E84400600C7901903C00E4F0A306 +:0400AE00D8FCD9FAA7 +:201339007A10E4FBFCE58225E0F582E58333F583EB33FBEC33FCEB9518F5F0EC95194006A8 +:09135900FCABF0438201DADD2255 +:011362003258 +:011363003257 +:011364003256 +:011365003255 +:011366003254 +:20136700FBC2D530E715D2D5E4C39582F582E49583F583E495F0F5F0E49BFBE51B30E71762 +:20138700B2D5E4C39518F518E49519F519E4951AF51AE4951BF51BEB120D4730D513FBE430 +:1213A700C39582F582E49583F583E495F0F5F0E49B2280 +:0113B9003201 +:0113BA003200 +:0113BB0032FF +:0113BC0032FE +:0113BD0032FD +:0113BE0032FC +:0113BF0032FB +:0113C00032FA +:0113C10032F9 +:0113C20032F8 +:0113C30032F7 +:0113C40032F6 +:0113C50032F5 +:2013C600AE82AF8390E600E05418C423541F70057CB1FD801C90E600E05418C423541FFB37 +:2013E600BB01067A617B0180047AC27B028A048B058C188D19151874FFB518021519E5188F +:15140600451970F1EE24FFFAEF34FFFB8A068B07EA4B70DD2224 +:01141B00329E +:20141C00B98003EA13B34010EA2401FAE43BFBE43CFC50047C800582BC000EBB000BBA0014 +:20143C0008E4F5F0F583F58222A2D1E582138CF092F78B838A8222E4F583F58275F080F4D4 +:0F145C00A2D11322E4F583F58275F0C0747F22CC +:01146B00324E +:20146C0012158B30D502B2D1BF0009BC0003021460021453BC000302143DE583B4FF0BE5A1 +:20148C0082B4FF0302146002143DE582B4FF03021453C395835007247F400B02143D2480A2 +:2014AC00145003021453F582C3ED9AEE9BEF9C40111582C3EA33F9EB33FAEC33FBE433FC75 +:2014CC008005E4CCCBCAF9C08275F019C3E99DEA9EEB9FEC9400D5F002802D400EE99DF961 +:2014EC00EA9EFAEB9FFBEC9400FCC3B3E833F8E58233F582E58333F583C3E933F9EA33FAC1 +:20150C00EB33FBEC33FC80C4B3E4F938FAE43582FBE43583FCD082500405827C801215FD0A +:03152C0002143472 +:0D00590075814B121630E5826003020056DF +:1C152F0020F71430F6148883A88220F507E6A88375830022E280F7E49322E022CB +:01154B00326D +:20154C00C2D5E58330E70DD2D5E4C39582F582E49583F583E51930E70DB2D5E4C39518F51A +:18156C0018E49519F51912133930D50BE4C39582F582E49583F5832276 +:011584003234 +:011585003233 +:011586003232 +:011587003231 +:011588003230 +:01158900322F +:01158A00322E +:20158B00AA82AB83A2F73392D1F5826002D2F7ACF0E58124F9F8E6FD08E6FE0886F008E6C3 +:0E15AB00A2F73392D5F5836002D2F7AFF0229B +:0115B90032FF +:2015BA006040F82582500274FFF582E824F8501ECCCBCAF9E4CC24F85014CBCAF9E4CB2439 +:2015DA00F8500BCAF9E4CA24F8500379002224086010F8C3EC13FCEB13FBEA13FAE913F9EC +:0315FA00D8F12203 +:2015FD007804EC7011E58224F8500AF582E4C9CACBFCD8EF22EC7820058220E713D58201ED +:13161D0022C3E933F9EA33FAEB33FBEC33FCD8EA158222FA +:04163000758200229D +:011634003283 +:011635003282 +:011636003281 +:011637003280 +:00000001FF diff --git a/PyHT6022/Firmware/DSO6022BL/dso6022bl.c b/Firmware/DSO6022BL/dso6022bl.c similarity index 100% rename from PyHT6022/Firmware/DSO6022BL/dso6022bl.c rename to Firmware/DSO6022BL/dso6022bl.c diff --git a/PyHT6022/Firmware/DSO6022BL/fl_fw.sh b/Firmware/DSO6022BL/fl_fw.sh similarity index 100% rename from PyHT6022/Firmware/DSO6022BL/fl_fw.sh rename to Firmware/DSO6022BL/fl_fw.sh diff --git a/Firmware/README.md b/Firmware/README.md new file mode 100644 index 0000000..21822c8 --- /dev/null +++ b/Firmware/README.md @@ -0,0 +1,29 @@ +# About the firmware +The 6022BE (and 6022BL) has only limited persistent storage so the firmware must be uploaded to the device's RAM +every time the oscilloscope is powered up. +The dump of the packet transfer to the 6022BE was captured by [Robert](https://github.com/rpcope1/Hantek6022API) +and is given as `firmware_packet_dump.csv` and was used by him to build the **stock_firmware** in this module. + +This stock version was later analysed and improved by [Jochen](https://github.com/jhoenicke/Hantek6022API) +and Robert to create the two **mod_firmware** versions. +Without source code this was a not so easy task - good work! +If you're interested in the details read the huge EEVBLOG thread, this is a +[good starting point](https://www.eevblog.com/forum/testgear/hantek-6022be-20mhz-usb-dso/msg656059/#msg656059). + +The original custom firmware (for 6022BE) is based on fx2lib code. The latest version also allows reading/writing of EEPROMs and thus has all features like the stock and modded versions and allows an easy implementation of new features. + +My project [OpenHantek6022](https://github.com/OpenHantek/OpenHantek6022) uses the improved final versions [DSO6022BE](https://github.com/Ho-Ro/Hantek6022API/tree/master/PyHT6022/Firmware/DSO6022BE), [DSO6022BL](https://github.com/Ho-Ro/Hantek6022API/tree/master/PyHT6022/Firmware/DSO6022BL) and [DDS120](https://github.com/Ho-Ro/Hantek6022API/tree/master/PyHT6022/Firmware/DDS120) for the currently supported scope variants. These FWs provide more sampling rates (20 kS/s .. 30 MS/s) and more calibration-out frequencies as well as support for AC/DC coupling (small HW mod requred for Hantek scopes). + +Provided are different FW flavours as part of the python package: + +| **Name** | **Path** | **Comment** | +|--------------------|------------------------------|------------------------------------------------------------------| +| stock_firmware | stock/stock_fw.ihex | Firmware that was originally uploaded to the device by vendor SW | +| mod_firmware_01 | modded/mod_fw_01.ihex | Patched stock firmware with sample rate and stability improvements | +| mod_firmware_iso | modded/mod_fw_iso.ihex | Patched stock firmware that allows isochronous transfer (instead of bulk) | +| dso6022be_firmware | DSO6022BE/dso6022be-firmware.hex | backported from sigrok-fw | +| dso6022bl_firmware | DSO6022BL/dso6022bl-firmware.hex | backported from sigrok-fw | +| dds120_firmware | DDS120/dds120-firmware.hex | backported from sigrok-fw | + +Default: + firmware = default_firmware = dso6022be_firmware diff --git a/PyHT6022/Firmware/custom/Makefile b/Firmware/custom/Makefile similarity index 100% rename from PyHT6022/Firmware/custom/Makefile rename to Firmware/custom/Makefile diff --git a/PyHT6022/Firmware/custom/device.c b/Firmware/custom/device.c similarity index 100% rename from PyHT6022/Firmware/custom/device.c rename to Firmware/custom/device.c diff --git a/PyHT6022/Firmware/custom/dscr.a51 b/Firmware/custom/dscr.a51 similarity index 100% rename from PyHT6022/Firmware/custom/dscr.a51 rename to Firmware/custom/dscr.a51 diff --git a/PyHT6022/Firmware/custom/fw.c b/Firmware/custom/fw.c similarity index 100% rename from PyHT6022/Firmware/custom/fw.c rename to Firmware/custom/fw.c diff --git a/PyHT6022/Firmware/custom/lsusb_custom.lst b/Firmware/custom/lsusb_custom.lst similarity index 100% rename from PyHT6022/Firmware/custom/lsusb_custom.lst rename to Firmware/custom/lsusb_custom.lst diff --git a/PyHT6022/Firmware/dso602x_fw_version.h b/Firmware/dso602x_fw_version.h similarity index 61% rename from PyHT6022/Firmware/dso602x_fw_version.h rename to Firmware/dso602x_fw_version.h index c35925a..996ce3b 100644 --- a/PyHT6022/Firmware/dso602x_fw_version.h +++ b/Firmware/dso602x_fw_version.h @@ -6,7 +6,7 @@ const uint16_t DSO602x_FW_VER = 0x0210; -// setup.py: __version__ = '2.10.6' +// setup.py: __version__ = '2.10.7' // PyHT6022/LibUsbScope.py: FIRMWARE_VERSION = 0x0210 -// PyHT6022/Firmware/DSO6022BE/descriptor.inc: FIRMWARE_VERSION = 0x1002 +// Firmware/DSO6022BE/descriptor.inc: FIRMWARE_VERSION = 0x1002 diff --git a/Firmware/fx2lib/.gitignore b/Firmware/fx2lib/.gitignore new file mode 100644 index 0000000..382cdbf --- /dev/null +++ b/Firmware/fx2lib/.gitignore @@ -0,0 +1,21 @@ +*~ +.*~ +*.orig +*.new +*.asm +*.rel +*.lst +*.sym +*.adb +*.cdb +*.ihx +*.bix +*.rst +*.mem +*.map +*.lnk +*.kpf +*.swp +*.iic +docs/html +build diff --git a/Firmware/fx2lib/CHANGELOG b/Firmware/fx2lib/CHANGELOG new file mode 100644 index 0000000..fbe7fdd --- /dev/null +++ b/Firmware/fx2lib/CHANGELOG @@ -0,0 +1,32 @@ +0.2 + * Change I2C routines to return FALSE intead of infinite loop possibility. + * Addition of fx2load script to load eeprom information. + * EEprom upload/download example. + * New SETUP_TYPE macro + * Removed printfs from setupdat module. + * Add usb "other speed" descriptor handling to setupdat + * Support for usb suspend/wakeup + * Enhanced renumerate macro to handle properly when loading from eeprom + * Addition of framework files. Allows quick starting of new firmware projects. + * ihx2iic helper script. Allows easy converting of ihx files to iic for + loading to eeprom. + * New GPIF macros to set TC with 16 or 32 bit values. + * Addtional enable/disable macros for endpoint interrupts. + * Additional ep0 utilities (writeep0) + * Additional i2c write functionality for i2c parts requiring different + address width's or even no address data. + * Correct fx2 register documentation. + * Addition of serial io example. + * Added cancel_i2c_trans extern bool to allow canceling a blocked i2c transaction. + * FX1 development board debug light addresses. + * Various other minor bug fixes/optimizations. + * remove usbjt.h. In place, use autovector.h. jump table routines no longer + need defined in your firmware. fx2.lib contains default routines. Override + them with interrupt handlers you want to handle. + * added fx2ints.h. Interrupt numbers/macros for standard fx2 interrupts. + * added timer example + * Moved examples and firmwware framework to use common lib/fx2.mk Makefile. + fx2.mk can be easily adapted for any firmware project. + +0.1 + * Initial Release. diff --git a/Firmware/fx2lib/COPYING b/Firmware/fx2lib/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/Firmware/fx2lib/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Firmware/fx2lib/COPYING.LESSER b/Firmware/fx2lib/COPYING.LESSER new file mode 100644 index 0000000..cca7fc2 --- /dev/null +++ b/Firmware/fx2lib/COPYING.LESSER @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/Firmware/fx2lib/Makefile b/Firmware/fx2lib/Makefile new file mode 100644 index 0000000..7e31f3c --- /dev/null +++ b/Firmware/fx2lib/Makefile @@ -0,0 +1,29 @@ + + +VER=devel +TAG=HEAD + +.PHONY: all docs + +all: + make -C lib + make -C examples + +clean: + make -C lib clean + make -C examples clean + +docs: + doxygen docs/docs.conf + make -C docs/intro + +dist: all docs + mkdir -p build + git archive --prefix=fx2lib/ $(TAG) > build/fx2-$(VER).tar + tar -C .. -rf build/fx2-$(VER).tar \ + fx2lib/docs/html \ + fx2lib/lib/fx2.lib \ + fx2lib/docs/intro/intro.pdf + cat build/fx2-$(VER).tar | gzip > build/fx2-$(VER).tgz + + diff --git a/Firmware/fx2lib/NOTES b/Firmware/fx2lib/NOTES new file mode 100644 index 0000000..aff01c5 --- /dev/null +++ b/Firmware/fx2lib/NOTES @@ -0,0 +1,42 @@ +Notes on Various things I've learned about SDCC and the FX2 + +* libusb on Linux +* cycfx2prog: http://www.triplespark.net/elec/periph/USB-FX2/software/index.html + - most of this functionality is now in the fx2load package for python + - which is in examples/fx2 +* sdcc has sdcc/support/scripts/keil2sdcc.pl which I used to create the fx2regs.h file from the keil header. +* sdcc is little endian, keil is big endian (important if doing usb communication) +* xdata can go up to 64k on the EZ-USB development board but + - the fx2 chip itself only has 16k (end at 0x4000) Firmware written for other than the dev board + - should use --xram-size --xram-loc etc to make sure it isn't using memory beyond 16k. +* linux has objcopy, which can be used in place of Hex2bix for bix files + - objcopy -I ihex -O binary --pad-to=8192 input [output] + + +Memory + * 256 bytes internal + - lower 128=registers/bits (direct or indirect) + - upper 128=stack (or whatever but only indirect addressing) + - sfs occupy upper 128 space only direct addressing + + * external + - 16k on chip 0-0x3fff + - 512 bytes on chip scratch ram 0xe000 - 0xe1ff (data memory only) + - epbuffers and control at 0xe200-0xffff (data memory only) + + Only the on chip 16k and 512 bytes can be uploaded w/ eeprom or downloaded to host with SETUPPTR + Might be possible to load the descriptors to the scratch ram instead of code ram area? + +sdcc data types + data/near=direct addressable internal memory (default for model-small) + xdata/far=external ram (default for model-large) + idata=indirect addressable internal memory + pdata=access to xdata area, but uses sfr to get to address (sdcc 4.1) + code=code memory, study this more. + bit=uses lower 128 bit area + + +TODO: + * Possibly add CKCON and bmSTRETCH customization + * IN2CLR and INT4CLR registers can be used intead of explicitly clearing int2 and int4 interrupts. (Faster) + See (15.5) diff --git a/Firmware/fx2lib/README b/Firmware/fx2lib/README new file mode 100644 index 0000000..ead1b63 --- /dev/null +++ b/Firmware/fx2lib/README @@ -0,0 +1,41 @@ +Before building this library, you need have sdcc installed and in your path. + +http://sdcc.sf.net + +To build this library, run make + +> make + +This produces lib/fx2.lib. You can also run make in the lib folder. + +You can also build the documentation if you have doxygen installed. + +> make docs + +** Firmware framework Quickstart + +> cd fw +> make + +You can copy the fw directory to your own directory and customize it as needed. + +** More custom firmware + +To use routines included with this library in your own firmware, +add the include files to your include path and the lib file to your compile command: + +> sdcc -mmcs51 -I fx2.lib -L + +fx2lib also includes an example program for loading firmware onto your device. +See examples/fx2. + + +Enjoy! +Comments, Patches, all welcome. + +Contributors + Dennis Muhlestein + Ubixum, Inc + Steve Calfee + Sven Schnelle + Tim 'mithro' Ansell diff --git a/Firmware/fx2lib/appveyor.yml b/Firmware/fx2lib/appveyor.yml new file mode 100644 index 0000000..5abf6ea --- /dev/null +++ b/Firmware/fx2lib/appveyor.yml @@ -0,0 +1,16 @@ +version: 1.0.{build} + +image: Ubuntu1804 + +init: +- sh: >- + sudo apt-get update + + sudo apt-get install --quiet --yes sdcc libusb-1.0-0-dev doxygen doxygen-doc doxygen-gui graphviz rubber + +build_script: +- sh: make dist + +artifacts: +- path: build/fx2-devel.tgz + name: fx2-devel.tgz diff --git a/Firmware/fx2lib/docs/intro/.gitignore b/Firmware/fx2lib/docs/intro/.gitignore new file mode 100644 index 0000000..d59d748 --- /dev/null +++ b/Firmware/fx2lib/docs/intro/.gitignore @@ -0,0 +1,6 @@ +*.aux +*.log +*.toc +html +*.pdf +*.out diff --git a/Firmware/fx2lib/docs/intro/Makefile b/Firmware/fx2lib/docs/intro/Makefile new file mode 100644 index 0000000..c1f32e7 --- /dev/null +++ b/Firmware/fx2lib/docs/intro/Makefile @@ -0,0 +1,11 @@ + +.PHONY: pdf html + + +pdf: intro.pdf +intro.pdf: intro.tex + rubber -d intro + +html: intro.tex + mkdir -p html + latex2html -dir html intro.tex diff --git a/Firmware/fx2lib/docs/intro/intro.tex b/Firmware/fx2lib/docs/intro/intro.tex new file mode 100644 index 0000000..e499fd5 --- /dev/null +++ b/Firmware/fx2lib/docs/intro/intro.tex @@ -0,0 +1,80 @@ + +\documentclass[12pt]{article} +\usepackage[pdftex,bookmarks=true,linktocpage=true,pdfborder={0 0 0 0}]{hyperref} +\usepackage{amsmath} + +\newcommand{\itwoc}{$\text{I}^{2}\text{C}$ } + + +\title{Fx2lib Introduction} +\begin{document} +\maketitle +\tableofcontents +\section{Introduction} +Fx2lib is an open source library for the Cypress EZ-USB Fx2 8051 and variants. +It is written in C and can be compiled with \href{http://sdcc.sourceforge.net}{SDCC}. +Fx2lib contains libraries for performing common tasks with the Fx2 chip as well as a framework for starting new firmware projects. +There are also a number of utilities for performing common firmware development tasks. + +\section{Fx2lib Features} + +Fx2lib provides libaries for the following common firmware tasks: + +\begin{itemize} + \item Serial IO. Ease of setting BAUD rate and reading and writing from serial ports. + \item Vendor Commands. Handling of required USB vendor commands and ease of implementing your own vendor command handlers. + \item USB interrupts. Ease of enabling/disabling USB interrupts and adding your own interrupt handlers. + \item \itwoc IO. Ease of reading and writing to \itwoc devices. EEprom functions are also included. + \item GPIF. Functions for setting up the GPIF as well as performing single and fifo reads/writes. + \item Endpoints. Simplify reading/writing with endpoint 0. + \item Other definitions and macros. All Fx2 SFR, sbit and registers defined as well as other macros for common fx2 tasks. +\end{itemize} + +Detailed documentation for the library API is available online or with your downloaded fx2lib copy. + +\section{Fx2lib Utilities} + +\begin{itemize} + \item gpif2dat. Takes the output from the Cypress GPIF designer (the .c file) and creates an sdcc compatible c file with only the waveforms and initialization structures needed for use with the Fx2lib GPIF functions. + \item ihx2iic. Creates a compressed iic from your firmware ihx file. Used for storing your firmware on an eeprom. + \item fx2load. Command line interface and Python bindings for loading firmware onto an Fx2 device and for doing basic device IO. +\end{itemize} + +\section{Getting Started} + +\begin{enumerate} +\item Obtain Fx2lib. + + Fx2lib can be compiled from sources or is available as a pre-compiled library. + If you choose to compile Fx2lib from sources, simply make sure sdcc is in your path and run make in the fx2lib root folder. + Whether you have downloaded a pre-compiled version or build your own Fx2lib library, you should have fx2lib/lib/fx2.lib available for the examples and your own firmware. +\item Install the drivers. + + Fx2lib uses \href{http://libusb.sourceforge.net}{libusb} to handle low level USB communication with the underlying operating system. + Each operating system has different requirements for driver installation. + See the Fx2lib driver guide for details on installing USB drivers for your specific operating system. + You'll need to install the drivers specifically for the device you plan on doing the Fx2 development with. + +\item Running Example Firmware. + + Each firmware example has a Makefile and a load script. + Simply run make to create the associated .ihx file and then run make load to load the firmware onto your device. + The examples/NOTES contains more details on each examples firmware. + + The default load targets use the Cypress vendor id with the development board product ID. + Depending on your hardware, you'll need to change these appropriately. +\item Starting your own firmware. + + Fx2lib provides a quick start firmware framework in the fx2lib/fw directory. + Simply copy this directory to your own location and begin modifying the files to start your own firmware. + +\end{enumerate} + + +\section{Where Next} + + \begin{itemize} + \item \href{http://fx2lib.sourceforge.net/docs/}{Fx2lib API documentation} + \end{itemize} + +\end{document} diff --git a/Firmware/fx2lib/examples/Makefile b/Firmware/fx2lib/examples/Makefile new file mode 100644 index 0000000..4ff5f81 --- /dev/null +++ b/Firmware/fx2lib/examples/Makefile @@ -0,0 +1,10 @@ +DIRS= bulkloop debugdevice debugdevice_full_duplex eeprom i2c lights reset serial timers usbmon_c + +.PHONY: dirs $(DIRS) clean + +dirs: $(DIRS) +clean: $(DIRS) + +$(DIRS): + $(MAKE) -C $@ $(MAKECMDGOALS) + diff --git a/Firmware/fx2lib/examples/NOTES b/Firmware/fx2lib/examples/NOTES new file mode 100644 index 0000000..ab38355 --- /dev/null +++ b/Firmware/fx2lib/examples/NOTES @@ -0,0 +1,88 @@ +The examples here show various firmware examples and also various ways to +start new firmware projects as well as various ways to start communicating with your device. +In addition, you can look at the fx2.mk include and the example project Makefiles +to see how you might set up your own project. + +For simple examples, you can ignore the link warnings. (Those pertain to the usb jump table +and device descriptor areas and are not used for all examples) + +You can move up the food chain of programming languages pretty quickly if you like: + + C: Program Your Firmware + C++: Write a libusb driver + Python: Write Bindings for your driver so you can test things interactively! + +fx2: + An example firmware loader and basic firmware terminal using the above strategy. + Requires libusb-1.0, Python 2.5 + + Installation: + cd fx2 + python setup.py install + + + Use the fx2load w/ reset_bix function to load firmware onto a device. + Example: + python + > from fx2load import * + > openfx2() + > reset_bix('') + > f.do_usb_command (..... + > f.ep_bulk(...... + + There is also an fx2load script for doing the same thing with the command line. + + +eeprom: + Simple firmware for reading and writing information from the eeprom. The client.py + file contains a function to read an existing prom image. + + +lights: + A really simple program that cycles the lights on the CY3864 development board. + + +bulkloop: + Demonstrations: + * looping data on endpoints. + * Custom device descriptor. + * Vendor commands. + * Usb jump table. + * serial IO + + +debugdevice: + This firmware implements a half-duplex version of the EHCI defined "debug + device", which is used for low level hardware debugging in the USB stack. + + +debugdevice_full_duplex: + This firmware implements a full-duplex version of the EHCI defined "debug + device", which is used for low level hardware debugging in the USB stack. + + +i2c: + A port of the Cypress i2c example. + + +reset: + Shows writing to the eeprom on the dev board. The included iic data is the default data + on the dev board and you can use this program to reset your board back to the default + state if you happen to write a non-working iic file to the device. You shouldn't + probably use this on a real board unless you really know what you're doing :) + + +serial: + A simple terminal echo firmware. Echos whatever you type back to the serial terminal. + + +timers: + Demonstrates setting up timers t0, t1, and t2 to be 16 bit counters and also demonstrates + installing interrupts to process the timer overlow. + + +usbmon_c: + Firmware used to test usbmon + (https://www.kernel.org/doc/Documentation/usb/usbmon.txt) collected traces of + the I/O on the USB bus. + diff --git a/Firmware/fx2lib/examples/bulkloop/Makefile b/Firmware/fx2lib/examples/bulkloop/Makefile new file mode 100644 index 0000000..c5cb8c6 --- /dev/null +++ b/Firmware/fx2lib/examples/bulkloop/Makefile @@ -0,0 +1,12 @@ +FX2LIBDIR=../../ +BASENAME = bulkloop +SOURCES=bulkloop.c +A51_SOURCES=dscr.a51 +PID=0x1004 + +include $(FX2LIBDIR)lib/fx2.mk + + +test: test.cpp + g++ -o test test.cpp -lusb-1.0 + diff --git a/Firmware/fx2lib/examples/bulkloop/bulkloop.c b/Firmware/fx2lib/examples/bulkloop/bulkloop.c new file mode 100644 index 0000000..59ce010 --- /dev/null +++ b/Firmware/fx2lib/examples/bulkloop/bulkloop.c @@ -0,0 +1,227 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +#define SYNCDELAY SYNCDELAY4 +#define REARMVAL 0x80 +#define REARM() EP2BCL=REARMVAL + + + +volatile WORD bytes; +volatile __bit gotbuf; +volatile BYTE icount; +volatile __bit got_sud; +DWORD lcount; +__bit on; + +void main() { + + REVCTL=0; // not using advanced endpoint controls + + d2off(); + on=0; + lcount=0; + got_sud=FALSE; + icount=0; + gotbuf=FALSE; + bytes=0; + + // renumerate + RENUMERATE_UNCOND(); + + + SETCPUFREQ(CLK_48M); + SETIF48MHZ(); + sio0_init(57600); + + + USE_USB_INTS(); + ENABLE_SUDAV(); + ENABLE_SOF(); + ENABLE_HISPEED(); + ENABLE_USBRESET(); + + + // only valid endpoints are 2/6 + EP2CFG = 0xA2; // 10100010 + SYNCDELAY; + EP6CFG = 0xE2; // 11100010 + SYNCDELAY; + EP1INCFG &= ~bmVALID; + SYNCDELAY; + EP1OUTCFG &= ~bmVALID; + SYNCDELAY; + EP4CFG &= ~bmVALID; + SYNCDELAY; + EP8CFG &= ~bmVALID; + SYNCDELAY; + + + // arm ep2 + EP2BCL = 0x80; // write once + SYNCDELAY; + EP2BCL = 0x80; // do it again + + + // make it so we enumberate + + + EA=1; // global interrupt enable + printf ( "Done initializing stuff\n" ); + + + d3off(); + + while(TRUE) { + + if ( got_sud ) { + printf ( "Handle setupdata\n" ); + handle_setupdata(); + got_sud=FALSE; + } + + if ( !(EP2468STAT & bmEP2EMPTY) ) { + printf ( "ep2 out received data\n" ); + if ( !(EP2468STAT & bmEP6FULL) ) { // wait for at least one empty in buffer + WORD i; + printf ( "Sending data to ep6 in\n"); + + bytes = MAKEWORD(EP2BCH,EP2BCL); + + for (i=0;i +#include +#include + +int main(int argc, char* argv[]) { + + libusb_context* ctx; + libusb_init(&ctx); + + libusb_device_handle* hndl = libusb_open_device_with_vid_pid(ctx,0x04b4,0x1004); + libusb_claim_interface(hndl,0); + libusb_set_interface_alt_setting(hndl,0,0); + + unsigned short buf[100]; + for (int i=0;i<100;++i) { + buf[i]=i; + } + int transferred; + int rv=libusb_bulk_transfer(hndl,0x02,(unsigned char*)buf,sizeof(buf),&transferred,100); + if(rv) { + printf ( "OUT Transfer failed: %d\n", rv ); + return rv; + } + + unsigned short buf2[100]; + rv=libusb_bulk_transfer(hndl,0x86,(unsigned char*)buf2,sizeof(buf2),&transferred,100); + if(rv) { + printf ( "IN Transfer failed: %d\n", rv ); + return rv; + } + for (int i=0;i<100;++i) { + printf ( "%d ", buf2[i] ); + } + printf("\n"); + + return 0; +} diff --git a/Firmware/fx2lib/examples/bulkloop/test.py b/Firmware/fx2lib/examples/bulkloop/test.py new file mode 100644 index 0000000..80aaf81 --- /dev/null +++ b/Firmware/fx2lib/examples/bulkloop/test.py @@ -0,0 +1,39 @@ +# Copyright (C) 2009 Ubixum, Inc. +# +# This library is free software; you can redistribute it and/or +# +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USAimport struct + + +import struct + +from fx2load import * + +openfx2(0x04b4,0x1004) + + +def do_bulk(): + # send 100 shorts to ep2 + + buf=struct.pack ( 'H'*100, *[i for i in range(100)] ) + f.ep_bulk( buf, 0x02, 1000) + + # read them back out + buf='\x00'*200 + f.ep_bulk( buf, 0x86, 1000) + + + print struct.unpack ( 'H'*100, buf ) + +[do_bulk() for i in range(3)] diff --git a/Firmware/fx2lib/examples/debugdevice/Makefile b/Firmware/fx2lib/examples/debugdevice/Makefile new file mode 100644 index 0000000..0ded63a --- /dev/null +++ b/Firmware/fx2lib/examples/debugdevice/Makefile @@ -0,0 +1,8 @@ +FX2LIBDIR=../../ +BASENAME = debugdev +SOURCES=debugdev.c +A51_SOURCES=dscr.a51 +PID=0x1004 + +include $(FX2LIBDIR)lib/fx2.mk + diff --git a/Firmware/fx2lib/examples/debugdevice/debugdev.c b/Firmware/fx2lib/examples/debugdevice/debugdev.c new file mode 100644 index 0000000..e2a5220 --- /dev/null +++ b/Firmware/fx2lib/examples/debugdevice/debugdev.c @@ -0,0 +1,236 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SYNCDELAY SYNCDELAY4 +#define REARMVAL 0x80 +#define REARM() EP2BCL=REARMVAL + +volatile WORD bytes; +volatile __bit gotbuf; +volatile BYTE icount; +volatile __bit got_sud; +DWORD lcount; +__bit on; + +extern WORD debug_dscr; +extern void _transchar(char c); +void main() +{ + REVCTL=0; // not using advanced endpoint controls + + d2off(); + on=0; + lcount=0; + got_sud=FALSE; + icount=0; + gotbuf=FALSE; + bytes=0; + + // renumerate + RENUMERATE_UNCOND(); + + + SETCPUFREQ(CLK_48M); + SETIF48MHZ(); + sio0_init(115200); + + + USE_USB_INTS(); + ENABLE_SUDAV(); + ENABLE_SOF(); + ENABLE_HISPEED(); + ENABLE_USBRESET(); + + + // only valid endpoints are 2/6 + EP2CFG = 0xA2; // 10100010 + SYNCDELAY; + EP6CFG = 0xE2; // 11100010 + SYNCDELAY; + EP1INCFG &= ~bmVALID; + SYNCDELAY; + EP1OUTCFG &= ~bmVALID; + SYNCDELAY; + EP4CFG &= ~bmVALID; + SYNCDELAY; + EP8CFG &= ~bmVALID; + SYNCDELAY; + + + // arm ep2 + EP2BCL = 0x80; // write once + SYNCDELAY; + EP2BCL = 0x80; // do it again + + + // make it so we enumberate + + + EA=1; // global __interrupt enable + printf ( "USB DEBUG: Done initializing stuff\n" ); + + + d3off(); + + while(TRUE) { + + if ( got_sud ) { + handle_setupdata(); + got_sud=FALSE; + } + + if ( !(EP2468STAT & bmEP2EMPTY) ) { + if ( !(EP2468STAT & bmEP6FULL) ) { // wait for at least one empty in buffer + WORD i; + + bytes = MAKEWORD(EP2BCH,EP2BCL); + + for (i=0;i + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SYNCDELAY SYNCDELAY4 +#define REARMVAL 0x80 +#define REARM() EP2BCL=REARMVAL + +volatile __bit got_sud; +extern __code WORD debug_dscr; + +#define INPUTDATA IOB +#define OUTPUTDATA IOD + +#define DVALID_IN (1 << 0) +#define DLAST_IN (1 << 2) +#define DRDY_IN (1 << 3) + +#define DVALID_OUT (1 << 4) +#define DLAST_OUT (1 << 6) +#define DRDY_OUT (1 << 7) + +typedef enum { + TX_STATE_IDLE=0, + TX_STATE_DATA, + TX_STATE_ACK, +} tx_state_t; + +typedef enum { + RX_STATE_IDLE=0, + RX_STATE_DATA, + RX_STATE_ACK, +} rx_state_t; + +static void tx_state(void) +{ + static int offset, last; + static tx_state_t state = TX_STATE_IDLE; + + switch(state) { + case TX_STATE_IDLE: + if (EP2468STAT & bmEP6FULL) + break; + IOA |= DRDY_OUT; + + if(!(IOA & DVALID_IN)) + break; + state = TX_STATE_DATA; + /* intentional fall through */ + + case TX_STATE_DATA: + last = IOA & DLAST_IN; + EP6FIFOBUF[offset] = INPUTDATA; + IOA &= ~DRDY_OUT; + state = TX_STATE_ACK; + /* intentional fall through */ + + case TX_STATE_ACK: + if (IOA & DVALID_IN) + break; + offset++; + if (last) { + EP6BCH = MSB(offset); + SYNCDELAY; + EP6BCL = LSB(offset); + state = TX_STATE_IDLE; + offset = 0; + break; + } + state = TX_STATE_IDLE;; + break; + default: + state = TX_STATE_IDLE; + } +} + +static void rx_state(void) +{ + static int offset, remaining; + static rx_state_t state = RX_STATE_IDLE; + + switch(state) { + case RX_STATE_IDLE: + if (EP2468STAT & bmEP2EMPTY) + break; + + state = RX_STATE_DATA; + offset = 0; + remaining = MAKEWORD(EP2BCH, EP2BCL); + break; + + case RX_STATE_DATA: + if (!(IOA & DRDY_IN)) + break; + + OUTPUTDATA = EP2FIFOBUF[offset++]; + + if (--remaining) + IOA &= ~DLAST_OUT; + else + IOA |= DLAST_OUT; + + IOA |= DVALID_OUT; + + state = RX_STATE_ACK; + break; + + case RX_STATE_ACK: + if (IOA & DRDY_IN) + break; + + IOA &= ~DVALID_OUT; + + if (remaining) { + state = RX_STATE_DATA; + } else { + state = RX_STATE_IDLE; + REARM(); + } + break; + default: + state = RX_STATE_IDLE; + } +} + +static void mainloop(void) +{ + while(TRUE) { + if (got_sud) { + handle_setupdata(); + got_sud=FALSE; + } + tx_state(); + rx_state(); + } +} + +static void clock_setup(void) +{ + SETCPUFREQ(CLK_48M); + SETIF48MHZ(); +} + +static void usb_setup(void) +{ + RENUMERATE_UNCOND(); + + USE_USB_INTS(); + ENABLE_SUDAV(); + ENABLE_SOF(); + ENABLE_HISPEED(); + ENABLE_USBRESET(); + + /* INT endpoint */ + EP1INCFG = bmVALID | (3 << 4); + SYNCDELAY; + + /* BULK IN endpoint EP2 */ + EP2CFG = 0xA2; // 10100010 + SYNCDELAY; + + /* BULK OUT endpoint EP6 */ + EP6CFG = 0xE2; + SYNCDELAY; + + /* disable all other endpoints */ + + EP1OUTCFG &= ~bmVALID; + SYNCDELAY; + + EP4CFG &= ~bmVALID; + SYNCDELAY; + + EP8CFG &= ~bmVALID; + SYNCDELAY; + + // arm ep2 + EP2BCL = 0x80; // write once + SYNCDELAY; + EP2BCL = 0x80; // do it again +} + +static void port_setup(void) +{ + IOA = 0; + IOB = 0xff; + IOD = 0xff; + + OEA = 0xf0; /* [3:0] INPUT, [7:4] OUTPUT */ + OEB = 0; /* INPUTDATA */ + OED = 0xff; /* OUTPUTDATA */ +} + +void main() +{ + REVCTL=0; // not using advanced endpoint controls + + port_setup(); + + clock_setup(); + + usb_setup(); + + delay(10); + + EA=1; // global __interrupt enable + + mainloop(); +} + +#define VC_EPSTAT 0xB1 + +BOOL handle_vendorcommand(BYTE cmd) +{ + __xdata BYTE* pep; + switch ( cmd ) { + case 6: + return TRUE; + case VC_EPSTAT: + + pep = ep_addr(SETUPDAT[2]); + if (pep) { + EP0BUF[0] = *pep; + EP0BCH=0; + EP0BCL=1; + return TRUE; + } + default: + } + return FALSE; +} + +// this firmware only supports 0,0 +BOOL handle_get_interface(BYTE ifc, BYTE *alt_ifc) +{ + if (ifc) + return FALSE; + *alt_ifc=0; + return TRUE; +} + +BOOL handle_set_interface(BYTE ifc, BYTE alt_ifc) +{ + if (ifc==0&&alt_ifc==0) { + // SEE TRM 2.3.7 + // reset toggles + RESETTOGGLE(0x02); + RESETTOGGLE(0x86); + // restore endpoints to default condition + RESETFIFO(0x02); + EP2BCL=0x80; + SYNCDELAY; + EP2BCL=0X80; + SYNCDELAY; + RESETFIFO(0x86); + return TRUE; + } else + return FALSE; +} + +// get/set configuration +BYTE handle_get_configuration() +{ + return 1; +} + +BOOL handle_get_descriptor() +{ + BYTE desc = SETUPDAT[3]; + if (desc != DSCR_DEBUG_TYPE) + return FALSE; + + SUDPTRH = MSB((WORD)&debug_dscr); + SUDPTRL = LSB((WORD)&debug_dscr); + return TRUE; +} + +BOOL handle_set_configuration(BYTE cfg) +{ + + return cfg==1 ? TRUE : FALSE; // we only handle cfg 1 +} + + +// copied usb jt routines from usbjt.h +void sudav_isr() __interrupt SUDAV_ISR +{ + got_sud = TRUE; + CLEAR_SUDAV(); +} + +void sof_isr () __interrupt SOF_ISR __using 1 +{ + CLEAR_SOF(); +} + +void usbreset_isr() __interrupt USBRESET_ISR +{ + handle_hispeed(FALSE); + CLEAR_USBRESET(); +} + +void hispeed_isr() __interrupt HISPEED_ISR +{ + handle_hispeed(TRUE); + CLEAR_HISPEED(); +} diff --git a/Firmware/fx2lib/examples/debugdevice_full_duplex/download.sh b/Firmware/fx2lib/examples/debugdevice_full_duplex/download.sh new file mode 100755 index 0000000..e7dbeed --- /dev/null +++ b/Firmware/fx2lib/examples/debugdevice_full_duplex/download.sh @@ -0,0 +1,15 @@ +#!/bin/bash -e + +DEVS=$(lsusb|grep 04b4:8613|sed 's/:.*//;s/Bus //;s/Device //;s/ /\//') + +if [ -z "$1" ]; then + echo "$0: usage: $0 " + exit 1; +fi + +for dev in $DEVS;do + echo "Downloading $1 to $dev" + sudo /sbin/fxload -D /dev/bus/usb/$dev -t fx2lp -I $1 +done + +exit 0 \ No newline at end of file diff --git a/Firmware/fx2lib/examples/debugdevice_full_duplex/dscr.a51 b/Firmware/fx2lib/examples/debugdevice_full_duplex/dscr.a51 new file mode 100644 index 0000000..ca85fa4 --- /dev/null +++ b/Firmware/fx2lib/examples/debugdevice_full_duplex/dscr.a51 @@ -0,0 +1,356 @@ +; Copyright (C) 2009 Ubixum, Inc. +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +; this is a the default +; full speed and high speed +; descriptors found in the TRM +; change however you want but leave +; the descriptor pointers so the setupdat.c file works right + + +.module DEV_DSCR + +; descriptor types +; same as setupdat.h +DSCR_DEVICE_TYPE=1 +DSCR_CONFIG_TYPE=2 +DSCR_STRING_TYPE=3 +DSCR_INTERFACE_TYPE=4 +DSCR_ENDPOINT_TYPE=5 +DSCR_DEVQUAL_TYPE=6 + +; for the repeating interfaces +DSCR_INTERFACE_LEN=9 +DSCR_ENDPOINT_LEN=7 + +; endpoint types +ENDPOINT_TYPE_CONTROL=0 +ENDPOINT_TYPE_ISO=1 +ENDPOINT_TYPE_BULK=2 +ENDPOINT_TYPE_INT=3 + + .globl _dev_dscr, _dev_qual_dscr, _highspd_dscr, _fullspd_dscr, _debug_dscr, _dev_strings, _dev_strings_end +; These need to be in code memory. If +; they aren't you'll have to manully copy them somewhere +; in code memory otherwise SUDPTRH:L don't work right + .area DSCR_AREA (CODE) + +_dev_dscr: + .db dev_dscr_end-_dev_dscr ; len + .db DSCR_DEVICE_TYPE ; type + .dw 0x0002 ; usb 2.0 + .db 0x02 ; class (vendor specific) + .db 0x00 ; subclass (vendor specific) + .db 0x00 ; protocol (vendor specific) + .db 0x40 ; packet size (ep0) + .dw 0xb404 ; vendor id + .dw 0x1386 ; product id + .dw 0x0100 ; version id + .db 0x01 ; manufacturure str idx + .db 0x02 ; product str idx + .db 0x00 ; serial str idx + .db 0x01 ; n configurations +dev_dscr_end: + +_dev_qual_dscr: + .db dev_qualdscr_end-_dev_qual_dscr + .db DSCR_DEVQUAL_TYPE + .dw 0x0002 ; usb 2.0 + .db 0x2 + .db 0x00 + .db 0x0 + .db 64 ; max packet + .db 1 ; n configs + .db 0 ; extra reserved byte +dev_qualdscr_end: + +_debug_dscr: + .db _debug_dscr_end - _debug_dscr + .db 10 + .db 0x86 + .db 0x02 +_debug_dscr_end: + + +_highspd_dscr: + .db highspd_dscr_end-_highspd_dscr ; dscr len ;; Descriptor length + .db DSCR_CONFIG_TYPE + ; can't use .dw because byte order is different + .db (highspd_dscr_realend-_highspd_dscr) % 256 ; total length of config lsb + .db (highspd_dscr_realend-_highspd_dscr) / 256 ; total length of config msb + .db 2 ; n interfaces + .db 1 ; config number + .db 0 ; config string + .db 0x80 ; attrs = bus powered, no wakeup + .db 0x32 ; max power = 100ma +highspd_dscr_end: + +; all the interfaces next +; NOTE the default TRM actually has more alt interfaces +; but you can add them back in if you need them. +; here, we just use the default alt setting 1 from the trm + ; control endpoints + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0x00 ; index + .db 0x00 ; alt setting idx + .db 0x01 ; n endpoints + .db 0x02 ; class + .db 0x02 + .db 0x01 + .db 0x00 ; string index + + ; CDC header + .db 0x05 + .db 0x24 + .db 0x00 + .db 0x10 + .db 0x01 + + ; CDC ACM + .db 0x04 + .db 0x24 + .db 0x02 + .db 0x00 + + ; CDC union + .db 0x05 + .db 0x24 + .db 0x06 + .db 0x00 + .db 0x01 + + ; CDC call managment + .db 0x05 + .db 0x24 + .db 0x01 + .db 0x01 + .db 0x01 + +; endpoint 1 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x81 ; ep1 dir=IN and address + .db ENDPOINT_TYPE_INT ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=512 bytes + .db 0x40 ; polling interval + + + ; data endpoints + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0x01 ; index + .db 0x00 ; alt setting idx + .db 0x02 ; n endpoints + .db 0x0a ; class + .db 0x00 + .db 0x00 + .db 0x00 ; string index + +; endpoint 2 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x02 ; ep2 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x86 ; ep6 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +highspd_dscr_realend: + + .even +_fullspd_dscr: + .db fullspd_dscr_end-_fullspd_dscr ; dscr len + .db DSCR_CONFIG_TYPE + ; can't use .dw because byte order is different + .db (fullspd_dscr_realend-_fullspd_dscr) % 256 ; total length of config lsb + .db (fullspd_dscr_realend-_fullspd_dscr) / 256 ; total length of config msb + .db 2 ; n interfaces + .db 1 ; config number + .db 0 ; config string + .db 0x80 ; attrs = bus powered, no wakeup + .db 0x32 ; max power = 100ma +fullspd_dscr_end: + +; all the interfaces next +; NOTE the default TRM actually has more alt interfaces +; but you can add them back in if you need them. +; here, we just use the default alt setting 1 from the trm + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 0 ; alt setting idx + .db 2 ; n endpoints + .db 0x2 ; class + .db 0x2 + .db 0x1 + .db 3 ; string index + + ; CDC header + .db 0x05 + .db 0x24 + .db 0x00 + .db 0x10 + .db 0x01 + + ; CDC ACM + .db 0x04 + .db 0x24 + .db 0x02 + .db 0x00 + + ; CDC union + .db 0x05 + .db 0x24 + .db 0x06 + .db 0x00 + .db 0x01 + + ; CDC call managment + .db 0x05 + .db 0x24 + .db 0x01 + .db 0x01 + .db 0x01 + +; endpoint 1 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x81 ; ep1 dir=IN and address + .db ENDPOINT_TYPE_INT ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=512 bytes + .db 0x40 ; polling interval + + + ; data endpoints + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0x01 ; index + .db 0x00 ; alt setting idx + .db 0x02 ; n endpoints + .db 0x0a ; class + .db 0x00 + .db 0x00 + .db 0x00 ; string index + +; endpoint 2 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x02 ; ep2 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x86 ; ep6 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +fullspd_dscr_realend: + +.even +_dev_strings: +; sample string +_string0: + .db string0end-_string0 ; len + .db DSCR_STRING_TYPE + .db 0x09, 0x04 ; who knows +string0end: +; add more strings here + +_string1: + .db string1end-_string1 + .db DSCR_STRING_TYPE + .ascii 'N' + .db 0 + .ascii 'o' + .db 0 + .ascii 'n' + .db 0 + .ascii 'e' + .db 0 +string1end: + +_string2: + .db string2end-_string2 + .db DSCR_STRING_TYPE + .ascii 'E' + .db 0 + .ascii 'H' + .db 0 + .ascii 'C' + .db 0 + .ascii 'I' + .db 0 + .ascii ' ' + .db 0 + .ascii 'D' + .db 0 + .ascii 'e' + .db 0 + .ascii 'b' + .db 0 + .ascii 'u' + .db 0 + .ascii 'g' + .db 0 + .ascii ' ' + .db 0 + .ascii 'c' + .db 0 + .ascii 'a' + .db 0 + .ascii 'b' + .db 0 + .ascii 'l' + .db 0 + .ascii 'e' + .db 0 +string2end: + +_string3: + .db string3end-_string3 + .db DSCR_STRING_TYPE + .ascii 'i' + .db 0 + .ascii 'F' + .db 0 + .ascii 'a' + .db 0 + .ascii 'c' + .db 0 + .ascii 'e' + .db 0 +string3end: + +_dev_strings_end: + .dw 0x0000 ; just in case someone passes an index higher than the end to the firmware diff --git a/Firmware/fx2lib/examples/debugdevice_full_duplex/terminal.c b/Firmware/fx2lib/examples/debugdevice_full_duplex/terminal.c new file mode 100644 index 0000000..a9d5eef --- /dev/null +++ b/Firmware/fx2lib/examples/debugdevice_full_duplex/terminal.c @@ -0,0 +1,153 @@ +/** + * Copyright (C) 2012 Sven Schnelle + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ +#include +#include +#include +#include +#include +#include + +void tp_diff(struct timespec *diff, struct timespec *start, struct timespec *end) +{ + if (end->tv_nsec - start->tv_nsec < 0) { + diff->tv_sec = end->tv_sec - start->tv_sec - 1; + diff->tv_nsec = 1000000000 + end->tv_nsec - start->tv_nsec; + } else { + diff->tv_sec = end->tv_sec - start->tv_sec; + diff->tv_nsec = end->tv_nsec - start->tv_nsec; + } +} + +static int format_timediff(struct timespec *diff, char *out, int outlen) +{ + if (diff->tv_sec > 1) + return snprintf(out, outlen, "%d.%02lds", (int)diff->tv_sec, + diff->tv_nsec / 10000000); + + if (diff->tv_nsec > 1000000) + return snprintf(out, outlen, "%ldms", diff->tv_nsec / 1000000); + + if (diff->tv_nsec > 1000) + return snprintf(out, outlen, "%ldus", diff->tv_nsec / 1000); + + return snprintf(out, outlen, "%ldns", diff->tv_nsec); + +} + +static int terminal_loop(libusb_device_handle *hndl, FILE *outfile) +{ + unsigned char buf[512]; + char timebuf[32]; + + struct timespec tp, oldtp, diff, lastlinetp, linediff; + unsigned char c; + int print_time = 1; + int len, ret, i; + + if (clock_gettime(CLOCK_MONOTONIC, &oldtp) == -1) { + fprintf(stderr, "clock_gettime: %s\n", strerror(errno)); + return -1; + } + + memcpy(&lastlinetp, &oldtp, sizeof(lastlinetp)); + for(;;) { + ret = libusb_bulk_transfer(hndl, 0x86, (unsigned char*)buf ,sizeof(buf), &len, sizeof(buf)); + + if (ret == -4) { + fprintf(stderr, "device disappeared\n"); + return -1; + } + + if(ret != -7 && ret != 0) { + printf("IN Transfer failed: %d\n", ret); + return -1; + } + + for (i = 0; i < len; i++) { + + if (print_time) { + print_time = 0; + if (clock_gettime(CLOCK_MONOTONIC, &tp) == -1) { + fprintf(stderr, "clock_gettime: %s\n", strerror(errno)); + return -1; + } + + tp_diff(&diff, &oldtp, &tp); + tp_diff(&linediff, &lastlinetp, &tp); + + format_timediff(&linediff, timebuf, sizeof(timebuf)-1); + + printf("%3d.%03ld [%5s]: ", (int)diff.tv_sec, diff.tv_nsec / 1000000, timebuf); + fprintf(outfile, "%3d.%03ld [%5s]: ", (int)diff.tv_sec, diff.tv_nsec / 1000000, timebuf); + + memcpy(&lastlinetp, &tp, sizeof(lastlinetp)); + } + + c = buf[i]; + + if (c == '\r') + continue; + + printf ("%c", c); + + print_time = !!(c == '\n'); + + + if (outfile) + fputc(buf[i], outfile); + } + } +} + +int main(int argc __attribute__((unused)), + char **argv __attribute__((unused))) +{ + FILE *outfile; + libusb_context* ctx; + libusb_device_handle *hndl; + + libusb_init(&ctx); + +restart: + hndl = libusb_open_device_with_vid_pid(ctx, 0x4b4, 0x8613); + if (!hndl) { +// fprintf(stderr, "failed to open device\n"); + sleep(1); + goto restart; + } + + libusb_claim_interface(hndl, 0); + libusb_set_interface_alt_setting(hndl, 0, 0); + + printf("Device opened\n"); + + outfile = fopen("debuglog.txt", "w+"); + if (!outfile) { + fprintf(stderr, "fopen: debuglog.txt: %s", strerror(errno)); + goto out; + } + + if (terminal_loop(hndl, outfile) == -1) + goto restart; + +out: + if (outfile) + fclose(outfile); + libusb_close(hndl); + return 0; +} diff --git a/Firmware/fx2lib/examples/debugdevice_full_duplex/test.cpp b/Firmware/fx2lib/examples/debugdevice_full_duplex/test.cpp new file mode 100644 index 0000000..e7062eb --- /dev/null +++ b/Firmware/fx2lib/examples/debugdevice_full_duplex/test.cpp @@ -0,0 +1,110 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ +#include +#include +#include +#include + +int main(int argc __attribute__((unused)), + char **argv __attribute__((unused))) +{ + int transferred, rv, i, hdlidx; + libusb_context* ctx; + unsigned char buf[256]; + libusb_device_handle *hndl[2]; + ssize_t devcount; + struct libusb_device_descriptor desc; + + libusb_device **devlist; + libusb_init(&ctx); + + devcount = libusb_get_device_list(ctx, &devlist); + + for(i = 0, hdlidx = 0; i < devcount && hdlidx < 2; i++) { + if (libusb_get_device_descriptor(devlist[i], &desc) != 0) + continue; + + if (desc.idVendor == 0x04b4 && desc.idProduct == 0x8613) { + if (!(libusb_open(devlist[i], &hndl[hdlidx]))) { + printf("opened device %d\n", hdlidx); + hdlidx++; + } + } + + } + + if (hdlidx != 2) { + fprintf(stderr, "Need two devices, have %d\n", hdlidx); + return 1; + } + + libusb_claim_interface(hndl[0],0); + libusb_claim_interface(hndl[1],0); + + libusb_set_interface_alt_setting(hndl[0], 0, 0); + libusb_set_interface_alt_setting(hndl[1], 0, 0); + + for (i = 0; i < (int)sizeof(buf); i++) + buf[i] = i; + + printf("OUT transfer to device 0, PIPE 2\n"); + rv = libusb_bulk_transfer(hndl[0], 0x02, buf, sizeof(buf), &transferred, sizeof(buf)); + + if(rv) + printf("OUT Transfer failed: %d\n", rv); + + printf("IN transfer to device 1, PIPE 6\n"); + + memset(buf, 0, sizeof(buf)); + transferred = 0; + + rv=libusb_bulk_transfer(hndl[1], 0x86, (unsigned char*)buf ,sizeof(buf), &transferred, sizeof(buf)); + if(rv) + printf("IN Transfer failed: %d\n", rv); + + printf("received %d bytes:\n", transferred); + + for (i = 0; i < transferred; i++) + printf ("%02x ", buf[i]); + printf("\n"); + + printf("OUT transfer to device 1, PIPE 2\n"); + rv = libusb_bulk_transfer(hndl[1], 0x02, buf, sizeof(buf), &transferred, sizeof(buf)); + + if(rv) + printf("OUT Transfer failed: %d\n", rv); + + printf("IN transfer to device 0, PIPE 6\n"); + + memset(buf, 0, sizeof(buf)); + transferred = 0; + + rv=libusb_bulk_transfer(hndl[0], 0x86, (unsigned char*)buf ,sizeof(buf), &transferred, sizeof(buf)); + if(rv) + printf("IN Transfer failed: %d\n", rv); + + printf("received %d bytes:\n", transferred); + + for (i = 0; i < transferred; i++) + printf ("%02x ", buf[i]); + printf("\n"); + + libusb_free_device_list(devlist, 1); + libusb_close(hndl[0]); + return 0; +} diff --git a/Firmware/fx2lib/examples/eeprom/Makefile b/Firmware/fx2lib/examples/eeprom/Makefile new file mode 100644 index 0000000..0830aa9 --- /dev/null +++ b/Firmware/fx2lib/examples/eeprom/Makefile @@ -0,0 +1,10 @@ +DIRS= firmware + +.PHONY: dirs $(DIRS) clean + +dirs: $(DIRS) +clean: $(DIRS) + +$(DIRS): + $(MAKE) -C $@ $(MAKECMDGOALS) + diff --git a/Firmware/fx2lib/examples/eeprom/client.py b/Firmware/fx2lib/examples/eeprom/client.py new file mode 100644 index 0000000..80d630f --- /dev/null +++ b/Firmware/fx2lib/examples/eeprom/client.py @@ -0,0 +1,92 @@ +# Copyright (C) 2009 Ubixum, Inc. +# +# This library is free software; you can redistribute it and/or +# +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +import sys +from fx2load import * + + +def get_eeprom(addr,length): + assert f.isopen() + + prom_val = ''; + while len(prom_val) 1024 and 1024 or length-len(prom_val) + ret=f.do_usb_command ( buf, + 0xc0, + 0xb1, + addr+len(prom_val),0,transfer_len ) + if (ret>=0): + prom_val += buf[:ret] + else: + raise Exception("eeprom read didn't work: %d" % ret ) + return prom_val + + +def hexchartoint(c): + return int(c.encode('hex'),16) + + +def fetch_eeprom(): + """ + See TRM 3.4.2, 3.4,3. + This function dynamically determines how much data to read for c2 eeprom data and downloads + the eeprom iic file. + """ + assert f.isopen() + # fetch 1st 8 bytes + prom=get_eeprom(0,8) + if prom[0] == '\xc0': + return prom # c0 blocks are 8 bytes long + if prom[0] != '\xc2': raise Exception ( "Envalid eeprom (%s)" % prom[0].encode('hex') ) + # the length of the 1st data block is bytes 8,9 (0 based) + read_addr=8 + while True: + size_read = get_eeprom(read_addr,4) # get the data length and start address + prom += size_read + read_addr+=4 + # if this is the end 0x80 0x01 0xe6 0x00, then break + if size_read == '\x80\x01\xe6\x00': break + # else it is a data block + size = (hexchartoint(size_read[0]) << 8) + hexchartoint(size_read[1]) + print "Next eeprom data size %d" % size + prom += get_eeprom(read_addr,size) + read_addr+=size + # one last byte + prom += get_eeprom(read_addr,1) # should always be 0 + assert prom[-1] == '\x00' + return prom + + +def set_eeprom(prom): + assert f.isopen() + bytes_written=0; + while bytes_written 1024 and 1024 or len(prom)-bytes_written + print "Writing %d Bytes.." % to_write + ret=f.do_usb_command(prom[bytes_written:bytes_written+to_write], 0x40,0xb1,bytes_written, 0, to_write, 10000) + if ret>0: + bytes_written += ret; + else: + raise Exception ( "eeprom write didn't work: %d" % ret ) + + +if __name__=='__main__': + + openfx2(0x04b4,0x0083) # vid/pid of eeprom firmware + diff --git a/Firmware/fx2lib/examples/eeprom/firmware/Makefile b/Firmware/fx2lib/examples/eeprom/firmware/Makefile new file mode 100644 index 0000000..173bcfb --- /dev/null +++ b/Firmware/fx2lib/examples/eeprom/firmware/Makefile @@ -0,0 +1,6 @@ +FX2LIBDIR=../../.. +BASENAME = eeprom +SOURCES=eeprom.c +A51_SOURCES=dscr.a51 + +include $(FX2LIBDIR)/lib/fx2.mk diff --git a/Firmware/fx2lib/examples/eeprom/firmware/dscr.a51 b/Firmware/fx2lib/examples/eeprom/firmware/dscr.a51 new file mode 100644 index 0000000..515d6e1 --- /dev/null +++ b/Firmware/fx2lib/examples/eeprom/firmware/dscr.a51 @@ -0,0 +1,277 @@ +; Copyright (C) 2009 Ubixum, Inc. +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +; this is a the default +; full speed and high speed +; descriptors found in the TRM +; change however you want but leave +; the descriptor pointers so the setupdat.c file works right + + +.module DEV_DSCR + +; descriptor types +; same as setupdat.h +DSCR_DEVICE_TYPE=1 +DSCR_CONFIG_TYPE=2 +DSCR_STRING_TYPE=3 +DSCR_INTERFACE_TYPE=4 +DSCR_ENDPOINT_TYPE=5 +DSCR_DEVQUAL_TYPE=6 + +; for the repeating interfaces +DSCR_INTERFACE_LEN=9 +DSCR_ENDPOINT_LEN=7 + +; endpoint types +ENDPOINT_TYPE_CONTROL=0 +ENDPOINT_TYPE_ISO=1 +ENDPOINT_TYPE_BULK=2 +ENDPOINT_TYPE_INT=3 + + .globl _dev_dscr, _dev_qual_dscr, _highspd_dscr, _fullspd_dscr, _dev_strings, _dev_strings_end +; These need to be in code memory. If +; they aren't you'll have to manully copy them somewhere +; in code memory otherwise SUDPTRH:L don't work right + .area DSCR_AREA (CODE) + +_dev_dscr: + .db dev_dscr_end-_dev_dscr ; len + .db DSCR_DEVICE_TYPE ; type + .dw 0x0002 ; usb 2.0 + .db 0xff ; class (vendor specific) + .db 0xff ; subclass (vendor specific) + .db 0xff ; protocol (vendor specific) + .db 64 ; packet size (ep0) + .dw 0xb404 ; vendor id + .dw 0x8300 ; product id + .dw 0x0100 ; version id + .db 0 ; manufacturure str idx + .db 1 ; product str idx + .db 0 ; serial str idx + .db 1 ; n configurations +dev_dscr_end: + +_dev_qual_dscr: + .db dev_qualdscr_end-_dev_qual_dscr + .db DSCR_DEVQUAL_TYPE + .dw 0x0002 ; usb 2.0 + .db 0xff + .db 0xff + .db 0xff + .db 64 ; max packet + .db 1 ; n configs + .db 0 ; extra reserved byte +dev_qualdscr_end: + +_highspd_dscr: + .db highspd_dscr_end-_highspd_dscr ; dscr len ;; Descriptor length + .db DSCR_CONFIG_TYPE + ; can't use .dw because byte order is different + .db (highspd_dscr_realend-_highspd_dscr) % 256 ; total length of config lsb + .db (highspd_dscr_realend-_highspd_dscr) / 256 ; total length of config msb + .db 1 ; n interfaces + .db 1 ; config number + .db 0 ; config string + .db 0x80 ; attrs = bus powered, no wakeup + .db 0x32 ; max power = 100ma +highspd_dscr_end: + +; all the interfaces next +; NOTE the default TRM actually has more alt interfaces +; but you can add them back in if you need them. +; here, we just use the default alt setting 1 from the trm + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 0 ; alt setting idx + .db 6 ; n endpoints + .db 0xff ; class + .db 0xff + .db 0xff + .db 0 ; string index + +; endpoint 1 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x01 ; ep1 dir=out and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 1 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x81 ; ep1 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 2 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x02 ; ep2 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 4 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x04 ; ep4 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x86 ; ep6 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 8 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x88 ; ep8 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval +highspd_dscr_realend: + + .even +_fullspd_dscr: + .db fullspd_dscr_end-_fullspd_dscr ; dscr len + .db DSCR_CONFIG_TYPE + ; can't use .dw because byte order is different + .db (fullspd_dscr_realend-_fullspd_dscr) % 256 ; total length of config lsb + .db (fullspd_dscr_realend-_fullspd_dscr) / 256 ; total length of config msb + .db 1 ; n interfaces + .db 1 ; config number + .db 0 ; config string + .db 0x80 ; attrs = bus powered, no wakeup + .db 0x32 ; max power = 100ma +fullspd_dscr_end: + +; all the interfaces next +; NOTE the default TRM actually has more alt interfaces +; but you can add them back in if you need them. +; here, we just use the default alt setting 1 from the trm + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 0 ; alt setting idx + .db 6 ; n endpoints + .db 0xff ; class + .db 0xff + .db 0xff + .db 0 ; string index + +; endpoint 1 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x01 ; ep1 dir=out and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +; endpoint 1 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x81 ; ep1 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +; endpoint 2 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x02 ; ep2 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +; endpoint 4 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x04 ; ep4 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x86 ; ep6 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x88 ; ep6 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval +fullspd_dscr_realend: + + .even +_dev_strings: +; sample string +_string0: + .db string0end-_string0 ; len + .db DSCR_STRING_TYPE + .db 0x09, 0x04 ; 0x0409 is the language code for English. Possible to add more codes after this. +string0end: +; add more strings here + +string1: + .db string1end-string1 + .db DSCR_STRING_TYPE + .ascii 'U' + .db 0 + .ascii 's' + .db 0 + .ascii 'b' + .db 0 + .ascii ' ' + .db 0 + .ascii 'T' + .db 0 + .ascii 'e' + .db 0 + .ascii 'r' + .db 0 + .ascii 'm' + .db 0 +string1end: + +_dev_strings_end: + .dw 0x0000 +; in case you wanted to look at memory between _dev_strings and _dev_strings_end diff --git a/Firmware/fx2lib/examples/eeprom/firmware/eeprom.c b/Firmware/fx2lib/examples/eeprom/firmware/eeprom.c new file mode 100644 index 0000000..83afae4 --- /dev/null +++ b/Firmware/fx2lib/examples/eeprom/firmware/eeprom.c @@ -0,0 +1,172 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SYNCDELAY SYNCDELAY4; + +volatile __bit dosud; +__bit on; +WORD count; + + +void main() { + + REVCTL = 0; // not using advanced endpoint controls + + dosud=FALSE; + on=FALSE; + + REVCTL = 0x03; // DYN_OUT=1, ENH_PKT=1 + + RENUMERATE_UNCOND(); + + + SETCPUFREQ(CLK_48M); + sio0_init(57600); // needed for printf on sio0 + + + USE_USB_INTS(); + + ENABLE_SUDAV(); + ENABLE_USBRESET(); + ENABLE_HISPEED(); + + EA=1; + + + while(TRUE) { + + //printf ( "sud is %d\n" , dosud ); + if (dosud) { + handle_setupdata(); + dosud=FALSE; + } + + } + + +} + +BOOL handle_get_descriptor() { + return FALSE; +} + +#define VC_EEPROM 0xb1 + +BOOL handle_vendorcommand(BYTE cmd) { + WORD addr=SETUP_VALUE(),len=SETUP_LENGTH(); + printf ( "Handle Vendor Command %02x, addr %d, len %d\n" , cmd, addr, len ); + switch (cmd) { + case VC_EEPROM: + { + // wait for ep0 not busy + switch (SETUP_TYPE) { + case 0xc0: + while (len) { // still have bytes to read + BYTE cur_read = len > 64 ? 64 : len; // can't read more than 64 bytes at a time + while (EP0CS&bmEPBUSY); // can't do this until EP0 is ready + eeprom_read(0x51, addr, cur_read, EP0BUF ); + EP0BCH=0; + SYNCDELAY; + EP0BCL=cur_read; + len -= cur_read; + addr += cur_read; + } + break; + case 0x40: + while (len) { + BYTE cur_write, c; +// printf ( "Len More Bytes %d\n" , len ); + EP0BCL = 0; // allow pc transfer in + while(EP0CS & bmEPBUSY); // wait + cur_write=EP0BCL; +// printf ( "Writing %d Bytes to %d..\n", cur_write, addr ); + if ( !eeprom_write(0x51, addr, cur_write, EP0BUF ) ) return FALSE; + addr += cur_write; + len -= cur_write; + } + break; + default: + return FALSE; // bad type + } + + printf ( "All OK\n" ); + return TRUE; + } + } + return FALSE; +} + + +// set *alt_ifc to the current alt interface for ifc +BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc) { + *alt_ifc=0; + return TRUE; +} +// return TRUE if you set the interface requested +// NOTE this function should reconfigure and reset the endpoints +// according to the interface descriptors you provided. +BOOL handle_set_interface(BYTE ifc,BYTE alt_ifc) { + //return ifc==0&&alt_ifc==0; + printf ( "Host wants to set interface: %d\n", alt_ifc ); + + return TRUE; +} +// handle getting and setting the configuration +// 0 is the default. If you support more than one config +// keep track of the config number and return the correct number +// config numbers are set int the dscr file. +volatile BYTE config=1; +BYTE handle_get_configuration() { + return config; +} +// return TRUE if you handle this request +// NOTE changing config requires the device to reset all the endpoints +BOOL handle_set_configuration(BYTE cfg) { + printf ( "host wants config: %d\n" , cfg ); + config=cfg; + return TRUE; +} + + +void sudav_isr() __interrupt SUDAV_ISR { + dosud=TRUE; + CLEAR_SUDAV(); +} + +void usbreset_isr() __interrupt USBRESET_ISR { + handle_hispeed(FALSE); + CLEAR_USBRESET(); +} +void hispeed_isr() __interrupt HISPEED_ISR { + handle_hispeed(TRUE); + CLEAR_HISPEED(); +} + diff --git a/Firmware/fx2lib/examples/fx2/.gitignore b/Firmware/fx2lib/examples/fx2/.gitignore new file mode 100644 index 0000000..6f97ca1 --- /dev/null +++ b/Firmware/fx2lib/examples/fx2/.gitignore @@ -0,0 +1,2 @@ +build +*.pyc diff --git a/Firmware/fx2lib/examples/fx2/cpp/.gitignore b/Firmware/fx2lib/examples/fx2/cpp/.gitignore new file mode 100644 index 0000000..c300f8b --- /dev/null +++ b/Firmware/fx2lib/examples/fx2/cpp/.gitignore @@ -0,0 +1,2 @@ +fx2.py +fx2_wrap.cpp diff --git a/Firmware/fx2lib/examples/fx2/cpp/__init__.py b/Firmware/fx2lib/examples/fx2/cpp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Firmware/fx2lib/examples/fx2/cpp/fx2.cpp b/Firmware/fx2lib/examples/fx2/cpp/fx2.cpp new file mode 100644 index 0000000..f53fbea --- /dev/null +++ b/Firmware/fx2lib/examples/fx2/cpp/fx2.cpp @@ -0,0 +1,161 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include +#include + +#include "fx2.h" + + +fx2::fx2():dev_handle(NULL) { + + int rv=libusb_init(&libusb_ctx); + assert(!rv); + libusb_set_debug(libusb_ctx,0); +} + +void fx2::set_debug_level(int n) { + libusb_set_debug(libusb_ctx,n); +} + +fx2::~fx2() { + + if (isopen()) close(); + + libusb_exit(libusb_ctx); +} + +#define CHECK_OPEN(r) if (!dev_handle) {\ + printf ( "Device not opened.\n" ); \ + return r;\ + } + + +void fx2::open(int vid,int pid,int idx) { + + libusb_device **list; + int devices = libusb_get_device_list( libusb_ctx, &list ); + int cur_idx=0; + for ( int i=0;iinterface=iface; + } + int rv=libusb_set_interface_alt_setting(dev_handle,interface,alt); + assert(!rv); + alt_setting=alt; +} +void fx2::close() { + CHECK_OPEN() + libusb_release_interface(dev_handle,interface); + libusb_close(dev_handle); + dev_handle=NULL; + interface=0;alt_setting=0; +} + + +int fx2::do_usb_command(char* buf, int size, unsigned char type, unsigned char request, unsigned short value, unsigned short index, unsigned short length, int timeout ) { + CHECK_OPEN(-1) + return libusb_control_transfer ( + dev_handle, + type, + request, + value, + index, + (unsigned char*)buf, + length, + timeout); +} + +int fx2::clear_halt(char ep) { + CHECK_OPEN(-1) + return libusb_clear_halt(dev_handle,(unsigned char)ep); +} + +int fx2::reset() { + CHECK_OPEN(-1) + int rv=libusb_reset_device(dev_handle); + if (rv==LIBUSB_ERROR_NO_DEVICE) { + printf ( "Device Changed. Closing\n"); + libusb_close(dev_handle); + interface=0;alt_setting=0; + } + return rv; +} + +int fx2::set_configuration(int configuration) { + CHECK_OPEN(-1) + libusb_release_interface(dev_handle,interface); + int rv=libusb_set_configuration(dev_handle,configuration); + if (!rv) { + libusb_claim_interface(dev_handle,interface); + } +} + + +bool fx2::ep_bulk(char* buf, int size, unsigned char ep, int timeout) { + CHECK_OPEN(-1) + int transferred; + int rv=libusb_bulk_transfer ( dev_handle, ep, (unsigned char*)buf, size, &transferred, timeout ); + + if (!rv) return true; + + if (rv==LIBUSB_ERROR_TIMEOUT) { + printf ( "Transfer Timeout. %d bytes transferred.\n", transferred ); + } else if (rv<0) { + printf ( "Transfer Error: %d\n", rv ); + } + + return false; + +} diff --git a/Firmware/fx2lib/examples/fx2/cpp/fx2.h b/Firmware/fx2lib/examples/fx2/cpp/fx2.h new file mode 100644 index 0000000..bb61613 --- /dev/null +++ b/Firmware/fx2lib/examples/fx2/cpp/fx2.h @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#ifndef FX2_H +#define FX2_H + +#include + +const int VID=0x04b4; +const int PID=0x0082; + +class fx2 { + + private: + libusb_context* libusb_ctx; + libusb_device_handle* dev_handle; + int interface,alt_setting; + + public: + fx2(); + ~fx2(); + /** + * open + * vid = vendor id + * pid = product id + * idx = nth device if there are more than one. + * + * Opens device with vid,pid and claims alt 0 of interface 0 + **/ + void open(int vid=VID,int pid=PID, int idx=0); + void set_interface(int interface, int alt_setting); + bool isopen() { return dev_handle != NULL; } + void close(); + /** + * level n = 0-3 + */ + void set_debug_level(int n); + int do_usb_command(char* buf, int size, unsigned char type, unsigned char request, unsigned short value, unsigned short index, unsigned short length, int timeout=1000 ); + int clear_halt(char ep); + int reset(); + int set_configuration(int config); + bool ep_bulk(char* buf, int size, unsigned char ep, int timeout); + +}; + +#endif diff --git a/Firmware/fx2lib/examples/fx2/cpp/fx2.i b/Firmware/fx2lib/examples/fx2/cpp/fx2.i new file mode 100644 index 0000000..9ffbc96 --- /dev/null +++ b/Firmware/fx2lib/examples/fx2/cpp/fx2.i @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +/* interface file for python/swig */ + +%module fx2 +//%include "typemaps.i" +%include "cdata.i" +%apply (char* STRING, int LENGTH) { (char* buf, int size) } + +%{ +#include "fx2.h" +%} + +%include "fx2.h" diff --git a/Firmware/fx2lib/examples/fx2/fx2load/__init__.py b/Firmware/fx2lib/examples/fx2/fx2load/__init__.py new file mode 100644 index 0000000..12465ec --- /dev/null +++ b/Firmware/fx2lib/examples/fx2/fx2load/__init__.py @@ -0,0 +1,59 @@ +# Copyright (C) 2009 Ubixum, Inc. +# +# This library is free software; you can redistribute it and/or +# +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +from time import sleep +from fx2 import fx2 + +f=fx2.fx2() + +# use this functions 1st + +def openfx2(vid=0x04b4,pid=0x0082,idx=0): + f.open(vid,pid,idx) + +def reset_device(reset): + print reset and "Put device in reset" or "Set device to run" + write_ram (0xe600,reset and '\x01' or '\x00', 1) + +def write_ram(addr,data,length): + transferred=0 + while(transferred1024 and 1024 or length-transferred + buf=data[transferred:] + ret=f.do_usb_command( buf, + 0x40, + 0xa0, + addr+transferred, 0, + this_transfer_size ) + if (ret>0): + print "wrote %d bytes" % ret + transferred+=ret + else: + print "Error: %d" % ret + return + +def reset_bix(filename): + """ + Use this function to reset your firmware. You'll need to reopen the device afterward. + """ + reset_device(True) + bix=open(filename).read() + print "loading bix file of length: %d" % len(bix) + write_ram( 0, bix,len(bix) ); + reset_device(False) + f.close() + diff --git a/Firmware/fx2lib/examples/fx2/scripts/fx2load b/Firmware/fx2lib/examples/fx2/scripts/fx2load new file mode 100755 index 0000000..b461c6b --- /dev/null +++ b/Firmware/fx2lib/examples/fx2/scripts/fx2load @@ -0,0 +1,34 @@ +#!/bin/env python + +# Copyright (C) 2009 Ubixum, Inc. +# +# This library is free software; you can redistribute it and/or +# +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +import optparse + +parser=optparse.OptionParser (usage="Usage: %prog [options] bixfile") +parser.add_option( "-v", "--vid", type='int', default=0x04b4,help='Vendor ID (0x04b4)') +parser.add_option( "-p", '--pid', type='int', default=0x0082,help='Product Id (0x0082)') + +opts,args=parser.parse_args() + +if len(args) < 1: + parser.error("Specify the path to your firmware bix file as the first argument") + +from fx2load import * +openfx2(opts.vid,opts.pid) +reset_bix(args[0]) diff --git a/Firmware/fx2lib/examples/fx2/setup.py b/Firmware/fx2lib/examples/fx2/setup.py new file mode 100644 index 0000000..53a6d41 --- /dev/null +++ b/Firmware/fx2lib/examples/fx2/setup.py @@ -0,0 +1,19 @@ +from distutils.core import setup, Extension + +fx2_mod = Extension ( + '_fx2', + sources=['cpp/fx2.cpp', 'cpp/fx2.i'], + swig_opts=['-c++'], + include_dirs = ['/usr/include/python2.5'], + libraries = ['usb-1.0'] +) + + +setup( + name='fx2', + version='0.2', + ext_modules=[fx2_mod], + scripts=['scripts/fx2load'], + packages=['fx2load','fx2'], + package_dir={'fx2':'cpp'} +) diff --git a/Firmware/fx2lib/examples/i2c/Makefile b/Firmware/fx2lib/examples/i2c/Makefile new file mode 100644 index 0000000..b21e70a --- /dev/null +++ b/Firmware/fx2lib/examples/i2c/Makefile @@ -0,0 +1,8 @@ +FX2LIBDIR=../.. +BASENAME = i2c +SOURCES=i2c.c +DSCR_AREA= +INT2JT= +include $(FX2LIBDIR)/lib/fx2.mk + + diff --git a/Firmware/fx2lib/examples/i2c/i2c.c b/Firmware/fx2lib/examples/i2c/i2c.c new file mode 100644 index 0000000..7af95bb --- /dev/null +++ b/Firmware/fx2lib/examples/i2c/i2c.c @@ -0,0 +1,92 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + + + +#include + +#include + +#define LED_ADDR 0x21 +#define BTN_ADDR 0x20 + +#define KEY_F1 0 +#define KEY_F2 1 +#define KEY_F3 2 +#define KEY_F4 3 + + +BYTE digits[] = { 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x98, 0x88, 0x83, 0xc6, 0xa1, 0x86, 0x8e }; + + +/** + * This is pretty much the same function that is provided as the dev_io example from Cypress + * Except is uses i2c read and write functions not from their library + **/ +void main(void) { + + BYTE num = 0; + //BYTE xdata buttons; + BYTE buttons; + BYTE kstates = 0xff; + BYTE kdeltas; + BYTE key; + BYTE display = 1; + + while(1) + { + i2c_read ( BTN_ADDR, 1, &buttons ); + + kdeltas = kstates ^ buttons; // + kstates = buttons; + key = 0; + + while(kdeltas) + { + if(kdeltas & 0x01) + { + if(!((kstates >> key) & 0x01)) + switch(key) + { + case KEY_F1: // wakeup? + num = 0; + break; + case KEY_F2: + if(--num > 0x0f) + num = 0x0f; + break; + case KEY_F3: + if(++num > 0x0f) + num = 0; + break; + case KEY_F4: + num = 0x0f; + } + display = 1; + } + kdeltas = kdeltas >> 1; + ++key; + } + if(display) + { + i2c_write ( LED_ADDR, 1, &digits[num], 0, NULL ); + display = 0; + } + } + +} diff --git a/Firmware/fx2lib/examples/i2c/load.py b/Firmware/fx2lib/examples/i2c/load.py new file mode 100644 index 0000000..0274237 --- /dev/null +++ b/Firmware/fx2lib/examples/i2c/load.py @@ -0,0 +1,20 @@ +# Copyright (C) 2009 Ubixum, Inc. +# +# This library is free software; you can redistribute it and/or +# +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USAimport struct +from fx2load import * + +openfx2() +reset_bix('i2c.bix') diff --git a/Firmware/fx2lib/examples/lights/.gitignore b/Firmware/fx2lib/examples/lights/.gitignore new file mode 100644 index 0000000..32d2545 --- /dev/null +++ b/Firmware/fx2lib/examples/lights/.gitignore @@ -0,0 +1 @@ +lights diff --git a/Firmware/fx2lib/examples/lights/Makefile b/Firmware/fx2lib/examples/lights/Makefile new file mode 100644 index 0000000..0abc9d4 --- /dev/null +++ b/Firmware/fx2lib/examples/lights/Makefile @@ -0,0 +1,8 @@ +FX2LIBDIR=../.. +BASENAME = lights +SOURCES=lights.c +DSCR_AREA= +INT2JT= +include $(FX2LIBDIR)/lib/fx2.mk + + diff --git a/Firmware/fx2lib/examples/lights/lights.c b/Firmware/fx2lib/examples/lights/lights.c new file mode 100644 index 0000000..8d55d90 --- /dev/null +++ b/Firmware/fx2lib/examples/lights/lights.c @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +#include +#include + +volatile __xdata BYTE* bytes[] = { &D2ON, &D3ON, &D4ON, &D5ON, &D2OFF, &D3OFF, &D4OFF, &D5OFF }; + +void main(void) +{ + volatile BYTE tmp; + BYTE cur=0; + + // loop endlessly + for(;;) { + tmp=*bytes[cur]; + delay(50); + cur = cur == 7 ? 0 : cur+1; + } +} diff --git a/Firmware/fx2lib/examples/reset/Makefile b/Firmware/fx2lib/examples/reset/Makefile new file mode 100644 index 0000000..1731c0a --- /dev/null +++ b/Firmware/fx2lib/examples/reset/Makefile @@ -0,0 +1,8 @@ +FX2LIBDIR=../.. +BASENAME = reset +SOURCES=reset.c fx2_c0.c +DSCR_AREA= +INT2JT= +include $(FX2LIBDIR)/lib/fx2.mk + + diff --git a/Firmware/fx2lib/examples/reset/fx2_c0.c b/Firmware/fx2lib/examples/reset/fx2_c0.c new file mode 100644 index 0000000..629f1b0 --- /dev/null +++ b/Firmware/fx2lib/examples/reset/fx2_c0.c @@ -0,0 +1,4 @@ +__xdata unsigned char fx2_c0[] = { + 0xc0, 0xb4, 0x04, 0x82, + 0x00, 0x00, 0x00, 0x00 +}; diff --git a/Firmware/fx2lib/examples/reset/reset.c b/Firmware/fx2lib/examples/reset/reset.c new file mode 100644 index 0000000..f4f92ad --- /dev/null +++ b/Firmware/fx2lib/examples/reset/reset.c @@ -0,0 +1,82 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +#include +#include + +#include +#include +#include +#include + +#define LG_PROM 0x51 // large prom ( is 16 bit addr mode) + +#define READ_SIZE 100 + +__xdata BYTE buf[READ_SIZE]; + +#define IIC_SIZE 8 +extern __xdata BYTE fx2_c0[]; + +/* + Modified eeprom_write that always uses two byte buffer. + So can write to LG_PROM w/ out recompiling lib. + (The library dynamically detects the prom based on the startup state. + On the dev board, you can switch the prom with EEPROM select while + the firmware is running.) +*/ +void eeprom_write_local(BYTE prom_addr, WORD addr, WORD length, BYTE* buf) { + BYTE addr_len=0; + // 1st bytes of buffer are address and next byte is value + BYTE data_buffer[3]; + BYTE cur_byte=0; + + while ( cur_byte + +#include +#include +#include +#include + + + +volatile BYTE ctr=0; +BYTE ctr_repeat=200; +volatile BOOL on=FALSE; + + +void timer1_isr() __interrupt 3 __critical { + + if (ctr == 0) { // timer overflowed ctr_repeat times + if (on) { + d2on(); + } else { + d2off(); + } + on = !on; + } + + ctr = ctr >= ctr_repeat ? 0 : ctr + 1; + +} + + + +void main(void) +{ + + SETCPUFREQ(CLK_48M); + + // if this image is loaded to as iic to + // the eeprom + // the C2 bit will turn this on + // turn it back off so the device can + // handle usb requests + USBCS &= ~bmRENUM; + + EA=1; // enable interrupts + + sio0_init(57600); + + // timer 0 setup + + TL1=TH1=0; // start at 0 + ET1=1; // timer 1 interrupts + TR1=1; // start timer 1 + + + d5off(); // end init + + while (1) { + char r=getchar(); + putchar(r); + } + + +} diff --git a/Firmware/fx2lib/examples/timers/.gitignore b/Firmware/fx2lib/examples/timers/.gitignore new file mode 100644 index 0000000..2fdd3f2 --- /dev/null +++ b/Firmware/fx2lib/examples/timers/.gitignore @@ -0,0 +1 @@ +timers diff --git a/Firmware/fx2lib/examples/timers/Makefile b/Firmware/fx2lib/examples/timers/Makefile new file mode 100644 index 0000000..4e2384e --- /dev/null +++ b/Firmware/fx2lib/examples/timers/Makefile @@ -0,0 +1,8 @@ +FX2LIBDIR=../.. +BASENAME = timers +SOURCES=timers.c +DSCR_AREA= +INT2JT= +include $(FX2LIBDIR)/lib/fx2.mk + + diff --git a/Firmware/fx2lib/examples/timers/timers.c b/Firmware/fx2lib/examples/timers/timers.c new file mode 100644 index 0000000..fdc77ac --- /dev/null +++ b/Firmware/fx2lib/examples/timers/timers.c @@ -0,0 +1,79 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include +#include +#include +#include + +volatile __bit d2; +volatile __bit d3; +volatile __bit d4; +volatile __bit d5; + +void timer0_isr() __interrupt TF0_ISR { + d2 = !d2; + if (d2) { d2on(); } else { d2off(); } +} + +void timer1_isr() __interrupt TF1_ISR { + d3 = !d3; + if (d3) { d3on(); } else { d3off(); } +} + +void timer2_isr() __interrupt TF2_ISR { + d4 = !d4; + if (d4) { d4on(); } else { d4off(); } + + CLEAR_TIMER2(); // This one is not done automatically! +} + + +void main(void) +{ + WORD counter=0; + + SETCPUFREQ(CLK_12M); + + // enable timer 0 and timer 1 to be 16 bit counters + TMOD = 0x11; + + // enable timer 2 to also be a 16 bit counter + T2CON = 0; + RCAP2L = 0; // reload values for t2 + RCAP2H = 0; + + EA=1; // enable interrupts + ENABLE_TIMER0(); + ENABLE_TIMER1(); + ENABLE_TIMER2(); + TR0=1; // start t0 + TR1=1; // start t1 + TR2=1; // start t2 + + // and blink d5 + while (TRUE) { + ++counter; + if (!counter) { + d5 = !d5; + if (d5) { d5off(); } else { d5on(); } + } + } +} + + diff --git a/Firmware/fx2lib/examples/usbmon_c/Makefile b/Firmware/fx2lib/examples/usbmon_c/Makefile new file mode 100644 index 0000000..b718b56 --- /dev/null +++ b/Firmware/fx2lib/examples/usbmon_c/Makefile @@ -0,0 +1,19 @@ +FX2LIBDIR=../../ +BASENAME = usbmon +SOURCES=usbmon.c +A51_SOURCES=dscr.a51 +PID=0x1004 + +HOSTCC=gcc +CFLAGS=-Wall -Wextra -Os -lusb-1.0 + +include $(FX2LIBDIR)lib/fx2.mk + +download: build/$(BASENAME).ihx + ./download.sh $< + +clean: + rm -rf build + +test: test.c + $(HOSTCC) $(CFLAGS) -o $@ $< \ No newline at end of file diff --git a/Firmware/fx2lib/examples/usbmon_c/download.sh b/Firmware/fx2lib/examples/usbmon_c/download.sh new file mode 100755 index 0000000..787df86 --- /dev/null +++ b/Firmware/fx2lib/examples/usbmon_c/download.sh @@ -0,0 +1,15 @@ +#!/bin/bash -e + +DEVS=$(lsusb|grep 04b4:8613|sed 's/:.*//;s/Bus //;s/Device //;s/ /\//') + +if [ -z "$1" ]; then + echo "$0: usage: $0 " + exit 1; +fi + +for dev in $DEVS;do + echo "Downloading $1 to $dev" + sudo /sbin/fxload -D /dev/bus/usb/$dev -t fx2lp -I $1 +done + +exit 0 diff --git a/Firmware/fx2lib/examples/usbmon_c/dscr.a51 b/Firmware/fx2lib/examples/usbmon_c/dscr.a51 new file mode 100644 index 0000000..a500e4d --- /dev/null +++ b/Firmware/fx2lib/examples/usbmon_c/dscr.a51 @@ -0,0 +1,241 @@ +; Copyright (C) 2009 Ubixum, Inc. +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +; this is a the default +; full speed and high speed +; descriptors found in the TRM +; change however you want but leave +; the descriptor pointers so the setupdat.c file works right + + +.module DEV_DSCR + +; descriptor types +; same as setupdat.h +DSCR_DEVICE_TYPE=1 +DSCR_CONFIG_TYPE=2 +DSCR_STRING_TYPE=3 +DSCR_INTERFACE_TYPE=4 +DSCR_ENDPOINT_TYPE=5 +DSCR_DEVQUAL_TYPE=6 + +; for the repeating interfaces +DSCR_INTERFACE_LEN=9 +DSCR_ENDPOINT_LEN=7 + +; endpoint types +ENDPOINT_TYPE_CONTROL=0 +ENDPOINT_TYPE_ISO=1 +ENDPOINT_TYPE_BULK=2 +ENDPOINT_TYPE_INT=3 + + .globl _dev_dscr, _dev_qual_dscr, _highspd_dscr, _fullspd_dscr, _debug_dscr, _dev_strings, _dev_strings_end +; These need to be in code memory. If +; they aren't you'll have to manully copy them somewhere +; in code memory otherwise SUDPTRH:L don't work right + .area DSCR_AREA (CODE) + +_dev_dscr: + .db dev_dscr_end-_dev_dscr ; len + .db DSCR_DEVICE_TYPE ; type + .dw 0x0002 ; usb 2.0 + .db 0xff ; class (vendor specific) + .db 0 ; subclass (vendor specific) + .db 0 ; protocol (vendor specific) + .db 64 ; packet size (ep0) + .dw 0xb404 ; vendor id + .dw 0x1386 ; product id + .dw 0x0100 ; version id + .db 1 ; manufacturure str idx + .db 2 ; product str idx + .db 0 ; serial str idx + .db 1 ; n configurations +dev_dscr_end: + +_dev_qual_dscr: + .db dev_qualdscr_end-_dev_qual_dscr + .db DSCR_DEVQUAL_TYPE + .dw 0x0002 ; usb 2.0 + .db 0xff + .db 0x00 + .db 0x0 + .db 64 ; max packet + .db 1 ; n configs + .db 0 ; extra reserved byte +dev_qualdscr_end: + +_debug_dscr: + .db _debug_dscr_end - _debug_dscr + .db 10 + .db 0x86 + .db 0x02 +_debug_dscr_end: + + +_highspd_dscr: + .db highspd_dscr_end-_highspd_dscr ; dscr len ;; Descriptor length + .db DSCR_CONFIG_TYPE + ; can't use .dw because byte order is different + .db (highspd_dscr_realend-_highspd_dscr) % 256 ; total length of config lsb + .db (highspd_dscr_realend-_highspd_dscr) / 256 ; total length of config msb + .db 1 ; n interfaces + .db 1 ; config number + .db 0 ; config string + .db 0x80 ; attrs = bus powered, no wakeup + .db 0x32 ; max power = 100ma +highspd_dscr_end: + +; all the interfaces next +; NOTE the default TRM actually has more alt interfaces +; but you can add them back in if you need them. +; here, we just use the default alt setting 1 from the trm + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 0 ; alt setting idx + .db 2 ; n endpoints + .db 0xff ; class + .db 0 + .db 0 + .db 3 ; string index + +; endpoint 2 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x02 ; ep2 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x86 ; ep6 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +highspd_dscr_realend: + + .even +_fullspd_dscr: + .db fullspd_dscr_end-_fullspd_dscr ; dscr len + .db DSCR_CONFIG_TYPE + ; can't use .dw because byte order is different + .db (fullspd_dscr_realend-_fullspd_dscr) % 256 ; total length of config lsb + .db (fullspd_dscr_realend-_fullspd_dscr) / 256 ; total length of config msb + .db 1 ; n interfaces + .db 1 ; config number + .db 0 ; config string + .db 0x80 ; attrs = bus powered, no wakeup + .db 0x32 ; max power = 100ma +fullspd_dscr_end: + +; all the interfaces next +; NOTE the default TRM actually has more alt interfaces +; but you can add them back in if you need them. +; here, we just use the default alt setting 1 from the trm + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 0 ; alt setting idx + .db 2 ; n endpoints + .db 0xff ; class + .db 0xff + .db 0xff + .db 3 ; string index + +; endpoint 2 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x02 ; ep2 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x86 ; ep6 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +fullspd_dscr_realend: + +.even +_dev_strings: +; sample string +_string0: + .db string0end-_string0 ; len + .db DSCR_STRING_TYPE + .db 0x09, 0x04 ; who knows +string0end: +; add more strings here + +_string1: + .db string1end-_string1 + .db DSCR_STRING_TYPE + .ascii 'I' + .db 0 + .ascii 'O' + .db 0 + .ascii 'D' + .db 0 + .ascii 'e' + .db 0 + .ascii 'v' + .db 0 +string1end: + +_string2: + .db string2end-_string2 + .db DSCR_STRING_TYPE + .ascii 'U' + .db 0 + .ascii 'S' + .db 0 + .ascii 'B' + .db 0 + .ascii 'M' + .db 0 + .ascii 'O' + .db 0 + .ascii 'N' + .db 0 +string2end: + +_string3: + .db string3end-_string3 + .db DSCR_STRING_TYPE + .ascii 'i' + .db 0 + .ascii 'F' + .db 0 + .ascii 'a' + .db 0 + .ascii 'c' + .db 0 + .ascii 'e' + .db 0 +string3end: + +_dev_strings_end: + .dw 0x0000 ; just in case someone passes an index higher than the end to the firmware diff --git a/Firmware/fx2lib/examples/usbmon_c/test.c b/Firmware/fx2lib/examples/usbmon_c/test.c new file mode 100644 index 0000000..09f2d78 --- /dev/null +++ b/Firmware/fx2lib/examples/usbmon_c/test.c @@ -0,0 +1,88 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ +#include +#include +#include +#include + +#include + + +int main(int argc __attribute__((unused)), + char **argv __attribute__((unused))) +{ + int transferred, rv, i, ret = 1;; + libusb_device_handle *hndl; + libusb_context *ctx; + unsigned char buf[512]; + + + libusb_init(&ctx); + + hndl = libusb_open_device_with_vid_pid(ctx, 0x4b4, 0x8613); + + if (!hndl) { + fprintf(stderr, "failed to open device\n"); + goto out; + } + + libusb_claim_interface(hndl, 0); + + libusb_set_interface_alt_setting(hndl, 0, 0); + +for(;;) { + for (i = 0; i < (int)sizeof(buf); i++) + buf[i] = i; + + printf("OUT transfer to device\n"); + transferred = 0; + rv = libusb_bulk_transfer(hndl, 0x02, bufl, 32, &transferred, 500); + if(rv) { + fprintf(stderr, "OUT Transfer failed: %d (%d transferred)\n", rv, transferred); +// goto out; + } + + rv = libusb_bulk_transfer(hndl, 0x02, buf, 0, &transferred, 500); + if(rv) { + fprintf(stderr, "OUT0 Transfer failed: %d (%d transferred)\n", rv, transferred); +// goto out; + } + + printf("IN transfer to device\n"); + + memset(buf, 0, sizeof(buf)); + transferred = 0; + + rv=libusb_bulk_transfer(hndl, 0x86, (unsigned char*)buf ,sizeof(buf), &transferred, 500); + if(rv) { + fprintf(stderr, "IN Transfer failed: %d (%d transferred)\n", rv, transferred); +// goto out; + } else { + printf("received %d bytes:\n", transferred); + + for (i = 0; i < transferred; i++) + printf ("%02x ", buf[i]); + printf("\n"); + } + sleep(1); +} + ret = 0; +out: + libusb_close(hndl); + return ret; +} diff --git a/Firmware/fx2lib/examples/usbmon_c/usbmon.c b/Firmware/fx2lib/examples/usbmon_c/usbmon.c new file mode 100644 index 0000000..7849f4d --- /dev/null +++ b/Firmware/fx2lib/examples/usbmon_c/usbmon.c @@ -0,0 +1,226 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SYNCDELAY() SYNCDELAY4 + +volatile __bit got_sud; + +static void setup_usb(void) +{ + USE_USB_INTS(); + ENABLE_SUDAV(); + ENABLE_SOF(); + ENABLE_HISPEED(); + ENABLE_USBRESET(); + + CPUCS = 0x12; + REVCTL = bmBIT0 | bmBIT1; + + IFCONFIG = 0xe3; + SYNCDELAY(); + + PINFLAGSAB = 0xe8; /* FLAGA = EP2EF, FLAGB = EP6FF */ + SYNCDELAY(); + + PORTACFG |= 0x80; + SYNCDELAY(); + + // only valid endpoints are 2/6 + EP1INCFG &= ~bmVALID; + SYNCDELAY(); + + EP1OUTCFG &= ~bmVALID; + SYNCDELAY(); + + EP2CFG = 0xa0; /* EP2 OUT, 4x buffer */ + SYNCDELAY(); + + EP4CFG = 0x02; + SYNCDELAY(); + + EP6CFG = 0xe0; /* EP6 IN, 4x buffer */ + SYNCDELAY(); + + EP8CFG = 0x02; + SYNCDELAY(); + + FIFORESET = 0x80; + SYNCDELAY(); + + FIFORESET = 0x02; + SYNCDELAY(); + + FIFORESET = 0x04; + SYNCDELAY(); + + FIFORESET = 0x06; + SYNCDELAY(); + + FIFORESET = 0x08; + SYNCDELAY(); + + FIFORESET = 0x00; + SYNCDELAY(); + + OUTPKTEND = 0x82; + SYNCDELAY(); + OUTPKTEND = 0x82; + SYNCDELAY(); + OUTPKTEND = 0x82; + SYNCDELAY(); + OUTPKTEND = 0x82; + SYNCDELAY(); + + + EP2FIFOCFG = 0; + SYNCDELAY(); + + EP2FIFOCFG = bmAUTOOUT | bmWORDWIDE; + SYNCDELAY(); + + EP6FIFOCFG = 0; + SYNCDELAY(); + + EP6FIFOCFG = bmAUTOIN | bmWORDWIDE; + SYNCDELAY(); + + EP6AUTOINLENH = 0x02; + SYNCDELAY(); + + EP6AUTOINLENL = 0x00; + SYNCDELAY(); + +} + +void main() +{ + got_sud=FALSE; + + // renumerate + RENUMERATE_UNCOND(); + + setup_usb(); + + EA=1; // global __interrupt enable + + while(TRUE) { + if (got_sud) { + handle_setupdata(); + got_sud=FALSE; + } + } +} + +// copied routines from setupdat.h + +// value (low byte) = ep +#define VC_EPSTAT 0xB1 + + +BOOL handle_vendorcommand(BYTE cmd) +{ + __xdata BYTE* pep; + switch ( cmd ) { + case 6: + return TRUE; + case VC_EPSTAT: + + pep = ep_addr(SETUPDAT[2]); + if (pep) { + EP0BUF[0] = *pep; + EP0BCH=0; + EP0BCL=1; + return TRUE; + } + default: + break; + } + return FALSE; +} + +// this firmware only supports 0,0 +BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc) +{ + if (ifc==0) { + *alt_ifc=0; + return TRUE; + } else { + return FALSE; + } +} +BOOL handle_set_interface(BYTE ifc, BYTE alt_ifc) +{ + RESETTOGGLE(0x02); + RESETTOGGLE(0x86); + OUTPKTEND=0x82; + OUTPKTEND=0x82; + OUTPKTEND=0x82; + OUTPKTEND=0x82; + return ifc == 0 && alt_ifc == 0; +} + +// get/set configuration +BYTE handle_get_configuration() +{ + return 1; +} + +BOOL handle_get_descriptor(BYTE desc) +{ + (void)desc; + return FALSE; +} + +BOOL handle_set_configuration(BYTE cfg) +{ + + return cfg==1 ? TRUE : FALSE; // we only handle cfg 1 +} + +void sudav_isr() __interrupt SUDAV_ISR +{ + + got_sud=TRUE; + CLEAR_SUDAV(); +} + +void sof_isr () __interrupt SOF_ISR __using 1 +{ + CLEAR_SOF(); +} + +void usbreset_isr() __interrupt USBRESET_ISR +{ + handle_hispeed(FALSE); + CLEAR_USBRESET(); +} +void hispeed_isr() __interrupt HISPEED_ISR +{ + handle_hispeed(TRUE); + CLEAR_HISPEED(); +} diff --git a/Firmware/fx2lib/fw/.gitignore b/Firmware/fx2lib/fw/.gitignore new file mode 100644 index 0000000..42e046d --- /dev/null +++ b/Firmware/fx2lib/fw/.gitignore @@ -0,0 +1,9 @@ +*.asm +*.lst +*.rel +*.rst +*.sym +*.map +*.mem +*.bix +*.iic diff --git a/Firmware/fx2lib/fw/Makefile b/Firmware/fx2lib/fw/Makefile new file mode 100644 index 0000000..e8526eb --- /dev/null +++ b/Firmware/fx2lib/fw/Makefile @@ -0,0 +1,26 @@ +# Copyright (C) 2010 Ubixum, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + + +# change location of fx2libdir if needed +SOURCES=fw.c device.c +A51_SOURCES=dscr.a51 +BASENAME=firmware + + +include ../lib/fx2.mk + diff --git a/Firmware/fx2lib/fw/device.c b/Firmware/fx2lib/fw/device.c new file mode 100644 index 0000000..72a281d --- /dev/null +++ b/Firmware/fx2lib/fw/device.c @@ -0,0 +1,98 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +#ifdef DEBUG_FIRMWARE +#include +#else +#define printf(...) +#endif + +BOOL handle_get_descriptor() { + +} + +//************************** Configuration Handlers ***************************** + +// change to support as many interfaces as you need +//volatile xdata BYTE interface=0; +//volatile xdata BYTE alt=0; // alt interface + +// set *alt_ifc to the current alt interface for ifc +BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc) { +// *alt_ifc=alt; + return TRUE; +} +// return TRUE if you set the interface requested +// NOTE this function should reconfigure and reset the endpoints +// according to the interface descriptors you provided. +BOOL handle_set_interface(BYTE ifc,BYTE alt_ifc) { + printf ( "Set Interface.\n" ); + //interface=ifc; + //alt=alt_ifc; + return TRUE; +} + +// handle getting and setting the configuration +// 1 is the default. If you support more than one config +// keep track of the config number and return the correct number +// config numbers are set int the dscr file. +//volatile BYTE config=1; +BYTE handle_get_configuration() { + return 1; +} + +// NOTE changing config requires the device to reset all the endpoints +BOOL handle_set_configuration(BYTE cfg) { + printf ( "Set Configuration.\n" ); + //config=cfg; + return TRUE; +} + + +//******************* VENDOR COMMAND HANDLERS ************************** + + +BOOL handle_vendorcommand(BYTE cmd) { + // your custom vendor handler code here.. + return FALSE; // not handled by handlers +} + + +//******************** INIT *********************** + +void main_init() { + + REVCTL=3; + SETIF48MHZ(); + + // set IFCONFIG + // config your endpoints etc. + // config gpif + + printf ( "Initialization Done.\n" ); + +} + + +void main_loop() { + // do some work +} + + diff --git a/Firmware/fx2lib/fw/dscr.a51 b/Firmware/fx2lib/fw/dscr.a51 new file mode 100644 index 0000000..09167b1 --- /dev/null +++ b/Firmware/fx2lib/fw/dscr.a51 @@ -0,0 +1,256 @@ +; Copyright (C) 2009 Ubixum, Inc. +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +; this is a the default +; full speed and high speed +; descriptors found in the TRM +; change however you want but leave +; the descriptor pointers so the setupdat.c file works right + + +.module DEV_DSCR + +; descriptor types +; same as setupdat.h +DSCR_DEVICE_TYPE=1 +DSCR_CONFIG_TYPE=2 +DSCR_STRING_TYPE=3 +DSCR_INTERFACE_TYPE=4 +DSCR_ENDPOINT_TYPE=5 +DSCR_DEVQUAL_TYPE=6 + +; for the repeating interfaces +DSCR_INTERFACE_LEN=9 +DSCR_ENDPOINT_LEN=7 + +; endpoint types +ENDPOINT_TYPE_CONTROL=0 +ENDPOINT_TYPE_ISO=1 +ENDPOINT_TYPE_BULK=2 +ENDPOINT_TYPE_INT=3 + + .globl _dev_dscr, _dev_qual_dscr, _highspd_dscr, _fullspd_dscr, _dev_strings, _dev_strings_end +; These need to be in code memory. If +; they aren't you'll have to manully copy them somewhere +; in code memory otherwise SUDPTRH:L don't work right + .area DSCR_AREA (CODE) + +_dev_dscr: + .db dev_dscr_end-_dev_dscr ; len + .db DSCR_DEVICE_TYPE ; type + .dw 0x0002 ; usb 2.0 + .db 0xff ; class (vendor specific) + .db 0xff ; subclass (vendor specific) + .db 0xff ; protocol (vendor specific) + .db 64 ; packet size (ep0) + .dw 0xB404 ; vendor id + .dw 0x1386 ; product id + .dw 0x0100 ; version id + .db 0 ; manufacturure str idx + .db 2 ; product str idx + .db 0 ; serial str idx + .db 1 ; n configurations +dev_dscr_end: + +_dev_qual_dscr: + .db dev_qualdscr_end-_dev_qual_dscr + .db DSCR_DEVQUAL_TYPE + .dw 0x0002 ; usb 2.0 + .db 0xff + .db 0xff + .db 0xff + .db 64 ; max packet + .db 1 ; n configs + .db 0 ; extra reserved byte +dev_qualdscr_end: + +_highspd_dscr: + .db highspd_dscr_end-_highspd_dscr ; dscr len ;; Descriptor length + .db DSCR_CONFIG_TYPE + ; can't use .dw because byte order is different + .db (highspd_dscr_realend-_highspd_dscr) % 256 ; total length of config lsb + .db (highspd_dscr_realend-_highspd_dscr) / 256 ; total length of config msb + .db 1 ; n interfaces + .db 1 ; config number + .db 0 ; config string + .db 0x80 ; attrs = bus powered, no wakeup + .db 0x32 ; max power = 100ma +highspd_dscr_end: + +; all the interfaces next +; NOTE the default TRM actually has more alt interfaces +; but you can add them back in if you need them. +; here, we just use the default alt setting 1 from the trm + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 0 ; alt setting idx + .db 6 ; n endpoints + .db 0xff ; class + .db 0xff + .db 0xff + .db 0 ; string index + +; endpoint 1 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x01 ; ep1 dir=out and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 1 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x81 ; ep1 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 2 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x02 ; ep2 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 4 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x04 ; ep4 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x86 ; ep6 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; endpoint 8 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x88 ; ep8 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x00 ; polling interval +highspd_dscr_realend: + +.even +_fullspd_dscr: + .db fullspd_dscr_end-_fullspd_dscr ; dscr len + .db DSCR_CONFIG_TYPE + ; can't use .dw because byte order is different + .db (fullspd_dscr_realend-_fullspd_dscr) % 256 ; total length of config lsb + .db (fullspd_dscr_realend-_fullspd_dscr) / 256 ; total length of config msb + .db 1 ; n interfaces + .db 1 ; config number + .db 0 ; config string + .db 0x80 ; attrs = bus powered, no wakeup + .db 0x32 ; max power = 100ma +fullspd_dscr_end: + +; all the interfaces next +; NOTE the default TRM actually has more alt interfaces +; but you can add them back in if you need them. +; here, we just use the default alt setting 1 from the trm + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 0 ; alt setting idx + .db 6 ; n endpoints + .db 0xff ; class + .db 0xff + .db 0xff + .db 0 ; string index + +; endpoint 1 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x01 ; ep1 dir=out and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +; endpoint 1 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x81 ; ep1 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +; endpoint 2 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x02 ; ep2 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +; endpoint 4 out + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x04 ; ep4 dir=OUT and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval + +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x86 ; ep6 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x88 ; ep6 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=64 bytes + .db 0x00 ; polling interval +fullspd_dscr_realend: + +.even +_dev_strings: +; sample string +_string0: + .db string0end-_string0 ; len + .db DSCR_STRING_TYPE + .db 0x09, 0x04 ; 0x0409 is the language code for English. Possible to add more codes after this. +string0end: +; add more strings here + + +_dev_strings_end: + .dw 0x0000 ; in case you wanted to look at memory between _dev_strings and _dev_strings_end diff --git a/Firmware/fx2lib/fw/fw.c b/Firmware/fx2lib/fw/fw.c new file mode 100644 index 0000000..e6a8fe9 --- /dev/null +++ b/Firmware/fx2lib/fw/fw.c @@ -0,0 +1,135 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include +#include +#include +#include +#include + +#ifdef DEBUG_FIRMWARE +#include +#include +#else +#define printf(...) +#endif + + + + +volatile __bit dosud=FALSE; +volatile __bit dosuspend=FALSE; + +// custom functions +extern void main_loop(); +extern void main_init(); + + +void main() { + +#ifdef DEBUG_FIRMWARE + SETCPUFREQ(CLK_48M); // required for sio0_init + // main_init can still set this to whatever you want. + sio0_init(57600); // needed for printf if debug defined +#endif + + main_init(); + + // set up interrupts. + USE_USB_INTS(); + + ENABLE_SUDAV(); + ENABLE_USBRESET(); + ENABLE_HISPEED(); + ENABLE_SUSPEND(); + ENABLE_RESUME(); + + EA=1; + +// iic files (c2 load) don't need to renumerate/delay +// trm 3.6 +#ifndef NORENUM + RENUMERATE(); +#else + USBCS &= ~bmDISCON; +#endif + + while(TRUE) { + + main_loop(); + + if (dosud) { + dosud=FALSE; + handle_setupdata(); + } + + if (dosuspend) { + dosuspend=FALSE; + do { + printf ( "I'm going to Suspend.\n" ); + WAKEUPCS |= bmWU|bmWU2; // make sure ext wakeups are cleared + SUSPEND=1; + PCON |= 1; + __asm + nop + nop + nop + nop + nop + nop + nop + __endasm; + } while ( !remote_wakeup_allowed && REMOTE_WAKEUP()); + printf ( "I'm going to wake up.\n"); + + // resume + // trm 6.4 + if ( REMOTE_WAKEUP() ) { + delay(5); + USBCS |= bmSIGRESUME; + delay(15); + USBCS &= ~bmSIGRESUME; + } + + } + + } // end while + +} // end main + +void resume_isr() __interrupt RESUME_ISR { + CLEAR_RESUME(); +} + +void sudav_isr() __interrupt SUDAV_ISR { + dosud=TRUE; + CLEAR_SUDAV(); +} +void usbreset_isr() __interrupt USBRESET_ISR { + handle_hispeed(FALSE); + CLEAR_USBRESET(); +} +void hispeed_isr() __interrupt HISPEED_ISR { + handle_hispeed(TRUE); + CLEAR_HISPEED(); +} + +void suspend_isr() __interrupt SUSPEND_ISR { + dosuspend=TRUE; + CLEAR_SUSPEND(); +} diff --git a/Firmware/fx2lib/fw/readme.txt b/Firmware/fx2lib/fw/readme.txt new file mode 100644 index 0000000..b8c5b50 --- /dev/null +++ b/Firmware/fx2lib/fw/readme.txt @@ -0,0 +1,20 @@ +Starting a new firmware is easy. + +1) The fw should build without modification. + +> make # builds firmware.ihx +> make bix # builds firmware.bix +> make iic # builds firmware.iic + +2) modify device.c to initialize your device and + handle data according to your needs. + + +3) add more sources, gpif data etc. + +4) modify the device descriptor (dscr.a51) + + +For a fast way to deploy, you can use the fx2load +package provided in examples/fx2 + diff --git a/Firmware/fx2lib/include/autovector.h b/Firmware/fx2lib/include/autovector.h new file mode 100644 index 0000000..c58677c --- /dev/null +++ b/Firmware/fx2lib/include/autovector.h @@ -0,0 +1,227 @@ +// Copyright (C) 2010 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + + +/** \file usbjt.h + * + * To use usbjt, you must tell the linker where to put the IN2JT. + * It must lie on a page boundary or your interrupts won't work right. + * + * example: + * -Wl"-b INT2JT = 0x1A00" + * + * Make sure that INT2JT doesn't overlap your other code! + * + * Unlike the standard fx2 interrupts (\ref fx2ints.h), the autovectored + * interrupts are defined in assemply and have pre-written function names. + * Be sure to override the functions defined in this header or your + * interrupt handler will not be called. + **/ + +#ifndef USBJT_H +#define USBJT_H + +#include "fx2regs.h" + + +/** + * Enable all interrupts (EA=1) separate from this macro. + * This macro causes the autovector assembly for int2 interrupts + * to be overlayed at 0x43. In addition, the jump table for the + * interrupts will be included in the firmware. The jump table + * must lie on a page boundary. This is done by passing the linker + * arguments to sdcc. + * + * \code + * sdcc -Wl"-b INT2JT = 0xaddr" + * \endcode + **/ +#define USE_USB_INTS() {EUSB=1;\ + INTSETUP|=bmAV2EN;} +/** This macro causes the autovector assemby for int4 to be overlayed + * at 0x53. Don't use this if you want external pin generated int4 interrupts + * and want to define your own interrupt handler. It is possible to use + * usb interrupts with autovectoring and not use GPIF interrupts but GPIF + * interrupts require the USB jump table. (You can't USE your own usb interrupt + * handler if you want to enable GPIF interrupts.) + **/ +#define USE_GPIF_INTS() {EIEX4=1;\ + INTSETUP|=bmAV4EN|INT4IN;} + + +#define CLEAR_USBINT() EXIF &= ~0x10 +#define CLEAR_GPIF() EXIF &= ~0x40 + +#define ENABLE_SUDAV() USBIE|=bmSUDAV +#define CLEAR_SUDAV() CLEAR_USBINT(); USBIRQ=bmSUDAV + +#define ENABLE_SUTOK() USBIE|=bmSUTOK; +#define CLEAR_SUTOK() CLEAR_USBINT(); USBIRQ=bmSUTOK + +#define ENABLE_SOF() USBIE|=bmSOF +#define CLEAR_SOF() CLEAR_USBINT(); USBIRQ=bmSOF + +#define ENABLE_SUSPEND() USBIE|=bmSUSP +#define CLEAR_SUSPEND() CLEAR_USBINT(); USBIRQ=bmSUSP + +#define ENABLE_USBRESET() USBIE|= bmURES +#define CLEAR_USBRESET() CLEAR_USBINT(); USBIRQ=bmURES + +#define ENABLE_HISPEED() USBIE|=bmHSGRANT +#define CLEAR_HISPEED() CLEAR_USBINT(); USBIRQ=bmHSGRANT + +#define ENABLE_EP0IN() EPIE|=bmEP0IN +#define CLEAR_EP0IN() CLEAR_USBINT(); EPIRQ=bmEP0IN + +#define ENABLE_EP0OUT() EPIE|=bmEP0OUT +#define CLEAR_EP0OUT() CLEAR_USBINT(); EPIRQ=bmEP0OUT + +#define ENABLE_EP1IN() EPIE|=bmEP1IN +#define CLEAR_EP1IN() CLEAR_USBINT(); EPIRQ=bmEP1IN + +#define ENABLE_EP1OUT() EPIE|=bmEP1OUT +#define CLEAR_EP1OUT() CLEAR_USBINT(); EPIRQ=bmEP1OUT + +#define ENABLE_EP2() EPIE|=bmEP2 +#define CLEAR_EP2() CLEAR_USBINT(); EPIRQ=bmEP2 + +#define ENABLE_EP4() EPIE|=bmEP4 +#define CLEAR_EP4() CLEAR_USBINT(); EPIRQ=bmEP4 + +#define ENABLE_EP6() EPIE|=bmEP6 +#define CLEAR_EP6() CLEAR_USBINT(); EPIRQ=bmEP6 + +#define ENABLE_EP8() EPIE|=bmEP8 +#define CLEAR_EP8() CLEAR_USBINT(); EPIRQ=bmEP8 + +#define ENABLE_EP2ISOERR() USBERRIE |= bmISOEP2 +#define CLEAR_EP2ISOERR() CLEAR_USBINT(); USBERRIRQ = bmISOEP2 + +#define ENABLE_EP6PF() EP6FIFOIE |= bmBIT2 +#define CLEAR_EP6PF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT2 + +#define ENABLE_EP6FF() EP6FIFOIE |= bmBIT0 +#define CLEAR_EP6FF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT0 + +#define ENABLE_GPIFDONE() GPIFIE |= 0x01; +#define CLEAR_GPIFDONE() CLEAR_GPIF(); GPIFIRQ = 0x01; + +#define ENABLE_GPIFWF() GPIFIE |= 0x02; +#define CLEAR_GPIFWF() GLEAR_GPIF(); GPIFIRQ = 0x02; + +/** + * ez-usb has 12 built in ISRs, to get + * sdcc to put these USB ISRs immediately + * after the other ISRs (and not waste space) + * we start at 13 + **/ +typedef enum { + SUDAV_ISR=13, + SOF_ISR, + SUTOK_ISR, + SUSPEND_ISR, + USBRESET_ISR, + HISPEED_ISR, + EP0ACK_ISR, + EP0IN_ISR, + EP0OUT_ISR, + EP1IN_ISR, + EP1OUT_ISR, + EP2_ISR, + EP4_ISR, + EP6_ISR, + EP8_ISR, + IBN_ISR, + EP0PING_ISR, + EP1PING_ISR, + EP2PING_ISR, + EP4PING_ISR, + EP6PING_ISR, + EP8PING_ISR, + ERRLIMIT_ISR, + EP2ISOERR_ISR, + EP4ISOERR_ISR, + EP6ISOERR_ISR, + EP8ISOERR_ISR, + RESERVED_ISR, + EP2PF_ISR, + EP4PF_ISR, + EP6PF_ISR, + EP8PF_ISR, + EP2EF_ISR, + EP4EF_ISR, + EP6EF_ISR, + EP8EF_ISR, + EP2FF_ISR, + EP4FF_ISR, + EP6FF_ISR, + EP8FF_ISR, + GPIFDONE_ISR, + GPIFWF_ISR +} USB_ISR; + +// you must include the predef of these in the file with your main +// so lets just define them here + +void usb_isr(void) __interrupt (8); +void sudav_isr() __interrupt; +void sof_isr() __interrupt; +void sutok_isr() __interrupt; +void suspend_isr() __interrupt; +void usbreset_isr() __interrupt; +void hispeed_isr() __interrupt; +void ep0ack_isr() __interrupt; +void ep0in_isr() __interrupt; +void ep0out_isr() __interrupt; +void ep1in_isr() __interrupt; +void ep1out_isr() __interrupt; +void ep2_isr() __interrupt; +void ep4_isr() __interrupt; +void ep6_isr() __interrupt; +void ep8_isr() __interrupt; +void ibn_isr() __interrupt; +void ep0ping_isr() __interrupt; +void ep1ping_isr() __interrupt; +void ep2ping_isr() __interrupt; +void ep4ping_isr() __interrupt; +void ep6ping_isr() __interrupt; +void ep8ping_isr() __interrupt; +void errlimit_isr() __interrupt; +void ep2isoerr_isr() __interrupt; +void ep4isoerr_isr() __interrupt; +void ep6isoerr_isr() __interrupt; +void ep8isoerr_isr() __interrupt; +void spare_isr() __interrupt; // not used +// gpif ints +void gpif_isr(void) __interrupt (10); +void ep2pf_isr() __interrupt; +void ep4pf_isr() __interrupt; +void ep6pf_isr() __interrupt; +void ep8pf_isr() __interrupt; +void ep2ef_isr() __interrupt; +void ep4ef_isr() __interrupt; +void ep6ef_isr() __interrupt; +void ep8ef_isr() __interrupt; +void ep2ff_isr() __interrupt; +void ep4ff_isr() __interrupt; +void ep6ff_isr() __interrupt; +void ep8ff_isr() __interrupt; +void gpifdone_isr() __interrupt; +void gpifwf_isr() __interrupt; + +#endif + diff --git a/Firmware/fx2lib/include/delay.h b/Firmware/fx2lib/include/delay.h new file mode 100644 index 0000000..893ca67 --- /dev/null +++ b/Firmware/fx2lib/include/delay.h @@ -0,0 +1,109 @@ +// Copyright (C) 2009 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +/*! \file + * Functions for causing delays. + * */ + + +#ifndef DELAY_H +#define DELAY_H + +#include "fx2types.h" + +/** + * 0-65536 millis + **/ +void delay(WORD millis); + +/** + * See TRM 15-14,15-15 + * some registers (r/w) require syncdelay after + * + * up to the programmer to determine which sync is needed. + * for standard 48mhz clock w/ 48mhz IFCONFIG 3 nops is sufficient. + * + * slower clock and faster ifclock require more delay + * + * min delay = roof ( 1.5 x (ifclock/clkout + 1) ) + * + * Minimum IFCLOCK is 5mhz but you have to use an + * external clock source to go below 30mhz + * + * IFCLKSRC 1 = internal, 0=external + * 3048mhz 0 = 30mhz, 1 = 48mzh + * + * Figure your own sync delay out if IFCLKSRC=0. + **/ + +#define NOP __asm nop __endasm + +/** + * SYNCDELAY2 can work for the following clock speeds + * + * ifclk/clk + * \li 48/12 + * + * ceil(1.5 * (20.8 / 83.3 + 1)) = 2 + * + * \see NOP + * + **/ +#define SYNCDELAY2 NOP; NOP + +/** + * SYNCDELAY3 can work for the following clock speeds + * + * ifcfg/clk + * \li 48/24 + * \li 48/48 + * \li 30/12 + * \li 30/24 + * + * \see NOP + **/ +#define SYNCDELAY3 NOP; NOP; NOP + +/** + * SYNCDELAY4 should be used for the following speeds + * + * ifcfg/clk + * \li 30/48 + * + * \see NOP + **/ +#define SYNCDELAY4 NOP; NOP; NOP; NOP + +/** + * All the SYNCDELAYs you could possibly want for other speeds + * + * \see NOP + **/ +#define SYNCDELAY5 NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY6 NOP; NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY7 NOP; NOP; NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY8 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY9 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY10 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY11 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY12 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY13 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY14 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY15 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP +#define SYNCDELAY16 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP + +#endif + diff --git a/Firmware/fx2lib/include/eputils.h b/Firmware/fx2lib/include/eputils.h new file mode 100644 index 0000000..9aae156 --- /dev/null +++ b/Firmware/fx2lib/include/eputils.h @@ -0,0 +1,92 @@ +// Copyright (C) 2009 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +/*! \file + * Functions and macros for working with endpoints. + * */ + +#ifndef EPUTILS_H +#define EPUTILS_H + +#include "fx2types.h" + +/** + * NOTE you can't use these unless you define SYNCDELAY + * as a macro or function. The reason is that SYNCDELAY + * needs to be longer or shorter depending on your IFCONFIG + * settings. + * See delay.h + * + * Example: + * \code + * #define SYNCDELAY SYNCDELAY4 // SYNCDELAY4 from delay.h + * \endcode + * + * + **/ + +/** + * Stalls EP0. + **/ +#define STALLEP0() EP0CS |= bmEPSTALL + +/** + * \brief Reset the toggle on an endpoint. + * To use this, the endpoint needs bit 8 to be IN=1,OUT=0 + **/ +#define RESETTOGGLE(ep) do {\ + BYTE x = ep; \ + if (x&0x80) { x |= 0x10; } \ + x &= 0x1F; \ + TOGCTL = x; \ + TOGCTL = x | bmRESETTOGGLE; \ +} while (0) + + +/** + * RESETFIFO should not use 0x80|epnum for IN endpoints + * Only use 0x02, 0x04, 0x06, 0x06 for ep value + **/ +#define RESETFIFO(ep) {FIFORESET=0x80; SYNCDELAY;\ + FIFORESET=0x80 | ep; SYNCDELAY;\ + FIFORESET=0x00; SYNCDELAY;} +/** + * Quickly reset all endpoint FIFOS. + **/ +#define RESETFIFOS() {FIFORESET=0x80; SYNCDELAY;\ + FIFORESET=0x82; SYNCDELAY;\ + FIFORESET=0x84; SYNCDELAY;\ + FIFORESET=0x86; SYNCDELAY;\ + FIFORESET=0x88; SYNCDELAY;\ + FIFORESET=0x00; SYNCDELAY;} + +/** + * Continually read available bytes from endpoint0 into dst, wait + * until more bytes are available, and loop until len bytes have + * been read. + **/ +void readep0( BYTE* dst, WORD len ); + + +/** + * Write bytes from src to ep0, allowing host to transfer data + * between 64 byte blocks. + **/ +void writeep0 ( BYTE* src, WORD len ); + + + +#endif diff --git a/Firmware/fx2lib/include/fx2ints.h b/Firmware/fx2lib/include/fx2ints.h new file mode 100644 index 0000000..45ae71e --- /dev/null +++ b/Firmware/fx2lib/include/fx2ints.h @@ -0,0 +1,116 @@ +// Copyright (C) 2010 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +/*! \file + * Define the standard fx2 interrupts. For int2 and int4 autovector + * interrupts see \ref autovector.h + * + * To enable an interrupt, simply define an interrupt handler function + * and use the appropriate ENABLE_* macro. Interrupt enable macros + * do not enable interrupts globally. Use EA=1 to enable interrupts. + * + * \code + * void main() { + * ENABLE_RESUME(); + * EA=1; + * ... + * } + * + * void handle_resume() interrupt RESUME_ISR { + * CLEAR_RESUME(); + * } + * \endcode + * + * */ + + +/** + * \brief interrupt numbers for standard fx2 interrupts + + **/ +typedef enum { + IE0_ISR=0, ///< External interrupt 0 + TF0_ISR, ///< Timer 0 interrupt + IE1_ISR, ///< External interrupt 1 + TF1_ISR, ///< Timer 1 interrupt + TI_0_ISR, ///< Serial port 0 transmit or receive interrupt + TF2_ISR, ///< Timer 2 interrupt + RESUME_ISR, ///< Resume interrupt + TI_1_ISR, ///< Serial port 1 transmit or receive interrupt + USBINT_ISR, ///< Usb Interrupt. An interrupt handler for this should only be used if not using auto vectored interrupts with int2 + I2CINT_ISR, ///< I2C Bus interrupt + IE4_ISR, ///< External interrupt 4. An interrupt handler for this should only be used if not using auto vectored interrupts with int4 + IE5_ISR, ///< External interrupt 5 + IE6_ISR, ///< External interrupt 6 +} FX2_ISR; + + +/** + * \brief Enable the timer 0 interrupt. + * + * There is not CLEAR_TIMER0 because the timer interrupt flag + * is automatically cleared when the isr is called. + **/ +#define ENABLE_TIMER0() ET0=1 + +/** + * \brief Enable timer 1 interrupt + * There is no CLEAR_TIMER1 because the timer interrupt flag + * is automatically cleared when the isr is called. + **/ +#define ENABLE_TIMER1() ET1=1 + + +/** + * \brief Enable timer 2 interrupt + * + * This is the same interrupt whether timer 2 overflowed or + * for the external EXF2 flag. + **/ +#define ENABLE_TIMER2() ET2=1 +/** + * \brief Clear timer 2 interrupt + * + * Clears both the TF2 AND EXF2 flag + **/ +#define CLEAR_TIMER2() TF2=0;EXF2=0; + +/** + * \brief Enable the Resume Interrupt. Requires EA=1 separately. + **/ +#define ENABLE_RESUME() ERESI = 1 + +/** + * \brief Clear the resume interrupt. Use within the resume + * interrupt handler. + **/ +#define CLEAR_RESUME() RESI=0 + + +#define ENABLE_INT4() + +/** + * \brief + * Enable external interupt for int5# + **/ +#define ENABLE_INT5() EIEX5=1 + +/** + * \brief + * Clear int5# interrupt + **/ +#define CLEAR_INT5() EXIF &= ~0x80 + diff --git a/Firmware/fx2lib/include/fx2macros.h b/Firmware/fx2lib/include/fx2macros.h new file mode 100644 index 0000000..f59139c --- /dev/null +++ b/Firmware/fx2lib/include/fx2macros.h @@ -0,0 +1,127 @@ +// Copyright (C) 2009 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +/*! \file + * Macros for simple common tasks in fx2 firmware. + * */ + +#ifndef FX2MACROS_H +#define FX2MACROS_H + +#include "fx2regs.h" +#include "fx2types.h" + +#define MSB(addr) (BYTE)(((WORD)(addr) >> 8) & 0xff) +#define LSB(addr) (BYTE)((WORD)(addr) & 0xff) +#define MAKEWORD(msb,lsb) (((WORD)msb << 8) | lsb) + +#define MSW(dword) (WORD)((dword >> 16) & 0xffff) +#define LSW(dword) (WORD)(dword & 0xffff) +#define MAKEDWORD(msw,lsw) (((DWORD)msw << 16) | lsw) + +// clock stuff + +/** + * \brief Used for getting and setting the CPU clock speed. + **/ +typedef enum { CLK_12M =0, CLK_24M, CLK_48M} CLK_SPD; + +/** + * \brief Evaluates to a CLK_SPD enum. + **/ +#define CPUFREQ (CLK_SPD)((CPUCS & bmCLKSPD) >> 3) +/** + * \brief Sets the cpu to operate at a specific + * clock speed. + **/ +#define SETCPUFREQ(SPD) CPUCS = (CPUCS & ~bmCLKSPD) | (SPD << 3) + +/** + * \brief Evaluates to a DWORD value representing + * the clock speed in cycles per second. + * + * Speeds: + * + * \li 12000000L + * \li 24000000L + * \li 48000000L + * + **/ +#define XTAL (CPUFREQ==CLK_12M ? 12000000L :\ + CPUFREQ==CLK_24M ? 24000000L : 48000000L) + + +/** + * \brief Evaluates to the i2c bus frequency in cyles per + * second. + * + * Speeds: + * + * \li 400000L + * \li 100000L + * + **/ +#define I2CFREQ ((I2CTL & bm400KHZ) ? 400000L : 100000L) + + +#define IFFREQ (IFCONFIG & bm3048MHZ ? 48000000L : 30000000L) +#define SETIF30MHZ() IFCONFIG &= ~bm3048MHZ +#define SETIF48MHZ() IFCONFIG |= bm3048MHZ + + +// eeprom stuff +#define EEPROM_TWO_BYTE (I2CS & bmBIT4) + +/** + * \brief Cause the device to disconnect and reconnect to USB. This macro + * unconditionally renumerates the device no matter how the firmware is loaded. + * + * NOTE Windows really doesn't like this if the firmware is loaded + * from an eeprom. You'll see information messages about the device not + * working properly. On the other hand, if you are changing the device + * descriptor, e.g., the vendor and product id, when downloading firmware to the device, + * you'll need to use this macro instead of the + * standard RENUMERATE macro. + **/ +#define RENUMERATE_UNCOND() USBCS|=bmDISCON|bmRENUM;delay(1500);USBCS&=~bmDISCON +/** + * \brief Cause the device to disconnect and reconnect to the USB bus. This macro + * doesn't do anything if the firmware is loaded from an eeprom. + **/ +#define RENUMERATE() if(!(USBCS&bmRENUM)) {USBCS|=bmDISCON|bmRENUM;delay(1500);USBCS &= ~bmDISCON;} + + +// interrupts +// USB interrupts are in usbjt.h + + + + +/** + * \brief TRUE if the FX2 has transitioned to high speed on the USB bus.. + **/ +#define HISPEED (USBCS&bmHSM) + + + + +/** + * \brief Evaluates to TRUE if a remote wakeup event has occurred. + **/ +#define REMOTE_WAKEUP() (((WAKEUPCS & bmWU) && (WAKEUPCS & bmWUEN)) || ((WAKEUPCS & bmWU2) && (WAKEUPCS & bmWU2EN))) + + +#endif diff --git a/Firmware/fx2lib/include/fx2regs.h b/Firmware/fx2lib/include/fx2regs.h new file mode 100644 index 0000000..51ec63a --- /dev/null +++ b/Firmware/fx2lib/include/fx2regs.h @@ -0,0 +1,646 @@ +// Copyright (C) 2009 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +/*! \file + * + * This is the basic header/register file for working with the cypress fx2 + * (cyc768013) and variants 8051 chipset. It contains the special function + * register definitions as well as the special configuration registers + * addresses. + * + * The TRM for the fx2 chip contains the full documentation for what each of + * these registers do. + * + * */ + + +/** \mainpage FX2LIB Documentation + * \verbinclude README + **/ + +/** \example fw.c + * The firmware framework allows for easily beginning a new firware project. + **/ + +#ifndef FX2REGS_H +#define FX2REGS_H + +#include "fx2types.h" + +__xdata __at 0xE400 volatile BYTE GPIF_WAVE_DATA; +__xdata __at 0xE480 volatile BYTE RES_WAVEDATA_END; + +// General Configuration + +__xdata __at 0xE600 volatile BYTE CPUCS; ///< Control & Status +__xdata __at 0xE601 volatile BYTE IFCONFIG; ///< Interface Configuration +__xdata __at 0xE602 volatile BYTE PINFLAGSAB; ///< FIFO FLAGA and FLAGB Assignments +__xdata __at 0xE603 volatile BYTE PINFLAGSCD; ///< FIFO FLAGC and FLAGD Assignments +__xdata __at 0xE604 volatile BYTE FIFORESET; ///< Restore FIFOS to default state +__xdata __at 0xE605 volatile BYTE BREAKPT; ///< Breakpoint +__xdata __at 0xE606 volatile BYTE BPADDRH; ///< Breakpoint Address H +__xdata __at 0xE607 volatile BYTE BPADDRL; ///< Breakpoint Address L +__xdata __at 0xE608 volatile BYTE UART230; ///< 230 Kbaud clock for T0,T1,T2 +__xdata __at 0xE609 volatile BYTE FIFOPINPOLAR; ///< FIFO polarities +__xdata __at 0xE60A volatile BYTE REVID; ///< Chip Revision +__xdata __at 0xE60B volatile BYTE REVCTL; ///< Chip Revision Control + +// Endpoint Configuration + +__xdata __at 0xE610 volatile BYTE EP1OUTCFG; ///< Endpoint 1-OUT Configuration +__xdata __at 0xE611 volatile BYTE EP1INCFG; ///< Endpoint 1-IN Configuration +__xdata __at 0xE612 volatile BYTE EP2CFG; ///< Endpoint 2 Configuration +__xdata __at 0xE613 volatile BYTE EP4CFG; ///< Endpoint 4 Configuration +__xdata __at 0xE614 volatile BYTE EP6CFG; ///< Endpoint 6 Configuration +__xdata __at 0xE615 volatile BYTE EP8CFG; ///< Endpoint 8 Configuration +__xdata __at 0xE618 volatile BYTE EP2FIFOCFG; ///< Endpoint 2 FIFO configuration +__xdata __at 0xE619 volatile BYTE EP4FIFOCFG; ///< Endpoint 4 FIFO configuration +__xdata __at 0xE61A volatile BYTE EP6FIFOCFG; ///< Endpoint 6 FIFO configuration +__xdata __at 0xE61B volatile BYTE EP8FIFOCFG; ///< Endpoint 8 FIFO configuration +__xdata __at 0xE620 volatile BYTE EP2AUTOINLENH; ///< Endpoint 2 Packet Length H (IN only) +__xdata __at 0xE621 volatile BYTE EP2AUTOINLENL; ///< Endpoint 2 Packet Length L (IN only) +__xdata __at 0xE622 volatile BYTE EP4AUTOINLENH; ///< Endpoint 4 Packet Length H (IN only) +__xdata __at 0xE623 volatile BYTE EP4AUTOINLENL; ///< Endpoint 4 Packet Length L (IN only) +__xdata __at 0xE624 volatile BYTE EP6AUTOINLENH; ///< Endpoint 6 Packet Length H (IN only) +__xdata __at 0xE625 volatile BYTE EP6AUTOINLENL; ///< Endpoint 6 Packet Length L (IN only) +__xdata __at 0xE626 volatile BYTE EP8AUTOINLENH; ///< Endpoint 8 Packet Length H (IN only) +__xdata __at 0xE627 volatile BYTE EP8AUTOINLENL; ///< Endpoint 8 Packet Length L (IN only) +__xdata __at 0xE630 volatile BYTE EP2FIFOPFH; ///< EP2 Programmable Flag trigger H +__xdata __at 0xE631 volatile BYTE EP2FIFOPFL; ///< EP2 Programmable Flag trigger L +__xdata __at 0xE632 volatile BYTE EP4FIFOPFH; ///< EP4 Programmable Flag trigger H +__xdata __at 0xE633 volatile BYTE EP4FIFOPFL; ///< EP4 Programmable Flag trigger L +__xdata __at 0xE634 volatile BYTE EP6FIFOPFH; ///< EP6 Programmable Flag trigger H +__xdata __at 0xE635 volatile BYTE EP6FIFOPFL; ///< EP6 Programmable Flag trigger L +__xdata __at 0xE636 volatile BYTE EP8FIFOPFH; ///< EP8 Programmable Flag trigger H +__xdata __at 0xE637 volatile BYTE EP8FIFOPFL; ///< EP8 Programmable Flag trigger L +__xdata __at 0xE640 volatile BYTE EP2ISOINPKTS; ///< EP2 (if ISO) IN Packets per frame (1-3) +__xdata __at 0xE641 volatile BYTE EP4ISOINPKTS; ///< EP4 (if ISO) IN Packets per frame (1-3) +__xdata __at 0xE642 volatile BYTE EP6ISOINPKTS; ///< EP6 (if ISO) IN Packets per frame (1-3) +__xdata __at 0xE643 volatile BYTE EP8ISOINPKTS; ///< EP8 (if ISO) IN Packets per frame (1-3) +__xdata __at 0xE648 volatile BYTE INPKTEND; ///< Force IN Packet End +__xdata __at 0xE649 volatile BYTE OUTPKTEND; ///< Force OUT Packet End + +// Interrupts + +__xdata __at 0xE650 volatile BYTE EP2FIFOIE; ///< Endpoint 2 Flag Interrupt Enable +__xdata __at 0xE651 volatile BYTE EP2FIFOIRQ; ///< Endpoint 2 Flag Interrupt Request +__xdata __at 0xE652 volatile BYTE EP4FIFOIE; ///< Endpoint 4 Flag Interrupt Enable +__xdata __at 0xE653 volatile BYTE EP4FIFOIRQ; ///< Endpoint 4 Flag Interrupt Request +__xdata __at 0xE654 volatile BYTE EP6FIFOIE; ///< Endpoint 6 Flag Interrupt Enable +__xdata __at 0xE655 volatile BYTE EP6FIFOIRQ; ///< Endpoint 6 Flag Interrupt Request +__xdata __at 0xE656 volatile BYTE EP8FIFOIE; ///< Endpoint 8 Flag Interrupt Enable +__xdata __at 0xE657 volatile BYTE EP8FIFOIRQ; ///< Endpoint 8 Flag Interrupt Request +__xdata __at 0xE658 volatile BYTE IBNIE; ///< IN-BULK-NAK Interrupt Enable +__xdata __at 0xE659 volatile BYTE IBNIRQ; ///< IN-BULK-NAK interrupt Request +__xdata __at 0xE65A volatile BYTE NAKIE; ///< Endpoint Ping NAK interrupt Enable +__xdata __at 0xE65B volatile BYTE NAKIRQ; ///< Endpoint Ping NAK interrupt Request +__xdata __at 0xE65C volatile BYTE USBIE; ///< USB Int Enables +__xdata __at 0xE65D volatile BYTE USBIRQ; ///< USB Interrupt Requests +__xdata __at 0xE65E volatile BYTE EPIE; ///< Endpoint Interrupt Enables +__xdata __at 0xE65F volatile BYTE EPIRQ; ///< Endpoint Interrupt Requests +__xdata __at 0xE660 volatile BYTE GPIFIE; ///< GPIF Interrupt Enable +__xdata __at 0xE661 volatile BYTE GPIFIRQ; ///< GPIF Interrupt Request +__xdata __at 0xE662 volatile BYTE USBERRIE; ///< USB Error Interrupt Enables +__xdata __at 0xE663 volatile BYTE USBERRIRQ; ///< USB Error Interrupt Requests +__xdata __at 0xE664 volatile BYTE ERRCNTLIM; ///< USB Error counter and limit +__xdata __at 0xE665 volatile BYTE CLRERRCNT; ///< Clear Error Counter EC[3..0] +__xdata __at 0xE666 volatile BYTE INT2IVEC; ///< Interupt 2 (USB) Autovector +__xdata __at 0xE667 volatile BYTE INT4IVEC; ///< Interupt 4 (FIFOS & GPIF) Autovector +__xdata __at 0xE668 volatile BYTE INTSETUP; ///< Interrupt 2&4 Setup + +// Input/Output + +__xdata __at 0xE670 volatile BYTE PORTACFG; ///< I/O PORTA Alternate Configuration +__xdata __at 0xE671 volatile BYTE PORTCCFG; ///< I/O PORTC Alternate Configuration +__xdata __at 0xE672 volatile BYTE PORTECFG; ///< I/O PORTE Alternate Configuration +__xdata __at 0xE678 volatile BYTE I2CS; ///< Control & Status +__xdata __at 0xE679 volatile BYTE I2DAT; ///< Data +__xdata __at 0xE67A volatile BYTE I2CTL; ///< I2C Control +__xdata __at 0xE67B volatile BYTE XAUTODAT1; ///< Autoptr1 MOVX access +__xdata __at 0xE67C volatile BYTE XAUTODAT2; ///< Autoptr2 MOVX access + +#define EXTAUTODAT1 XAUTODAT1 +#define EXTAUTODAT2 XAUTODAT2 + +// USB Control + +__xdata __at 0xE680 volatile BYTE USBCS; ///< USB Control & Status +__xdata __at 0xE681 volatile BYTE SUSPEND; ///< Put chip into suspend +__xdata __at 0xE682 volatile BYTE WAKEUPCS; ///< Wakeup source and polarity +__xdata __at 0xE683 volatile BYTE TOGCTL; ///< Toggle Control +__xdata __at 0xE684 volatile BYTE USBFRAMEH; ///< USB Frame count H +__xdata __at 0xE685 volatile BYTE USBFRAMEL; ///< USB Frame count L +__xdata __at 0xE686 volatile BYTE MICROFRAME; ///< Microframe count, 0-7 +__xdata __at 0xE687 volatile BYTE FNADDR; ///< USB Function address + +// Endpoints + +__xdata __at 0xE68A volatile BYTE EP0BCH; ///< Endpoint 0 Byte Count H +__xdata __at 0xE68B volatile BYTE EP0BCL; ///< Endpoint 0 Byte Count L +__xdata __at 0xE68D volatile BYTE EP1OUTBC; ///< Endpoint 1 OUT Byte Count +__xdata __at 0xE68F volatile BYTE EP1INBC; ///< Endpoint 1 IN Byte Count +__xdata __at 0xE690 volatile BYTE EP2BCH; ///< Endpoint 2 Byte Count H +__xdata __at 0xE691 volatile BYTE EP2BCL; ///< Endpoint 2 Byte Count L +__xdata __at 0xE694 volatile BYTE EP4BCH; ///< Endpoint 4 Byte Count H +__xdata __at 0xE695 volatile BYTE EP4BCL; ///< Endpoint 4 Byte Count L +__xdata __at 0xE698 volatile BYTE EP6BCH; ///< Endpoint 6 Byte Count H +__xdata __at 0xE699 volatile BYTE EP6BCL; ///< Endpoint 6 Byte Count L +__xdata __at 0xE69C volatile BYTE EP8BCH; ///< Endpoint 8 Byte Count H +__xdata __at 0xE69D volatile BYTE EP8BCL; ///< Endpoint 8 Byte Count L +__xdata __at 0xE6A0 volatile BYTE EP0CS; ///< Endpoint Control and Status +__xdata __at 0xE6A1 volatile BYTE EP1OUTCS; ///< Endpoint 1 OUT Control and Status +__xdata __at 0xE6A2 volatile BYTE EP1INCS; ///< Endpoint 1 IN Control and Status +__xdata __at 0xE6A3 volatile BYTE EP2CS; ///< Endpoint 2 Control and Status +__xdata __at 0xE6A4 volatile BYTE EP4CS; ///< Endpoint 4 Control and Status +__xdata __at 0xE6A5 volatile BYTE EP6CS; ///< Endpoint 6 Control and Status +__xdata __at 0xE6A6 volatile BYTE EP8CS; ///< Endpoint 8 Control and Status +__xdata __at 0xE6A7 volatile BYTE EP2FIFOFLGS; ///< Endpoint 2 Flags +__xdata __at 0xE6A8 volatile BYTE EP4FIFOFLGS; ///< Endpoint 4 Flags +__xdata __at 0xE6A9 volatile BYTE EP6FIFOFLGS; ///< Endpoint 6 Flags +__xdata __at 0xE6AA volatile BYTE EP8FIFOFLGS; ///< Endpoint 8 Flags +__xdata __at 0xE6AB volatile BYTE EP2FIFOBCH; ///< EP2 FIFO total byte count H +__xdata __at 0xE6AC volatile BYTE EP2FIFOBCL; ///< EP2 FIFO total byte count L +__xdata __at 0xE6AD volatile BYTE EP4FIFOBCH; ///< EP4 FIFO total byte count H +__xdata __at 0xE6AE volatile BYTE EP4FIFOBCL; ///< EP4 FIFO total byte count L +__xdata __at 0xE6AF volatile BYTE EP6FIFOBCH; ///< EP6 FIFO total byte count H +__xdata __at 0xE6B0 volatile BYTE EP6FIFOBCL; ///< EP6 FIFO total byte count L +__xdata __at 0xE6B1 volatile BYTE EP8FIFOBCH; ///< EP8 FIFO total byte count H +__xdata __at 0xE6B2 volatile BYTE EP8FIFOBCL; ///< EP8 FIFO total byte count L +__xdata __at 0xE6B3 volatile BYTE SUDPTRH; ///< Setup Data Pointer high address byte +__xdata __at 0xE6B4 volatile BYTE SUDPTRL; ///< Setup Data Pointer low address byte +__xdata __at 0xE6B5 volatile BYTE SUDPTRCTL; ///< Setup Data Pointer Auto Mode +__xdata __at 0xE6B8 volatile BYTE SETUPDAT[8]; ///< 8 bytes of SETUP data + +// GPIF + +__xdata __at 0xE6C0 volatile BYTE GPIFWFSELECT; ///< Waveform Selector +__xdata __at 0xE6C1 volatile BYTE GPIFIDLECS; ///< GPIF Done, GPIF IDLE drive mode +__xdata __at 0xE6C2 volatile BYTE GPIFIDLECTL; ///< Inactive Bus, CTL states +__xdata __at 0xE6C3 volatile BYTE GPIFCTLCFG; ///< CTL OUT pin drive +__xdata __at 0xE6C4 volatile BYTE GPIFADRH; ///< GPIF Address H +__xdata __at 0xE6C5 volatile BYTE GPIFADRL; ///< GPIF Address L + +__xdata __at 0xE6CE volatile BYTE GPIFTCB3; ///< GPIF Transaction Count Byte 3 +__xdata __at 0xE6CF volatile BYTE GPIFTCB2; ///< GPIF Transaction Count Byte 2 +__xdata __at 0xE6D0 volatile BYTE GPIFTCB1; ///< GPIF Transaction Count Byte 1 +__xdata __at 0xE6D1 volatile BYTE GPIFTCB0; ///< GPIF Transaction Count Byte 0 + +__xdata __at 0xE6D2 volatile BYTE EP2GPIFFLGSEL; ///< EP2 GPIF Flag select +__xdata __at 0xE6D3 volatile BYTE EP2GPIFPFSTOP; ///< Stop GPIF EP2 transaction on prog. flag +__xdata __at 0xE6D4 volatile BYTE EP2GPIFTRIG; ///< EP2 FIFO Trigger +__xdata __at 0xE6DA volatile BYTE EP4GPIFFLGSEL; ///< EP4 GPIF Flag select +__xdata __at 0xE6DB volatile BYTE EP4GPIFPFSTOP; ///< Stop GPIF EP4 transaction on prog. flag +__xdata __at 0xE6DC volatile BYTE EP4GPIFTRIG; ///< EP4 FIFO Trigger +__xdata __at 0xE6E2 volatile BYTE EP6GPIFFLGSEL; ///< EP6 GPIF Flag select +__xdata __at 0xE6E3 volatile BYTE EP6GPIFPFSTOP; ///< Stop GPIF EP6 transaction on prog. flag +__xdata __at 0xE6E4 volatile BYTE EP6GPIFTRIG; ///< EP6 FIFO Trigger +__xdata __at 0xE6EA volatile BYTE EP8GPIFFLGSEL; ///< EP8 GPIF Flag select +__xdata __at 0xE6EB volatile BYTE EP8GPIFPFSTOP; ///< Stop GPIF EP8 transaction on prog. flag +__xdata __at 0xE6EC volatile BYTE EP8GPIFTRIG; ///< EP8 FIFO Trigger +__xdata __at 0xE6F0 volatile BYTE XGPIFSGLDATH; ///< GPIF Data H (16-bit mode only) +__xdata __at 0xE6F1 volatile BYTE XGPIFSGLDATLX; ///< Read/Write GPIF Data L & trigger transac +__xdata __at 0xE6F2 volatile BYTE XGPIFSGLDATLNOX; ///< Read GPIF Data L, no transac trigger +__xdata __at 0xE6F3 volatile BYTE GPIFREADYCFG; ///< Internal RDY,Sync/Async, RDY5CFG +__xdata __at 0xE6F4 volatile BYTE GPIFREADYSTAT; ///< RDY pin states +__xdata __at 0xE6F5 volatile BYTE GPIFABORT; ///< Abort GPIF cycles + +// UDMA + +__xdata __at 0xE6C6 volatile BYTE FLOWSTATE; /// Cypress KBA89285 +__xdata __at 0xE507 volatile BYTE UNIQID0; // ID register byte 0 (LSB) +__xdata __at 0xE508 volatile BYTE UNIQID1; // ID register +__xdata __at 0xE509 volatile BYTE UNIQID2; // ID register +__xdata __at 0xE50A volatile BYTE UNIQID3; // ID register +__xdata __at 0xE50B volatile BYTE UNIQID4; // ID register +__xdata __at 0xE50C volatile BYTE UNIQID5; // ID register byte 5 (MSB) + +// Feature Registers (FX2LP/FX1 only) +__xdata __at 0xE50D volatile BYTE GPCR2; ///< Chip Features + +/** + * SFRs below + * According to TRM 15.2, only rows 0 and 8 of the SFRs are bit addressible + * row 0: IOA, IOB, IOC, IOD, SCON1, PSW, ACC, B + * row 8: TCON, SCON0, IE, IP, T2CON, IECON, EIE, EIP + * + * All others have to move a byte to the SRF address + **/ + +__sfr __at 0x80 IOA; + /* IOA */ + __sbit __at 0x80 + 0 PA0; + __sbit __at 0x80 + 1 PA1; + __sbit __at 0x80 + 2 PA2; + __sbit __at 0x80 + 3 PA3; + __sbit __at 0x80 + 4 PA4; + __sbit __at 0x80 + 5 PA5; + __sbit __at 0x80 + 6 PA6; + __sbit __at 0x80 + 7 PA7; +__sfr __at 0x81 SP; +__sfr __at 0x82 DPL; +__sfr __at 0x83 DPH; +__sfr __at 0x84 DPL1; +__sfr __at 0x85 DPH1; +__sfr __at 0x86 DPS; +__sfr __at 0x87 PCON; +__sfr __at 0x88 TCON; + /* TCON */ + __sbit __at 0x88+0 IT0; + __sbit __at 0x88+1 IE0; + __sbit __at 0x88+2 IT1; + __sbit __at 0x88+3 IE1; + __sbit __at 0x88+4 TR0; + __sbit __at 0x88+5 TF0; + __sbit __at 0x88+6 TR1; + __sbit __at 0x88+7 TF1; +__sfr __at 0x89 TMOD; +__sfr __at 0x8A TL0; +__sfr __at 0x8B TL1; +__sfr __at 0x8C TH0; +__sfr __at 0x8D TH1; +__sfr __at 0x8E CKCON; +__sfr __at 0x90 IOB; + /* IOB */ + __sbit __at 0x90 + 0 PB0; + __sbit __at 0x90 + 1 PB1; + __sbit __at 0x90 + 2 PB2; + __sbit __at 0x90 + 3 PB3; + __sbit __at 0x90 + 4 PB4; + __sbit __at 0x90 + 5 PB5; + __sbit __at 0x90 + 6 PB6; + __sbit __at 0x90 + 7 PB7; +__sfr __at 0x91 EXIF; + +//__sfr __at 0x92 MPAGE; +__sfr __at 0x92 _XPAGE; // same as MPAGE for pdata __sfr access w/ sdcc +__sfr __at 0x98 SCON0; + /* SCON0 */ + __sbit __at 0x98+0 RI; + __sbit __at 0x98+1 TI; + __sbit __at 0x98+2 RB8; + __sbit __at 0x98+3 TB8; + __sbit __at 0x98+4 REN; + __sbit __at 0x98+5 SM2; + __sbit __at 0x98+6 SM1; + __sbit __at 0x98+7 SM0; +__sfr __at 0x99 SBUF0; + +__sfr __at 0x9A AUTOPTRH1; +__sfr __at 0x9B AUTOPTRL1; +__sfr __at 0x9D AUTOPTRH2; +__sfr __at 0x9E AUTOPTRL2; + +__sfr __at 0xA0 IOC; + /* IOC */ + __sbit __at 0xA0 + 0 PC0; + __sbit __at 0xA0 + 1 PC1; + __sbit __at 0xA0 + 2 PC2; + __sbit __at 0xA0 + 3 PC3; + __sbit __at 0xA0 + 4 PC4; + __sbit __at 0xA0 + 5 PC5; + __sbit __at 0xA0 + 6 PC6; + __sbit __at 0xA0 + 7 PC7; +__sfr __at 0xA1 INT2CLR; +__sfr __at 0xA2 INT4CLR; + +__sfr __at 0xA8 IE; + /* IE */ + __sbit __at 0xA8+0 EX0; + __sbit __at 0xA8+1 ET0; + __sbit __at 0xA8+2 EX1; + __sbit __at 0xA8+3 ET1; + __sbit __at 0xA8+4 ES0; + __sbit __at 0xA8+5 ET2; + __sbit __at 0xA8+6 ES1; + __sbit __at 0xA8+7 EA; + +__sfr __at 0xAA EP2468STAT; +__sfr __at 0xAB EP24FIFOFLGS; +__sfr __at 0xAC EP68FIFOFLGS; +__sfr __at 0xAF AUTOPTRSETUP; +__sfr __at 0xB0 IOD; + /* IOD */ + __sbit __at 0xB0 + 0 PD0; + __sbit __at 0xB0 + 1 PD1; + __sbit __at 0xB0 + 2 PD2; + __sbit __at 0xB0 + 3 PD3; + __sbit __at 0xB0 + 4 PD4; + __sbit __at 0xB0 + 5 PD5; + __sbit __at 0xB0 + 6 PD6; + __sbit __at 0xB0 + 7 PD7; +__sfr __at 0xB1 IOE; +__sfr __at 0xB2 OEA; +__sfr __at 0xB3 OEB; +__sfr __at 0xB4 OEC; +__sfr __at 0xB5 OED; +__sfr __at 0xB6 OEE; + +__sfr __at 0xB8 IP; + /* IP */ + __sbit __at 0xB8+0 PX0; + __sbit __at 0xB8+1 PT0; + __sbit __at 0xB8+2 PX1; + __sbit __at 0xB8+3 PT1; + __sbit __at 0xB8+4 PS0; + __sbit __at 0xB8+5 PT2; + __sbit __at 0xB8+6 PS1; + +__sfr __at 0xBA EP01STAT; +__sfr __at 0xBB GPIFTRIG; + +__sfr __at 0xBD GPIFSGLDATH; +__sfr __at 0xBE GPIFSGLDATLX; +__sfr __at 0xBF GPIFSGLDATLNOX; + +__sfr __at 0xC0 SCON1; + /* SCON1 */ + __sbit __at 0xC0+0 RI1; + __sbit __at 0xC0+1 TI1; + __sbit __at 0xC0+2 RB81; + __sbit __at 0xC0+3 TB81; + __sbit __at 0xC0+4 REN1; + __sbit __at 0xC0+5 SM21; + __sbit __at 0xC0+6 SM11; + __sbit __at 0xC0+7 SM01; +__sfr __at 0xC1 SBUF1; +__sfr __at 0xC8 T2CON; + /* T2CON */ + __sbit __at 0xC8+0 CP_RL2; + __sbit __at 0xC8+1 C_T2; + __sbit __at 0xC8+2 TR2; + __sbit __at 0xC8+3 EXEN2; + __sbit __at 0xC8+4 TCLK; + __sbit __at 0xC8+5 RCLK; + __sbit __at 0xC8+6 EXF2; + __sbit __at 0xC8+7 TF2; +__sfr __at 0xCA RCAP2L; +__sfr __at 0xCB RCAP2H; +__sfr __at 0xCC TL2; +__sfr __at 0xCD TH2; +__sfr __at 0xD0 PSW; + /* PSW */ + __sbit __at 0xD0+0 P; + __sbit __at 0xD0+1 FL; + __sbit __at 0xD0+2 OV; + __sbit __at 0xD0+3 RS0; + __sbit __at 0xD0+4 RS1; + __sbit __at 0xD0+5 F0; + __sbit __at 0xD0+6 AC; + __sbit __at 0xD0+7 CY; +__sfr __at 0xD8 EICON; // Was WDCON in DS80C320; Bit Values differ from Reg320 + /* EICON */ + __sbit __at 0xD8+3 INT6; + __sbit __at 0xD8+4 RESI; + __sbit __at 0xD8+5 ERESI; + __sbit __at 0xD8+7 SMOD1; +__sfr __at 0xE0 ACC; +__sfr __at 0xE8 EIE; // EIE Bit Values differ from Reg320 + /* EIE */ + __sbit __at 0xE8+0 EUSB; + __sbit __at 0xE8+1 EI2C; + __sbit __at 0xE8+2 EIEX4; + __sbit __at 0xE8+3 EIEX5; + __sbit __at 0xE8+4 EIEX6; +__sfr __at 0xF0 B; +__sfr __at 0xF8 EIP; // EIP Bit Values differ from Reg320 + /* EIP */ + __sbit __at 0xF8+0 PUSB; + __sbit __at 0xF8+1 PI2C; + __sbit __at 0xF8+2 EIPX4; + __sbit __at 0xF8+3 EIPX5; + __sbit __at 0xF8+4 EIPX6; + + +/* CPU Control & Status Register (CPUCS) */ +#define bmPRTCSTB bmBIT5 +#define bmCLKSPD (bmBIT4 | bmBIT3) +#define bmCLKSPD1 bmBIT4 +#define bmCLKSPD0 bmBIT3 +#define bmCLKINV bmBIT2 +#define bmCLKOE bmBIT1 +#define bm8051RES bmBIT0 +/* Port Alternate Configuration Registers */ +/* Port A (PORTACFG) */ +#define bmFLAGD bmBIT7 +#define bmSLCS bmBIT6 +#define bmINT1 bmBIT1 +#define bmINT0 bmBIT0 +/* Port C (PORTCCFG) */ +#define bmGPIFA7 bmBIT7 +#define bmGPIFA6 bmBIT6 +#define bmGPIFA5 bmBIT5 +#define bmGPIFA4 bmBIT4 +#define bmGPIFA3 bmBIT3 +#define bmGPIFA2 bmBIT2 +#define bmGPIFA1 bmBIT1 +#define bmGPIFA0 bmBIT0 +/* Port E (PORTECFG) */ +#define bmGPIFA8 bmBIT7 +#define bmT2EX bmBIT6 +#define bmINT6 bmBIT5 +#define bmRXD1OUT bmBIT4 +#define bmRXD0OUT bmBIT3 +#define bmT2OUT bmBIT2 +#define bmT1OUT bmBIT1 +#define bmT0OUT bmBIT0 + +/* I2C Control & Status Register (I2CS) */ +#define bmSTART bmBIT7 +#define bmSTOP bmBIT6 +#define bmLASTRD bmBIT5 +#define bmID (bmBIT4 | bmBIT3) +#define bmBERR bmBIT2 +#define bmACK bmBIT1 +#define bmDONE bmBIT0 +/* I2C Control Register (I2CTL) */ +#define bmSTOPIE bmBIT1 +#define bm400KHZ bmBIT0 +/* Interrupt 2 (USB) Autovector Register (INT2IVEC) */ +#define bmIV4 bmBIT6 +#define bmIV3 bmBIT5 +#define bmIV2 bmBIT4 +#define bmIV1 bmBIT3 +#define bmIV0 bmBIT2 +/* USB Interrupt Request & Enable Registers (USBIE/USBIRQ) */ +#define bmEP0ACK bmBIT6 +#define bmHSGRANT bmBIT5 +#define bmURES bmBIT4 +#define bmSUSP bmBIT3 +#define bmSUTOK bmBIT2 +#define bmSOF bmBIT1 +#define bmSUDAV bmBIT0 +/* USBERRIE/IRQ */ +#define bmERRLIMIT bmBIT0 +#define bmISOEP2 bmBIT4 +#define bmISOEP4 bmBIT5 +#define bmISOEP6 bmBIT6 +#define bmISOEP8 bmBIT7 + +/* Endpoint Interrupt & Enable Registers (EPIE/EPIRQ) */ +#define bmEP0IN bmBIT0 +#define bmEP0OUT bmBIT1 +#define bmEP1IN bmBIT2 +#define bmEP1OUT bmBIT3 +#define bmEP2 bmBIT4 +#define bmEP4 bmBIT5 +#define bmEP6 bmBIT6 +#define bmEP8 bmBIT7 +/* Breakpoint register (BREAKPT) */ +#define bmBREAK bmBIT3 +#define bmBPPULSE bmBIT2 +#define bmBPEN bmBIT1 +/* Interrupt 2 & 4 Setup (INTSETUP) */ +#define bmAV2EN bmBIT3 +#define INT4IN bmBIT1 +#define bmAV4EN bmBIT0 +/* USB Control & Status Register (USBCS) */ +#define bmHSM bmBIT7 +#define bmDISCON bmBIT3 +#define bmNOSYNSOF bmBIT2 +#define bmRENUM bmBIT1 +#define bmSIGRESUME bmBIT0 +/* Wakeup Control and Status Register (WAKEUPCS) */ +#define bmWU2 bmBIT7 +#define bmWU bmBIT6 +#define bmWU2POL bmBIT5 +#define bmWUPOL bmBIT4 +#define bmDPEN bmBIT2 +#define bmWU2EN bmBIT1 +#define bmWUEN bmBIT0 +/* End Point 0 Control & Status Register (EP0CS) */ +#define bmHSNAK bmBIT7 +/* End Point 0-1 Control & Status Registers (EP0CS/EP1OUTCS/EP1INCS) */ +#define bmEPBUSY bmBIT1 +#define bmEPSTALL bmBIT0 +/* End Point 2-8 Control & Status Registers (EP2CS/EP4CS/EP6CS/EP8CS) */ +#define bmNPAK (bmBIT6 | bmBIT5 | bmBIT4) +#define bmEPFULL bmBIT3 +#define bmEPEMPTY bmBIT2 +/* Endpoint Status (EP2468STAT) SFR bits */ +#define bmEP8FULL bmBIT7 +#define bmEP8EMPTY bmBIT6 +#define bmEP6FULL bmBIT5 +#define bmEP6EMPTY bmBIT4 +#define bmEP4FULL bmBIT3 +#define bmEP4EMPTY bmBIT2 +#define bmEP2FULL bmBIT1 +#define bmEP2EMPTY bmBIT0 +/* Endpoint Config (EP[2468]CFG) */ +#define bmVALID bmBIT7 +#define bmDIR bmBIT6 +#define bmTYPE (bmBIT4|bmBIT5) +#define bmTYPE1 bmBIT5 +#define bmTYPE0 bmBIT4 +#define bmSIZE bmBIT3 +/* Endpoint Config (EP[24]CFG) */ +#define bmBUF (bmBIT0|bmBIT1) +#define bmBUF1 bmBIT1 +#define bmBUF0 bmBIT0 +/* SETUP Data Pointer Auto Mode (SUDPTRCTL) */ +#define bmSDPAUTO bmBIT0 +/* Endpoint Data Toggle Control (TOGCTL) */ +#define bmQUERYTOGGLE bmBIT7 +#define bmSETTOGGLE bmBIT6 +#define bmRESETTOGGLE bmBIT5 +#define bmTOGCTLEPMASK bmBIT3 | bmBIT2 | bmBIT1 | bmBIT0 +/* IBN (In Bulk Nak) enable and request bits (IBNIE/IBNIRQ) */ +#define bmEP8IBN bmBIT5 +#define bmEP6IBN bmBIT4 +#define bmEP4IBN bmBIT3 +#define bmEP2IBN bmBIT2 +#define bmEP1IBN bmBIT1 +#define bmEP0IBN bmBIT0 + +/* PING-NAK enable and request bits (NAKIE/NAKIRQ) */ +#define bmEP8PING bmBIT7 +#define bmEP6PING bmBIT6 +#define bmEP4PING bmBIT5 +#define bmEP2PING bmBIT4 +#define bmEP1PING bmBIT3 +#define bmEP0PING bmBIT2 +#define bmIBN bmBIT0 + +/* Interface Configuration bits (IFCONFIG) */ +#define bmIFCLKSRC bmBIT7 +#define bm3048MHZ bmBIT6 +#define bmIFCLKOE bmBIT5 +#define bmIFCLKPOL bmBIT4 +#define bmASYNC bmBIT3 +#define bmGSTATE bmBIT2 +#define bmIFCFG1 bmBIT1 +#define bmIFCFG0 bmBIT0 +#define bmIFCFGMASK (bmIFCFG0 | bmIFCFG1) +#define bmIFGPIF bmIFCFG1 + +/* EP 2468 FIFO Configuration bits (EP2FIFOCFG,EP4FIFOCFG,EP6FIFOCFG,EP8FIFOCFG) */ +#define bmINFM bmBIT6 +#define bmOEP bmBIT5 +#define bmAUTOOUT bmBIT4 +#define bmAUTOIN bmBIT3 +#define bmZEROLENIN bmBIT2 +#define bmWORDWIDE bmBIT0 + +/* Chip Revision Control Bits (REVCTL) - used to ebable/disable revision specidic + features */ +#define bmNOAUTOARM bmBIT1 +#define bmSKIPCOMMIT bmBIT0 + +/* Fifo Reset bits (FIFORESET) */ +#define bmNAKALL bmBIT7 + +/* Chip Feature Register (GPCR2) */ +#define bmFULLSPEEDONLY bmBIT4 + +/* EP 01 status (EP01STAT) */ +#define bmEP1INBSY bmBIT2 +#define bmEP1OUTBSY bmBIT1 +#define bmEP0BSY bmBIT0 + +#endif /* FX2REGS_H */ diff --git a/Firmware/fx2lib/include/fx2types.h b/Firmware/fx2lib/include/fx2types.h new file mode 100644 index 0000000..7401aa5 --- /dev/null +++ b/Firmware/fx2lib/include/fx2types.h @@ -0,0 +1,50 @@ +// Copyright (C) 2009 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +/*! \file + * define standard types of fixed widths. + * */ + +#ifndef FXTYPES_H +#define FXTYPES_H + +typedef unsigned int WORD; +typedef unsigned char BYTE; +typedef unsigned long DWORD; +typedef unsigned char BOOL; +typedef enum { + FALSE=0, + TRUE +} BOOL_VALS; + +#ifndef NULL +#define NULL (void*)0 +#endif + +/*----------------------------------------------------------------------------- + Bit Masks +-----------------------------------------------------------------------------*/ + +#define bmBIT0 1 +#define bmBIT1 2 +#define bmBIT2 4 +#define bmBIT3 8 +#define bmBIT4 16 +#define bmBIT5 32 +#define bmBIT6 64 +#define bmBIT7 128 + +#endif diff --git a/Firmware/fx2lib/include/gpif.h b/Firmware/fx2lib/include/gpif.h new file mode 100644 index 0000000..5afaf26 --- /dev/null +++ b/Firmware/fx2lib/include/gpif.h @@ -0,0 +1,110 @@ +// Copyright (C) 2009 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +/*! \file + * + * These functions do the same thing that the Cypress gpif designer expored c file does. + * Instead of including their file directly in your project, you include just the + * generated waveform data. The gpif2dat script in the utils folder will export your + * waveform data to a file that can be included in your project. + * */ + +#ifndef GPIF_H +#define GPIF_H + +#include "fx2types.h" + +#define GPIFDONE (GPIFTRIG&0x80) +#define GPIFTC16 (MAKEWORD(GPIFTCB1,GPIFTCB0)) +#define GPIFTC32 (MAKEDWORD(MAKEWORD(GPIFTCB3,GPIFTCB2),MAKEWORD(GPIFTCB1,GPIFTCB0))) + + +/** + * Gpif designer generates a c file with waveform data. + * Copy the WaveData[128] array + * and the InitData[7] to your code somewhere + * Then this function is pretty much the reset of the generated + * code but ported to sdcc. + * + * uses syncdelay of 4 which might not be long enough if peripheral + * runs slower than 30mhz. May not affect anything. + * + * IFCONFIG is set with IFCFG[1:0] = 10 for GPIF master but you still + * have to set the ifclk, polarity, and the rest of the bits + **/ + +void gpif_init( BYTE* waveform, BYTE* initdata ); + +/** + * Uses the correct bytes from your flowstates array. + * This may or may not be needed depending on whether + * your waveform data uses flowstates. If you don't + * know if you need them or not, you probably don't. + * + * flowstates should have 36 elements. + * bank should be 0-3 + **/ +void gpif_setflowstate( BYTE* flowstates, BYTE bank); + + + +//! These defines/functions pretty much out of the TRM 10.4 +#define GPIFTRGWR 0 +#define GPIFTRGRD 4 +typedef enum { + GPIF_EP2 = 0, + GPIF_EP4 = 1, + GPIF_EP6 = 2, + GPIF_EP8 = 3 +} GPIF_EP_NUM; + +/** + * \brief Simple function to help set the transaction count for gpif + * transactions. + * \param tc 32 bit Transaction Count + **/ +void gpif_set_tc32(DWORD tc); +/** + * \brief Simple function to set transaction count for gpif transactions. + * \param tc 16 bit Transaction Count + **/ +void gpif_set_tc16(WORD tc); + + +/** + * Use the gpif to read a single word at a time. + * Read len words and store in res + * + * At least one EPxFIFOCFG has to have wordwide=1 or this + * functions won't transfer both bytes. + **/ + +void gpif_single_read16( WORD* res , WORD len); + +/** + * Use the gpif to write a single word at a time. + * Write len words from data + * + * At leat one EPxFIFOCFG has to have wordwide=1 or this + * function won't transfer both bytes. + **/ +void gpif_single_write16( WORD* dat, WORD len); + +void gpif_fifo_read ( GPIF_EP_NUM ep_num ); + +void gpif_fifo_write( GPIF_EP_NUM ep_num ); + +#endif diff --git a/Firmware/fx2lib/include/i2c.h b/Firmware/fx2lib/include/i2c.h new file mode 100644 index 0000000..3d7d5f3 --- /dev/null +++ b/Firmware/fx2lib/include/i2c.h @@ -0,0 +1,97 @@ +// Copyright (C) 2009 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +/** \file i2c.h + * Utilities for reading and writing to i2c devices and as eeproms. + **/ + +#ifndef I2C_H +#define I2C_H + +#include "fx2types.h" + +/** + * i2c_write and i2c_read set this to FALSE at the beginning of a + * transaction. If for some reason, the read/write is taking too + * long or not returning, firmware can set this to TRUE to cause the + * routine to abort. (Usually done via an interrupt). + **/ +extern volatile __xdata BOOL cancel_i2c_trans; + +/** + * \brief write data to i2c bus. + * + * Writes data from addr buffer 1st, then data buffer. + * Either buffer can be NULL (as long as you set lenN to 0). + * + * Two buffers allows writing data all in one i2c write command without + * having to write a hardware address and a data byte with each + * i2c transaction. + * + * \param addr i2c address + * \param len1 length of addr data + * \param addr_buf addr data + * \param len2 length of data + * \param data_buf data bytes + **/ +BOOL i2c_write ( BYTE addr, WORD len1, BYTE* addr_buf, WORD len2, BYTE* data_buf ); + +/** + * \brief read data on the i2c bus. + * + * \param addr i2c address + * \param len number of bytes to read + * \param buf buffer to store data + **/ +BOOL i2c_read ( BYTE addr, WORD len, BYTE* buf); + +/** + * \brief read data from an attached eeprom. + * + * Writes the address of the data to read then reads len bytes into buf. + * This function checks the I2CS register to determine if a one or two + * byte address eepom was detected on the i2c bus. Reading from proms + * at non-standard addresses my require using the i2c_read/write commands + * explicitly. + * + * \param prom_addr eeprom i2c address + * \param addr address of bytes to start reading + * \param len number of bytes to read + * \param buf data buffer + **/ +BOOL eeprom_read( BYTE prom_addr, WORD addr, WORD len, BYTE* buf); + +/** + * \brief write data to the eeprom + * + * This function checks the I2CS register to determin if a one or two + * two byte eeprom is detected. If the prom is not detected at boot time + * or is connected to alternate addresses, the i2c_read/write commands should + * be used explicitly insread of using this function. + * + * For each byte in buf, the address is written and then the data byte. Many + * proms support writing multiple bytes at the same time. For these, it is + * also better to use i2c_read/write explicitly. This function is rather slow + * but is effective. + * + * \param prom_addr eeprom i2c address + * \param addr address of bytes to start writing + * \param len number of bytes to write + * \param buf data buffer + **/ +BOOL eeprom_write( BYTE prom_addr, WORD addr, WORD len, BYTE* buf); + +#endif diff --git a/Firmware/fx2lib/include/lights.h b/Firmware/fx2lib/include/lights.h new file mode 100644 index 0000000..fe62beb --- /dev/null +++ b/Firmware/fx2lib/include/lights.h @@ -0,0 +1,96 @@ +// Copyright (C) 2009 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +/** \file lights.h + * macros for turning lights on the EZ-USB development board on and off. + **/ + +#ifndef LIGHTS_H +#define LIGHTS_H + +#include "fx2types.h" + +#ifndef FX1 +// FX2 Dev board lights +#define D2ONH #0x88 // assembly high byte of light addr +#define D2OFFH #0x80 +#define D3ONH #0x98 +#define D3OFFH #0x90 +#define D4ONH #0xA8 +#define D4OFFH #0xA0 +#define D5ONH #0xB8 +#define D5OFFH #0xB0 +volatile __xdata __at 0x8800 BYTE D2ON; +volatile __xdata __at 0x8000 BYTE D2OFF; +volatile __xdata __at 0x9800 BYTE D3ON; +volatile __xdata __at 0x9000 BYTE D3OFF; +volatile __xdata __at 0xA800 BYTE D4ON; +volatile __xdata __at 0xA000 BYTE D4OFF; +volatile __xdata __at 0xB800 BYTE D5ON; +volatile __xdata __at 0xB000 BYTE D5OFF; +#else +// FX1 dev board lights +#define D2ONH #0x80 // assembly high byte of light addr +#define D2OFFH #0x81 +#define D3ONH #0x90 +#define D3OFFH #0x91 +#define D4ONH #0xA0 +#define D4OFFH #0xA1 +#define D5ONH #0xB0 +#define D5OFFH #0xB1 +volatile __xdata __at 0x8000 BYTE D2ON; +volatile __xdata __at 0x8100 BYTE D2OFF; +volatile __xdata __at 0x9000 BYTE D3ON; +volatile __xdata __at 0x9100 BYTE D3OFF; +volatile __xdata __at 0xA000 BYTE D4ON; +volatile __xdata __at 0xA100 BYTE D4OFF; +volatile __xdata __at 0xB000 BYTE D5ON; +volatile __xdata __at 0xB100 BYTE D5OFF; +#endif + +/** + * Easier to use macros defined below +**/ +#define activate_light(LIGHT_ADDR) __asm \ + mov __XPAGE, LIGHT_ADDR \ + __endasm; __asm \ + movx a, @r0 \ +__endasm \ + +/** + * Easy to make lights blink with these macros: + * \code + * WORD ct=0; + * BOOL on=FALSE; + * while (TRUE) { + * if (!ct) { + * on=!on; + * if (on) d2on(); else d2off(); + * } + * ++ct; + * } + * \endcode + **/ +#define d2on() activate_light(D2ONH) +#define d2off() activate_light(D2OFFH) +#define d3on() activate_light(D3ONH) +#define d3off() activate_light(D3OFFH) +#define d4on() activate_light(D4ONH) +#define d4off() activate_light(D4OFFH) +#define d5on() activate_light(D5ONH) +#define d5off() activate_light(D5OFFH) + +#endif diff --git a/Firmware/fx2lib/include/serial.h b/Firmware/fx2lib/include/serial.h new file mode 100644 index 0000000..285ec48 --- /dev/null +++ b/Firmware/fx2lib/include/serial.h @@ -0,0 +1,55 @@ +// Copyright (C) 2009 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +/** \file serial.h + * defines functions to print to a serial console with SIO0 + **/ + +#include "fx2types.h" + + +/** + * This function inits sio0 to use T2CON (timer 2) + * See TRM 14.3.4.1 (Table 14-16) + * Certain baud rates have too high an error rate to work. All baud rates are .16% + * except: + * + * 12MHZ 24MHZ + * \li 57600 -6.99% + * \li 38400 -2.34% -2.34% + * \li 19200 -2.34% + * + * Possible Baud rates: + * \li 2400 + * \li 4800 + * \li 9600 + * \li 19200 + * \li 28800 + * \li 38400 + * \li 57600 + * + * Any of these rates should work except 57600 at 12mhz. -2.34% is pushing + * most hardware specs for working. All rates at 48mhz work at .16% + **/ + +void sio0_init( DWORD baud_rate ) __critical ; // baud_rate max should be 57600 since int=2 bytes + +/** + putchar('\\n') or putchar('\\r') both transmit \\r\\n + Just use one or the other. (This makes terminal echo easy) +**/ +int putchar(char c); +int getchar(); diff --git a/Firmware/fx2lib/include/setupdat.h b/Firmware/fx2lib/include/setupdat.h new file mode 100644 index 0000000..0027845 --- /dev/null +++ b/Firmware/fx2lib/include/setupdat.h @@ -0,0 +1,224 @@ +// Copyright (C) 2009 Ubixum, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +#ifndef SETUPDAT_H +#define SETUPDAT_H + +#include "fx2regs.h" +#include "delay.h" +/** \file setupdat.h + Utilities for handling setup data and vendor commands. + + \verbatim + + This module needs initialized with a device descriptor. + NOTE that your descriptors need to be located in code memory + to use the SUDPTRH:L to auto transfer the data + + and vendor commands handler. You have to provide callbacks. + +DEVICE DESCRIPTORS + + // copy the dscr_asm file from the lib dir to your + // own project directory, change it how + // you want, and link it against your project + +VENDOR COMMANDS + + 0xA0 is handled by ez-usb firmware. (Upload/Download ram) + 0xA1-0xAF is reserved for other ez-usb functions so don't use that + Any other value (Above 0x0C anyway) can be used for device specific + commands. + + If you include this file, you need to define a function for vendor + commands even if you don't want to implement any vendor commands. + The function should return TRUE if you handled the command and FALSE + if you didn't. The handle_setup function calls + EP0CS |= bmHSNAK; + before returning so there is no reason to set that bit in your + vendor command handler. (You do need to Set EP0 data and + byte counts appropriately though.) + + // return TRUE if you handle the command + // you can directly get SETUPDAT[0-7] for the data sent with the command + BOOL handle_vendorcommand(BYTE cmd) { return FALSE; } + // a note on vencor commands + // this from the usb spec for requesttype + D7 Data Phase Transfer Direction + 0 = Host to Device + 1 = Device to Host + D6..5 Type + 0 = Standard + 1 = Class + 2 = Vendor + 3 = Reserved + D4..0 Recipient + 0 = Device + 1 = Interface + 2 = Endpoint + 3 = Other + 4..31 = Reserved + // if you want libusb to send data back to the host via ep0, you need to make + // sure the requesttype had 1 in bit 7. This is for libusb on linux anyway. + + + // set *alt_ifc to the current alt interface for ifc + BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc) { *ifc=0;*alt_ifc=0;} + // return TRUE if you set the interface requested + // NOTE this function should reconfigure and reset the endpoints + // according to the interface descriptors you provided. + BOOL handle_set_interface(BYTE ifc,BYTE alt_ifc) { return TRUE; } + // handle getting and setting the configuration + // 0 is the default. If you support more than one config + // keep track of the config number and return the correct number + // config numbers are set int the dscr file. + BYTE handle_get_configuration() { return 1; } + // return TRUE if you handle this request + // NOTE changing config requires the device to reset all the endpoints + BOOL handle_set_configuration(BYTE cfg) { return FALSE; } + // ep num (byte 7 is dir 1=IN,0=OUT) + // client needs to reset the endpoint to default state + void handle_reset_ep(BYTE ep) { } + + \endverbatim +*/ + + +#define SETUP_VALUE() MAKEWORD(SETUPDAT[3],SETUPDAT[2]) +#define SETUP_INDEX() MAKEWORD(SETUPDAT[5],SETUPDAT[4]) +#define SETUP_LENGTH() MAKEWORD(SETUPDAT[7],SETUPDAT[6]) +#define SETUP_TYPE SETUPDAT[0] + +/** + * self_powered is set to FALSE by default. It is + * used for GET_FEATURE requests. Firmware can set it to + * TRUE if the device is not powered by the USB bus. + **/ +extern volatile BOOL self_powered; + +/** + * remote_wakeup_allowed defaults to FALSE but can be + * set to TRUE with SET_FEATURE from the host. (firmware shouldn't + * set this.) + **/ +extern volatile BOOL remote_wakeup_allowed; + +//! see TRM 2-3 +//! here are the usb setup data commands +//! these are the usb spec pretty much + +typedef enum { + GET_STATUS, + CLEAR_FEATURE, + // 0x02 is reserved + SET_FEATURE=0x03, + // 0x04 is reserved + SET_ADDRESS=0x05, // this is handled by EZ-USB core unless RENUM=0 + GET_DESCRIPTOR, + SET_DESCRIPTOR, + GET_CONFIGURATION, + SET_CONFIGURATION, + GET_INTERFACE, + SET_INTERFACE, + SYNC_FRAME +} SETUP_DATA; + + +/** + * returns the control/status register for an end point + * (bit 7=1 for IN, 0 for out + **/ +__xdata BYTE* ep_addr(BYTE ep); + +/* + You can call this function directly if you are polling + for setup data in your main loop. + You can also use the usbjt and enable the sudav isr + and call the function from withing the sudav isr routine +*/ +void handle_setupdata(); + + +/** + For devices to properly handle usb hispeed + (This is if your descriptor has high speed and full speed versions + and it should since the fx2lp is a high speed capable device + ) + enable both USBRESET and HISPEED interrupts and + call this function to switch the descriptors. This function uses + a __critical section to switch the descriptors and is safe to call + from the hispeed or reset interrupt. See \ref fw.c + + \param highspeed Call the function with highspeed = TRUE if + calling because the highspeed interrupt was received. + If calling from usbreset, call with highspeed=false +**/ +void handle_hispeed( BOOL highspeed ); + + +/* descriptor types */ +#define DSCR_DEVICE_TYPE 1 +#define DSCR_CONFIG_TYPE 2 +#define DSCR_STRING_TYPE 3 +#define DSCR_DEVQUAL_TYPE 6 +#define DSCR_OTHERSPD_TYPE 7 +#define DSCR_DEBUG_TYPE 10 + +/* usb spec 2 */ +#define DSCR_BCD 2 + + +/* device descriptor */ +#define DSCR_DEVICE_LEN 18 + +typedef struct { + BYTE dsc_len; // descriptor length (18 for this ) + BYTE dsc_type; // dscr type + WORD bcd; // bcd + BYTE dev_class; // device class + BYTE dev_subclass; // sub class + BYTE dev_protocol; // sub sub class + BYTE max_pkt; // max packet size + WORD vendor_id; + WORD product_id; + WORD dev_version; // product version id + BYTE idx_manstr; // manufacturer string index + BYTE idx_devstr; // product string index + BYTE idx_serstr; // serial number index + BYTE num_configs; // number of configurations + +} DEVICE_DSCR; + + +/* config descriptor */ +#define DSCR_CONFIG_LEN 9 +typedef struct { + BYTE dsc_len; // 9 for this one + BYTE dsc_type; // dscr type + +} CONFIG_DSCR; + +/* string descriptor */ +typedef struct { + BYTE dsc_len; + BYTE dsc_type; + BYTE pstr; +} STRING_DSCR; + + + + +#endif diff --git a/Firmware/fx2lib/utils/gpif2dat b/Firmware/fx2lib/utils/gpif2dat new file mode 100755 index 0000000..7762f94 --- /dev/null +++ b/Firmware/fx2lib/utils/gpif2dat @@ -0,0 +1,20 @@ +#!/bin/env python + +import sys,re + +if __name__=='__main__': + if len(sys.argv)<3: + print "Usage: %s " % sys.argv[0] + sys.exit(-1) + + f=open(sys.argv[1],'r').read() + o=open(sys.argv[2],'w') + + # write every thing between the wave data and the TODO + datre = re.compile ( 'const char xdata .*?\};', re.S ) + data = datre.findall(f) + for dat in data: + o.write(dat.replace('\r\n','\n')) + o.write('\n') + o.close() + diff --git a/Firmware/fx2lib/utils/ihx2iic.py b/Firmware/fx2lib/utils/ihx2iic.py new file mode 100755 index 0000000..3dfc531 --- /dev/null +++ b/Firmware/fx2lib/utils/ihx2iic.py @@ -0,0 +1,186 @@ +#!/usr/bin/env python3 +# +# Copyright 2009, Ubixum, Inc +# +# This file copied and modified for fx2lib from the GnuRadio project +# +# Copyright 2004,2006 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +import re +import sys, struct +import os, os.path +from optparse import OptionParser +from functools import reduce + + +def hex_to_bytes (s): + if len (s) & 0x1: + raise ValueError("Length must be even") + r = [] + for i in range (0, len(s), 2): + r.append (int (s[i:i+2], 16)) + return r + +def msb (x): + return (x >> 8) & 0xff + +def lsb (x): + return x & 0xff + +class ihx_rec (object): + def __init__ (self, addr, type, data): + self.addr = addr + self.type = type + self.data = data + +class ihx_file (object): + def __init__ (self): + self.pat = re.compile (r':[0-9A-F]{10,}') + def read (self, file): + r = [] + for line in file: + line = line.strip().upper () + if not self.pat.match (line): + raise ValueError("Invalid hex record format") + bytes = hex_to_bytes (line[1:]) + sum = reduce (lambda x, y: x + y, bytes, 0) % 256 + if sum != 0: + raise ValueError("Bad hex checksum") + lenx = bytes[0] + addr = (bytes[1] << 8) + bytes[2] + type = bytes[3] + data = bytes[4:-1] + if lenx != len (data): + raise ValueError("Invalid hex record (bad length)") + if type != 0: + break; + r.append (ihx_rec (addr, type, data)) + + return r + + +def build_eeprom_image (filename, outfile,vid,pid,devid,cb): + """Build a ``C2 Load'' EEPROM image. + + For details on this format, see section 3.4.3 of + the EZ-USB FX2 Technical Reference Manual + """ + + image = [ + 0xC2, # boot from EEPROM + lsb (vid), + msb (vid), + lsb (pid), + msb (pid), + lsb (devid), + msb (devid), + cb # configuration byte + ] + + # you could just append all the records.. + # but that would most likely cause a lot of + # extra headers/addrs to be written + ihx = ihx_file(); + records = ihx.read(open(filename)) + + # create image map of all values we're writing data too + image_map={} + for r in records: + addr=r.addr + c=0 + l=len(r.data) + while c> 8) & 0xff + +def lsb (x): + return x & 0xff + +class ihx_rec (object): + def __init__ (self, addr, type, data): + self.addr = addr + self.type = type + self.data = data + +class ihx_file (object): + def __init__ (self): + self.pat = re.compile (r':[0-9A-F]{10,}') + def read (self, file): + r = [] + for line in file: + line = line.strip().upper () + if not self.pat.match (line): + raise ValueError, "Invalid hex record format" + bytes = hex_to_bytes (line[1:]) + sum = reduce (lambda x, y: x + y, bytes, 0) % 256 + if sum != 0: + raise ValueError, "Bad hex checksum" + lenx = bytes[0] + addr = (bytes[1] << 8) + bytes[2] + type = bytes[3] + data = bytes[4:-1] + if lenx != len (data): + raise ValueError, "Invalid hex record (bad length)" + if type != 0: + break; + r.append (ihx_rec (addr, type, data)) + + return r + + +def build_eeprom_image (filename, outfile,vid,pid,devid,cb): + """Build a ``C2 Load'' EEPROM image. + + For details on this format, see section 3.4.3 of + the EZ-USB FX2 Technical Reference Manual + """ + + image = [ + 0xC2, # boot from EEPROM + lsb (vid), + msb (vid), + lsb (pid), + msb (pid), + lsb (devid), + msb (devid), + cb # configuration byte + ] + + # you could just append all the records.. + # but that would most likely cause a lot of + # extra headers/addrs to be written + ihx = ihx_file(); + records = ihx.read(open(filename)) + + # create image map of all values we're writing data too + image_map={} + for r in records: + addr=r.addr + c=0 + l=len(r.data) + while cMANIFEST.in) # the python scripts that can be found via the PATH scripts=[ os.path.join( 'examples', 'calibrate_6022.py' ),