ZMOD API
Public Member Functions | List of all members
ZMODADC1410 Class Reference
Inheritance diagram for ZMODADC1410:
ZMOD

Public Member Functions

 ZMODADC1410 (uintptr_t baseAddress, uintptr_t dmaAddress, uintptr_t iicAddress, uintptr_t flashAddress, int zmodInterrupt, int dmaInterrupt)
 
uint32_t * allocChannelsBuffer (size_t length)
 
void freeChannelsBuffer (uint32_t *buf, size_t length)
 
uint16_t channelData (uint8_t channel, uint32_t data)
 
int16_t signedChannelData (uint8_t channel, uint32_t data)
 
void setTransferLength (size_t length)
 
void setTrigger (uint8_t channel, uint8_t mode, int16_t level, uint8_t edge, uint32_t window)
 
void enableBufferFullInterrupt (uint8_t enBuffFullInt)
 
uint8_t isBufferFull ()
 
void waitForBufferFullPolling ()
 
void start ()
 
void stop ()
 
uint8_t acquireTriggeredPolling (uint32_t *buffer, uint8_t channel, uint32_t level, uint32_t edge, uint32_t window, size_t length)
 
uint8_t acquireImmediatePolling (uint32_t *buffer, size_t length)
 
uint8_t acquireTriggeredInterrupt (uint32_t *buffer, uint8_t channel, uint32_t level, uint32_t edge, uint32_t window, size_t length)
 
uint8_t acquireImmediateInterrupt (uint32_t *buffer, uint8_t channel, size_t length)
 
uint8_t autoTestRamp (uint8_t channel, uint32_t level, uint32_t edge, uint32_t window, size_t length)
 
void processInterrupt () override
 
void setGain (uint8_t channel, uint8_t gain)
 
void setCoupling (uint8_t channel, uint8_t coupling)
 
int32_t computeCoefMult (float cg, uint8_t gain)
 
int32_t computeCoefAdd (float ca, uint8_t gain)
 
virtual int readUserCalib ()
 
void setCalibValues (uint8_t channel, uint8_t gain, float valG, float valA)
 
float getVoltFromSignedRaw (int32_t raw, uint8_t gain)
 
- Public Member Functions inherited from ZMOD
 ZMOD (uintptr_t baseAddress, uintptr_t dmaAddress, uintptr_t iicAddress, uintptr_t flashAddress, enum dma_direction direction, int zmodInterrupt, int dmaInterrupt)
 
 ~ZMOD ()
 
void writeReg (uint8_t regAddr, uint32_t value)
 
void writeRegFld (uint8_t regAddr, uint8_t lsbBit, uint8_t noBits, uint32_t value)
 
uint32_t readReg (uint8_t regAddr)
 
uint32_t readRegFld (uint8_t regAddr, uint8_t lsbBit, uint8_t noBits)
 
void writeSignedRegFld (uint8_t regAddr, uint8_t lsbBit, uint8_t noBits, int32_t value)
 
int32_t readSignedRegFld (uint8_t regAddr, uint8_t lsbBit, uint8_t noBits)
 
void setTransferSize (size_t size)
 
int startDMATransfer (uint32_t *buffer)
 
bool isDMATransferComplete ()
 
void sendCommand (uint32_t command)
 
uint32_t receiveCommand ()
 
void sendCommands (uint32_t *commands, size_t length)
 
size_t receiveCommands (uint32_t *commands)
 
size_t sendReceiveCommands (uint32_t *sentCommands, uint32_t *receivedCommands, size_t length)
 
void writeUserCalib ()
 
int restoreFactoryCalib ()
 
void formatValue (char *dest, float val, const char *unit)
 

Additional Inherited Members

- Protected Member Functions inherited from ZMOD
int initCalib (uint32_t calibSize, uint8_t calibID, uint32_t userCalibAddr, uint32_t factCalibAddr)
 
void * allocDMABuffer (size_t size)
 
void freeDMABuffer (uint32_t *buf, size_t size)
 
