Specifications

October 25, 2006 Cypress Semiconductor – Rev. ** 39
LIN Bus 2.0 Reference Design 4. Slave Design IP
SLAVE_TO_MASTER constant and the
EVENT_TRIGGERED constant. Here is an example.
_Frame3:
Frame3:
db 0xFF
db SLAVE_TO_MASTER |
EVENT_TRIGGERED
db BufferFrame3
db 1
Once a frame is declared as event triggered and the frame
is due, the program checks the status register of the frame if
the data is updated. A response is transmitted only if the
data is updated. The main function should set the
bfDATA_READY flag in the status byte. Here is a code snip-
pet that updates the flag if there is a data change. The
Frame3 is event triggered and the buffer for this frame is
BufferFrame3.
PrevValue = PRT2DR; // Initialize Backup
value at start of main function
while(1)
{
******
******
Some Code
******
******
CurrentValue = PRT2DR;
if (PrevValue != CurrentValue)
{
BufferFrame3[0] |=
bfDATA_READY;
PrevValue = CurrentValue;
// Add code to update the Frame’s data
}
}
In this example, the PrevValue is a variable that holds some
initial value present in PRT2DR. If there is a change of the
state of PRT2DR, then the bfDATA_READY flag of the
Frame3 status byte is set and the PrevValue variable is
updated with the current value. So the next time Frame3
becomes due, it is transmitted. Also, the firmware clears the
bfDATA_READY flag, so that the frame is transmitted only
when this flag is set by the foreground function, which is
under the condition that the signal for Frame3 has changed.
4.7 LIN 2.0 Slave Design API
The Lin20CoreAPI.asm file has all the library functions
required for the operation of the LIN slave. This section
describes each API function and includes comments about
how to use the function.
l_sys_init
C Prototype: l_u8 l_sys_init (void);
Description: This is a dummy function included in the API
for consistency with the LIN specifications.
Parameters: None.
Returns: Always 0.
l_ifc_init
C Prototype: l_u8 l_ifc_init (void);
Description: Initializes the LIN 2.0 slave node. Loads the
Synchro Reception Configuration and initializes all the
parameters. Call this function in the main function to start
the LIN operation.
Parameters: None.
Returns: Zero if initialization is successful. Non zero for fail-
ure of initialization. But in this library, this function always
returns a zero. The prototype has been maintained for con-
sistency with the LIN 2.0 specification.
l_bytes_rd
C Prototype: void l_bytes_rd (const char*
l_signal_handle, l_u8 start, l_u8 count,
char* data);
Description: Reads and returns the current value of the
selected bytes in the signal specified by l_signal_handle.
Parameters:
l_signal_handle: Name of the frame from which bytes have
to be read.
start: The offset from where the bytes have to be read.
count: Number of counts to be read.
data: Buffer to which the data have to be read.
Example: For example, if you want to read two bytes from
Frame1 from the third byte of the buffer to another buffer
called TempBuffer, the following code is to be used:
l_bytes_rd(Frame1, 2, 2, TempBuffer);
Note that the third byte of the frame buffer will have an offset
of two. That is why two was used as the offset parameter.
Returns: None.
l_bytes_wr
C Prototype: void l_bytes_wr(const char*
l_signal_handle, l_u8 start, l_u8 count,
char* data);
Description: Writes to the selected bytes the value from the
specified buffer.
Parameters: