drivers/ec_device.c
changeset 2 b0a7a4745bf9
parent 0 05c992bf5847
child 5 6f2508af550c
equal deleted inserted replaced
1:98acc19c7594 2:b0a7a4745bf9
    11 
    11 
    12 #include <linux/skbuff.h>
    12 #include <linux/skbuff.h>
    13 #include <linux/if_ether.h>
    13 #include <linux/if_ether.h>
    14 #include <linux/netdevice.h>
    14 #include <linux/netdevice.h>
    15 #include <rtai.h>
    15 #include <rtai.h>
       
    16 #include <linux/delay.h>
    16 
    17 
    17 #include "ec_device.h"
    18 #include "ec_device.h"
    18 #include "ec_dbg.h"
    19 #include "ec_dbg.h"
    19 
    20 
    20 /***************************************************************/
    21 /***************************************************************/
   235   rdtscl(ecd->tx_time); // Get CPU cycles
   236   rdtscl(ecd->tx_time); // Get CPU cycles
   236 
   237 
   237   // Start sending of frame
   238   // Start sending of frame
   238   ecd->state = ECAT_DS_SENT;
   239   ecd->state = ECAT_DS_SENT;
   239   ecd->dev->hard_start_xmit(ecd->tx_skb, ecd->dev);
   240   ecd->dev->hard_start_xmit(ecd->tx_skb, ecd->dev);
   240   
   241 
   241   return 0;
   242   return 0;
   242 }
   243 }
   243 
   244 
   244 /***************************************************************/
   245 /***************************************************************/
   245 
   246 
   261 int EtherCAT_device_receive(EtherCAT_device_t *ecd, 
   262 int EtherCAT_device_receive(EtherCAT_device_t *ecd, 
   262                             unsigned char *data,
   263                             unsigned char *data,
   263                             unsigned int size)
   264                             unsigned int size)
   264 {
   265 {
   265   int cnt;
   266   int cnt;
   266 //  unsigned long flags;
   267 
   267   
       
   268   if (ecd->state != ECAT_DS_RECEIVED)
   268   if (ecd->state != ECAT_DS_RECEIVED)
   269   {
   269   {
   270     EC_DBG(KERN_ERR "EtherCAT: receive - Nothing received!\n");
   270     EC_DBG(KERN_ERR "EtherCAT: receive - Nothing received!\n");
   271     return -1;
   271     return -1;
   272   }
   272   }
   273     
       
   274 //  flags = rt_spin_lock_irqsave(ecd->lock);
       
   275 
   273 
   276   cnt = min(ecd->rx_data_length, size);
   274   cnt = min(ecd->rx_data_length, size);
   277   memcpy(data,ecd->rx_data, cnt);
   275   memcpy(data,ecd->rx_data, cnt);
   278 
       
   279 //  rt_spin_unlock_irqrestore(ecd->lock, flags);
       
   280 
   276 
   281   return cnt;
   277   return cnt;
   282 }
   278 }
   283 
   279 
   284 /***************************************************************/
   280 /***************************************************************/