uint8_t computeCRC (uint8_t *pData, uint32_t len)
 
int32_t toSigned (uint32_t value, uint8_t noBits)
 
- Protected Attributes inherited from ZMOD
uintptr_t baseAddr
 
uintptr_t dmaAddr
 
uintptr_t flashAddr
 
size_t transferSize
 
uint8_t * calib
 
uint32_t calibSize
 
uint16_t userCalibAddr
 
uint16_t factCalibAddr
 
uint8_t calibID
 
enum dma_direction direction
 

Constructor & Destructor Documentation

◆ ZMODADC1410()

ZMODADC1410::ZMODADC1410 ( uintptr_t  baseAddress,
uintptr_t  dmaAddress,
uintptr_t  iicAddress,
uintptr_t  flashAddress,
int  zmodInterrupt,
int  dmaInterrupt 
)

Initialize a ZMOD ADC1410 instance.

Parameters
baseAddrthe base address of the ZMOD device, can be found by either looking in the device tree files on a Linux platform, or the xparameters.h file on a baremetal platform, or in Vivado's Address Editor tab.
dmaAddrthe base address of the DMA device, can be found by either looking in the device tree files on a Linux platform, or the xparameters.h file on a baremetal platform, or in Vivado's Address Editor tab.
iicAddressthe base address of the I2C device used for flash, can be found by either looking in the device tree files on a Linux platform, or the xparameters.h file on a baremetal platform, or in Vivado's Address Editor tab.
flashAddressis the I2C slave address of the I2C device used for flash, can be found in the carrier board reference manual, associated to the SZG connector where the ZMpd is plugged,
directionthe direction of the DMA transfer, can be either DMA_DIRECTION_TX for a transfer from the processor to the FPGA, or DMA_DIRECTION_RX for a transfer from the FPGA to the processor.
zmodInterruptthe interrupt number of the ZMOD device, can be found by looking at the xparameters.h file on a baremental platform, and is irrelevant on a Linux platform.
dmaInterruptthe interrupt number of the DMA device, can be found by looking at the xparameters.h file on a baremental platform, and is irrelevant on a Linux platform.

Member Function Documentation

◆ acquireImmediateInterrupt()

uint8_t ZMODADC1410::acquireImmediateInterrupt ( uint32_t *  buffer,
uint8_t  channel,
size_t  length 
)

(Baremetal only) Acquire data using an interrupt method, will block until the acquisition completes.

Parameters
channelthe channel on which to run the data acquisition, 0 for channel 1, 1 for channel 2s
lengththe number of samples to be acquired
Returns
0 on success, any other number on failure

◆ acquireImmediatePolling()

uint8_t ZMODADC1410::acquireImmediatePolling ( uint32_t *  buffer,
size_t  length 
)

Acquire data using a polling method, will block until the acquisition completes.

Parameters
bufferthe buffer to receive the acquired data, must be previously allocated to a dimension large enough to accommodate the requested acquisition
lengththe number of samples to be acquired
Returns
0 on success, any other number on failure

◆ acquireTriggeredInterrupt()

uint8_t ZMODADC1410::acquireTriggeredInterrupt ( uint32_t *  buffer,
uint8_t  channel,
uint32_t  level,
uint32_t  edge,
uint32_t  window,
size_t  length 
)

(Baremetal only) Acquire data using an interrupt method, will block until the acquisition completes.

Parameters
bufferthe buffer to receive the acquired data, must be previously allocated to a dimension large enough to accommodate the requested acquisition
channelthe channel for which trigger is set: 0 for channel 1, 1 for channel 2
levelthe level on which to run the data acquisition, can be any valid 14bit unsigned number
edgethe trigger edge at which to run the data acquisition, 0 for rising edge, 1 for falling edge
windowthe window position at which to run the data acquisition, can be any unsigned number smaller than length
lengththe number of samples to be acquired
Returns
0 on success, any other number on failure

◆ acquireTriggeredPolling()

