Documentation ¶
Overview ¶
Analog-Digital-Converter (OpenADC). Implements AdcInterface.
Analog-Digital-Converter (OpenADC) interface.
Collects power trace measurements.
FPGA interface.
External memory interface.
simple-serial protocol.
Serial USART interface.
Provides low-level interface for ChipWhisperer USB device. Based on chipwhisperer/software/chipwhisperer/hardware/naeusb/naeusb.py. Implementation is hard-coded for ChipWhisperer-Lite hardware.
Index ¶
- Variables
- type Adc
- func (c *Adc) ActiveCount() uint32
- func (c *Adc) AdcClockSource() AdcSrcTuple
- func (c *Adc) AdcFreq() uint32
- func (c *Adc) AdcSampleRate() uint32
- func (c *Adc) ClkGenDcmLocked() bool
- func (c *Adc) ClkGenInputSource() ClkGenInputSrc
- func (c *Adc) ClkGenOutputFreq() uint32
- func (c *Adc) Close() error
- func (c *Adc) DcmLocked() bool
- func (c *Adc) DownsampleFactor() uint16
- func (c *Adc) Error() error
- func (c *Adc) ExtClockFreq() uint32
- func (c *Adc) FreqCounter() uint32
- func (c *Adc) FreqCounterSource() FreqCounterSrc
- func (c *Adc) Gain() uint8
- func (c *Adc) GainMode() GainMode
- func (c *Adc) Hs2() Hs2Mode
- func (c *Adc) MaxSamples() uint32
- func (c *Adc) NRST() GpioMode
- func (c *Adc) PDIC() GpioMode
- func (c *Adc) PDID() GpioMode
- func (c *Adc) PreTriggerSamples() uint32
- func (c *Adc) ProcessTraceData(data []byte) []float64
- func (c *Adc) SetAdcClockSource(src AdcSrcTuple)
- func (c *Adc) SetArmOff()
- func (c *Adc) SetArmOn()
- func (c *Adc) SetClkGenInputSource(src ClkGenInputSrc)
- func (c *Adc) SetClkGenOutputFreq(freq uint32)
- func (c *Adc) SetDownsampleFactor(factor uint16)
- func (c *Adc) SetExtClockFreq(freq uint32)
- func (c *Adc) SetFreqCounterSource(src FreqCounterSrc)
- func (c *Adc) SetGain(gain uint8)
- func (c *Adc) SetGainMode(mode GainMode)
- func (c *Adc) SetHs2(mode Hs2Mode)
- func (c *Adc) SetNRST(mode GpioMode)
- func (c *Adc) SetPDIC(mode GpioMode)
- func (c *Adc) SetPDID(mode GpioMode)
- func (c *Adc) SetPreTriggerSamples(samples uint32)
- func (c *Adc) SetTargetIo1(mode TargetIoMode)
- func (c *Adc) SetTargetIo2(mode TargetIoMode)
- func (c *Adc) SetTotalSamples(samples uint32)
- func (c *Adc) SetTriggerMode(mode TriggerMode)
- func (c *Adc) SetTriggerOffset(offset uint32)
- func (c *Adc) SetTriggerTargetIoPin(pin TriggerTargetIoPin)
- func (c *Adc) SysFreq() uint32
- func (c *Adc) TargetIo1() TargetIoMode
- func (c *Adc) TargetIo2() TargetIoMode
- func (c *Adc) TotalSamples() uint32
- func (c *Adc) TraceData() []float64
- func (c *Adc) TriggerMode() TriggerMode
- func (c *Adc) TriggerOffset() uint32
- func (c *Adc) TriggerPinState() bool
- func (c *Adc) TriggerTargetIoPins() []TriggerTargetIoPin
- func (c *Adc) Version() HwVersion
- func (c *Adc) WaitForTigger() bool
- type AdcInterface
- type AdcSrc
- type AdcSrcTuple
- type Address
- type AddressBlock
- type AdvClkSettings
- type BaudRate
- type Capture
- type ClkGenInputSrc
- type DataBits
- type DcmInput
- type Fpga
- type FreqCounterSrc
- type FwVersion
- type GainMode
- type GpioMode
- type Hs2Mode
- type HwType
- type HwVersion
- type Memory
- type Parity
- type PtGen
- type Request
- type SimpleSerial
- type StopBits
- type TargetIoMode
- type Trace
- type TriggerMode
- type TriggerTargetIoPin
- type Usart
- type UsartConfig
- type UsartInterface
- type UsbDevice
- func (d *UsbDevice) Close() error
- func (d *UsbDevice) ControlIn(request Request, val uint16, data interface{}) error
- func (d *UsbDevice) ControlOut(request Request, val uint16, data interface{}) error
- func (d *UsbDevice) Read(p []byte) (n int, err error)
- func (d *UsbDevice) ReadFwVersion(ver *FwVersion) error
- func (d *UsbDevice) Write(buf []byte) (n int, err error)
- type UsbDeviceInterface
Constants ¶
This section is empty.
Variables ¶
var AdcSrcClkGenX1ViaDcm = AdcSrcTuple{ AdcSrcDcm, 1, DcmInputClkGen, }
var AdcSrcClkGenX4ViaDcm = AdcSrcTuple{ AdcSrcDcm, 4, DcmInputClkGen, }
var AdcSrcExtClkDirect = AdcSrcTuple{ AdcSrcExtClk, 4, DcmInputClkGen, }
Predefined ADC clock values
var AdcSrcExtClkX1ViaDcm = AdcSrcTuple{ AdcSrcDcm, 1, DcmInputExtClk, }
var AdcSrcExtClkX4ViaDcm = AdcSrcTuple{ AdcSrcDcm, 4, DcmInputExtClk, }
Functions ¶
This section is empty.
Types ¶
type Adc ¶
type Adc struct {
// contains filtered or unexported fields
}
func (*Adc) ActiveCount ¶
func (*Adc) AdcSampleRate ¶
ADC Sample Rate. Takes account of decimation factor (if set).
func (*Adc) ClkGenDcmLocked ¶
func (*Adc) ClkGenInputSource ¶
func (c *Adc) ClkGenInputSource() ClkGenInputSrc
func (*Adc) ClkGenOutputFreq ¶
func (*Adc) DownsampleFactor ¶
func (*Adc) ExtClockFreq ¶
func (*Adc) FreqCounter ¶
func (*Adc) FreqCounterSource ¶
func (c *Adc) FreqCounterSource() FreqCounterSrc
func (*Adc) MaxSamples ¶
func (*Adc) PreTriggerSamples ¶
func (*Adc) ProcessTraceData ¶
Converts encoded data samples to float measurements. Exported for testing.
func (*Adc) SetAdcClockSource ¶
func (c *Adc) SetAdcClockSource(src AdcSrcTuple)
func (*Adc) SetClkGenInputSource ¶
func (c *Adc) SetClkGenInputSource(src ClkGenInputSrc)
func (*Adc) SetClkGenOutputFreq ¶
func (*Adc) SetDownsampleFactor ¶
func (*Adc) SetExtClockFreq ¶
func (*Adc) SetFreqCounterSource ¶
func (c *Adc) SetFreqCounterSource(src FreqCounterSrc)
func (*Adc) SetGainMode ¶
func (*Adc) SetPreTriggerSamples ¶
func (*Adc) SetTargetIo1 ¶
func (c *Adc) SetTargetIo1(mode TargetIoMode)
func (*Adc) SetTargetIo2 ¶
func (c *Adc) SetTargetIo2(mode TargetIoMode)
func (*Adc) SetTotalSamples ¶
func (*Adc) SetTriggerMode ¶
func (c *Adc) SetTriggerMode(mode TriggerMode)
func (*Adc) SetTriggerOffset ¶
func (*Adc) SetTriggerTargetIoPin ¶
func (c *Adc) SetTriggerTargetIoPin(pin TriggerTargetIoPin)
func (*Adc) TargetIo2 ¶
func (c *Adc) TargetIo2() TargetIoMode
func (*Adc) TotalSamples ¶
func (*Adc) TriggerMode ¶
func (c *Adc) TriggerMode() TriggerMode
func (*Adc) TriggerOffset ¶
func (*Adc) TriggerTargetIoPins ¶
func (c *Adc) TriggerTargetIoPins() []TriggerTargetIoPin
TODO(cfir): add boolean operations support.
func (*Adc) WaitForTigger ¶
type AdcInterface ¶
type AdcInterface interface { io.Closer Error() error // // Hardware information. // Version() HwVersion SysFreq() uint32 MaxSamples() uint32 // // Gain settings. // GainMode() GainMode // Sets the AD8331 Low Noise Amplifier into to "High" or \"Low\" gain mode. // Low mode ranges from -4.5dB to +43.5dB, and High mode ranges from +7.5dB to +55.5dB. // Better performance is found using the "High" gain mode typically. SetGainMode(mode GainMode) Gain() uint8 // Sets the AD8331 gain value. // This is a unitless number which ranges from 0 (minimum) to 78 (maximum). // The resulting gain in dB is given in the "calculated" output. SetGain(gain uint8) // Gives the status of the digital signal being used as the trigger signal, // either high or low. TriggerPinState() bool // When using a digital system, sets the trigger mode: // =============== ============================== // Mode Description // =============== ============================== // Rising Edge Trigger on rising edge only. // Falling Edge Trigger on falling edge only. // Low Trigger when line is "low". // High Trigger when line is "high". // =============== ============================== // Note the "Trigger Mode" should be set to "Rising Edge" if using either // the "SAD Trigger" or "IO Trigger" modes. // If using STREAM mode (CW-Pro only), the trigger should use a rising or // falling edge. Using a constant level is possible, but normally requires // additional delay added via "offset" (see stream mode help for details). TriggerMode() TriggerMode SetTriggerMode(mode TriggerMode) // Delays this many samples after the trigger event before recording samples. // Based on the ADC clock cycles. If using a 4x mode for example, an offset of "1000" // would mean we skip 250 cycles of the target device. TriggerOffset() uint32 SetTriggerOffset(offset uint32) // Record a certain number of samples before the main samples are captured. // If "offset" is set to 0, this means recording samples BEFORE the trigger event. PreTriggerSamples() uint32 SetPreTriggerSamples(samples uint32) // Total number of samples to record. Note the capture system has an upper // limit. Older FPGA bitstreams had a lower limit of about 256 samples. // For the CW-Lite/Pro, the current lower limit is 128 samples due to interactions with // the SAD trigger module. TotalSamples() uint32 SetTotalSamples(samples uint32) // Downsamples incomming ADC data by throwing away the specified number of // samples between captures. Synchronous to the trigger so presample // mode is DISABLED when this value is greater than 1. DownsampleFactor() uint16 SetDownsampleFactor(factor uint16) // Measures number of ADC clock cycles during which the trigger was active. // If trigger toggles more than once this may not be valid.`, ActiveCount() uint32 // The ADC sample clock is generated from this source. // Options are either an external input (which input set elsewhere) or an internal // clock generator. Details of each option: // =================== ====================== =================== =============== // Name Description Input Freq Range Fine Phase Adj. // =================== ====================== =================== =============== // EXCLK Direct Connects sample clock 1-105 MHz NO // external pin directly. // EXTCLK xN via DCM Takes external pin, 5-105 MHz (x1) YES // multiplies frequency 5-26.25 MHz (x4) // xN and feeds to ADC. // CLKGEN xN via DCM Multiples CLKGEN by 5-105 MHz (x1) YES // xN and feeds to ADC. 5-26.25 MHz (x4) // =================== ====================== =================== =============== AdcClockSource() AdcSrcTuple SetAdcClockSource(src AdcSrcTuple) AdcFreq() uint32 // ADC Sample Rate. Takes account of decimation factor (if set). AdcSampleRate() uint32 DcmLocked() bool // Freq Counter: Frequency of clock measured on EXTCLOCK pin in Hz. FreqCounter() uint32 FreqCounterSource() FreqCounterSrc SetFreqCounterSource(src FreqCounterSrc) ClkGenInputSource() ClkGenInputSrc SetClkGenInputSource(src ClkGenInputSrc) // The input frequency from the EXTCLK source in Hz. // // This value is used to help calculate the correct CLKGEN settings to // obtain a desired output frequency when using EXTCLK as CLKGEN input. // It is not a frequency counter - it is only helpful if the EXTCLK // frequency is already known. // // Getter: Return the last set EXTCLK frequency in MHz (int) // // Setter: Update the EXTCLK frequency ExtClockFreq() uint32 SetExtClockFreq(freq uint32) // CLKGEN output frequency in Hz. // The CLKGEN module takes the input source and multiplies/divides it // to get a faster or slower clock as desired. // // Getter: // Return the current calculated CLKGEN output frequency in Hz // (float). Note that this is the theoretical frequency - use the // freq counter to determine the actual output. // // Setter: // Attempt to set a new CLKGEN frequency in Hz. When this value is // set, all possible DCM multiply/divide settings are tested to find // which is closest to the desired output speed. If EXTCLK is the // CLKGEN source, the EXTCLK frequency must be properly set for this // to work. Also, both DCMs are reset. ClkGenOutputFreq() uint32 SetClkGenOutputFreq(freq uint32) ClkGenDcmLocked() bool // The logical input into the trigger module. // // The trigger module uses some combination of the scope's I/O pins to // produce a single value, which it uses for edge/level detection or UART // triggers. This trigger output can combine 5 pins using one of 3 // different boolean operations. // TriggerTargetIoPins() []TriggerTargetIoPin SetTriggerTargetIoPin(pin TriggerTargetIoPin) // // GPIO settings. // // Thr function of the Target IO1 pin. TargetIo1() TargetIoMode SetTargetIo1(mode TargetIoMode) // Thr function of the Target IO2 pin. TargetIo2() TargetIoMode SetTargetIo2(mode TargetIoMode) // Special GPIO: NRST NRST() GpioMode SetNRST(mode GpioMode) // Special GPIO: PDIC PDIC() GpioMode SetPDIC(mode GpioMode) // Special GPIO: PDID PDID() GpioMode SetPDID(mode GpioMode) // The clock signal routed to the HS2 high speed output pin. Hs2() Hs2Mode SetHs2(mode Hs2Mode) // // Capture settings. // SetArmOn() SetArmOff() WaitForTigger() bool TraceData() []float64 }
type AdcSrcTuple ¶
type AddressBlock ¶
type AdvClkSettings ¶
type Capture ¶
type Capture []Trace
func NewCapture ¶
Captures a set traces. Retries on transient errors.
func (Capture) SamplesMatrix ¶
Collects all samples in a single m (#traces) by n (#samples) matrix.
_ _
| -- T1 -- | | -- T2 -- | | -- .. -- | | -- TM -- | |_ _|
type ClkGenInputSrc ¶
type ClkGenInputSrc int
const ( ClkGenInputSystem ClkGenInputSrc = iota ClkGenInputExtClk ClkGenInputSrc = iota )
type Fpga ¶
type Fpga struct { Mem *Memory // contains filtered or unexported fields }
func NewFpga ¶
func NewFpga(dev UsbDeviceInterface) (*Fpga, error)
func (*Fpga) IsProgrammed ¶
func (*Fpga) ProgramCwlite ¶
type FreqCounterSrc ¶
type FreqCounterSrc int
const ( FreqCounterExtClkInput FreqCounterSrc = iota FreqCounterClkGenOutput FreqCounterSrc = iota )
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
func NewMemory ¶
func NewMemory(dev UsbDeviceInterface) *Memory
type Request ¶
type Request uint8
const ( ReqMemReadBulk Request = 0x10 ReqMemWriteBulk Request = 0x11 ReqMemReadCtrl Request = 0x12 ReqMemWriteCtrl Request = 0x13 ReqFpgaStatus Request = 0x15 ReqFpgaProgram Request = 0x16 ReqFwVersion Request = 0x17 ReqUsart0Data Request = 0x1a ReqUsart0Config Request = 0x1b ReqXmegaProgram Request = 0x20 )
type SimpleSerial ¶
type SimpleSerial struct {
// contains filtered or unexported fields
}
func NewSimpleSerial ¶
func NewSimpleSerial(usart UsartInterface) (*SimpleSerial, error)
func (*SimpleSerial) ResponseLine ¶
func (s *SimpleSerial) ResponseLine() (string, error)
Reads response line.
func (*SimpleSerial) WriteKey ¶
func (s *SimpleSerial) WriteKey(k []byte) error
func (*SimpleSerial) WritePlaintext ¶
func (s *SimpleSerial) WritePlaintext(p []byte) error
type TargetIoMode ¶
type TargetIoMode int
const ( TargetIoModeSerialRx TargetIoMode = iota TargetIoModeSerialTx TargetIoMode = iota TargetIoModeHighZ TargetIoMode = iota TargetIoModeGpioLow TargetIoMode = iota TargetIoModeGpioHigh TargetIoMode = iota TargetIoModeGpioDisabled TargetIoMode = iota )
type TriggerMode ¶
type TriggerMode int
const ( TriggerModeRisingEdge TriggerMode = iota TriggerModeFallingEdge TriggerMode = iota TriggerModeLow TriggerMode = iota TriggerModeHigh TriggerMode = iota )
type TriggerTargetIoPin ¶
type TriggerTargetIoPin int
const ( TriggerTargetIoPin1 TriggerTargetIoPin = iota TriggerTargetIoPin2 TriggerTargetIoPin = iota TriggerTargetIoPin3 TriggerTargetIoPin = iota TriggerTargetIoPin4 TriggerTargetIoPin = iota )
type Usart ¶
type Usart struct {
// contains filtered or unexported fields
}
func NewUsart ¶
func NewUsart(dev UsbDeviceInterface, conf *UsartConfig) (*Usart, error)
func (*Usart) SetTimeout ¶
type UsartConfig ¶
Struct layout matches what cmdInit expects, so don't change this.
type UsartInterface ¶
type UsbDevice ¶
type UsbDevice struct {
// contains filtered or unexported fields
}
Encapsulates CW USB resources.
func OpenCwLiteUsbDevice ¶
func (*UsbDevice) ControlOut ¶
func (*UsbDevice) ReadFwVersion ¶
Reads CW capture firmware version.
type UsbDeviceInterface ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Captures target power traces to file.
|
Captures target power traces to file. |
stm32f
Programs a STM32 device using the NAEUSB firmware.
|
Programs a STM32 device using the NAEUSB firmware. |
xmega
Programs an XMEGA device using the NAEUSB firmware.
|
Programs an XMEGA device using the NAEUSB firmware. |