From cda66615116012b01fca5dd16d907b5490aef3f5 Mon Sep 17 00:00:00 2001 From: ppisa Date: Wed, 1 Jun 2005 18:22:12 +0000 Subject: [PATCH] Some more C_CAN changes --- lincan/src/c_can.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lincan/src/c_can.c b/lincan/src/c_can.c index e51181b..a0503b4 100644 --- a/lincan/src/c_can.c +++ b/lincan/src/c_can.c @@ -484,18 +484,26 @@ int c_can_pre_read_config(struct canchip_t *pchip, struct msgobj_t *pmsgobj) spin_lock( &c_can_if1lock ); - //loading Message Object in IF1 - if (c_can_if1_busycheck(pmsgobj->hostchip)) return -ENODEV; + if (c_can_if1_busycheck(pmsgobj->hostchip)) + goto error_enodev; + c_can_write_reg_w(pmsgobj->hostchip, readMaskCM, CCIF1CM); c_can_write_reg_w(pmsgobj->hostchip, pmsgobj->object, CCIF1CR); + //setting Message Valid Bit to zero - if (c_can_if1_busycheck(pmsgobj->hostchip)) return -ENODEV; + if (c_can_if1_busycheck(pmsgobj->hostchip)) + goto error_enodev; + c_can_write_reg_w(pmsgobj->hostchip, 0, CCIF1A2); c_can_write_reg_w(pmsgobj->hostchip, writeMaskCM, CCIF1CM); c_can_write_reg_w(pmsgobj->hostchip, pmsgobj->object, CCIF1CR); + //Configuring Message-Object - if (c_can_if1_busycheck(pmsgobj->hostchip)) return -ENODEV; + /* Only access when the C_CAN controller is idle */ + if (c_can_if1_busycheck(pmsgobj->hostchip)) + goto error_enodev; + mcreg = c_can_read_reg_w(pmsgobj->hostchip, CCIF1CM); c_can_write_reg_w(pmsgobj->hostchip, ((mcreg & IFXMC_UMASK) | IFXMC_EOB | IFXMC_RXIE), CCIF1DMC); @@ -524,6 +532,12 @@ int c_can_pre_read_config(struct canchip_t *pchip, struct msgobj_t *pmsgobj) #endif return 0; + +error_enodev: + CANMSG("Timeout in c_can_if1_busycheck\n"); + spin_unlock(&c_can_if1lock); + return -ENODEV; + } /////////////////////////////////////////////////////////////////////// -- 2.39.2