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
.../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
.../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;
}