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

Public Member Functions

 ZMODDAC1411 (uintptr_t baseAddress, uintptr_t dmaAddress, uintptr_t iicAddress, uintptr_t flashAddress, int dmaInterrupt)
 
uint32_t * allocChannelsBuffer (size_t length)
 
void freeChannelsBuffer (uint32_t *buf, size_t length)
 
uint32_t arrangeChannelData (uint8_t channel, uint16_t data)
 
uint32_t arrangeSignedChannelData (uint8_t channel, int16_t data)
 
void setOutputSampleFrequencyDivider (uint16_t val)
 
uint8_t setData (uint32_t *buffer, size_t length)
 
void setGain (uint8_t channel, uint8_t gain)
 
void start ()
 
void stop ()
 
void resetOutputCounter ()
 
void processInterrupt () override
 
int32_t computeCoefMult (float cg, uint8_t gain)
 
int32_t computeCoefAdd (float ca, float cg, uint8_t gain)
 
int readUserCalib () override
 
void setCalibValues (uint8_t channel, uint8_t gain, float valG, float valA)
 
int32_t getSignedRawFromVolt (float voltValue, 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

◆ ZMODDAC1411()

ZMODDAC1411::ZMODDAC1411 ( uintptr_t  baseAddress,
uintptr_t  dmaAddress,
uintptr_t  iicAddress,
uintptr_t  flashAddress,
int  dmaInterrupt 
)

Initialize a ZMOD DAC1411 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

◆ allocChannelsBuffer()

uint32_t * ZMODDAC1411::allocChannelsBuffer ( size_t  length)

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

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

◆ arrangeChannelData()

uint32_t ZMODDAC1411::arrangeChannelData ( uint8_t  channel,
uint16_t  data 
)

Position the channel data in a 32 bits value to be sent to IP.

Parameters
channelthe channel to extract 0 for channel A, 1 for channel B
datathe unsigned channel data (14 bits)
Returns
the 32 bits value containing the channel data on the proper position

◆ arrangeSignedChannelData()

uint32_t ZMODDAC1411::arrangeSignedChannelData ( uint8_t  channel,
int16_t  data 
)

Position the channel data in a 32 bits value to be sent to IP.

Parameters
channelthe channel to extract 0 for channel A, 1 for channel B
datathe signed channel data (14 bits)
Returns
the 32 bits value containing the channel data on the proper position

◆ computeCoefAdd()

int32_t ZMODDAC1411::computeCoefAdd ( float  ca,
float  cg,
uint8_t  gain 
)

Computes the Additive calibration coefficient.

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

◆ computeCoefMult()

int32_t ZMODDAC1411::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 coef. in the 18 lsb bits: bit 17 sign, bit 16-0 the value

◆ freeChannelsBuffer()

void ZMODDAC1411::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.

◆ getSignedRawFromVolt()

int32_t ZMODDAC1411::getSignedRawFromVolt ( float  voltValue,
uint8_t  gain 
)

Converts a value in Volts measure unit into a signed raw value (to be provided to the ZmodDAC1411 IP core). If the value is outside the range corresponding to the specified gain, it is limited to the nearest range limit.

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

◆ processInterrupt()

void ZMODDAC1411::processInterrupt ( )
overridevirtual

Call when a ZMOD interrupt occurs.

Reimplemented from ZMOD.

◆ readUserCalib()

int ZMODDAC1411::readUserCalib ( )
overridevirtual

Reads the calibration data into the calib class member. It calls the ZMOD At 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 CALIBECLYPSEDAC 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.

◆ resetOutputCounter()

void ZMODDAC1411::resetOutputCounter ( )

Reset the output counter so that the next time the instrument is started the first value from the buffer will be sent to DAC.

◆ setData()

uint8_t ZMODDAC1411::setData ( uint32_t *  buffer,
size_t  length 
)

Send to the IP the data to be generated by DAC.

Parameters
bufferthe buffer containing the data to be sent to DAC, must be previously allocated and filled with data.
lengththe number of values from buffer to be used.
Returns
0 on success, any other number on failure

◆ setGain()

void ZMODDAC1411::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

◆ setOutputSampleFrequencyDivider()

void ZMODDAC1411::setOutputSampleFrequencyDivider ( uint16_t  val)

Set the 14 bits output sample frequency divider.

◆ start()

void ZMODDAC1411::start ( )

Start the DAC to generate the values previously prepared.

◆ stop()

void ZMODDAC1411::stop ( )

Stop the DAC.


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