uint8_t ZMODADC1410::acquireTriggeredPolling ( uint32_t *  buffer,
uint8_t  channel,
uint32_t  level,
uint32_t  edge,
uint32_t  window,
size_t  length 
)

Acquire data using a polling method, will block until the acquisition completes.

Parameters
bufferthe buffer to receive the acquired data, must be previously allocated to a dimension large enough to accommodate the requested acquisition
channelthe channel for which trigger is set: 0 for channel 1, 1 for channel 2
levelthe level on which to run the data acquisition, can be any valid 14bit unsigned number
edgethe trigger edge at which to run the data acquisition, 0 for rising edge, 1 for falling edge
windowthe window position at which to run the data acquisition, can be any unsigned number smaller than length
lengththe number of samples to be acquired
Returns
0 on success, any other number on failure

◆ allocChannelsBuffer()

uint32_t * ZMODADC1410::allocChannelsBuffer ( size_t  length)

Allocates the data buffer used for AXI DMA transfers, 4 bytes for each element (sample).

Parameters
lengththe number of elements (samples) in the buffer.
Returns
the pointer to the allocated buffer

◆ autoTestRamp()

uint8_t ZMODADC1410::autoTestRamp ( uint8_t  channel,
uint32_t  level,
uint32_t  edge,
uint32_t  window,
size_t  length 
)

Performs an auto test in ramp mode. It puts the Analog to Digital converter in test mode ramp mode, then performs an acquisition according to the specified trigger parameters. Then it checks the acquired data to be consistent with the trigger parameters.

Parameters
channelthe channel for which trigger is set: 0 for channel 1, 1 for channel 2
levelthe level on which to run the data acquisition, can be any valid 14bit unsigned number
edgethe trigger edge at which to run the data acquisition, 0 for rising edge, 1 for falling edge
windowthe window position at which to run the data acquisition, can be any unsigned number smaller than length
lengththe number of samples to be acquired
Returns
the status: ERR_SUCCESS for success, ERR_FAIL if the acquired data does not match the expected data.

◆ channelData()

uint16_t ZMODADC1410::channelData ( uint8_t  channel,
uint32_t  data 
)

Extract channel data from a buffer element.

Parameters
channelthe channel to extract 0 for channel 1, 1 for channel 2
datathe buffer element from which to extract the channel data (32 bits)
Returns
the channel data (14 bits)

◆ computeCoefAdd()

int32_t ZMODADC1410::computeCoefAdd ( float  ca,
uint8_t  gain 
)

Computes the Additive calibration coefficient.

Parameters
ca- add coefficient as it is stored in Flash
gain0 LOW and 1 HIGH
Returns
a signed 32 value containing the additive coefficient in the 18 lsb bits: bit 17 sign, bit 16-0 the value

◆ computeCoefMult()

int32_t ZMODADC1410::computeCoefMult ( float  cg,
uint8_t  gain 
)

Computes the Multiplicative calibration coefficient.

Parameters
cg- gain coefficient as it is stored in Flash
gain0 LOW and 1 HIGH
Returns
a signed 32 value containing the multiplicative coefficient in the 18 lsb bits: bit 17 sign, bit 16-0 the value

◆ enableBufferFullInterrupt()

void ZMODADC1410::enableBufferFullInterrupt ( uint8_t  enBuffFullInt)

Enables / disables the buffer full ZMODADC1410 IP interrupt.

Parameters
lengththe length of the transfer in number of elements (samples) to be transfered

◆ freeChannelsBuffer()

void ZMODADC1410::freeChannelsBuffer ( uint32_t *  buf,
size_t  length 
)

Free the data buffer used for AXI DMA transfers, 4 bytes for each sample.

Parameters
bufthe address of the DMA buffer
lengththe number of samples in the buffer.

◆ getVoltFromSignedRaw()

float ZMODADC1410::getVoltFromSignedRaw ( int32_t  raw,
uint8_t  gain 
)

Converts a signed raw value (provided by ZmodADC1410 IP core) to a value in Volts measure unit.

Parameters
raw- the signed value as .
gain0 LOW and 1 HIGH
Returns
the Volts value.

◆ isBufferFull()

uint8_t ZMODADC1410::isBufferFull ( )

Check if the ZMODADC1410 buffer is full by reading the Buffer Full bit in Status Register.

Returns
true if the DMA transfer completed, false if it is still running

◆ processInterrupt()

void ZMODADC1410::processInterrupt ( )
overridevirtual

Call when a ZMOD interrupt occurs. For example when ZMOD's buffer full interrupt occurs, starts the DMA transfer.

Reimplemented from ZMOD.

◆ readUserCalib()

int ZMODADC1410::readUserCalib ( )
virtual

Reads the calibration data into the calib class member. It calls the readUserCalib from the ZMOD class level to read the user calibration data as an array of bytes into the area pointed by calib base class member. Then the calibration data is interpreted according to CALIBECLYPSEADC structure.

Returns
the status: ERR_SUCCESS for success, ERR_CALIB_ID for calib ID error, ERR_CALIB_CRC for CRC error, ERR_FAIL if calibration is not initialized.

Reimplemented from ZMOD.

◆ setCalibValues()

void ZMODADC1410::setCalibValues ( uint8_t  channel,
uint8_t  gain,
float  valG,
float  valA 
)

Set a pair of calibration values for a specific channel and gain into the calib area (interpreted as CALIBECLYPSEADC). In order for this change to be applied to user calibration area from flash, writeUserCalib function must be called.

Parameters
channelthe channel for which calibration values are set: 0 for channel 1, 1 for channel 2
gainthe gain for which calibration values are set: 0 for LOW gain, 1 for HIGH gain
valGthe gain calibration value to be set
valAthe additive calibration value to be set

◆ setCoupling()

void ZMODADC1410::setCoupling ( uint8_t  channel,
uint8_t  coupling 
)

Set the coupling for a channel.

Parameters
channelthe channel: 0 for DC Coupling, 1 for AC Coupling

◆ setGain()

void ZMODADC1410::setGain ( uint8_t  channel,
uint8_t  gain 
)

Set the gain for a channel.

Parameters
channelthe channel: 0 for channel 1, 1 for channel 2
gainthe gain : 0 for LOW gain, 1 for HIGH gain

◆ setTransferLength()

void ZMODADC1410::setTransferLength ( size_t  length)

Set the length of a transfer.

Parameters
lengththe length of the transfer in number of elements (samples) to be transfered

◆ setTrigger()

void ZMODADC1410::setTrigger ( uint8_t  channel,
uint8_t  mode,
int16_t  level,
uint8_t  edge,
uint32_t  window 
)

Set the trigger parameters of the data acquisition.

Parameters
channelthe trigger channel, 0 for channel 1, 1 for channel 2
modethe trigger mode for the data acquisition, 0 for normal trigger, 1 for not trigger
levelthe level on which to run the data acquisition, can be any valid 14bit unsigned number
edgethe trigger edge at which to run the data acquisition, 0 for rising edge, 1 for falling edge
windowthe window position at which to run the data acquisition
Todo:
change level to a 16bit unsigned number when hardware changes

◆ signedChannelData()

int16_t ZMODADC1410::signedChannelData ( uint8_t  channel,
uint32_t  data 
)

Extract signed channel data from a buffer element, making sure the most significant bit is taken into account.

Parameters
channelthe channel to extract 0 for channel 1, 1 for channel 2
datathe buffer element from which to extract the channel data (32 bits)
Returns
the signed channel data (14 bits)

◆ start()

void ZMODADC1410::start ( )

Start the ADC to acquire data according to previous acquisition settings.

◆ stop()

void ZMODADC1410::stop ( )

Stop the ADC acquisition process.

◆ waitForBufferFullPolling()

void ZMODADC1410::waitForBufferFullPolling ( )

Wait (by polling) until the ZMODADC1410 sets the Buffer Full bit in Status Register, will block until buffer full is set.


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