/*********************************************************************//**
 * @brief		CAN_IRQ Handler, control receive message operation
 * param[in]	none
 * @return 		none
 **********************************************************************/
void CAN_IRQHandler()
{
	uint8_t IntStatus;
	uint32_t data1;
	/* get interrupt status
	 * Note that: Interrupt register CANICR will be reset after read.
	 * So function "CAN_IntGetStatus" should be call only one time
	 */
	IntStatus = CAN_IntGetStatus(LPC_CAN2);
	//check receive interrupt
	if((IntStatus>>0)&0x01)
	{
		CAN_ReceiveMsg(LPC_CAN2,&RXMsg);
		PrintMessage(&RXMsg);
		CANRxCount++; //count success received message
		//increase data for next TX Message
		TXMsg.id ++;
		data1 = (TXMsg.dataA[0])|(((TXMsg.dataA[1]))<<8)|((TXMsg.dataA[2])<<16)|((TXMsg.dataA[3])<<24);
		if(data1 == 0xFFFFFFFF) data1 = 0;
		else data1++;
		*((uint8_t *) &TXMsg.dataA[0])= *((uint8_t *) &TXMsg.dataB[0])= data1 & 0x000000FF;
		*((uint8_t *) &TXMsg.dataA[1])= *((uint8_t *) &TXMsg.dataB[1])=(data1 & 0x0000FF00)>>8;;
		*((uint8_t *) &TXMsg.dataA[2])= *((uint8_t *) &TXMsg.dataB[2])=(data1 & 0x00FF0000)>>16;
		*((uint8_t *) &TXMsg.dataA[3])= *((uint8_t *) &TXMsg.dataB[3])=(data1 & 0xFF000000)>>24;

		CAN_SendMsg(LPC_CAN1, &TXMsg);
	}
}
示例#2
0
/*********************************************************************//**
 * @brief		CAN IRQ Handler
 * @param[in]	none
 * @return 		none
 **********************************************************************/
void CAN_IRQHandler(void)
{
	uint8_t IntStatus;
	//check FullCAN interrupt enable or not
	if(CAN_FullCANIntGetStatus(LPC_CANAF)== SET)
	{	//check is FullCAN interrupt occurs or not
		if ((CAN_FullCANPendGetStatus(LPC_CANAF,FULLCAN_IC0))
				||(CAN_FullCANPendGetStatus(LPC_CANAF,FULLCAN_IC1)))
		{
			//read received FullCAN Object in Object Section
			FCAN_ReadObj(LPC_CANAF, &AFRxMsg[CANRxCount]);
			CANRxCount++;
		}
	}
	/* get interrupt status
	 * Note that: Interrupt register CANICR will be reset after read.
	 * So function "CAN_IntGetStatus" should be call only one time
	 */
	IntStatus = CAN_IntGetStatus(LPC_CAN2);
	//check receive interrupt
	if((IntStatus>>0)&0x01)
	{
		CAN_ReceiveMsg(LPC_CAN2, &AFRxMsg[CANRxCount]);
		CANRxCount++;
	}
}
示例#3
0
文件: platform.c 项目: ARMinARM/elua
void CAN_IRQHandler(void)
{
  // CAN1 Error (bits 1~10 cleared when read)
  if (LPC_CAN1->ICR & (1<<2 | 1<<5 | 1<<7))
    can_err_flag[0] = 1;
  
  // CAN1 Receive
  if (LPC_CAN1->ICR & (1<<0))
  {
    can_rx_flag[0] = 1;
    CAN_ReceiveMsg(LPC_CAN1, &(can_msg_rx[0]));
  }

  // CAN2 Error (bits 1~10 cleared when read)
  if (LPC_CAN2->ICR & (1<<2 | 1<<5 | 1<<7))
    can_err_flag[1] = 1;

  // CAN2 Receive
  if (LPC_CAN2->ICR & (1<<0))
  {
    can_rx_flag[1] = 1;
    CAN_ReceiveMsg(LPC_CAN2, &(can_msg_rx[1]));
  }
}
示例#4
0
/*********************************************************************//**
 * @brief		CAN_IRQ Handler, control receive message operation
 * param[in]	none
 * @return 		none
 **********************************************************************/
void CAN_IRQHandler()
{
    uint8_t IntStatus;
//	uint32_t data1;
    /* Get CAN status */
    IntStatus = CAN_GetCTRLStatus(LPC_CAN1, CANCTRL_STS);
    //check receive buffer status
    if((IntStatus>>0)&0x01)
    {
        CAN_ReceiveMsg(LPC_CAN1,&RXMsg);
        _DBG_("Received buffer:");
        PrintMessage(&RXMsg);
        //Validate received and transmited message
        if(Check_Message(&TXMsg, &RXMsg))
            _DBG_("Self test is SUCCESSFUL!!!");
        else
            _DBG_("Self test is FAIL!!!");
    }
}
示例#5
0
/*********************************************************************//**
 * @brief		Recevie Message Interrupt call-back function
 * @param[in]	none
 * @return 		none
 **********************************************************************/
void CAN_Callback1()
{
	CAN_ReceiveMsg(LPC_CAN2, &AFRxMsg[CANRxCount]);
	CANRxCount++;

}