logic-analyzer
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
logic_analyzer::LogicAnalyzer Class Reference

Main Logic Analyzer API using the SUMP Protocol. When you try to connect to the Logic Analzyer - SUMP calls the following requests 1) RESET, 2) ID and then 3) GET_METADATA: This is used to populate the Device! All other requests are called when you click on the capture button. More...

#include <logic_analyzer.h>

Public Member Functions

 LogicAnalyzer ()
 Default Constructor.
 
 ~LogicAnalyzer ()
 Destructor.
 
void begin (Stream &procesingStream, AbstractCapture *capture, uint32_t maxCaptureSize, uint8_t pinStart=0, uint8_t numberOfPins=8, bool setup_pins=false)
 Starts the processing. More...
 
uint16_t startPin ()
 Provides the GPIO number of the start pin which is used for capturing.
 
uint16_t numberOfPins ()
 Provides the number of subsequent GPIO pins which will be used for capturing.
 
Stream & stream ()
 provides command output stream of capturing divice
 
Status status ()
 provides the actual Status
 
void setStatus (Status status)
 Defines the actual status.
 
RingBufferbuffer ()
 Provides access to the buffer.
 
void processCommand ()
 process the next available command - Call this function from your Arduino loop()!
 
PinBitArray triggerValues ()
 provides the trigger values
 
void setTriggerValues (PinBitArray values)
 defines the trigger values
 
PinBitArray triggerMask ()
 provides the trigger mask
 
void setTriggerMask (PinBitArray values)
 defines the trigger mask
 
int readCount ()
 provides the read count
 
void setReadCount (int count)
 defines the read count
 
int delayCount ()
 provides the delay count
 
void setDelayCount (int count)
 defines the delay count
 
uint64_t captureFrequency ()
 provides the caputring frequency
 
uint64_t delayTimeUs ()
 Provides the delay time between measurements in microseconds.
 
void setCaptureFrequency (uint64_t value)
 defines the caputring frequency
 
bool isContinuousCapture ()
 checks if the caputring is continuous
 
void setContinuousCapture (bool cont)
 defines the caputring as continuous
 
void setEventHandler (EventHandler eh)
 defines a event handler that gets notified on some defined events
 
void clear ()
 Resets the status and buffer.
 
size_t size ()
 returns the max buffer size
 
size_t available ()
 returns the avialable buffer entries
 
void setLogger (Stream &logger)
 Activate the logging by defining the logging output Stream.
 
void setCaptureOnArm (bool capture)
 Switch automatic capturing on ARMED status on/off.
 
void setDescription (const char *name)
 Defines the Description.
 
void setAllocateBuffer (bool do_allocate)
 Allows to switch of the automatic buffer allocation - call before begin!
 
void capture ()
 starts the capturing
 

Protected Member Functions

LogicAnalyzerStatestate ()
 Provides a reference to the LogicAnalyzerState.
 
bool hasCommand ()
 checks if there is a command available
 
uint8_t command ()
 gets the next 1 byte command
 
Sump4ByteComandArgcommandExt ()
 gets the next 4 byte command
 
void write (uint8_t cmd, uint32_t number)
 writes a byte command with uint32_t number argument
 
void write (uint8_t cmd, const char *str)
 writes a byte command with char* argument
 
PinBitArray commandExtPinBitArray ()
 Provides the command as PinBitArray.
 
void raiseEvent (Event event)
 raises an event
 
void setupDelay (uint32_t divider)
 
void sendMetadata ()
 
void processCommand (int cmd)
 

Protected Attributes

bool is_capture_on_arm = true
 
bool do_allocate_buffer = true
 
uint64_t sump_reset_igorne_timeout =0
 
AbstractCapturecapture_ptr = nullptr
 
const char * description = "ARDUINO"
 
const char * device_id = "1ALS"
 
const char * firmware_version = "01.0"
 
const char * protocol_version = "\x041\x002"
 

Detailed Description

Main Logic Analyzer API using the SUMP Protocol. When you try to connect to the Logic Analzyer - SUMP calls the following requests 1) RESET, 2) ID and then 3) GET_METADATA: This is used to populate the Device! All other requests are called when you click on the capture button.

Author
Phil Schatzmann

Member Function Documentation

◆ begin()

void logic_analyzer::LogicAnalyzer::begin ( Stream &  procesingStream,
AbstractCapture capture,
uint32_t  maxCaptureSize,
uint8_t  pinStart = 0,
uint8_t  numberOfPins = 8,
bool  setup_pins = false 
)
inline

Starts the processing.

Parameters
procesingStreamStream which is used to communicate to pulsview
captureAbstractCapture
maxCaptureFreqMax Supported Capturing Frequency
maxCaptureFreqThresholdThreshold which is used to change to the 'full speed' implementation which does not dontain any delays
maxCaptureSizeMaximum number of captured entries
pinStartStart GPIO Pin Number for capturing
numberOfPinsNumber of subsequent pins to capture
setup_pinsChange the pin mode to input

◆ processCommand()

void logic_analyzer::LogicAnalyzer::processCommand ( int  cmd)
inlineprotected

Proposess the SUMP commands

Resets the buffer and processing status. Resets are repeated 5 times!

Asks for device identification. The device will respond with four bytes.

◆ sendMetadata()

void logic_analyzer::LogicAnalyzer::sendMetadata ( )
inlineprotected

This function returns the metadata about our capabilities. It is sent in response to the OpenBench Logic Sniffer extended get metadata command

◆ setupDelay()

void logic_analyzer::LogicAnalyzer::setupDelay ( uint32_t  divider)
inlineprotected

This function calculates what delay we need for the specific sample rate. The dividers are based on SUMP's 100Mhz clock. For example, a 1MHz sample rate has a divider of 99 (0x63 in the command byte). rate = clock / (divider + 1) rate = 100,000,000 / (99 + 1) result is 1,000,000 saying we want a 1MHz sample rate. We calculate our inter sample delay from the divider and the delay between samples gives us the sample rate per second. So for 1MHz, delay = (99 + 1) / 100 which gives us a 1 microsecond delay. For 500KHz, delay = (199 + 1) / 100 which gives us a 2 microsecond delay.


The documentation for this class was generated from the following file: