#define GLOBALS_LK_DIAGNO

#include "Link_Layer.h"
#include <string.h>

volatile _LinkData LinkDataBuf[2];
volatile _LinkData LinkData;
/*-------------------------------------------------------------------------
* Function Name  : LK_Link_main
* Description    :
* Input          :
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void LK_Link_main(uint32_t PDU_addr, uint8_t *CAN_BufAddr, uint8_t dlc)
{
    if (LinkDataBuf[0].TransferStatus == empoty)
    {
        LinkDataBuf[0].Identifier = PDU_addr; //
        (void)memcpy((uint8_t *)&LinkDataBuf[0].Data[0], CAN_BufAddr, dlc);
        LinkDataBuf[0].DLC = dlc;
        LinkDataBuf[0].TransferStatus = full;
    }
    else if (LinkDataBuf[1].TransferStatus == empoty)
    {
        LinkDataBuf[1].Identifier = PDU_addr;
        (void)memcpy((uint8_t *)&LinkDataBuf[1].Data[0], CAN_BufAddr, dlc);
        LinkDataBuf[1].DLC = dlc;
        LinkDataBuf[1].TransferStatus = full;
    }
}

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