]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
CPC-PCI second chip IRQ corrected. Message timestamp code added.
authorppisa <ppisa>
Fri, 2 Jul 2004 00:26:41 +0000 (00:26 +0000)
committerppisa <ppisa>
Fri, 2 Jul 2004 00:26:41 +0000 (00:26 +0000)
The timestamp code has some time overhead. If it is problem,
it can be disabled in the main.h file.

lincan/include/can_sysdep.h
lincan/include/main.h
lincan/src/c_can_irq.c
lincan/src/ems_cpcpci.c
lincan/src/i82527.c
lincan/src/sja1000.c
lincan/src/sja1000p.c
lincan/src/virtual.c

index 53e2ce1cde76dcde50420cc0987dce0499949c95..50a87a2c37e6e3259584191a5a675e18d02e315a 100644 (file)
@@ -203,4 +203,7 @@ extern can_spinlock_t can_irq_manipulation_lock;
 
 #endif /*CAN_WITH_RTL*/
 
+/* CAN message timestamp source, it is called from interrupt context */
+#define can_gettimeofday do_gettimeofday
+
 #endif /*_CAN_SYSDEP_H*/
index 4ef2b3e025aa1553d9a8a0925316812a1f990c08..4860694bab59f222b35c9f2b0205d1c0e9cb84cd 100644 (file)
@@ -480,6 +480,26 @@ const struct boardtype_t* boardtype_find(const char *str);
 
 int can_check_dev_taken(void *anydev);
 
+#if defined(can_gettimeofday) && defined(CAN_MSG_VERSION_2) && 1
+static inline
+void can_filltimestamp(canmsg_tstamp_t *ptimestamp)
+{
+       can_gettimeofday(ptimestamp);
+}
+#else /* No timestamp support, set field to zero */
+static inline
+void can_filltimestamp(canmsg_tstamp_t *ptimestamp)
+{
+    #ifdef CAN_MSG_VERSION_2
+       ptimestamp->tv_sec = 0;
+       ptimestamp->tv_usec = 0;
+    #else /* CAN_MSG_VERSION_2 */
+       *ptimestamp = 0;
+    #endif /* CAN_MSG_VERSION_2 */
+
+}
+#endif /* End of timestamp source selection */
+
 #ifdef CAN_WITH_RTL
 extern int can_rtl_priority;
 #endif /*CAN_WITH_RTL*/
index 29a85a4b4fa86c099cc95bba623516e7dbeb788d..d114336c68a1cca8b7606ce5ce194b8b2c909026 100644 (file)
@@ -52,6 +52,9 @@ inline void c_can_irq_write_handler( struct chip_t *pchip, int idxobj)
        if(pmsgobj->tx_slot){
                /* Do local transmitted message distribution if enabled */
                if (processlocal){
+                       /* fill CAN message timestamp */
+                       can_filltimestamp(&pmsgobj->tx_slot->msg.timestamp);
+
                        pmsgobj->tx_slot->msg.flags |= MSG_LOCAL;
                        canque_filter_msg2edges(pmsgobj->qends, &pmsgobj->tx_slot->msg);
                }
@@ -147,6 +150,9 @@ inline void c_can_irq_read_handler( struct chip_t *pchip,
                for ( i=0; i < pmsgobj->rx_msg.length; i++ )
                        DEBUGMSG(" data[%d] = 0x%.2x\n", i, pmsgobj->rx_msg.data[i]);
                
+               /* fill CAN message timestamp */
+               can_filltimestamp(&pmsgobj->rx_msg.timestamp);
+
                canque_filter_msg2edges(pmsgobj->qends, &pmsgobj->rx_msg);
            
            #ifdef CAN_WITH_STATISTICS
index 95162636f19dc7b77e49dcf4ff29acfcdada6889..603595db4d7f6c4ac342fcf381c119a0952c71d3 100644 (file)
@@ -197,7 +197,7 @@ can_irqreturn_t ems_cpcpci_irq_handler(int irq, void *dev_id, struct pt_regs *re
                        chip=candev->chip[i];
                        if(!chip || !(chip->flags&CHIP_CONFIGURED))
                                continue;
-                       sja1000p_irq_handler(irq, dev_id, regs);
+                       sja1000p_irq_handler(irq, chip, regs);
                }
                icr=readl(candev->dev_base_addr + PITA2_ICR);
        } while(icr & PITA2_ICR_INT0);
index 443124a6436987dd31636bcdd7f9d2350951ecbe..682374a39942d3fc191fdfbba5ccd1bdc47d68b2 100644 (file)
@@ -425,6 +425,9 @@ void i82527_irq_write_handler(struct chip_t *chip, struct msgobj_t *obj)
        if(obj->tx_slot){
                /* Do local transmitted message distribution if enabled */
                if (processlocal){
+                       /* fill CAN message timestamp */
+                       can_filltimestamp(&obj->tx_slot->msg.timestamp);
+
                        obj->tx_slot->msg.flags |= MSG_LOCAL;
                        canque_filter_msg2edges(obj->qends, &obj->tx_slot->msg);
                }
@@ -514,6 +517,9 @@ void i82527_irq_read_handler(struct chip_t *chip, struct msgobj_t *obj, int objn
                }
                
 
+               /* fill CAN message timestamp */
+               can_filltimestamp(&obj->rx_msg.timestamp);
+
                canque_filter_msg2edges(obj->qends, &obj->rx_msg);
                
                if (msgctl1 & NEWD_SET)
index 5b549c4d474ec226e9be14e2ba3e0949deb3127d..d5f7b1557864a2d5e027eb854d696c6a1b5eaed8 100644 (file)
@@ -387,12 +387,6 @@ void sja1000_irq_read_handler(struct chip_t *chip, struct msgobj_t *obj)
                id = can_read_reg(chip, SJARXID0) | (can_read_reg(chip, SJARXID1)<<8);
                obj->rx_msg.length = len = id & 0x0f;
                obj->rx_msg.flags = id&sjaID0_RTR ? MSG_RTR : 0;
-               #ifdef CAN_MSG_VERSION_2
-               obj->rx_msg.timestamp.tv_sec = 0;
-               obj->rx_msg.timestamp.tv_usec = 0;
-               #else /* CAN_MSG_VERSION_2 */
-               obj->rx_msg.timestamp = 0;
-               #endif /* CAN_MSG_VERSION_2 */
                obj->rx_msg.cob = 0;
                obj->rx_msg.id = id>>5;
 
@@ -402,6 +396,9 @@ void sja1000_irq_read_handler(struct chip_t *chip, struct msgobj_t *obj)
 
                can_write_reg(chip, sjaCMR_RRB, SJACMR);
 
+               /* fill CAN message timestamp */
+               can_filltimestamp(&obj->rx_msg.timestamp);
+
                canque_filter_msg2edges(obj->qends, &obj->rx_msg);
        } while(can_read_reg(chip, SJASR) & sjaSR_RBS);
 }
