From: ppisa Date: Fri, 2 Jul 2004 00:26:41 +0000 (+0000) Subject: CPC-PCI second chip IRQ corrected. Message timestamp code added. X-Git-Tag: CLT_COMM_CAN-lincan-0_2_8~3 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/commitdiff_plain/3a2bb63f0bb8de2aafb346b53b945c59b3f87a41 CPC-PCI second chip IRQ corrected. Message timestamp code added. The timestamp code has some time overhead. If it is problem, it can be disabled in the main.h file. --- diff --git a/lincan/include/can_sysdep.h b/lincan/include/can_sysdep.h index 53e2ce1..50a87a2 100644 --- a/lincan/include/can_sysdep.h +++ b/lincan/include/can_sysdep.h @@ -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*/ diff --git a/lincan/include/main.h b/lincan/include/main.h index 4ef2b3e..4860694 100644 --- a/lincan/include/main.h +++ b/lincan/include/main.h @@ -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*/ diff --git a/lincan/src/c_can_irq.c b/lincan/src/c_can_irq.c index 29a85a4..d114336 100644 --- a/lincan/src/c_can_irq.c +++ b/lincan/src/c_can_irq.c @@ -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 diff --git a/lincan/src/ems_cpcpci.c b/lincan/src/ems_cpcpci.c index 9516263..603595d 100644 --- a/lincan/src/ems_cpcpci.c +++ b/lincan/src/ems_cpcpci.c @@ -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); diff --git a/lincan/src/i82527.c b/lincan/src/i82527.c index 443124a..682374a 100644 --- a/lincan/src/i82527.c +++ b/lincan/src/i82527.c @@ -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) diff --git a/lincan/src/sja1000.c b/lincan/src/sja1000.c index 5b549c4..d5f7b15 100644 --- a/lincan/src/sja1000.c +++ b/lincan/src/sja1000.c @@ -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); } diff --git a/lincan/src/sja1000p.c b/lincan/src/sja1000p.c index dc15154..3087db5 100644 --- a/lincan/src/sja1000p.c +++ b/lincan/src/sja1000p.c @@ -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); } diff --git a/lincan/src/virtual.c b/lincan/src/virtual.c index d51defe..b7e5f37 100644 --- a/lincan/src/virtual.c +++ b/lincan/src/virtual.c @@ -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"); }