From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10395 invoked by alias); 1 Sep 2009 17:26:34 -0000 Received: (qmail 10384 invoked by uid 22791); 1 Sep 2009 17:26:33 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,SARE_FREE_WEBM_RuMail,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx40.mail.ru (HELO mx40.mail.ru) (94.100.176.54) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 01 Sep 2009 17:26:26 +0000 Received: from [79.134.88.136] (port=43462 helo=rain) by mx40.mail.ru with asmtp id 1MiX7d-00085f-00; Tue, 01 Sep 2009 21:26:21 +0400 Received: by rain (nbSMTP-1.00) for uid 1000 dushistov@mail.ru; Tue, 1 Sep 2009 21:27:24 +0400 (MSD) Date: Tue, 01 Sep 2009 17:26:00 -0000 From: Evgeniy Dushistov To: ecos-patches@ecos.sourceware.org Cc: Uwe Kindler Subject: [PATCH] fixes for at91 can driver Message-ID: <20090901172723.GA13991@rain> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="YiEDa0DAkWCtVeE4" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact ecos-patches-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-patches-owner@ecos.sourceware.org X-SW-Source: 2009-09/txt/msg00000.txt.bz2 --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1076 Hi, I have two problems with can_at91sam7 driver when try to use it with at91sam9263 cpu, but I suppose the same problems should happened with at91sam7 also. Problem 1. If standard id parameter is on, then I always receive messages with zero length. The root of evil is that driver hold id and length data in the same field of structure, and set id after length, so it zeroize the length part of field. See the first attached patch. Problem 2. If I call can_write several times without delay, can controller actualy send only the first one message. This is because of isr in can_at91sam7.c masks interrupt after it occurs, and interrupt enabled only in start_xmit implementation, start_xmit called only in can_write, so if messages copied into internal buffer, only the first one will be send, because of isr mask transmit notification interrupt, and it never enabled, so no new isr, no new dsr. But only can_at91sam7's dsr handler call can_xmt_msg, so no new messages will be copied from internal buffer to can controller. See the second attached patch. -- /Evgeniy --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-fix-dlc-always-zero-if-CYGOPT_IO_CAN_STD_CAN_ID-is.patch" Content-length: 852 .../arm/at91/at91sam7/current/src/can_at91sam7.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/packages/devs/can/arm/at91/at91sam7/current/src/can_at91sam7.c b/packages/devs/can/arm/at91/at91sam7/current/src/can_at91sam7.c index 763ffeb..30408ff 100644 --- a/packages/devs/can/arm/at91/at91sam7/current/src/can_at91sam7.c +++ b/packages/devs/can/arm/at91/at91sam7/current/src/can_at91sam7.c @@ -1234,7 +1234,8 @@ static bool at91sam7_can_getevent(can_channel *chan, CYG_CAN_EVENT_T *pevent, vo #endif // CYGOPT_IO_CAN_EXT_CAN_ID { #ifdef CYGOPT_IO_CAN_STD_CAN_ID - pevent->msg.id = MID_GET_STD(mid); + //in this case we hold dlc in id, so "|=" + pevent->msg.id |= MID_GET_STD(mid); #endif // CYGOPT_IO_CAN_STD_CAN_ID } -- 1.6.0.6 --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0002-fix-such-case.patch" Content-length: 863 .../arm/at91/at91sam7/current/src/can_at91sam7.c | 4 +++- packages/devs/mil_std_1553/current/src/mkocore | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/devs/can/arm/at91/at91sam7/current/src/can_at91sam7.c b/packages/devs/can/arm/at91/at91sam7/current/src/can_at91sam7.c index 30408ff..2e27c00 100644 --- a/packages/devs/can/arm/at91/at91sam7/current/src/can_at91sam7.c +++ b/packages/devs/can/arm/at91/at91sam7/current/src/can_at91sam7.c @@ -1167,8 +1167,10 @@ static bool at91sam7_can_putmsg(can_channel *priv, CYG_CAN_MSG_T *pmsg, void *pd { mcr |= MCR_RTR; } - + cyg_drv_dsr_lock(); HAL_WRITE_UINT32(CAN_MB_MCR(info, CAN_MBOX_TX(info)), mcr); + HAL_WRITE_UINT32(CAN_IER(info), 0x01 << CAN_MBOX_TX(info)); // enable tx interrupt + cyg_drv_dsr_unlock(); return true; } --YiEDa0DAkWCtVeE4--