X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/6234a9dc385e5a9258a84227b2eab09bbb099c27..c3d4c4186b0821e4d436df8d6502c37c7ac62a5c:/lincan/src/c_can.c diff --git a/lincan/src/c_can.c b/lincan/src/c_can.c index 9929467..cddac82 100644 --- a/lincan/src/c_can.c +++ b/lincan/src/c_can.c @@ -96,10 +96,10 @@ int c_can_chip_config(struct canchip_t *pchip) return -1; if (pchip->baudrate == 0) - pchip->baudrate = 1000; + pchip->baudrate = 1000000; if (c_can_baud_rate - (pchip, pchip->baudrate * 1000, pchip->clock, 0, 75, 0)) { + (pchip, pchip->baudrate, pchip->clock, 0, 75, 0)) { CANMSG("Error configuring baud rate\n"); return -ENODEV; } @@ -143,8 +143,8 @@ int c_can_if1_busycheck(struct canchip_t *pchip) unsigned short comreg = 0; comreg = c_can_read_reg_w(pchip, CCIF1CR); - while ((comreg & IFXCR_BUSY) && (i <= 10)) { - udelay(100); //100 microseconds + while ((comreg & IFXCR_BUSY) && (i <= 100)) { + udelay(1); //1 microseconds i++; comreg = c_can_read_reg_w(pchip, CCIF1CR); } @@ -167,8 +167,8 @@ int c_can_if2_busycheck(struct canchip_t *pchip) unsigned short comreg = 0; comreg = c_can_read_reg_w(pchip, CCIF2CR); - while ((comreg & IFXCR_BUSY) && (i <= 10)) { - udelay(100); //100 microseconds + while ((comreg & IFXCR_BUSY) && (i <= 100)) { + udelay(1); //1 microseconds i++; comreg = c_can_read_reg_w(pchip, CCIF2CR); } @@ -296,6 +296,11 @@ int c_can_mask(struct msgobj_t *pmsgobj, u32 mask, u16 usedirbit) if (c_can_if1_busycheck(pmsgobj->hostchip)) return -ENODEV; + //set indication, that mask is used + tempreg = c_can_read_reg_w(pmsgobj->hostchip, CCIF1DMC); + c_can_write_reg_w(pmsgobj->hostchip, tempreg | IFXMC_UMASK, + CCIF1DMC); + //writing acceptance mask for extended or standart mode if (can_msgobj_test_fl(pmsgobj, RX_MODE_EXT)) { if (usedirbit) @@ -317,6 +322,7 @@ int c_can_mask(struct msgobj_t *pmsgobj, u32 mask, u16 usedirbit) ((mask << 2) & 0x1FFC), CCIF1M2); c_can_write_reg_w(pmsgobj->hostchip, 0, CCIF1M1); } + //seting Message Valid Bit to one tempreg = c_can_read_reg_w(pmsgobj->hostchip, CCIF1A2); c_can_write_reg_w(pmsgobj->hostchip, tempreg | IFXARB2_MVAL, CCIF1A2);