@@ -413,6 +410,9 @@ void sja1000_irq_write_handler(struct chip_t *chip, struct msgobj_t *obj)
        if(obj->tx_slot){
                /* Do local transmitted message distribution if enabled */
                if (processlocal){
+                       /* fill CAN message timestamp */
+                       can_filltimestamp(&obj->tx_slot->msg.timestamp);
+                       
                        obj->tx_slot->msg.flags |= MSG_LOCAL;
                        canque_filter_msg2edges(obj->qends, &obj->tx_slot->msg);
                }
index dc151540fa5e6ba08cdf7a1b018af9078b847870..3087db5d23690bb1fdbd178a49bb9a9149f3eec3 100644 (file)
@@ -267,6 +267,9 @@ void sja1000p_read(struct chip_t *chip, struct msgobj_t *obj) {
                        obj->rx_msg.data[i]=can_read_reg(chip,datastart+i);
                }
 
+               /* fill CAN message timestamp */
+               can_filltimestamp(&obj->rx_msg.timestamp);
+
                canque_filter_msg2edges(obj->qends, &obj->rx_msg);
 
                can_write_reg(chip, sjaCMR_RRB, SJACMR);
@@ -559,6 +562,9 @@ void sja1000p_irq_write_handler(struct chip_t *chip, struct msgobj_t *obj)
        if(obj->tx_slot){
                /* Do local transmitted message distribution if enabled */
                if (processlocal){
+                       /* fill CAN message timestamp */
+                       can_filltimestamp(&obj->tx_slot->msg.timestamp);
+                       
                        obj->tx_slot->msg.flags |= MSG_LOCAL;
                        canque_filter_msg2edges(obj->qends, &obj->tx_slot->msg);
                }
index d51defe561b4b592917d482f021747aaa923478c..b7e5f37a55c091628bff07d0d74139636ae1284f 100644 (file)
@@ -320,6 +320,9 @@ void virtual_do_tx_timeout(unsigned long data)
        struct msgobj_t *obj=(struct msgobj_t *)data;
        
        if(obj->tx_slot) {
+               /* fill CAN message timestamp */
+               can_filltimestamp(&obj->tx_slot->msg.timestamp);
+
                /* Deliver message to edges */
                canque_filter_msg2edges(obj->qends, &obj->tx_slot->msg);
                /* Free transmitted slot */
@@ -359,6 +362,9 @@ int virtual_wakeup_tx(struct chip_t *chip, struct msgobj_t *obj)
                /* Ensure delivery of all ready slots */
                while((cmd=canque_test_outslot(obj->qends, &qedge, &slot)) >= 0){
                        if(cmd==0) {
+                               /* fill CAN message timestamp */
+                               can_filltimestamp(&slot->msg.timestamp);
+                               
                                canque_filter_msg2edges(obj->qends, &slot->msg);
                                DEBUGMSG("virtual: direct delivery\n");
                        }