#define U2_GLOBALS_LK_DIAGNO

#include "U2_Link_Layer.h"
#include "CAN_User.h"
#include <string.h>

volatile _U2_LinkData U2_LinkDataBuf[2];
volatile _U2_LinkData U2_LinkData;
/*-------------------------------------------------------------------------
* Function Name  : LK_Link_main
* Description    :
* Input          :
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void U2_LK_Link_main(uint16_t PDU_addr, uint8_t *CAN_BufAddr, uint8_t dlc)
{
    if (U2_LinkDataBuf[0].TransferStatus == u2_empoty)
    {
        U2_LinkDataBuf[0].Identifier = PDU_addr; //
        (void)memcpy((uint8_t *)&U2_LinkDataBuf[0].Data[0], CAN_BufAddr, dlc);
        U2_LinkDataBuf[0].DLC = dlc;
        U2_LinkDataBuf[0].TransferStatus = u2_full;
    }
    else if (U2_LinkDataBuf[1].TransferStatus == u2_empoty)
    {
        U2_LinkDataBuf[1].Identifier = PDU_addr;
        (void)memcpy((uint8_t *)&U2_LinkDataBuf[1].Data[0], CAN_BufAddr, dlc);
        U2_LinkDataBuf[1].DLC = dlc;
        U2_LinkDataBuf[1].TransferStatus = u2_full;
    }
                        if(Get_ReqSilentTimer() >0) Set_ReqSilentTimer(60);
                    
						if((CAN_BufAddr[1] == 0x50)&&(CAN_BufAddr[2] == 0x02))//¾²Ä¬Ä£Ê½
						{
							if(Get_ReqSilentTimer() >0) Set_ReqSilentTimer(60);
                            
							else Set_ReqSilentTimer(60);
                        
						}
}

/*-------------------------------------------------------------------------
* Function Name  : LK_FillMsg
* Description    :
* Input          :
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void U2_LK_FillMsg(uint8_t *data, uint8_t FillData, uint8_t dlc)
{
    uint8_t i;
    for (i = dlc; i < 8; i++)
    {
        *(data + i) = FillData;
    }
}
