|
|
|
@@ -2,7 +2,7 @@
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* SUMP Protocol Implementation for Arduino boards.
|
|
|
|
* SUMP Protocol Implementation for Arduino boards.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011,2012,2013,2014,2015 Andrew Gillham
|
|
|
|
* Copyright (c) 2011,2012,2013,2014 Andrew Gillham
|
|
|
|
* All rights reserved.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
@@ -62,7 +62,7 @@
|
|
|
|
* until after the trigger fires.
|
|
|
|
* until after the trigger fires.
|
|
|
|
* Please try it out and report back.
|
|
|
|
* Please try it out and report back.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Release: v0.14 December 16, 2015.
|
|
|
|
* Release: v0.12 September 6, 2013.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
@@ -81,7 +81,6 @@ void blinkled(void);
|
|
|
|
void get_metadata(void);
|
|
|
|
void get_metadata(void);
|
|
|
|
void debugprint(void);
|
|
|
|
void debugprint(void);
|
|
|
|
void debugdump(void);
|
|
|
|
void debugdump(void);
|
|
|
|
void prettydump(void);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
@@ -89,6 +88,11 @@ void prettydump(void);
|
|
|
|
* PORTD support with triggers seems to work but needs more testing.
|
|
|
|
* PORTD support with triggers seems to work but needs more testing.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
//#define USE_PORTD 1
|
|
|
|
//#define USE_PORTD 1
|
|
|
|
|
|
|
|
#if defined(USE_PORTD)
|
|
|
|
|
|
|
|
#define SHIFTBITS 2
|
|
|
|
|
|
|
|
#elif defined(__AVR_ATmega32U4__)
|
|
|
|
|
|
|
|
#define SHIFTBITS 1
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Arduino device profile: ols.profile-agla.cfg
|
|
|
|
* Arduino device profile: ols.profile-agla.cfg
|
|
|
|
@@ -115,6 +119,15 @@ void prettydump(void);
|
|
|
|
#define CHAN5 7
|
|
|
|
#define CHAN5 7
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define CHANPIN PINB
|
|
|
|
#define CHANPIN PINB
|
|
|
|
|
|
|
|
#if defined(__AVR_ATmega32U4__)
|
|
|
|
|
|
|
|
#define CHAN0 SCK
|
|
|
|
|
|
|
|
#define CHAN1 MOSI
|
|
|
|
|
|
|
|
#define CHAN2 MISO
|
|
|
|
|
|
|
|
#define CHAN3 8
|
|
|
|
|
|
|
|
#define CHAN4 9
|
|
|
|
|
|
|
|
#define CHAN5 10
|
|
|
|
|
|
|
|
#define CHAN6 11
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define CHAN0 8
|
|
|
|
#define CHAN0 8
|
|
|
|
#define CHAN1 9
|
|
|
|
#define CHAN1 9
|
|
|
|
#define CHAN2 10
|
|
|
|
#define CHAN2 10
|
|
|
|
@@ -122,8 +135,9 @@ void prettydump(void);
|
|
|
|
#define CHAN4 12
|
|
|
|
#define CHAN4 12
|
|
|
|
/* Comment out CHAN5 if you don't want to use the LED pin for an input */
|
|
|
|
/* Comment out CHAN5 if you don't want to use the LED pin for an input */
|
|
|
|
#define CHAN5 13
|
|
|
|
#define CHAN5 13
|
|
|
|
|
|
|
|
#endif /* AVR_ATmega32U4 */
|
|
|
|
#endif /* USE_PORTD */
|
|
|
|
#endif /* USE_PORTD */
|
|
|
|
#endif
|
|
|
|
#endif /* Mega1280 or Mega2560 */
|
|
|
|
#define ledPin 13
|
|
|
|
#define ledPin 13
|
|
|
|
|
|
|
|
|
|
|
|
/* XON/XOFF are not supported. */
|
|
|
|
/* XON/XOFF are not supported. */
|
|
|
|
@@ -155,6 +169,9 @@ void prettydump(void);
|
|
|
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
|
|
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
|
|
|
#define DEBUG_CAPTURE_SIZE 7168
|
|
|
|
#define DEBUG_CAPTURE_SIZE 7168
|
|
|
|
#define CAPTURE_SIZE 7168
|
|
|
|
#define CAPTURE_SIZE 7168
|
|
|
|
|
|
|
|
#elif defined(__AVR_ATmega32U4__)
|
|
|
|
|
|
|
|
#define DEBUG_CAPTURE_SIZE 1536
|
|
|
|
|
|
|
|
#define CAPTURE_SIZE 1536
|
|
|
|
#elif defined(__AVR_ATmega328P__)
|
|
|
|
#elif defined(__AVR_ATmega328P__)
|
|
|
|
#define DEBUG_CAPTURE_SIZE 1024
|
|
|
|
#define DEBUG_CAPTURE_SIZE 1024
|
|
|
|
#define CAPTURE_SIZE 1024
|
|
|
|
#define CAPTURE_SIZE 1024
|
|
|
|
@@ -171,11 +188,8 @@ void prettydump(void);
|
|
|
|
#define DEBUG_ENABLE DDRD = DDRD | B10000000
|
|
|
|
#define DEBUG_ENABLE DDRD = DDRD | B10000000
|
|
|
|
#define DEBUG_ON PORTD = B10000000
|
|
|
|
#define DEBUG_ON PORTD = B10000000
|
|
|
|
#define DEBUG_OFF PORTD = B00000000
|
|
|
|
#define DEBUG_OFF PORTD = B00000000
|
|
|
|
#endif /* USE_PORTD */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DEBUG
|
|
|
|
//#define DEBUG_MENU
|
|
|
|
|
|
|
|
//#define DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define MAX_CAPTURE_SIZE DEBUG_CAPTURE_SIZE
|
|
|
|
#define MAX_CAPTURE_SIZE DEBUG_CAPTURE_SIZE
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
@@ -209,6 +223,10 @@ boolean rleEnabled = 0;
|
|
|
|
void setup()
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
|
|
|
while (!Serial) {
|
|
|
|
|
|
|
|
; // wait for serial port to connect. Needed for Leonardo only
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* set debug pin (digital pin 8) to output right away so it settles.
|
|
|
|
* set debug pin (digital pin 8) to output right away so it settles.
|
|
|
|
@@ -226,14 +244,15 @@ void setup()
|
|
|
|
#ifdef CHAN5
|
|
|
|
#ifdef CHAN5
|
|
|
|
pinMode(CHAN5, INPUT);
|
|
|
|
pinMode(CHAN5, INPUT);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
|
|
|
#ifdef CHAN6
|
|
|
|
pinMode(CHAN6, INPUT);
|
|
|
|
pinMode(CHAN6, INPUT);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CHAN7
|
|
|
|
pinMode(CHAN7, INPUT);
|
|
|
|
pinMode(CHAN7, INPUT);
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
#ifndef CHAN5
|
|
|
|
#ifndef CHAN5
|
|
|
|
pinMode(ledPin, OUTPUT);
|
|
|
|
pinMode(ledPin, OUTPUT);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif /* Mega */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
|
|
|
|
@@ -267,10 +286,10 @@ void loop()
|
|
|
|
|
|
|
|
|
|
|
|
if (Serial.available() > 0) {
|
|
|
|
if (Serial.available() > 0) {
|
|
|
|
cmdByte = Serial.read();
|
|
|
|
cmdByte = Serial.read();
|
|
|
|
switch (cmdByte) {
|
|
|
|
switch(cmdByte) {
|
|
|
|
case SUMP_RESET:
|
|
|
|
case SUMP_RESET:
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* We don't do anything here as some unsupported extended commands have
|
|
|
|
* We don't do anything here as some unsupported extended commands have
|
|
|
|
* zero bytes and are mistaken as resets. This can trigger false resets
|
|
|
|
* zero bytes and are mistaken as resets. This can trigger false resets
|
|
|
|
* so we don't erase the data or do anything for a reset.
|
|
|
|
* so we don't erase the data or do anything for a reset.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@@ -284,14 +303,14 @@ void loop()
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SUMP_ARM:
|
|
|
|
case SUMP_ARM:
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Zero out any previous samples before arming.
|
|
|
|
* Zero out any previous samples before arming.
|
|
|
|
* Done here instead via reset due to spurious resets.
|
|
|
|
* Done here instead via reset due to spurious resets.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
|
|
|
|
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
|
|
|
|
logicdata[i] = 0;
|
|
|
|
logicdata[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* depending on the sample rate we need to delay in microseconds
|
|
|
|
* depending on the sample rate we need to delay in microseconds
|
|
|
|
* or milliseconds. We can't do the complex trigger at 1MHz
|
|
|
|
* or milliseconds. We can't do the complex trigger at 1MHz
|
|
|
|
* so in that case (delayTime == 1 and triggers enabled) use
|
|
|
|
* so in that case (delayTime == 1 and triggers enabled) use
|
|
|
|
* captureMicro() instead of triggerMicro().
|
|
|
|
* captureMicro() instead of triggerMicro().
|
|
|
|
@@ -303,7 +322,7 @@ void loop()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (divider == 49) {
|
|
|
|
else if (divider == 49) {
|
|
|
|
/* 2.0MHz */
|
|
|
|
/* 2.0MHz */
|
|
|
|
#if !defined(__AVR_ATmega168__)
|
|
|
|
#if defined(__AVR_ATmega168P__)
|
|
|
|
captureInline2mhz();
|
|
|
|
captureInline2mhz();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -321,24 +340,24 @@ void loop()
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SUMP_TRIGGER_MASK:
|
|
|
|
case SUMP_TRIGGER_MASK:
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* the trigger mask byte has a '1' for each enabled trigger so
|
|
|
|
* the trigger mask byte has a '1' for each enabled trigger so
|
|
|
|
* we can just use it directly as our trigger mask.
|
|
|
|
* we can just use it directly as our trigger mask.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
getCmd();
|
|
|
|
getCmd();
|
|
|
|
#ifdef USE_PORTD
|
|
|
|
#ifdef SHIFTBITS
|
|
|
|
trigger = cmdBytes[0] << 2;
|
|
|
|
trigger = cmdBytes[0] << SHIFTBITS;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
trigger = cmdBytes[0];
|
|
|
|
trigger = cmdBytes[0];
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SUMP_TRIGGER_VALUES:
|
|
|
|
case SUMP_TRIGGER_VALUES:
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* trigger_values can be used directly as the value of each bit
|
|
|
|
* trigger_values can be used directly as the value of each bit
|
|
|
|
* defines whether we're looking for it to be high or low.
|
|
|
|
* defines whether we're looking for it to be high or low.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
getCmd();
|
|
|
|
getCmd();
|
|
|
|
#ifdef USE_PORTD
|
|
|
|
#ifdef SHIFTBITS
|
|
|
|
trigger_values = cmdBytes[0] << 2;
|
|
|
|
trigger_values = cmdBytes[0] << SHIFTBITS;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
trigger_values = cmdBytes[0];
|
|
|
|
trigger_values = cmdBytes[0];
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
@@ -349,7 +368,7 @@ void loop()
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SUMP_SET_DIVIDER:
|
|
|
|
case SUMP_SET_DIVIDER:
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* the shifting needs to be done on the 32bit unsigned long variable
|
|
|
|
* the shifting needs to be done on the 32bit unsigned long variable
|
|
|
|
* so that << 16 doesn't end up as zero.
|
|
|
|
* so that << 16 doesn't end up as zero.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
getCmd();
|
|
|
|
getCmd();
|
|
|
|
@@ -362,7 +381,7 @@ void loop()
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SUMP_SET_READ_DELAY_COUNT:
|
|
|
|
case SUMP_SET_READ_DELAY_COUNT:
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* this just sets up how many samples there should be before
|
|
|
|
* this just sets up how many samples there should be before
|
|
|
|
* and after the trigger fires. The readCount is total samples
|
|
|
|
* and after the trigger fires. The readCount is total samples
|
|
|
|
* to return and delayCount number of samples after the trigger.
|
|
|
|
* to return and delayCount number of samples after the trigger.
|
|
|
|
* this sets the buffer splits like 0/100, 25/75, 50/50
|
|
|
|
* this sets the buffer splits like 0/100, 25/75, 50/50
|
|
|
|
@@ -386,7 +405,7 @@ void loop()
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SUMP_GET_METADATA:
|
|
|
|
case SUMP_GET_METADATA:
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* We return a description of our capabilities.
|
|
|
|
* We return a description of our capabilities.
|
|
|
|
* Check the function's comments below.
|
|
|
|
* Check the function's comments below.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
get_metadata();
|
|
|
|
get_metadata();
|
|
|
|
@@ -394,85 +413,37 @@ void loop()
|
|
|
|
case SUMP_SELF_TEST:
|
|
|
|
case SUMP_SELF_TEST:
|
|
|
|
/* ignored. */
|
|
|
|
/* ignored. */
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
#ifdef DEBUG_MENU
|
|
|
|
#ifdef DEBUG
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* a couple of debug commands used during development.
|
|
|
|
* a couple of debug commands used during development.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
case '?':
|
|
|
|
|
|
|
|
Serial.println("");
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
Serial.println("0 = clear cmd buffer");
|
|
|
|
|
|
|
|
Serial.println("1 = print cmd buffer");
|
|
|
|
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
Serial.println("2 = print data buffer");
|
|
|
|
|
|
|
|
Serial.println("3 = pretty print buffer");
|
|
|
|
|
|
|
|
Serial.println("4 = capture at 4MHz");
|
|
|
|
|
|
|
|
Serial.println("5 = capture at 1MHz");
|
|
|
|
|
|
|
|
Serial.println("6 = capture at 500KHz");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
case '0':
|
|
|
|
case '0':
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* This resets the debug buffer pointer, effectively clearing the
|
|
|
|
* This resets the debug buffer pointer, effectively clearing the
|
|
|
|
* previous commands out of the buffer. Clear the sample data as well.
|
|
|
|
* previous commands out of the buffer. Clear the sample data as well.
|
|
|
|
* Just send a '0' from the Arduino IDE's Serial Monitor.
|
|
|
|
* Just send a '0' from the Arduino IDE's Serial Monitor.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
savecount = 0;
|
|
|
|
savecount=0;
|
|
|
|
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
|
|
|
|
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
|
|
|
|
logicdata[i] = 0;
|
|
|
|
logicdata[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '1':
|
|
|
|
case '1':
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* This is used to see what commands were sent to the device.
|
|
|
|
* This is used to see what commands were sent to the device.
|
|
|
|
* you can use the Arduino serial monitor and send a '1' and get
|
|
|
|
* you can use the Arduino serial monitor and send a '1' and get
|
|
|
|
* a debug printout. useless except for development.
|
|
|
|
* a debug printout. useless except for development.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
blinkled();
|
|
|
|
blinkled();
|
|
|
|
debugprint();
|
|
|
|
debugprint();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
case '2':
|
|
|
|
case '2':
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* This dumps the sample data to the serial port.
|
|
|
|
* This dumps the sample data to the serial port. Used for debugging.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
debugdump();
|
|
|
|
debugdump();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '3':
|
|
|
|
#endif /* DEBUG */
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Prints a visual representation of the data buffer.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
prettydump();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '4':
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* This runs a sample capture at 4MHz.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
captureInline4mhz();
|
|
|
|
|
|
|
|
Serial.println("");
|
|
|
|
|
|
|
|
Serial.println("4MHz capture done.");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '5':
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* This runs a sample capture at 1MHz.
|
|
|
|
|
|
|
|
* delayTime = 1ms for 1MHz sampling.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
delayTime = 1;
|
|
|
|
|
|
|
|
captureMicro();
|
|
|
|
|
|
|
|
Serial.println("");
|
|
|
|
|
|
|
|
Serial.println("1MHz capture done.");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '6':
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* This runs a sample capture at 500KHz.
|
|
|
|
|
|
|
|
* delayTime = 2ms for 500KHz.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
delayTime = 1;
|
|
|
|
|
|
|
|
captureMicro();
|
|
|
|
|
|
|
|
Serial.println("");
|
|
|
|
|
|
|
|
Serial.println("500KHz capture done.");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
#endif /* DEBUG_MENU */
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
/* ignore any unrecognized bytes. */
|
|
|
|
/* ignore any unrecognized bytes. */
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
@@ -619,8 +590,8 @@ void captureMicro() {
|
|
|
|
* is done for any triggers, this is effectively the 0/100 buffer split.
|
|
|
|
* is done for any triggers, this is effectively the 0/100 buffer split.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
for (i = 0 ; i < readCount; i++) {
|
|
|
|
for (i = 0 ; i < readCount; i++) {
|
|
|
|
#ifdef USE_PORTD
|
|
|
|
#ifdef SHIFTBITS
|
|
|
|
Serial.write(logicdata[i] >> 2);
|
|
|
|
Serial.write(logicdata[i] >> SHIFTBITS);
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
Serial.write(logicdata[i]);
|
|
|
|
Serial.write(logicdata[i]);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
@@ -647,7 +618,7 @@ void captureMicro() {
|
|
|
|
void captureMilli() {
|
|
|
|
void captureMilli() {
|
|
|
|
unsigned int i = 0;
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (rleEnabled) {
|
|
|
|
if(rleEnabled) {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* very basic trigger, just like in captureMicros() above.
|
|
|
|
* very basic trigger, just like in captureMicros() above.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@@ -658,16 +629,16 @@ void captureMilli() {
|
|
|
|
byte lastSample = 0;
|
|
|
|
byte lastSample = 0;
|
|
|
|
byte sampleCount = 0;
|
|
|
|
byte sampleCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
while (i < readCount) {
|
|
|
|
while(i < readCount) {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Implementation of the RLE unlimited protocol: timings might be off a little
|
|
|
|
* Implementation of the RLE unlimited protocol: timings might be off a little
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (lastSample == (CHANPIN & B01111111) && sampleCount < 127) {
|
|
|
|
if(lastSample == (CHANPIN & B01111111) && sampleCount < 127) {
|
|
|
|
sampleCount++;
|
|
|
|
sampleCount++;
|
|
|
|
delay(delayTime);
|
|
|
|
delay(delayTime);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sampleCount != 0) {
|
|
|
|
if(sampleCount != 0) {
|
|
|
|
logicdata[i] = B10000000 | sampleCount;
|
|
|
|
logicdata[i] = B10000000 | sampleCount;
|
|
|
|
sampleCount = 0;
|
|
|
|
sampleCount = 0;
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
@@ -694,8 +665,8 @@ void captureMilli() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0 ; i < readCount; i++) {
|
|
|
|
for (i = 0 ; i < readCount; i++) {
|
|
|
|
#ifdef USE_PORTD
|
|
|
|
#ifdef SHIFTBITS
|
|
|
|
Serial.write(logicdata[i] >> 2);
|
|
|
|
Serial.write(logicdata[i] >> SHIFTBITS);
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
Serial.write(logicdata[i]);
|
|
|
|
Serial.write(logicdata[i]);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
@@ -888,8 +859,8 @@ void triggerMicro() {
|
|
|
|
if (logicIndex >= readCount) {
|
|
|
|
if (logicIndex >= readCount) {
|
|
|
|
logicIndex = 0;
|
|
|
|
logicIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef USE_PORTD
|
|
|
|
#ifdef SHIFTBITS
|
|
|
|
Serial.write(logicdata[logicIndex++] >> 2);
|
|
|
|
Serial.write(logicdata[logicIndex++] >> SHIFTBITS);
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
Serial.write(logicdata[logicIndex++]);
|
|
|
|
Serial.write(logicdata[logicIndex++]);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
@@ -935,6 +906,8 @@ void get_metadata() {
|
|
|
|
Serial.write('A');
|
|
|
|
Serial.write('A');
|
|
|
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
|
|
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
|
|
|
Serial.write('M');
|
|
|
|
Serial.write('M');
|
|
|
|
|
|
|
|
#elif defined(__AVR_ATmega32U4__)
|
|
|
|
|
|
|
|
Serial.write('L');
|
|
|
|
#endif /* Mega */
|
|
|
|
#endif /* Mega */
|
|
|
|
Serial.write('v');
|
|
|
|
Serial.write('v');
|
|
|
|
Serial.write('0');
|
|
|
|
Serial.write('0');
|
|
|
|
@@ -945,7 +918,7 @@ void get_metadata() {
|
|
|
|
Serial.write('0');
|
|
|
|
Serial.write('0');
|
|
|
|
Serial.write('.');
|
|
|
|
Serial.write('.');
|
|
|
|
Serial.write('1');
|
|
|
|
Serial.write('1');
|
|
|
|
Serial.write('3');
|
|
|
|
Serial.write('2');
|
|
|
|
Serial.write((uint8_t)0x00);
|
|
|
|
Serial.write((uint8_t)0x00);
|
|
|
|
|
|
|
|
|
|
|
|
/* sample memory */
|
|
|
|
/* sample memory */
|
|
|
|
@@ -956,6 +929,10 @@ void get_metadata() {
|
|
|
|
/* 7168 bytes */
|
|
|
|
/* 7168 bytes */
|
|
|
|
Serial.write((uint8_t)0x1C);
|
|
|
|
Serial.write((uint8_t)0x1C);
|
|
|
|
Serial.write((uint8_t)0x00);
|
|
|
|
Serial.write((uint8_t)0x00);
|
|
|
|
|
|
|
|
#elif defined(__AVR_ATmega32U4__)
|
|
|
|
|
|
|
|
/* 1024 bytes */
|
|
|
|
|
|
|
|
Serial.write((uint8_t)0x04);
|
|
|
|
|
|
|
|
Serial.write((uint8_t)0x00);
|
|
|
|
#elif defined(__AVR_ATmega328P__)
|
|
|
|
#elif defined(__AVR_ATmega328P__)
|
|
|
|
/* 1024 bytes */
|
|
|
|
/* 1024 bytes */
|
|
|
|
Serial.write((uint8_t)0x04);
|
|
|
|
Serial.write((uint8_t)0x04);
|
|
|
|
@@ -975,15 +952,15 @@ void get_metadata() {
|
|
|
|
|
|
|
|
|
|
|
|
/* number of probes (6 by default on Arduino, 8 on Mega) */
|
|
|
|
/* number of probes (6 by default on Arduino, 8 on Mega) */
|
|
|
|
Serial.write((uint8_t)0x40);
|
|
|
|
Serial.write((uint8_t)0x40);
|
|
|
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
|
|
|
#ifdef CHAN7
|
|
|
|
Serial.write((uint8_t)0x08);
|
|
|
|
Serial.write((uint8_t)0x08);
|
|
|
|
#else
|
|
|
|
#elif CHAN6
|
|
|
|
#ifdef CHAN5
|
|
|
|
Serial.write((uint8_t)0x07);
|
|
|
|
|
|
|
|
#elif CHAN5
|
|
|
|
Serial.write((uint8_t)0x06);
|
|
|
|
Serial.write((uint8_t)0x06);
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
Serial.write((uint8_t)0x05);
|
|
|
|
Serial.write((uint8_t)0x05);
|
|
|
|
#endif /* CHAN5 */
|
|
|
|
#endif
|
|
|
|
#endif /* Mega */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* protocol version (2) */
|
|
|
|
/* protocol version (2) */
|
|
|
|
Serial.write((uint8_t)0x41);
|
|
|
|
Serial.write((uint8_t)0x41);
|
|
|
|
@@ -994,7 +971,7 @@ void get_metadata() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* This is used by the '1' debug command to dump the contents of some
|
|
|
|
* This is used by the '0' debug command to dump the contents of some
|
|
|
|
* interesting variables and the debug buffer.
|
|
|
|
* interesting variables and the debug buffer.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@@ -1035,8 +1012,6 @@ void debugprint() {
|
|
|
|
Serial.println("done...");
|
|
|
|
Serial.println("done...");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
#ifdef DEBUG_MENU
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* This is used by the '2' debug command to dump the contents
|
|
|
|
* This is used by the '2' debug command to dump the contents
|
|
|
|
* of the sample buffer.
|
|
|
|
* of the sample buffer.
|
|
|
|
@@ -1048,8 +1023,8 @@ void debugdump() {
|
|
|
|
Serial.print("\r\n");
|
|
|
|
Serial.print("\r\n");
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
|
|
|
|
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
|
|
|
|
#ifdef USE_PORTD
|
|
|
|
#ifdef SHIFTBITS
|
|
|
|
Serial.print(logicdata[i] >> 2, HEX);
|
|
|
|
Serial.print(logicdata[i] >> SHIFTBITS, HEX);
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
Serial.print(logicdata[i], HEX);
|
|
|
|
Serial.print(logicdata[i], HEX);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
@@ -1061,36 +1036,8 @@ void debugdump() {
|
|
|
|
j++;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* DEBUG */
|
|
|
|
/*
|
|
|
|
|
|
|
|
* This is used by the '3' debugs command to dump the first 64 bytes
|
|
|
|
|
|
|
|
* of the sample buffer.
|
|
|
|
|
|
|
|
* It prints the data in a graphical representation.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void prettydump() {
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
byte j;
|
|
|
|
|
|
|
|
byte k;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Serial.print("\r\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0 ; i < 64; i++) {
|
|
|
|
|
|
|
|
#ifdef USE_PORTD
|
|
|
|
|
|
|
|
k = logicdata[i] >> 2;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
k = logicdata[i];
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (j = 0; j < 8; j++) {
|
|
|
|
|
|
|
|
if (k & 0x01)
|
|
|
|
|
|
|
|
Serial.print("| ");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
Serial.print(" |");
|
|
|
|
|
|
|
|
k = k >> 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Serial.print("\r\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* DEBUG_MENU */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|