Skip to content

Commit

Permalink
blink red after fw load, static green after start sampling
Browse files Browse the repository at this point in the history
Signed-off-by: Martin <[email protected]>
  • Loading branch information
Ho-Ro committed Mar 18, 2019
1 parent 3a6a6d4 commit eaa4de2
Show file tree
Hide file tree
Showing 6 changed files with 267 additions and 261 deletions.
484 changes: 242 additions & 242 deletions PyHT6022/HantekFirmware/custom/build/firmware.ihx

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion PyHT6022/HantekFirmware/custom/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
// change to support as many interfaces as you need
BYTE altiface = 0; // alt interface
extern volatile WORD ledcounter;
extern volatile __bit GREEN;
WORD samplerate;
BYTE numchannels;

Expand Down Expand Up @@ -159,6 +160,7 @@ void start_sampling()
ledcounter = 1000;
LED_RED = LED_OFF;
LED_GREEN = LED_ON;
GREEN = TRUE;
}

extern __code BYTE highspd_dscr;
Expand Down Expand Up @@ -343,7 +345,7 @@ BOOL eeprom() {
break;
case 0x40:
while ( len ) {
BYTE cur_write, c;
BYTE cur_write;
// printf ( "Len More Bytes %d\n" , len );
EP0BCL = 0; // allow pc transfer in
while ( EP0CS & bmEPBUSY ) // wait
Expand All @@ -369,6 +371,7 @@ BOOL handle_vendorcommand(BYTE cmd) {
// Set Red LED
LED_RED = LED_ON;
LED_GREEN = LED_OFF;
GREEN = FALSE;
ledcounter = 1000; // monoflop
switch (cmd) {
case 0xa2:
Expand Down
16 changes: 3 additions & 13 deletions PyHT6022/HantekFirmware/custom/dscr.a51
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ ENDPOINT_TYPE_BULK=2
ENDPOINT_TYPE_INT=3

.globl _dev_dscr, _dev_qual_dscr, _highspd_dscr, _fullspd_dscr, _dev_strings, _dev_strings_end
.globl _bulk_packet, _iso_packet

; 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:
Expand Down Expand Up @@ -97,27 +98,17 @@ highspd_dscr_end:
.db DSCR_INTERFACE_TYPE
.db 0 ; index
.db 0 ; alt setting idx
.db 2 ; n endpoints
.db 1 ; n endpoints
.db 0xff ; class
.db 0
.db 0
.db 0 ; 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 ; ep1 dir=in and address
.db ENDPOINT_TYPE_BULK ; type
_bulk_packet:
.db 0x00 ; max packet LSB
.db 0x02 ; max packet size=512 bytes
.db 0x00 ; polling interval
Expand All @@ -138,7 +129,6 @@ _bulk_packet:
.db DSCR_ENDPOINT_TYPE
.db 0x82 ; ep1 dir=in and address
.db ENDPOINT_TYPE_ISO ; type
_iso_packet:
.db 0x00 ; max packet LSB
.db 0x14 ; max packet size=3*1024 bytes
.db 0x01 ; polling interval
Expand Down
18 changes: 14 additions & 4 deletions PyHT6022/HantekFirmware/custom/fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
#define printf(...)
#endif

volatile WORD ledcounter = 0;
volatile WORD ledcounter = 1000;
volatile __bit GREEN = FALSE;

volatile __bit dosud=FALSE;
volatile __bit dosuspend=FALSE;
Expand Down Expand Up @@ -78,6 +79,10 @@ void main() {
OEC = 0xff;
OEA = 0x80;

LED_RED = LED_ON;
LED_GREEN = LED_OFF;
GREEN = FALSE;

while(TRUE) {

main_loop();
Expand Down Expand Up @@ -150,12 +155,17 @@ void suspend_isr() __interrupt SUSPEND_ISR {

void timer2_isr() __interrupt TF2_ISR {
CAL_OUT = !CAL_OUT;
if (ledcounter) {
if (--ledcounter == 0) {
// clear LED
if (--ledcounter == 0) {
ledcounter = 1000;
if ( GREEN ) {
// toggle green LED, switch red off
LED_GREEN = !LED_GREEN;
LED_RED = LED_OFF;
} else {
LED_RED = !LED_RED;
LED_GREEN = LED_OFF;
}
GREEN = FALSE;
}
TF2 = 0;
}
1 change: 1 addition & 0 deletions examples/examples_libusb/calibration.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
134 125 134 125 134 125 134 127 135 128 135 129 135 129 135 129 132 125 132 125 132 125 132 126 132 127 132 128 132 128 132 128
4 changes: 3 additions & 1 deletion examples/examples_libusb/get_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
calibration = scope.get_calibration_values()
scope.close_handle()

print( calibration )
# print( calibration )
for x in calibration:
print( x, end=" " )

0 comments on commit eaa4de2

Please sign in to comment.