X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hantek_6022bl.c;h=4920047cdfed7ccf0a4e294465fd6c1683b5f71e;hb=e583c3fcd0bd1e4a44846fba5e80bbea1ff215a2;hp=fc2c5812ef4e189372330fc36b89bd11163a2394;hpb=90fdecb7399353d9b806b303c92d20be810943b3;p=sigrok-firmware-fx2lafw.git diff --git a/hantek_6022bl.c b/hantek_6022bl.c index fc2c5812..4920047c 100644 --- a/hantek_6022bl.c +++ b/hantek_6022bl.c @@ -24,6 +24,11 @@ #include #include +#define SET_ANALOG_MODE() PA7 = 1 + +/* Toggle the 1kHz calibration pin, only accurate up to ca. 8MHz. */ +#define TOGGLE_CALIBRATION_PIN() PC2 = !PC2 + /* Change to support as many interfaces as you need. */ static BYTE altiface = 0; @@ -66,8 +71,7 @@ void suspend_isr(void) __interrupt SUSPEND_ISR void timer2_isr(void) __interrupt TF2_ISR { - /* Toggle the 1kHz calibration pin, only accurate up to ca 8MHz. */ - PC2 = !PC2; + TOGGLE_CALIBRATION_PIN(); if (ledcounter) { if (--ledcounter == 0) { @@ -76,6 +80,7 @@ void timer2_isr(void) __interrupt TF2_ISR PC1 = 1; } } + TF2 = 0; } @@ -164,8 +169,7 @@ static void start_sampling(void) { int i; - /* Set analog mode. */ - PA7 = 1; + SET_ANALOG_MODE(); clear_fifo(); @@ -253,16 +257,18 @@ static BOOL set_samplerate(BYTE rate) /* * The program for low-speed, e.g. 1 MHz, is: - * wait 24, CTL2=0, FIFO - * wait 23, CTL2=1 - * jump 0, CTL2=1 + * wait 24, CTLx=0, FIFO + * wait 23, CTLx=1 + * jump 0, CTLx=1 * * The program for 24 MHz is: - * wait 1, CTL2=0, FIFO - * jump 0, CTL2=1 + * wait 1, CTLx=0, FIFO + * jump 0, CTLx=1 * * The program for 30/48 MHz is: - * jump 0, CTL2=Z, FIFO, LOOP + * jump 0, CTLx=Z, FIFO, LOOP + * + * (CTLx is device-dependent, could be e.g. CTL0 or CTL2.) */ /* LENGTH / BRANCH 0-7 */ @@ -390,8 +396,7 @@ static void init(void) EP4CFG = 0; EP8CFG = 0; - /* Set analog mode. */ - PA7 = 1; + SET_ANALOG_MODE(); /* In idle mode tristate all outputs. */ GPIFIDLECTL = 0x00; /* Don't enable CTL0-5 outputs. */ @@ -439,7 +444,7 @@ static void main(void) PORTCCFG = 0; PORTACFG = 0; OEC = 0xff; - OEA = 0x80; + OEA = 0xff; while (TRUE) { if (dosud) { @@ -451,7 +456,7 @@ static void main(void) dosuspend = FALSE; do { /* Make sure ext wakeups are cleared. */ - WAKEUPCS |= bmWU|bmWU2; + WAKEUPCS |= bmWU | bmWU2; SUSPEND = 1; PCON |= 1; __asm