diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f20f6e1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "PyHT6022/HantekFirmware/fx2lib"] + path = PyHT6022/HantekFirmware/fx2lib + url = https://github.com/djmuhlestein/fx2lib diff --git a/PyHT6022/HantekFirmware/__init__.py b/PyHT6022/HantekFirmware/__init__.py index 4a54f45..dcca6b6 100644 --- a/PyHT6022/HantekFirmware/__init__.py +++ b/PyHT6022/HantekFirmware/__init__.py @@ -11,6 +11,9 @@ def fx2_ihex_to_control_packets(firmware_location): packets = [] + # disable 8051 + packets.append(FirmwareControlPacket(1, 0x7f92, '\x01')) + packets.append(FirmwareControlPacket(1, 0xe600, '\x01')) with open(firmware_location, 'r') as f: for line in f.readlines(): line = line.strip() @@ -28,9 +31,13 @@ def fx2_ihex_to_control_packets(firmware_location): packets.append(FirmwareControlPacket(record_len, addr, array.array('B', record_data).tostring())) elif record_type == 0x01: assert file_checksum == 0xFF - return packets + break; else: raise ValueError('Unknown record type 0x{:2x} encountered!'.format(record_type)) + # enable 8051 + packets.append(FirmwareControlPacket(1, 0x7f92, '\x00')) + packets.append(FirmwareControlPacket(1, 0xe600, '\x00')) + return packets base_path = os.path.dirname(os.path.realpath(__file__)) stock_firmware = fx2_ihex_to_control_packets(os.path.join(base_path, 'stock', 'stock_fw.ihex')) diff --git a/PyHT6022/HantekFirmware/custom/Makefile b/PyHT6022/HantekFirmware/custom/Makefile new file mode 100644 index 0000000..6cda412 --- /dev/null +++ b/PyHT6022/HantekFirmware/custom/Makefile @@ -0,0 +1,33 @@ +# 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 +FX2LIBDIR=../fx2lib +SOURCES=fw.c device.c +A51_SOURCES=dscr.a51 +BASENAME=firmware + + +DSCR_AREA=-Wl"-b DSCR_AREA=0x3d00" +INT2JT=-Wl"-b INT2JT=0x3f00" +CODE_SIZE=--code-size 0x3c00 +XRAM_LOC=--xram-loc 0x3c00 +XRAM_SIZE=--xram-size 0x0100 + +include $(FX2LIBDIR)/lib/fx2.mk + diff --git a/PyHT6022/HantekFirmware/custom/device.c b/PyHT6022/HantekFirmware/custom/device.c new file mode 100644 index 0000000..79f5185 --- /dev/null +++ b/PyHT6022/HantekFirmware/custom/device.c @@ -0,0 +1,213 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * Copyright (C) 2015 Jochen Hoenicke + * + * 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 set_voltage(BYTE channel, BYTE val) +{ + const BYTE val2bits[] = { 1, 0x24*4, 0x24*2, 1, 1, 0x24*0, + 1, 1, 1, 1, 0x24*6 }; + BYTE bits = val < 11 ? val2bits[val] : -1; + if (bits != 1) { + int mask = channel ? 0xe0 : 0x1c; + IOC = (IOC & ~mask) | (bits & mask); + return TRUE; + } + return FALSE; +} + +BOOL set_numchannels(BYTE numchannels) +{ + if (numchannels >=1 && numchannels <= 2) { + BYTE fifocfg = 7 + numchannels; + EP2FIFOCFG = fifocfg; + EP6FIFOCFG = fifocfg; + return TRUE; + } + return FALSE; +} + +struct samplerate_info { + BYTE rate; + BYTE wait0; + BYTE wait1; + BYTE jump; + BYTE jopcode; + BYTE ifcfg; +} samplerates[] = { + { 48, 1, 1, 9, 3, 0xea }, + { 30, 1, 1, 9, 3, 0xaa }, + { 24, 1, 1, 9, 1, 0xca }, + { 16, 1, 1, 1, 1, 0xca }, + { 12, 1, 2, 1, 1, 0xca }, + { 8, 2, 3, 1, 1, 0xca }, + { 4, 5, 6, 1, 1, 0xca }, + { 2, 11, 12, 1, 1, 0xca }, + { 1, 23, 24, 1, 1, 0xca }, + { 50, 47, 48, 1, 1, 0xca }, + { 20, 119, 120, 1, 1, 0xca }, + { 10, 239, 240, 1, 1, 0xca } +}; + +BOOL set_samplerate(BYTE rate) +{ + int i; + for (i = 0; i < sizeof(samplerates)/sizeof(samplerates[0]); i++) { + if (samplerates[i].rate == rate) { + BYTE* data; + IFCONFIG = samplerates[i].ifcfg; + GPIFABORT = 0xff; + GPIFREADYCFG = 0xc0; + GPIFCTLCFG = 0x00; + GPIFIDLECS = 0x00; + GPIFIDLECTL = 0x0f; + GPIFWFSELECT = 0x00; + GPIFREADYSTAT = 0x00; + + data = &GPIF_WAVE_DATA + 0; + *data++ = samplerates[i].wait0; + *data++ = samplerates[i].wait1; + *data++ = samplerates[i].jump; + data += 5; + *data++ = 1; + *data++ = 2; + *data++ = samplerates[i].jopcode; + data += 5; + *data++ = 0xff; + *data++ = samplerates[i].jopcode == 3 ? 0xff : 0xfb; + *data++ = 0xff; + data += 5; + *data++ = 0x0; + *data++ = 0x0; + *data++ = 0x12; + return TRUE; + } + } + return FALSE; +} + +BOOL handle_get_descriptor() { + return FALSE; +} + +//************************** Configuration Handlers ***************************** + +// change to support as many interfaces as you need +volatile 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" ); + if (ifc == 0) { + alt = alt_ifc; + // select_interface(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 config; +} + +// 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 ************************** + +extern volatile __bit active; + +BOOL handle_vendorcommand(BYTE cmd) { + active = 1; + switch (cmd) { + case 0xa0: + // handled by EZ-USB + return TRUE; + + case 0xe0: + case 0xe1: + while (EP0CS & bmEPBUSY); + set_voltage(cmd - 0xe0, EP0BUF[0]); + EP0BCH=0; + EP0BCL=0; + return TRUE; + case 0xe2: + while (EP0CS & bmEPBUSY); + set_samplerate(EP0BUF[0]); + EP0BCH=0; + EP0BCL=0; + return TRUE; + case 0xe4: + while (EP0CS & bmEPBUSY); + set_numchannels(EP0BUF[0]); + EP0BCH=0; + EP0BCL=0; + return TRUE; + } + return FALSE; // not handled by handlers +} + +//******************** INIT *********************** + +void main_init() { + + REVCTL=3; + SETIF48MHZ(); + + EP4CFG = 0; + EP8CFG = 0; + + set_voltage(0, 1); + set_voltage(1, 1); + set_samplerate(1); + set_numchannels(1); + + printf ( "Initialization Done.\n" ); +} + + +void main_loop() { +} + + diff --git a/PyHT6022/HantekFirmware/custom/dscr.a51 b/PyHT6022/HantekFirmware/custom/dscr.a51 new file mode 100644 index 0000000..dff69f3 --- /dev/null +++ b/PyHT6022/HantekFirmware/custom/dscr.a51 @@ -0,0 +1,358 @@ +; 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 0xB504 ; vendor id + .dw 0x2260 ; product id + .dw 0x0000 ; 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 0 + .db 0 + .db 0 + .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 55 ; max power = 110mA +highspd_dscr_end: + +; all the interfaces next +; BULK interface + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 0 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 0 + .db 0 ; string index + +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x86 ; 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 + +; ISOCHRONOUS interface + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 1 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 1 + .db 0 ; string index + +; endpoint 2 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x82 ; ep1 dir=in and address + .db ENDPOINT_TYPE_ISO ; type + .db 0x00 ; max packet LSB + .db 0x14 ; max packet size=3*1024 bytes + .db 0x01 ; polling interval + +; ISOCHRONOUS interface 16MB/s + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 2 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 1 + .db 0 ; string index + +; endpoint 2 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x82 ; ep1 dir=in and address + .db ENDPOINT_TYPE_ISO ; type + .db 0x00 ; max packet LSB + .db 0x0c ; max packet size=2*1024 bytes + .db 0x01 ; polling interval + +; ISOCHRONOUS interface 8MB/s + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 3 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 1 + .db 0 ; string index + +; endpoint 2 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x82 ; ep1 dir=in and address + .db ENDPOINT_TYPE_ISO ; type + .db 0x00 ; max packet LSB + .db 0x04 ; max packet size=1024 bytes + .db 0x01 ; polling interval + +; ISOCHRONOUS interface 4MB/s + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 4 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 1 + .db 0 ; string index + +; endpoint 2 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x82 ; ep1 dir=in and address + .db ENDPOINT_TYPE_ISO ; type + .db 0x00 ; max packet LSB + .db 0x04 ; max packet size=1024 bytes + .db 0x02 ; polling interval + + +; ISOCHRONOUS interface 2MB/s + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 5 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 1 + .db 0 ; string index + +; endpoint 2 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x82 ; ep1 dir=in and address + .db ENDPOINT_TYPE_ISO ; type + .db 0x00 ; max packet LSB + .db 0x04 ; max packet size=1024 bytes + .db 0x03 ; polling interval + +; ISOCHRONOUS interface 1MB/s + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 6 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 1 + .db 0 ; string index + +; endpoint 2 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x82 ; ep1 dir=in and address + .db ENDPOINT_TYPE_ISO ; type + .db 0x00 ; max packet LSB + .db 0x04 ; max packet size=1024 bytes + .db 0x04 ; polling interval + +; ISOCHRONOUS interface 500 kB/s + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 7 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 1 + .db 0 ; string index + +; endpoint 2 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x82 ; ep1 dir=in and address + .db ENDPOINT_TYPE_ISO ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x04 ; 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 55 ; max power = 110mA +fullspd_dscr_end: + + +; all the interfaces next +; BULK interface + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 0 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 0 + .db 0 ; string index + +; endpoint 6 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x86 ; ep1 dir=in and address + .db ENDPOINT_TYPE_BULK ; type + .db 0x40 ; max packet LSB + .db 0x00 ; max packet size=512 bytes + .db 0x00 ; polling interval + +; ISOCHRONOUS interface 1 MB/s + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 1 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 1 + .db 0 ; string index + +; endpoint 2 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x82 ; ep1 dir=in and address + .db ENDPOINT_TYPE_ISO ; type + .db 0xff ; max packet LSB + .db 0x03 ; max packet size=1023 bytes + .db 0x01 ; polling interval + +; ISOCHRONOUS interface 500 kB/s + .db DSCR_INTERFACE_LEN + .db DSCR_INTERFACE_TYPE + .db 0 ; index + .db 2 ; alt setting idx + .db 1 ; n endpoints + .db 0xff ; class + .db 0 + .db 1 + .db 0 ; string index + +; endpoint 2 in + .db DSCR_ENDPOINT_LEN + .db DSCR_ENDPOINT_TYPE + .db 0x82 ; ep1 dir=in and address + .db ENDPOINT_TYPE_ISO ; type + .db 0x00 ; max packet LSB + .db 0x02 ; max packet size=512 bytes + .db 0x01 ; 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 ; len + .db DSCR_STRING_TYPE + .ascii 'O\0D\0M\0' +string1end: +_string2: + .db string2end-_string2 ; len + .db DSCR_STRING_TYPE + .ascii 'H\0a\0n\0t\0e\0k\0D\0S\0O\0006\0000\0002\0002\0B\0E\0' +string2end: + + +_dev_strings_end: + .dw 0x0000 ; in case you wanted to look at memory between _dev_strings and _dev_strings_end diff --git a/PyHT6022/HantekFirmware/custom/fw.c b/PyHT6022/HantekFirmware/custom/fw.c new file mode 100644 index 0000000..a832b76 --- /dev/null +++ b/PyHT6022/HantekFirmware/custom/fw.c @@ -0,0 +1,170 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * Copyright (C) 2015 Jochen Hoenicke + * + * 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 active; +volatile WORD ledcounter = 0; + + +volatile __bit dosud=FALSE; +volatile __bit dosuspend=FALSE; + +// custom functions +extern void main_loop(); +extern void main_init(); + +void main() { + + SETCPUFREQ(CLK_48M); // required for sio0_init +#ifdef DEBUG_FIRMWARE + // 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; + + // init timer2 + RCAP2L = -2000 & 0xff; + RCAP2H = (-2000 >> 8) & 0xff; + T2CON = 0; + ET2 = 1; + TR2 = 1; + +// iic files (c2 load) don't need to renumerate/delay +// trm 3.6 +#ifndef NORENUM + RENUMERATE(); +#else + USBCS &= ~bmDISCON; +#endif + + PORTCCFG = 0; + PORTACFG = 0; + OEC = 0xff; + OEA = 0x80; + PC7 = 0; + PC6 = 0; + PC5 = 0; + PC4 = 0; + PC3 = 0; + PC2 = 0; + + 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(); +} + +void timer2_isr() __interrupt TF2_ISR { + PA7 = !PA7; + if (ledcounter-- == 0) { + if (active) { + active = 0; + PC1 = !PC1; // toggle green led + PC0 = 1; // clear red led + } else { + PC0 = !PC0; // toggle red led + PC1 = 1; // clear green led + } + ledcounter = 1000; + } + TF2 = 0; +} diff --git a/PyHT6022/HantekFirmware/fx2lib b/PyHT6022/HantekFirmware/fx2lib new file mode 160000 index 0000000..4d3336c --- /dev/null +++ b/PyHT6022/HantekFirmware/fx2lib @@ -0,0 +1 @@ +Subproject commit 4d3336c3b5ebc2127a8e3c013ea13ad58873e9e0 diff --git a/PyHT6022/HantekFirmware/modded/mod_fw_01.ihex b/PyHT6022/HantekFirmware/modded/mod_fw_01.ihex index c71dff6..e7d8606 100644 --- a/PyHT6022/HantekFirmware/modded/mod_fw_01.ihex +++ b/PyHT6022/HantekFirmware/modded/mod_fw_01.ihex @@ -1,5 +1,3 @@ -:017f920001ed -:01e600000118 :02095e00c105d1 :100cb80090e6007410f0120f1800000090e612740d :100cc800a0f0000000e490e613f000000090e614a5 @@ -401,6 +399,4 @@ :100362007a307b01800e79777a787b01800679ef8b :100372007af07b0190e040e9f0a3eaf0a3ebf0e42d :0a038200f51a74ca90e601f08047f6 -:017f920000ee -:01e600000019 :00000001ff diff --git a/PyHT6022/HantekFirmware/modded/mod_fw_iso.ihex b/PyHT6022/HantekFirmware/modded/mod_fw_iso.ihex index a335668..998cbce 100644 --- a/PyHT6022/HantekFirmware/modded/mod_fw_iso.ihex +++ b/PyHT6022/HantekFirmware/modded/mod_fw_iso.ihex @@ -1,5 +1,3 @@ -:017f920001ed -:01e600000118 :0e000000020d5290e682e044c0f090e681f0de :10000e004387010000000000227400f58690fda5d4 :10001e007c05a3e582458370f922d3223202119624 @@ -314,6 +312,4 @@ :0f12ff00d32290e6bae0f518d322e4f541d2e904 :10130e00d2af2232323232323232323232323232a2 :05131e003232323232d0 -:017f920000ee -:01e600000019 :00000001ff diff --git a/PyHT6022/HantekFirmware/stock/stock_fw.ihex b/PyHT6022/HantekFirmware/stock/stock_fw.ihex index bdf44c0..c713e37 100644 --- a/PyHT6022/HantekFirmware/stock/stock_fw.ihex +++ b/PyHT6022/HantekFirmware/stock/stock_fw.ihex @@ -1,7 +1,3 @@ -:017f920001ed -:01e600000118 -:017f920001ed -:01e600000118 :1003680090e668e0ff74fff0e0b40b04eff0d322ee :0603780090e668eff0c3ff :01037e00225c @@ -452,8 +448,4 @@ :100dbe00fae493a3f8e493a3c8c582c8cac583ca4c :100dce00f0a3c8c582c8cac583cadfe9dee780be04 :010a72000083 -:017f920001ed -:01e600000118 -:017f920000ee -:01e600000019 :00000001ff diff --git a/examples/example_linux_flashfirmware.py b/examples/example_linux_flashfirmware.py index 57ff411..d100aac 100644 --- a/examples/example_linux_flashfirmware.py +++ b/examples/example_linux_flashfirmware.py @@ -5,5 +5,5 @@ scope = Oscilloscope() scope.setup() scope.open_handle() -scope.flash_firmware() -scope.close_handle() \ No newline at end of file +scope.flash_firmware_from_hex('../PyHT6022/HantekFirmware/custom/build/firmware.ihx') +scope.close_handle()