keil_examples/CANACT/can.c
/******************************************************************************
** Function name:		CAN1_SendMessage
**
** Descriptions:		Send message block to CAN1	
**
** parameters:			pointer to the CAN message
** Returned value:		true or false, if message buffer is available,
**						message can be sent successfully, return TRUE,
**						otherwise, return FALSE.
** 
******************************************************************************/
Function name:         CAN1_SendMessage
Descriptions:          Send message block to CAN1

pointer to the CAN message
Returned value:                true or false, if message buffer is available,
message can be sent successfully, return TRUE,
otherwise, return FALSE.
Function name : CAN1_SendMessage Descriptions : Send message block to CAN1 pointer to the CAN message Returned value : true or false if message buffer is available message can be sent successfully return TRUE otherwise return FALSE .
uint32_t CAN1_SendMessage( CAN_MSG *pTxBuf )
{
  uint32_t CANStatus;
  CANStatus = LPC_CAN1->SR;
  if ( CANStatus & 0x00000004 )
  {
	LPC_CAN1->TFI1 = pTxBuf->Frame & 0xC00F0000;
	LPC_CAN1->TID1 = pTxBuf->MsgID;
	LPC_CAN1->TDA1 = pTxBuf->DataA;
	LPC_CAN1->TDB1 = pTxBuf->DataB;
	LPC_CAN1->CMR = 0x21;
	return ( TRUE );
  }
  else if ( CANStatus & 0x00000400 )
  {
	LPC_CAN1->TFI2 = pTxBuf->Frame & 0xC00F0000;
	LPC_CAN1->TID2 = pTxBuf->MsgID;
	LPC_CAN1->TDA2 = pTxBuf->DataA;
	LPC_CAN1->TDB2 = pTxBuf->DataB;
	LPC_CAN1->CMR = 0x41;
	return ( TRUE );
  }
  else if ( CANStatus & 0x00040000 )
  {	
	LPC_CAN1->TFI3 = pTxBuf->Frame & 0xC00F0000;
	LPC_CAN1->TID3 = pTxBuf->MsgID;
	LPC_CAN1->TDA3 = pTxBuf->DataA;
	LPC_CAN1->TDB3 = pTxBuf->DataB;
	LPC_CAN1->CMR = 0x81;
	return ( TRUE );
  }
  return ( FALSE );
}
uint32_t CAN1_SendMessage ( CAN_MSG * pTxBuf ) { uint32_t CANStatus ; CANStatus = LPC_CAN1 -> SR ; if ( CANStatus & 0x00000004 ) { LPC_CAN1 -> TFI1 = pTxBuf -> Frame & 0xC00F0000 ; LPC_CAN1 -> TID1 = pTxBuf -> MsgID ; LPC_CAN1 -> TDA1 = pTxBuf -> DataA ; LPC_CAN1 -> TDB1 = pTxBuf -> DataB ; LPC_CAN1 -> CMR = 0x21 ; return ( TRUE ) ; } else if ( CANStatus & 0x00000400 ) { LPC_CAN1 -> TFI2 = pTxBuf -> Frame & 0xC00F0000 ; LPC_CAN1 -> TID2 = pTxBuf -> MsgID ; LPC_CAN1 -> TDA2 = pTxBuf -> DataA ; LPC_CAN1 -> TDB2 = pTxBuf -> DataB ; LPC_CAN1 -> CMR = 0x41 ; return ( TRUE ) ; } else if ( CANStatus & 0x00040000 ) { LPC_CAN1 -> TFI3 = pTxBuf -> Frame & 0xC00F0000 ; LPC_CAN1 -> TID3 = pTxBuf -> MsgID ; LPC_CAN1 -> TDA3 = pTxBuf -> DataA ; LPC_CAN1 -> TDB3 = pTxBuf -> DataB ; LPC_CAN1 -> CMR = 0x81 ; return ( TRUE ) ; } return ( FALSE ) ; }
Function name:         CAN1_SendMessage
Descriptions:          Send message block to CAN1
Function name : CAN1_SendMessage Descriptions : Send message block to CAN1