The s32k344 LIN Slave receives both enhanced and classic check data

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

The s32k344 LIN Slave receives both enhanced and classic check data

Jump to solution
117 Views
harryoceana
Contributor II

s32k344 rtd 3.0.0  p07

Can the s32k344 LIN Slave receive both enhanced and classic check data?

I can only choose one of the following ways to receive

 

void LIN_Slave_Callback (uint8 Instance, const  Lpuart_Lin_Ip_StateStructType *LpuartStateStruct)
{
	Lpuart_Lin_Ip_PduType LinPdu_rx =
	    {
	                .Pid = LpuartStateStruct->CurrentPid,
	                .Cs = LPUART_LIN_IP_CLASSIC_CS,
	                .SduPtr = NULL_PTR,
					.Drc = LPUART_LIN_IP_FRAMERESPONSE_RX,
					.Dl = (uint8)BUFFER_SIZE
	    };

	Lpuart_Lin_Ip_PduType LinPdu_tx =
	    {
	                .Pid = LpuartStateStruct->CurrentPid,
	                .Cs = LPUART_LIN_IP_CLASSIC_CS,
	                .SduPtr = Slave_TxBuff,
					.Drc = LPUART_LIN_IP_FRAMERESPONSE_TX,
					.Dl = (uint8)BUFFER_SIZE
	    };

	      switch (LpuartStateStruct->CurrentEventId)
	      {
	          case LPUART_LIN_IP_RECV_HEADER_OK:
	        	  if(LpuartStateStruct->CurrentPid == PID_SLAVE_RECEIVE_DATA)
	        	  {
	        		  Lpuart_Lin_Ip_SendFrame(Instance, (const Lpuart_Lin_Ip_PduType *)&LinPdu_rx);
	        	  }

	        	  if(LpuartStateStruct->CurrentPid == PID_MASTER_RECEIVE_DATA)
	        	  {
	        		  Lpuart_Lin_Ip_SendFrame(Instance, (const Lpuart_Lin_Ip_PduType *)&LinPdu_tx);
	        	  }

	        	  break;

	          case LPUART_LIN_IP_SEND_HEADER_OK:
	        	  break;

	          case LPUART_LIN_IP_TX_COMPLETED:

	        	  //Lin_MasterRecv_Irq_Flag = 1;
	        	  break;

	          case LPUART_LIN_IP_RX_COMPLETED:
	        	  Siul2_Dio_Ip_TogglePins(LED3_BLUE_PORT,1<<LED3_BLUE_PIN);
	        	  Lin_SlaveRecv_Irq_Flag = 1;
	        	  break;


	          default:
	          /* do nothing */
	              break;
	      }
}

int main(void)
{
Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);
	IntCtrl_Ip_Init(&IntCtrlConfig_0);

	Get_Freq = Clock_Ip_GetClockFrequency(CORE_CLK);

	Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
        Lpuart_Lin_Ip_Init(Lpuart_Lin_Ip_Sa_pHwConfigPB_1.Instance, &Lpuart_Lin_Ip_Sa_pHwConfigPB_1);
	 while(1)
	 {
 if( Lin_SlaveRecv_Irq_Flag ==1) //处理从机接收标志位
	            	{
	            		/*此函数用来查询LIN总线状态 比如总线繁忙,接收完成或失败等。并且当接收成功时,可以把接收到的数据拷贝进接收缓存。*/
	               	    do
	                	    {
	                	      LpuartSlaveStatus = Lpuart_Lin_Ip_GetStatus(Lpuart_Lin_Ip_Sa_pHwConfigPB_1.Instance, (uint8 **)&RecvBuffer);
	                	    }
	                	    while (LPUART_LIN_IP_STATUS_RX_OK != LpuartSlaveStatus); //查询总线状态并且接收数据

	        			CopyBufferToData(Slave_RxBuff,RecvBuffer,8); //把接受到的数据拷贝进数据缓存
	        			memset(RecvBuffer,0,8*sizeof(uint8));//清除缓存,为下一次接收做准备
	        			LPUART_printf("Lin总线从机接收到的数据 :\r\n");//打印接收数据
	        			for(int i=0; i<8 ;i++)
	        			{
	        				LPUART_printf("data %d : 0x%x\r\n",i,Slave_RxBuff[i]);
	        			}
	        			Lin_SlaveRecv_Irq_Flag =0; //清零标志位,等待下一次接收
	            	}
}
return 0;
}

 

Labels (1)
0 Kudos
Reply
1 Solution
92 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes, this is possible. You need to have more PDUs defined for this, to have unique Pid with desired checksum type.

BR, Petr

View solution in original post

0 Kudos
Reply
1 Reply
93 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes, this is possible. You need to have more PDUs defined for this, to have unique Pid with desired checksum type.

BR, Petr

0 Kudos
Reply