Specifications
October 25, 2006 Cypress Semiconductor – Rev. ** 49
LIN Bus 2.0 Reference Design 5. Demonstration Projects
// If Bit 0 of second byte is 1, then switch On LED5
if(TempBuffer[1] & 0x01)
{
PRT1DR &= ~0x08;
Transmitter_CPutString("ON ");
}
// Else switch it off
else
{
PRT1DR |= 0x08;
Transmitter_CPutString("OFF ");
}
// If Bit 0 of first byte is 1, then switch On LED6
if(TempBuffer[0] & 0x01)
{
PRT1DR &= ~0x04;
Transmitter_CPutString("ON ");
}
// Else switch it off
else
{
PRT1DR |= 0x04;
Transmitter_CPutString("OFF ");
}
Transmitter_PutCRLF();
}
// Check if Frame4 has completed successfully
// This frame carries the switch status of Slave1. Update
// LEDs 1 to 4 with Bits 7,6,5,4 of the Slave1 switch Status
// Update the Indicator Status with Bits 0 and 1
if(BufferFrame4[0] & bfLAST_TRANSACTION_OK)
{
// Clear the bfLAST_TRANSACTION_OK flag
BufferFrame4[0] &= ~bfLAST_TRANSACTION_OK;
// Read the data byte of Frame4 to TempBuffer
l_bytes_rd(Frame4, 1, 1, TempBuffer);
// Update LEDs 1 to 4
PRT1DR |= 0xF0;
PRT1DR &= (~TempBuffer[0] | 0x0F);
// Update the Indicator switch status variable.
// Mask off bits other than 0 and 1
IndicatorStatus = TempBuffer[0] & 0x03;
// Now update the Indicator status on the buffer
// of Frame5. This new data will be sent when Frame5 is due.
l_bytes_wr(Frame5, 1, 1, &IndicatorStatus);
// Send the Slave1 switch status to Serial Port
Transmitter_CPutString("Slave-1 Switch Status: ");
Temp = 0x80;
for(i=0; i<8; i++)
{