Go to the documentation of this file.
38 #include <boost/static_assert.hpp>
39 #include <boost/thread/mutex.hpp>
40 #include <boost/thread.hpp>
46 struct WG0XSpiEepromCmd
63 this->page_ = page & 0xffff;
69 this->page_ = page & 0xffff;
75 this->page_ = (
length-1) & 0xffff;
90 struct EepromStatusReg
132 ROS_ERROR(
"Error reading SPI Eeprom Cmd busy bit");
142 }
while (tries <= 10);
144 ROS_ERROR(
"Timed out waiting for SPI state machine to be idle (%d)", tries);
168 ROS_ERROR(
"Error writing SPI EEPROM command");
184 if (stat.operation_ !=
cmd.operation_)
186 ROS_ERROR(
"Invalid readback of SPI EEPROM operation : got 0x%X, expected 0x%X\n", stat.operation_,
cmd.operation_);
195 ROS_WARN(
"Eeprom state machine took %d cycles", tries);
200 fprintf(stderr,
"eeprom busy reading again, waiting...\n");
202 }
while (++tries < 10);
204 ROS_ERROR(
"Eeprom SPI state machine busy after %d cycles", tries);
225 boost::lock_guard<boost::mutex> lock(
mutex_);
245 ROS_ERROR(
"Error zeroing eeprom data buffer");
252 WG0XSpiEepromCmd
cmd;
253 memset(&cmd,0,
sizeof(cmd));
254 cmd.build_read(page);
257 ROS_ERROR(
"Error sending SPI read command");
267 ROS_ERROR(
"Error reading eeprom data from buffer");
291 boost::lock_guard<boost::mutex> lock(
mutex_);
311 const void *write_buf =
data;
317 memcpy(buf, data,
length);
325 ROS_ERROR(
"Write of SPI EEPROM buffer failed");
331 cmd.build_write(page);
334 ROS_ERROR(
"Error giving SPI EEPROM write command");
363 EepromStatusReg status_reg;
369 if (status_reg.ready_)
374 }
while (++tries < 20);
376 if (!status_reg.ready_)
378 ROS_ERROR(
"Eeprom still busy after %d cycles", tries);
384 ROS_WARN(
"EEPROM took %d cycles to be ready", tries);
410 unsigned char data[2] = {0xD7, 0x00};
411 BOOST_STATIC_ASSERT(
sizeof(data) == 2);
419 WG0XSpiEepromCmd
cmd;
420 cmd.build_arbitrary(
sizeof(data));
423 ROS_ERROR(
"Sending SPI abitrary command");
431 ROS_ERROR(
"Reading status register data from SPI buffer");
458 BOOST_STATIC_ASSERT(
sizeof(WG0XSpiEepromCmd) == 3);
461 ROS_ERROR(
"Reading SPI command register with mailbox");
static const unsigned SPI_ARBITRARY_OP
bool readSpiEepromCmd(EthercatCom *com, WGMailbox *mbx, WG0XSpiEepromCmd &cmd)
Reads SPI state machine command register.
void build_arbitrary(unsigned length)
union ethercat_hardware::EepromStatusReg::@57 __attribute__((__packed__))
union ethercat_hardware::WG0XSpiEepromCmd::@53 __attribute__
boost::mutex mutex_
Only one eeprom transaction can occur at a time.
bool sendSpiEepromCmd(EthercatCom *com, WGMailbox *mbx, const WG0XSpiEepromCmd &cmd)
Sends command to SPI EEPROM state machine.
static const unsigned MAX_EEPROM_PAGE_SIZE
bool readEepromStatusReg(EthercatCom *com, WGMailbox *mbx, EepromStatusReg ®)
Reads EEPROM status register.
void build_write(unsigned page)
static const unsigned SPI_BUFFER_ADDR
bool waitForEepromReady(EthercatCom *com, WGMailbox *mbx)
Waits for EEPROM to become ready.
int writeMailbox(EthercatCom *com, unsigned address, void const *data, unsigned length)
Write data to WG0X local bus using mailbox communication.
static const unsigned SPI_COMMAND_ADDR
void build_read(unsigned page)
ethercat_hardware::MotorHeatingModelCommon __attribute__
bool waitForSpiEepromReady(EthercatCom *com, WGMailbox *mbx)
Waits for SPI eeprom state machine to be idle.
bool writeEepromPage(EthercatCom *com, WGMailbox *mbx, unsigned page, const void *data, unsigned length)
Write data to single eeprom page.
static const unsigned SPI_READ_OP
static const unsigned NUM_EEPROM_PAGES
static const unsigned SPI_WRITE_OP
bool readEepromPage(EthercatCom *com, WGMailbox *mbx, unsigned page, void *data, unsigned length)
Read data from single eeprom page.
ethercat_hardware
Author(s): Rob Wheeler
, Derek King
autogenerated on Thu Sep 26 2024 02:44:04