]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/include/can_sysdep.h
LinCAN driver updated to work on Real-Time Preemption enabled kernel.
[lincan.git] / lincan / include / can_sysdep.h
index 53e2ce1cde76dcde50420cc0987dce0499949c95..5a3b86cdd922a53a4d52f274416c9eb4800ef3fd 100644 (file)
@@ -16,6 +16,7 @@
 #include <rtl_core.h>
 #include <rtl_mutex.h>
 #include <rtl_sched.h>
+#include <time.h>
 #endif /*CAN_WITH_RTL*/
 
 /*#define __NO_VERSION__*/
 #define can_spin_unlock_irqrestore spin_unlock_irqrestore
 #define can_spin_lock_init         spin_lock_init
 
+#ifndef DEFINE_SPINLOCK
+#define CAN_DEFINE_SPINLOCK(x)     can_spinlock_t x = SPIN_LOCK_UNLOCKED
+#else /*DEFINE_SPINLOCK*/
+#define CAN_DEFINE_SPINLOCK        DEFINE_SPINLOCK
+#endif /*DEFINE_SPINLOCK*/
+
 #if defined(CONFIG_PREEMPT) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
 #define can_preempt_disable        preempt_disable
 #define can_preempt_enable         preempt_enable
 
 #define can_printk                 printk
 
+/* CAN message timestamp source, it is called from interrupt context */
+#define can_gettimeofday do_gettimeofday
+
 #else /*CAN_WITH_RTL*/
 
 #define can_spinlock_t             rtl_spinlock_t
 #define can_spin_unlock_irqrestore rtl_spin_unlock_irqrestore
 #define can_spin_lock_init         rtl_spin_lock_init
 
+#define CAN_DEFINE_SPINLOCK(x)     can_spinlock_t x = SPIN_LOCK_UNLOCKED
+
 #define can_preempt_disable()      do { } while (0)
 #define can_preempt_enable()       do { } while (0)
 
 
 extern can_spinlock_t can_irq_manipulation_lock;
 
+/* CAN message timestamp source, it is called from interrupt context */
+#define can_gettimeofday(ptr) do {\
+         struct timespec temp_timespec;\
+         clock_gettime(CLOCK_REALTIME,&temp_timespec);\
+         ptr->tv_usec=temp_timespec.tv_nsec/1000;\
+         ptr->tv_sec=temp_timespec.tv_sec;\
+       } while(0)
+
 #endif /*CAN_WITH_RTL*/
 
 #endif /*_CAN_SYSDEP_H*/