An Mbed library for an EtherCAT Arduino Shield developed by Esmacat to connect the larger Arduino ecosystem and other MCU boards capable of connecting a shield with an Arduino Uno form factor. EASE can easily turn an MCU board, including the Arduino ecosystem, into a cost-efficient EtherCAT slave subsystem in the larger EtherCAT system. Using EtherCAT communication, EASE can reliably communicate with other base boards through an EtherCAT master.

Information about Esmacat and EASE is provided in the link below. https://os.mbed.com/users/esmacat/code/EASE_Example/wiki/Homepage

Revision:
0:4a9e3331b131
Child:
1:b66c3e4ce9f5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EsmacatShield.cpp	Wed Jan 29 19:27:19 2020 +0000
@@ -0,0 +1,81 @@
+#include "EsmacatShield.h"
+
+EsmacatShield::EsmacatShield(SPI &spi, DigitalOut &pin):ecat_spi(spi),ecat_cs(pin) 
+{
+     
+}
+
+void EsmacatShield::setup_spi()
+{
+    /*Chip must be deselected*/
+    ecat_cs = 1;
+
+  /*Setup the spi for 8 bit data, Mode 1,
+    with a 3MHz clock rate*/
+    ecat_spi.format(8,1);
+    ecat_spi.frequency(3000000);
+    
+    /* Chip must be selected*/
+    ecat_cs = 0;
+
+}
+
+
+void EsmacatShield::write_reg_value(int write_addr,int value, bool led_on)
+{
+  uint8_t v1,v2;
+  // Chip must be selected
+  ecat_cs = 0;
+  wait_us(2000);                       //sleep for 2 ms;
+  write_addr = write_addr <<3;
+  if (led_on)
+  {
+    ecat_spi.write(((EASE_WRITE_REG|write_addr)| EASE_LED_ON)& EASE_SINGLE_SHOT);
+  }
+  else
+  {
+    ecat_spi.write((EASE_WRITE_REG|write_addr)& EASE_LED_OFF & EASE_SINGLE_SHOT); 
+  }
+  v1 = (value&0xFF00) >> 8;
+  v2 = (value&0x00FF);
+  ecat_spi.write(v1);
+  ecat_spi.write(v2);
+  // Chip must be deselected
+  ecat_cs = 1;
+  wait_us(2000);                       //sleep for 2 ms;
+}
+
+int* EsmacatShield::get_ecat_registers(int regs[8]) {
+  regs[0] = read_reg_value(1);
+  regs[1] = read_reg_value(2);
+  regs[2] = read_reg_value(3);
+  regs[3] = read_reg_value(4);
+  regs[4] = read_reg_value(5);
+  regs[5] = read_reg_value(6);
+  regs[6] = read_reg_value(7);
+  regs[7] = read_reg_value(0);
+  return(regs);
+}
+
+int EsmacatShield::read_reg_value(int read_addr)
+{
+  uint16_t v2,v3;
+  // Chip must be selected
+  ecat_cs = 0;
+  wait_us(2000);                       //sleep for 2 ms;
+  read_addr = read_addr <<3;
+  ecat_spi.write( EASE_READ_REG|read_addr);
+  v2 = ecat_spi.write(0x00);
+  v3 = ecat_spi.write(0x00);
+  // Chip must be deselected
+  ecat_cs = 1;
+  wait_us(2000);                      //sleep for 2 ms;
+
+  return (v2<<8)+v3;
+}
+
+EsmacatShield::~EsmacatShield(void) 
+{
+  //empty block
+}
+