|
| | 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) |
| |
| virtual void | processInterrupt () |
| |
| virtual int | readUserCalib () |
| |
| void | writeUserCalib () |
| |
| int | restoreFactoryCalib () |
| |
| void | formatValue (char *dest, float val, const char *unit) |
| |
|
| 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) |
| |
|
|
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 |
| |
◆ ZMOD()
| ZMOD::ZMOD |
( |
uintptr_t |
baseAddress, |
|
|
uintptr_t |
dmaAddress, |
|
|
uintptr_t |
iicAddress, |
|
|
uintptr_t |
flashAddress, |
|
|
enum dma_direction |
direction, |
|
|
int |
zmodInterrupt, |
|
|
int |
dmaInterrupt |
|
) |
| |
ZMOD class constructor.
- Parameters
-
| baseAddr | the 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. |
| dmaAddr | the 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. |
| iicAddress | the 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. |
| flashAddress | is 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, |
| direction | the 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. |
| zmodInterrupt | the 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. |
| dmaInterrupt | the 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. |
◆ ~ZMOD()
ZMOD class destructor. Destroys hardware instances.
◆ allocDMABuffer()
| void * ZMOD::allocDMABuffer |
( |
size_t |
size | ) |
|
|
protected |
Allocate a DMA buffer.
- Parameters
-
| size | the size of the DMA buffer, in bytes |
- Returns
- the address of the DMA buffer
◆ computeCRC()
| uint8_t ZMOD::computeCRC |
( |
uint8_t * |
pData, |
|
|
uint32_t |
len |
|
) |
| |
|
protected |
Computes a one byte checksum of an array of bytes.
- Parameters
-
| pData | a pointer to an array of bytes |
| len | the length of the array |
◆ formatValue()
| void ZMOD::formatValue |
( |
char * |
dest, |
|
|
float |
val, |
|
|
const char * |
unit |
|
) |
| |
Formats a float value in a string, with (eventually) sign, integer part, (eventually) decimal point and 3 decimals and (eventually) measure unit.
- Parameters
-
| dest | - the string to receive the formatted value. Must be previously allocated large enough (13 chars) |
| val | - the value to be formatted |
| unit | - the string containing the measure unit. If NULL, no measure unit is added. |
◆ freeDMABuffer()
| void ZMOD::freeDMABuffer |
( |
uint32_t * |
buf, |
|
|
size_t |
size |
|
) |
| |
|
protected |
Free a DMA buffer.
- Parameters
-
| buf | the address of the DMA buffer |
| size | the size of the DMA buffer |
◆ initCalib()
| int ZMOD::initCalib |
( |
uint32_t |
calibSize, |
|
|
uint8_t |
calibID, |
|
|
uint32_t |
userCalibAddr, |
|
|
uint32_t |
factCalibAddr |
|
) |
| |
|
protected |
Initialize the calibration related data. It allocates the calib area as an array of bytes having the desired length. It also stores the calibration ID and the user and factory calibration flash addresses. In the end it reads the user calibration values by calling the Zmod specific (virtual) readUserCalib function.
- Parameters
-
| calibSize | the size of calibration data to be retrieved from Flash. |
| calibID | the ID of the calibration data. |
| userCalibAddr | the flash address of user calibration area. |
| factCalibAddr | the flash address of factory calibration area. |
- Returns
- the status: ERR_SUCCESS for success, ERR_FAIL for allocation error.
◆ isDMATransferComplete()
| bool ZMOD::isDMATransferComplete |
( |
| ) |
|
Check if the DMA transfer previously started has completed.
- Returns
- true if the DMA transfer completed, false if it is still running
◆ processInterrupt()
| void ZMOD::processInterrupt |
( |
| ) |
|
|
virtual |
Call when a ZMOD interrupt occurs. Implemented on the child class to implement child specific interrupts. On the ZMOD level it should contain potential ZMOD common fields interrupts (none defined yet).
Reimplemented in ZMODADC1410, and ZMODDAC1411.
◆ readReg()
| uint32_t ZMOD::readReg |
( |
uint8_t |
regAddr | ) |
|
Read a Zmod IP register.
- Parameters
-
| regAddr | the offset address of the register |
- Returns
- the value read from the register
This function returns the value read from a Zmod IP register, specified by its offset address.
◆ readRegFld()
| uint32_t ZMOD::readRegFld |
( |
uint8_t |
regAddr, |
|
|
uint8_t |
lsbBit, |
|
|
uint8_t |
noBits |
|
) |
| |
Read a Zmod IP register field. A Zmod IP register field is a number of contiguous bits inside a Zmod IP register.
- Parameters
-
| regAddr | the offset address of the register |
| lsbBit | the index of the first bit to write out of the register |
| noBits | the number of bits to write |
- Returns
- the value read from the register, will only be read from the bits starting at lsbBit (inclusive) and ending at lsbBit + noBits (exclusive)
◆ readSignedRegFld()
| int32_t ZMOD::readSignedRegFld |
( |
uint8_t |
regAddr, |
|
|
uint8_t |
lsbBit, |
|
|
uint8_t |
noBits |
|
) |
| |
Read a Zmod IP register field, providing the signed value. A Zmod IP register field is a number of contiguous bits inside a Zmod IP register.
- Parameters
-
| regAddr | the offset address of the register |
| lsbBit | the index of the first bit to write out of the register |
| noBits | the number of bits to write |
- Returns
- the signed value read from the register, will only be read from the bits starting at lsbBit (inclusive) and ending at lsbBit + noBits (exclusive)
◆ readUserCalib()
| int ZMOD::readUserCalib |
( |
| ) |
|
|
virtual |
Reads the calibration data into the bytes array pointed by calib class member. At the ZMOD class level, the calib area is regarded just as an array of bytes. The area pointed by calib must be already allocated by calling initCalib (normally called from the child class). This function expects and verifies that the first byte of the data retrieved from flash is the calib id, while the last byte is the checksum.
- Returns
- the status: ERR_SUCCESS for success, ERR_CALIB_ID for calib ID error, ERR_CALIB_CRC for CRC error.
Reimplemented in ZMODADC1410, and ZMODDAC1411.
◆ receiveCommand()
| uint32_t ZMOD::receiveCommand |
( |
| ) |
|
Receive a command from the underlying interface of the ZMOD.
- Returns
- the received command
◆ receiveCommands()
| size_t ZMOD::receiveCommands |
( |
uint32_t * |
commands | ) |
|
Receive multiple commands from the underlying interface of the ZMOD.
- Parameters
-
| commands | a pointer to an array to receive the commands in |
- Returns
- the number of received commands
◆ restoreFactoryCalib()
| int ZMOD::restoreFactoryCalib |
( |
| ) |
|
Restores the factory calibration data by reading it from factory calibration area into the area pointed by calib and writing it into the user calibration area.
◆ sendCommand()
| void ZMOD::sendCommand |
( |
uint32_t |
command | ) |
|
Send a command to the underlying interface of the ZMOD.
- Parameters
-
| command | the command to send |
◆ sendCommands()
| void ZMOD::sendCommands |
( |
uint32_t * |
commands, |
|
|
size_t |
length |
|
) |
| |
Send multiple commands to the underlying interface of the ZMOD.
- Parameters
-
| commands | a pointer to an array of commands to send |
| length | the length of the array |
◆ sendReceiveCommands()
| size_t ZMOD::sendReceiveCommands |
( |
uint32_t * |
sentCommands, |
|
|
uint32_t * |
receivedCommands, |
|
|
size_t |
sentCommandsLength |
|
) |
| |
Send and receive multiple commands to and from the underlying interface of the ZMOD.
- Parameters
-
| sentCommands | a pointer to an array of commands to send |
| receivedCommands | a pointer to an array to receive the commands in |
| sentCommandsLength | the length of the array |
◆ setTransferSize()
| void ZMOD::setTransferSize |
( |
size_t |
size | ) |
|
Set the length (in bytes) of a transfer.
- Parameters
-
| length | the length of the transfer in number of bytes to be transfered |
◆ startDMATransfer()
| int ZMOD::startDMATransfer |
( |
uint32_t * |
buffer | ) |
|
Start a DMA transfer using the transfer length configured previously.
- Returns
- 0 on success, any other number on failure
◆ toSigned()
| int32_t ZMOD::toSigned |
( |
uint32_t |
value, |
|
|
uint8_t |
noBits |
|
) |
| |
|
protected |
Converts an unsigned value represented on a number of bits (the most lsb bits) to a signed value.
- Parameters
-
| value | - the value containing on its most lsb bits the value that must be interpreted as signed. |
| noBits | - the number of bits to be interpreted. |
◆ writeReg()
| void ZMOD::writeReg |
( |
uint8_t |
regAddr, |
|
|
uint32_t |
value |
|
) |
| |
Write a Zmod IP register.
- Parameters
-
| regAddr | the offset address of the register |
| value | the value to write in the register |
This function writes a value to a Zmod IP register, specified by its offset address.
◆ writeRegFld()
| void ZMOD::writeRegFld |
( |
uint8_t |
regAddr, |
|
|
uint8_t |
lsbBit, |
|
|
uint8_t |
noBits, |
|
|
uint32_t |
value |
|
) |
| |
Write a value to a Zmod IP register field. A Zmod IP register field is a number of contiguous bits inside a Zmod IP register.
- Parameters
-
| regAddr | the offset address of the register |
| lsbBit | the index of the first bit to write out of the register |
| noBits | the number of bits to write |
| value | the unsigned value to write in the register, will only be written to the bits starting at lsbBit (inclusive) and ending at lsbBit + noBits (exclusive) |
◆ writeSignedRegFld()
| void ZMOD::writeSignedRegFld |
( |
uint8_t |
regAddr, |
|
|
uint8_t |
lsbBit, |
|
|
uint8_t |
noBits, |
|
|
int32_t |
value |
|
) |
| |
Write a Zmod IP register field with the signed value. A Zmod IP register field is a number of contiguous bits inside a Zmod IP register.
- Parameters
-
| regAddr | the offset address of the register |
| lsbBit | the index of the first bit to write out of the register |
| noBits | the number of bits to write |
| value | the signed value to write in the register, will only be written to the bits starting at lsbBit (inclusive) and ending at lsbBit + noBits (exclusive) |
◆ writeUserCalib()
| void ZMOD::writeUserCalib |
( |
| ) |
|
Writes the calibration data from the area pointed by calib member into the user calibration area. At the ZMOD class level, the calib area is regarded just as an array of bytes. The area pointed by calib must be already allocated by calling initCalib (normally called from the child class). Before writing it fills the first byte of the calib area with the calibration ID and the last byte of the calib area with the checksum of all but the last byte of the calib area.
The documentation for this class was generated from the following files: