Hi again,
The initialize block is ran once at the beginning of the application before anything else in the model. That block should contain initialization logic for your application, such as turning on external peripherals, setting up internal peripherals, etc. In our example, it is used to wake up the LIN channel as to prepare it to receive messages on the bus right away.
For understanding how to model a triggered wakeup, let's break it down into its components and first understand what each function is used for.
Figure 1
CheckWakeup is used to validate whether the Lin channel has been woken up either internally or by the bus it is connected to. This is the function you want to use to check whether a wakeup call has been detected on the bus by the LIN hardware.
Figure 2
LinIf is composed of functions that are being called by various other drivers to notify various events. The WakeupConfirmation function is the one you are looking for since it is going to be called by CheckWakeup when a wakeup is successfully detected.
The LinIf block allows you to attach a logic to these functions. The above image shows how to declare what the function is going to do by attaching a function call subsystem that implements the logic of WakeupConfirmation. Here you should be implementing the behavior of your application on a wakeup detection.
Figure 3
WakeUpInternal is used for waking up your channel without sending a wakeup signal on the bus - this is the function you want to use as a slave node. This function does the actual wakeup of the channel (makes the channel exit its sleeping state) and should be called by your application before expecting to receive any messages on the bus. The recommendation here is to use this function within WakeupConfirmation so as to wake up your channel right upon a wakeup trigger detection.
So as to conclude, your application should look something like this:
1) Use an initialize block only if you have something you want your application to do before anything else - at the beginning.
2) Place the CheckWakeup function(Figure 1) in your model where you want the wakeup detection to be checked.
3) Place a LinIf block with the function set to WakeupConfirmation along with a function call subsystem in your top model or a non-triggered subsystem so as to declare the behavior of the said function. (Here you can also reset the data stores that you mentioned, initialize the counter, etc.)
4) Do not forget about doing the actual wakeup of the channel. Use the function WakeupInternal (Figure 3) inside the function call subsystem mentioned at the previous step.
NOTE: For being able to use the WakeupConfirmation successfully, you should have the settings Lin Channel Wake UP Support enabled in the configuration of your LIN channel.
