* Version lincan-0.2 9 Jul 2003
*/
-#define __NO_VERSION__
-#include <linux/module.h>
-
-#include <linux/autoconf.h>
-
-#include <linux/sched.h>
-#include <linux/fs.h>
-
+#include "../include/can.h"
+#include "../include/can_sysdep.h"
#include "../include/main.h"
#include "../include/i82527.h"
else
DEBUGMSG("Could read back, hardware is probably configured correctly\n");
- if (baudrate == 0)
- baudrate=1000;
+ if (chip->baudrate == 0)
+ chip->baudrate=1000000;
- if (i82527_baud_rate(chip,baudrate*1000,chip->clock,0,75,0)) {
+ if (i82527_baud_rate(chip,chip->baudrate,chip->clock,0,75,0)) {
CANMSG("Error configuring baud rate\n");
return -ENODEV;
}
struct canmsg_t *msg)
{
int i=0,id0=0,id1=0,id2=0,id3=0;
+ int len;
+
+ len = msg->length;
+ if(len > CAN_MSG_LENGTH) len = CAN_MSG_LENGTH;
canobj_write_reg(chip,obj,(RMPD_RES|TXRQ_RES|CPUU_SET|NEWD_RES),iMSGCTL1);
canobj_write_reg(chip,obj,(MVAL_SET|TXIE_SET|RXIE_RES|INTPD_RES),iMSGCTL0);
- if (extended) {
- canobj_write_reg(chip,obj,(msg->length<<4)+(MCFG_DIR|MCFG_XTD),iMSGCFG);
- }
- else {
- canobj_write_reg(chip,obj,(msg->length<<4)+MCFG_DIR,iMSGCFG);
- }
- if (extended) {
+
+ if (extended || (msg->flags&MSG_EXT)) {
+ canobj_write_reg(chip,obj,(len<<4)|(MCFG_DIR|MCFG_XTD),iMSGCFG);
id0 = (unsigned char) (msg->id<<3);
id1 = (unsigned char) (msg->id>>5);
id2 = (unsigned char) (msg->id>>13);
canobj_write_reg(chip,obj,id3,iMSGID0);
}
else {
+ canobj_write_reg(chip,obj,(len<<4)|MCFG_DIR,iMSGCFG);
id1 = (unsigned char) (msg->id<<5);
id0 = (unsigned char) (msg->id>>3);
canobj_write_reg(chip,obj,id1,iMSGID1);
canobj_write_reg(chip,obj,id0,iMSGID0);
}
canobj_write_reg(chip,obj,0xfa,iMSGCTL1);
- for (i=0; i<msg->length; i++) {
+ for (i=0; i<len; i++) {
canobj_write_reg(chip,obj,msg->data[i],iMSGDAT0+i);
}
canobj_write_reg(chip,obj,(MVAL_RES|TXIE_RES|RXIE_RES|INTPD_RES),+iMSGCTL0);
if(obj->tx_slot){
+ /* Do local transmitted message distribution if enabled */
+ if (processlocal){
+ obj->tx_slot->msg.flags |= MSG_LOCAL;
+ canque_filter_msg2edges(obj->qends, &obj->tx_slot->msg);
+ }
+ /* Free transmitted slot */
canque_free_outslot(obj->qends, obj->tx_qedge, obj->tx_slot);
obj->tx_slot=NULL;
}
inline void i82527_irq_read_handler(struct chip_t *chip, struct msgobj_t *obj,
unsigned long message_id)
{
- int i=0, tmp=1 ;
+ int i=0, tmp=1, len;
while (tmp) {
canobj_write_reg(chip,obj,(RMPD_RES|TXRQ_RES|MLST_RES|NEWD_RES),iMSGCTL1);
canobj_write_reg(chip,obj,(MVAL_SET|TXIE_RES|RXIE_SET|INTPD_RES),iMSGCTL0);
- obj->rx_msg.length =(canobj_read_reg(chip,obj,iMSGCFG) & 0xf0) >> 4;
+ len = (canobj_read_reg(chip,obj,iMSGCFG) >> 4) & 0xf;
+ obj->rx_msg.length = len;
obj->rx_msg.id = message_id;
+
+ if(len > CAN_MSG_LENGTH) len = CAN_MSG_LENGTH;
for (i=0; i < obj->rx_msg.length; i++)
obj->rx_msg.data[i] = canobj_read_reg(chip,obj,iMSGDAT0+i);
-//FIXME: Add buffer overflow check, currently it's silently over written!
-
canque_filter_msg2edges(obj->qends, &obj->rx_msg);
if (!((tmp=canobj_read_reg(chip,obj,iMSGCTL1)) & NEWD_SET)) {
spin_unlock(&hardware_p->rtr_lock);
if (waitqueue_active(&rtr_search->rtr_wq))
- wake_up_interruptible(&rtr_search->rtr_wq);
+ wake_up(&rtr_search->rtr_wq);
}
int i82527_wakeup_tx(struct chip_t *chip, struct msgobj_t *obj)