Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
ethercat_hardware::WGEeprom Class Reference

#include <wg_eeprom.h>

List of all members.

Public Member Functions

bool readEepromPage (EthercatCom *com, WGMailbox *mbx, unsigned page, void *data, unsigned length)
 Read data from single eeprom page.
 WGEeprom ()
bool writeEepromPage (EthercatCom *com, WGMailbox *mbx, unsigned page, const void *data, unsigned length)
 Write data to single eeprom page.

Protected Member Functions

bool readEepromStatusReg (EthercatCom *com, WGMailbox *mbx, EepromStatusReg &reg)
 Reads EEPROM status register.
bool readSpiEepromCmd (EthercatCom *com, WGMailbox *mbx, WG0XSpiEepromCmd &cmd)
 Reads SPI state machine command register.
bool sendSpiEepromCmd (EthercatCom *com, WGMailbox *mbx, const WG0XSpiEepromCmd &cmd)
 Sends command to SPI EEPROM state machine.
bool waitForEepromReady (EthercatCom *com, WGMailbox *mbx)
 Waits for EEPROM to become ready.
bool waitForSpiEepromReady (EthercatCom *com, WGMailbox *mbx)
 Waits for SPI eeprom state machine to be idle.

Protected Attributes

boost::mutex mutex_
 Only one eeprom transaction can occur at a time.

Static Protected Attributes

static const unsigned MAX_EEPROM_PAGE_SIZE = 264
static const unsigned NUM_EEPROM_PAGES = 4096

Detailed Description

Definition at line 48 of file wg_eeprom.h.


Constructor & Destructor Documentation

Definition at line 105 of file wg_eeprom.cpp.


Member Function Documentation

bool ethercat_hardware::WGEeprom::readEepromPage ( EthercatCom com,
WGMailbox mbx,
unsigned  page,
void *  data,
unsigned  length 
)

Read data from single eeprom page.

Data should be less than 264 bytes. Note that some eeproms only support 256 byte pages. If 264 bytes of data are read from a 256 byte eeprom, then last 8 bytes of data will be zeros. Function may block for extended periods of time (is not realtime safe).

Parameters:
comEtherCAT communication class used for communicating with device
mbxMailbox for used communication with device
pageEEPROM page number to read from. Should be 0 to 4095.
datapointer to data buffer
lengthlength of data in buffer
Returns:
true if there is success, false if there is an error

Definition at line 221 of file wg_eeprom.cpp.

Reads EEPROM status register.

Amoung other things, eeprom status register provide information about whether eeprom is busy performing a write.

Parameters:
comEtherCAT communication class used for communicating with device
regreference to EepromStatusReg struct where eeprom status will be stored
Returns:
true if there is success, false if there is an error

Definition at line 399 of file wg_eeprom.cpp.

bool ethercat_hardware::WGEeprom::readSpiEepromCmd ( EthercatCom com,
WGMailbox mbx,
WG0XSpiEepromCmd cmd 
) [protected]

Reads SPI state machine command register.

For communicating with EEPROM, there is a simple state machine that transfers data to/from FPGA buffer over SPI. When any type of comunication is done with EEPROM: 1. Write command or write data into FPGA buffer. 2. Have state machine start transfer bytes from buffer to EEPROM, and write data from EEPROM into buffer 3. Wait for state machine to complete (by reading its status) 4. Read EEPROM response from FPGA buffer.

Parameters:
comEtherCAT communication class used for communicating with device
regreference to WG0XSpiEepromCmd struct where read data will be stored
Returns:
true if there is success, false if there is an error

Definition at line 454 of file wg_eeprom.cpp.

bool ethercat_hardware::WGEeprom::sendSpiEepromCmd ( EthercatCom com,
WGMailbox mbx,
const WG0XSpiEepromCmd cmd 
) [protected]

Sends command to SPI EEPROM state machine.

This function makes sure SPI EEPROM state machine is idle before sending new command. It also waits for state machine to be idle before returning.

Parameters:
comEtherCAT communication class used for communicating with device
Returns:
true if command was send, false if there is an error

Definition at line 156 of file wg_eeprom.cpp.

Waits for EEPROM to become ready.

Certain eeprom operations (such as page reads), are complete immediately after data is trasferred. Other operations (such as page writes) take some amount of time after data is trasfered to complete. This polls the EEPROM status register until the 'ready' bit is set.

Parameters:
comEtherCAT communication class used for communicating with device
Returns:
true if there is success, false if there is an error or wait takes too long

Definition at line 357 of file wg_eeprom.cpp.

Waits for SPI eeprom state machine to be idle.

Polls busy SPI bit of SPI state machine.

Parameters:
comEtherCAT communication class used for communicating with device
Returns:
true if state machine is free, false if there is an error, or we timed out waiting

Definition at line 119 of file wg_eeprom.cpp.

bool ethercat_hardware::WGEeprom::writeEepromPage ( EthercatCom com,
WGMailbox mbx,
unsigned  page,
const void *  data,
unsigned  length 
)

Write data to single eeprom page.

Data should be less than 264 bytes. If data size is less than 264 bytes, then the page will be padded with 0xFF. Note that some eeproms only support 256 byte pages. With 256 byte eeproms, the eeprom FW with ingore last 8 bytes of requested write. Function may block for extended periods of time (is not realtime safe).

Parameters:
comEtherCAT communication class used for communicating with device
pageEEPROM page number to write to. Should be 0 to 4095.
datapointer to data buffer
lengthlength of data in buffer. If length < 264, eeprom page will be padded out to 264 bytes.
Returns:
true if there is success, false if there is an error

Definition at line 287 of file wg_eeprom.cpp.


Member Data Documentation

const unsigned ethercat_hardware::WGEeprom::MAX_EEPROM_PAGE_SIZE = 264 [static, protected]

Definition at line 57 of file wg_eeprom.h.

boost::mutex ethercat_hardware::WGEeprom::mutex_ [protected]

Only one eeprom transaction can occur at a time.

Definition at line 69 of file wg_eeprom.h.

const unsigned ethercat_hardware::WGEeprom::NUM_EEPROM_PAGES = 4096 [static, protected]

Definition at line 56 of file wg_eeprom.h.


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


ethercat_hardware
Author(s): Rob Wheeler , Derek King
autogenerated on Thu Jun 6 2019 19:46:33