Part Number:TMS320F28379D
Hi all,
Which can.c has to refer for dcan? For example projects can.c linked from deprecated path??
C:\ti\c2000\C2000Ware_1_00_01_00\driverlib\f2837xd\driverlib\can.c | |
C:\ti\c2000\C2000Ware_1_00_01_00\device_support\f2837xd\common\deprecated\driverlib\can.c |
I have one doubt please can you clarify? the logic mentioned with comments "// Loop through to program all 32 message objects" added two times, is there any specific reason for that??
*********************************************************************
void
CANInit(uint32_t ui32Base)
{
int16_t iMsg;
// Check the arguments.
ASSERT(CANBaseValid(ui32Base));
// Place CAN controller in init state, regardless of previous state. This
// will put controller in idle, and allow the message object RAM to be
// programmed.
HWREGH(ui32Base + CAN_O_CTL) = CAN_CTL_INIT;
HWREGH(ui32Base + CAN_O_CTL) = CAN_CTL_SWR;
// Wait for busy bit to clear
while(HWREGH(ui32Base + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY)
{
}
// Clear the message value bit in the arbitration register. This indicates
// the message is not valid and is a "safe" condition to leave the message
// object. The same arb reg is used to program all the message objects.
HWREGH(ui32Base + CAN_O_IF1CMD + 2) = (CAN_IF1CMD_DIR | CAN_IF1CMD_ARB |
CAN_IF1CMD_CONTROL) >> 16;
HWREGH(ui32Base + CAN_O_IF1ARB) = 0;
HWREGH(ui32Base + CAN_O_IF1ARB + 2) = 0;
HWREGH(ui32Base + CAN_O_IF1MCTL) = 0;
HWREGH(ui32Base + CAN_O_IF1MCTL + 2) = 0;
HWREGH(ui32Base + CAN_O_IF2CMD + 2) = (CAN_IF2CMD_DIR | CAN_IF2CMD_ARB |
CAN_IF2CMD_CONTROL) >> 16;
HWREGH(ui32Base + CAN_O_IF2ARB) = 0;
HWREGH(ui32Base + CAN_O_IF2ARB + 2) = 0;
HWREGH(ui32Base + CAN_O_IF2MCTL) = 0;
HWREGH(ui32Base + CAN_O_IF2MCTL + 2) = 0;
// Loop through to program all 32 message objects
for(iMsg = 1; iMsg <= 32; iMsg+=2)
{
// Wait for busy bit to clear
while(HWREGH(ui32Base + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY)
{
}
// Initiate programming the message object
HWREGH(ui32Base + CAN_O_IF1CMD) = iMsg;
// Wait for busy bit to clear
while(HWREGH(ui32Base + CAN_O_IF2CMD) & CAN_IF2CMD_BUSY)
{
}
// Initiate programming the message object
HWREGH(ui32Base + CAN_O_IF2CMD) = iMsg + 1;
}
// Make sure that the interrupt and new data flags are updated for the
// message objects.
HWREGH(ui32Base + CAN_O_IF1CMD + 2) = (CAN_IF1CMD_TXRQST |
CAN_IF1CMD_CLRINTPND) >> 16;
HWREGH(ui32Base + CAN_O_IF2CMD + 2) = (CAN_IF2CMD_TXRQST |
CAN_IF2CMD_CLRINTPND) >> 16;
// Loop through to program all 32 message objects
for(iMsg = 1; iMsg <= 32; iMsg+=2)
{
// Wait for busy bit to clear.
while(HWREGH(ui32Base + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY)
{
}
// Initiate programming the message object
HWREGH(ui32Base + CAN_O_IF1CMD) = iMsg;
// Wait for busy bit to clear.
while(HWREGH(ui32Base + CAN_O_IF2CMD) & CAN_IF2CMD_BUSY)
{
}
// Initiate programming the message object
HWREGH(ui32Base + CAN_O_IF2CMD) = iMsg + 1;
}
// Acknowledge any pending status interrupts.
HWREG(ui32Base + CAN_O_ES);
}
*********************************************************************
Thanks