#include <wg_eeprom.h>
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 ®) |
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 |
Definition at line 48 of file wg_eeprom.h.
Definition at line 105 of file wg_eeprom.cpp.
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).
com | EtherCAT communication class used for communicating with device |
mbx | Mailbox for used communication with device |
page | EEPROM page number to read from. Should be 0 to 4095. |
data | pointer to data buffer |
length | length of data in buffer |
Definition at line 221 of file wg_eeprom.cpp.
bool ethercat_hardware::WGEeprom::readEepromStatusReg | ( | EthercatCom * | com, |
WGMailbox * | mbx, | ||
EepromStatusReg & | reg | ||
) | [protected] |
Reads EEPROM status register.
Amoung other things, eeprom status register provide information about whether eeprom is busy performing a write.
com | EtherCAT communication class used for communicating with device |
reg | reference to EepromStatusReg struct where eeprom status will be stored |
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.
com | EtherCAT communication class used for communicating with device |
reg | reference to WG0XSpiEepromCmd struct where read data will be stored |
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.
com | EtherCAT communication class used for communicating with device |
Definition at line 156 of file wg_eeprom.cpp.
bool ethercat_hardware::WGEeprom::waitForEepromReady | ( | EthercatCom * | com, |
WGMailbox * | mbx | ||
) | [protected] |
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.
com | EtherCAT communication class used for communicating with device |
Definition at line 357 of file wg_eeprom.cpp.
bool ethercat_hardware::WGEeprom::waitForSpiEepromReady | ( | EthercatCom * | com, |
WGMailbox * | mbx | ||
) | [protected] |
Waits for SPI eeprom state machine to be idle.
Polls busy SPI bit of SPI state machine.
com | EtherCAT communication class used for communicating with device |
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).
com | EtherCAT communication class used for communicating with device |
page | EEPROM page number to write to. Should be 0 to 4095. |
data | pointer to data buffer |
length | length of data in buffer. If length < 264, eeprom page will be padded out to 264 bytes. |
Definition at line 287 of file wg_eeprom.cpp.
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.