]> sigrok.org Git - sigrok-firmware-fx2lafw.git/blobdiff - hantek_6022be.c
scopes: Adapt/fix some code comments, cosmetics.
[sigrok-firmware-fx2lafw.git] / hantek_6022be.c
index e089e96996c05eeafca9629a84f38360ba1c16d7..232237eb1296b2147222d5c9db271450f4ce460d 100644 (file)
@@ -15,8 +15,7 @@
  * 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
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <fx2macros.h>
@@ -67,7 +66,9 @@ 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. */
        PA7 = !PA7;
+
        if (ledcounter) {
                if (--ledcounter == 0) {
                        /* Clear LED. */
@@ -75,6 +76,7 @@ void timer2_isr(void) __interrupt TF2_ISR
                        PC1 = 1;
                }
        }
+
        TF2 = 0;
 }
 
@@ -248,16 +250,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 */
@@ -282,8 +286,8 @@ static BOOL set_samplerate(BYTE rate)
 
        /* OUTPUT 0-7 */
        EXTAUTODAT2 = samplerates[i].out0;
-       EXTAUTODAT2 = 0x44; /* OE0=1, CTL0=1 */
-       EXTAUTODAT2 = 0x44; /* OE0=1, CTL0=1 */
+       EXTAUTODAT2 = 0x44; /* OE2=1, CTL2=1 */
+       EXTAUTODAT2 = 0x44; /* OE2=1, CTL2=1 */
        EXTAUTODAT2 = 0;
        EXTAUTODAT2 = 0;
        EXTAUTODAT2 = 0;
@@ -443,7 +447,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