lin_common_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
7  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
9  * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
10  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
11  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
12  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
14  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
15  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
16  * THE POSSIBILITY OF SUCH DAMAGE.
17  */
34 #include "lin_common_api.h"
35 #include "lin_common_proto.h"
36 #include "lin_lin21_proto.h"
37 #include "lin_j2602_proto.h"
38 
39 /*******************************************************************************
40  * Code
41  ******************************************************************************/
42 
43 /*******************************************************************************
44  * Static function prototypes
45  ******************************************************************************/
46 #if (SUPPORT_MASTER_MODE == 1U)
47 static void lin_master_update_signal(l_ifc_handle iii);
48 
49 static void lin_master_update_frame_before_transmit(l_ifc_handle iii, l_u8 cur_id, l_u8 frame_index);
50 #endif /* End (SUPPORT_MASTER_MODE == 1U) */
51 
52 /*FUNCTION**********************************************************************
53  *
54  * Function Name : l_sys_init
55  * Description : This function performs the initialization of the LIN core.
56  * The implementation of this function can be replaced by user if needed.
57  *
58  * Implements : l_sys_init_Activity
59  *END**************************************************************************/
61 {
62  return (l_bool)0;
63 }
64 
65 #if (SUPPORT_MASTER_MODE == 1U)
66 /*FUNCTION**********************************************************************
67  *
68  * Function Name : l_sch_set
69  * Description : This function sets up the next schedule to be followed by the
70  * l_sch_tick function for a certain interface iii. The new schedule will be activated as soon as the current schedule reaches
71  * its next schedule entry point. The entry defines the starting entry point in the new schedule table. The value should
72  * be in the range 0 to N if the schedule table has N entries
73  *
74  * Implements : l_sch_set_Activity
75  *END**************************************************************************/
76 void l_sch_set(l_ifc_handle iii,
77  l_schedule_handle schedule_iii,
78  l_u8 entry)
79 {
80  DEV_ASSERT((l_u8)iii < LIN_NUM_OF_IFCS);
81  DEV_ASSERT((l_u8)schedule_iii < LIN_NUM_OF_SCHD_TBL);
82  const lin_protocol_user_config_t * prot_user_config_ptr = &g_lin_protocol_user_cfg_array[iii];
83 
84  /* Check if the interface is LIN Master */
85  if (prot_user_config_ptr->function == (bool)LIN_MASTER)
86  {
87  /* Check if input entry is in range from 0 to N = (Number of frame slots) */
88  if (entry <= prot_user_config_ptr->schedule_tbl[schedule_iii].num_slots)
89  {
90  l_u8 tmp_entry = entry;
92  /* save the new schedule which is activated after the */
93  /* current schedule reaches its next schedule entry point */
94  master_data_ptr->previous_schedule_id = master_data_ptr->active_schedule_id;
95  /* Insert new schedule at that point of the current schedule */
96  master_data_ptr->active_schedule_id = (l_u8)schedule_iii;
97 
98  /* if entry is 0 or 1 the new schedule table will be started from the beginning. */
99  if (tmp_entry == 0U)
100  {
101  /* Set entry equal to 1 */
102  tmp_entry = 1U;
103  }
104 
105  /* Assign the start entry of new schedule table by argument entry */
106  master_data_ptr->schedule_start_entry_ptr[schedule_iii] = (l_u8)(tmp_entry - 1U);
107  }
108  }
109 }
110 
111 /*FUNCTION**********************************************************************
112  *
113  * Function Name : lin_master_update_signal
114  * Description : This function handles update signal for master node.
115  * This function is implemented for Master.
116  *
117  * Implements : lin_master_update_signal_Activity
118  *END**************************************************************************/
119 static void lin_master_update_signal(l_ifc_handle iii)
120 {
121  l_u8 i;
122  l_u8 size;
123  l_u16 offset;
124  lin_master_data_t * master_data_ptr;
126 
127  if (master_data_ptr->frm_offset != 0xFFFFU)
128  {
129  /* Copy data from master_data_buffer to g_lin_frame_data_buffer */
130  /* Do this to satisfy Requirement: The master node updates its
131  * received signals periodically at the time base start */
132  size = master_data_ptr->frm_size;
133  offset = master_data_ptr->frm_offset;
134 
135  /* Check if size and offset are valid */
136  if ((size <= 8U) && ((size + offset) <= LIN_FRAME_BUF_SIZE))
137  {
138  /* Copy data from master_data_buffer to g_lin_frame_data_buffer */
139  for (i = 0U; i < size; i++)
140  {
141  g_lin_frame_data_buffer[offset + i] = master_data_ptr->master_data_buffer[i];
142  }
143  }
144 
145  master_data_ptr->frm_offset = 0xFFFFU;
146  }
147 
148  if (master_data_ptr->flag_offset != 0xFFU)
149  {
150  /* Do this to satisfy Requirement: The master node updates its
151  * received signals periodically at the time base start */
152  size = master_data_ptr->flag_size;
153  offset = master_data_ptr->flag_offset;
154 
155  /* Check if size and offset are valid */
156  if ((size <= LIN_FLAG_BUF_SIZE) && ((size + offset) <= LIN_FLAG_BUF_SIZE))
157  {
158  /* Update flag */
159  for (i = 0U; i < size; i++)
160  {
161  g_lin_flag_handle_tbl[offset + i] = 0xFF;
162  }
163 
164  master_data_ptr->flag_offset = 0xFF;
165  }
166  }
167 }
168 
169 /*FUNCTION**********************************************************************
170  *
171  * Function Name : lin_master_update_frame_before_transmit
172  * Description : This function update signal in transmitted frame of master.
173  * This function is implemented for Master.
174  *
175  * Implements : lin_master_update_frame_before_transmit_Activity
176  *END**************************************************************************/
177 static void lin_master_update_frame_before_transmit(l_ifc_handle iii, l_u8 cur_id, l_u8 frame_index)
178 {
179  l_u8 i;
180  l_u8 size;
181  l_u16 offset;
182  l_u8 active_schedule_id;
183  l_u8 flag;
184  const l_u8 * current_entry;
185  const lin_protocol_state_t * prot_state_ptr;
186  const lin_schedule_data_t * sch_data_ptr;
187  const lin_protocol_user_config_t * prot_user_config_ptr;
188  const lin_schedule_t * active_schedule_struct_ptr;
190 
191  if (0x3CU == cur_id)
192  {
193  active_schedule_id = master_data_ptr->active_schedule_id;
194  active_schedule_struct_ptr = (const lin_schedule_t *)&(g_lin_protocol_user_cfg_array[iii].schedule_tbl[active_schedule_id]);
195  if (LIN_SCH_TBL_DIAG != active_schedule_struct_ptr->sch_tbl_type)
196  {
197  current_entry = (l_u8 *)&master_data_ptr->schedule_start_entry_ptr[active_schedule_id];
198  prot_state_ptr = &g_lin_protocol_state_array[iii];
199  sch_data_ptr = &active_schedule_struct_ptr->ptr_sch_data_ptr[*current_entry];
200  /* Update transmitted data in case diagnostic frame is not added in diagnostic schedule table */
201  for (i = 0U; i < 8U; i++)
202  {
203  prot_state_ptr->response_buffer_ptr[i] = sch_data_ptr->tl_queue_data[i];
204  }
205  }
206  }
207  else
208  {
209  prot_user_config_ptr = &g_lin_protocol_user_cfg_array[iii];
210  /* Update buffer data if master is publisher and not transmit diagnostic request */
211  if (prot_user_config_ptr->frame_tbl_ptr[frame_index].frm_response == LIN_RES_PUB)
212  {
213  size = prot_user_config_ptr->frame_tbl_ptr[frame_index].frm_len;
214  offset = prot_user_config_ptr->frame_tbl_ptr[frame_index].frm_offset;
215  flag = g_lin_frame_updating_flag_tbl[frame_index];
216  /* Update data */
217  for (i = 0U; i < size; i++)
218  {
219  if((flag & (1U << i)) != 0U)
220  {
221  master_data_ptr->master_data_buffer[i] = g_buffer_backup_data[i];
222  }
223  else
224  {
225  master_data_ptr->master_data_buffer[i] = g_lin_frame_data_buffer[offset];
226  }
227  offset++;
228  }
229  }
230  }
231 }
232 
233 /*FUNCTION**********************************************************************
234  *
235  * Function Name : l_sch_tick
236  * Description : This function follows a schedule. When a frame becomes due, its
237  * transmission is initiated. When the end of the current schedule is reached,
238  * this function starts again at the beginning of the schedule.
239  * This API is for Master interface only.
240  *
241  * Implements : l_sch_tick_Activity
242  *END**************************************************************************/
243 l_u8 l_sch_tick(l_ifc_handle iii)
244 {
245  DEV_ASSERT((l_u8)iii < LIN_NUM_OF_IFCS);
246  const lin_schedule_t * active_schedule_struct_ptr;
247  l_u8 * current_entry;
248  l_u8 frame_index;
249  l_u8 cur_id;
250  l_u8 active_schedule_id;
251  l_u8 retVal = 0U;
252 
253  const lin_tl_descriptor_t * tl_desc_ptr = &g_lin_tl_descriptor_array[iii];
254  const lin_protocol_user_config_t * prot_user_config_ptr = &g_lin_protocol_user_cfg_array[iii];
255  lin_protocol_state_t * prot_state_ptr = &g_lin_protocol_state_array[iii];
256 
257  lin_master_data_t * master_data_ptr;
258 
259  /* Check if the interface is LIN Master */
260  if (prot_user_config_ptr->function == (bool)LIN_MASTER)
261  {
263 
265 
266  /* Get active_schedule_id */
267  active_schedule_id = master_data_ptr->active_schedule_id;
268  cur_id = prot_state_ptr->current_id;
269 
270  /* process diagnostic interleaved mode */
271  if ((tl_desc_ptr->diag_interleave_state == DIAG_NO_RESPONSE) && (prot_state_ptr->diagnostic_mode == DIAG_INTERLEAVE_MODE) &&
272  (cur_id == 0x3DU))
273  {
274  /* go back normal schedule table */
275  active_schedule_id = master_data_ptr->previous_schedule_id;
276  master_data_ptr->active_schedule_id = active_schedule_id;
277  master_data_ptr->schedule_start_entry_ptr[active_schedule_id] = 0U;
278  }
279 
280  active_schedule_struct_ptr = (const lin_schedule_t *)&prot_user_config_ptr->schedule_tbl[active_schedule_id];
281  current_entry = (l_u8 *)&master_data_ptr->schedule_start_entry_ptr[active_schedule_id];
282 
283  if (LIN_SCH_TBL_NULL != active_schedule_struct_ptr->sch_tbl_type)
284  {
285  /* Check if next_transmit is 0 */
286  if (0U == prot_state_ptr->next_transmit_tick)
287  {
288  /* Check protocol */
289  if (prot_user_config_ptr->protocol_version == LIN_PROTOCOL_21)
290  {
291  if (master_data_ptr->event_trigger_collision_flg == true)
292  {
293  /* Call collision resolver */
294  lin_collision_resolve(iii, cur_id);
295  /* Update active schedule table */
296  active_schedule_id = master_data_ptr->active_schedule_id;
297  active_schedule_struct_ptr = (const lin_schedule_t *)&prot_user_config_ptr->schedule_tbl[active_schedule_id];
298  /* Re-calculate current entry due to change table to collision */
299  current_entry = (l_u8 *)&master_data_ptr->schedule_start_entry_ptr[active_schedule_id];
300  master_data_ptr->event_trigger_collision_flg = false;
301  }
302  }
303 
304  /* Set new transmit tick */
305  prot_state_ptr->next_transmit_tick = active_schedule_struct_ptr->ptr_sch_data_ptr[*current_entry].delay_integer;
306  /* Get frame index to send */
307  frame_index = (l_u8)active_schedule_struct_ptr->ptr_sch_data_ptr[*current_entry].frm_id;
308 
309  if ((frame_index - prot_user_config_ptr->frame_start) < prot_user_config_ptr->number_of_configurable_frames)
310  {
311  cur_id = prot_user_config_ptr->list_identifiers_RAM_ptr[(frame_index - prot_user_config_ptr->frame_start) + 1U];
312  }
313 
314  if (LIN_FRM_SPRDC == prot_user_config_ptr->frame_tbl_ptr[frame_index].frm_type)
315  {
316  /* Sporadic frame */
317  cur_id = lin_check_sporadic_update(iii, frame_index);
318  frame_index = lin_get_frame_index(iii, cur_id);
319  }
320 
321  if (0xFFU != cur_id)
322  {
323  /* The latest point master can update value of signal in transmitted frame */
324  lin_master_update_frame_before_transmit(iii, cur_id, frame_index);
325 
326  /* Start transmit header */
327  (void)lin_lld_tx_header(iii, cur_id);
328  }
329  /* increase start entry */
330  *current_entry = (l_u8)(*current_entry + 1U);
331  /* Check if it is the last entry */
332  if (*current_entry >= active_schedule_struct_ptr->num_slots)
333  {
334  /* switch schedule table */
336  }
337  }
338 
339  /* Decrease next_transmit_tick */
340  prot_state_ptr->next_transmit_tick -= 1U;
341 
342  /* if the next call of l_sch_tick will start the transmission of the frame in the next schedule table entry */
343  /* The return value will in this case be the next schedule table entry's number */
344  /* counted from the beginning of the schedule table) in the schedule table */
345  /* The return value will be in range 1 to N if the schedule table has N entries */
346  if (0U == prot_state_ptr->next_transmit_tick)
347  {
348  /* The return value will be in range 1 to N if the schedule table has N entries */
349  if (*current_entry >= active_schedule_struct_ptr->num_slots)
350  {
351  /* If next entry is the first frame in the next schedule table */
352  /* Then return 1*/
353  retVal = 1U;
354  }
355  else
356  {
357  /* The return value will be in range 1 to N if the schedule table has N entries */
358  retVal = (l_u8)(*current_entry + 1U);
359  }
360  }
361  } /* End (LIN_SCH_TBL_NULL != active_schedule_struct_ptr->sch_tbl_type) */
362 
363  /* In the master node the status word is updated in the l_sch_tick function*/
364  switch (prot_user_config_ptr->protocol_version)
365  {
366  case LIN_PROTOCOL_21:
368  break;
369  case LIN_PROTOCOL_J2602:
371  break;
372  default:
373  /*do nothing*/
374  break;
375  }
376 
377  prot_state_ptr->current_id = cur_id;
378  } /* END (prot_user_config_ptr->function == LIN_MASTER) */
379 
380  return retVal;
381 }
382 
383 /*FUNCTION**********************************************************************
384  *
385  * Function Name : l_ifc_goto_sleep
386  * Description : Request slave nodes on the cluster connected to the interface to enter
387  * bus sleep mode by issuing one go to sleep command.
388  *
389  * Implements : l_ifc_goto_sleep_Activity
390  *END**************************************************************************/
391 void l_ifc_goto_sleep(l_ifc_handle iii)
392 {
393  DEV_ASSERT((l_u8)iii < LIN_NUM_OF_IFCS);
394 
395  const lin_protocol_user_config_t * prot_user_config_ptr = &g_lin_protocol_user_cfg_array[iii];
397 
398  if (prot_user_config_ptr->function == (bool)LIN_MASTER)
399  {
400  /* Set active schedule as GOTO_SLEEP_SCHEDULE */
401  /* current schedule reaches its next schedule entry point */
402  master_data_ptr->previous_schedule_id = master_data_ptr->active_schedule_id;
403  /* Insert new schedule at that point of the current schedule */
404  master_data_ptr->active_schedule_id = (l_u8)(prot_user_config_ptr->schedule_start + 1U);
405  /* Assign the start entry of new schedule table by argument entry */
406  master_data_ptr->schedule_start_entry_ptr[prot_user_config_ptr->schedule_start + 1U] = 0;
407  }
408 }
409 
410 #endif /* End (SUPPORT_MASTER_MODE == 1U) */
411 
412 /*FUNCTION**********************************************************************
413  *
414  * Function Name : l_ifc_init
415  * Description : Initialize the interface specified by name, i.e. sets up internal
416  * functions such as the baud rate
417  *
418  * Implements : l_ifc_init_Activity
419  *END**************************************************************************/
420 l_bool l_ifc_init(l_ifc_handle iii)
421 {
422  DEV_ASSERT((l_u8)iii < LIN_NUM_OF_IFCS);
423  lin_protocol_state_t * prot_state_ptr = &g_lin_protocol_state_array[iii];
424 #if (SUPPORT_MASTER_MODE == 1U)
425  const lin_protocol_user_config_t * prot_user_config_ptr = &g_lin_protocol_user_cfg_array[iii];
426  static l_u8 lin_schedule_start_entry[LIN_NUM_OF_SCHD_TBL];
427  lin_master_data_t * master_data_ptr;
428 #endif /* End (SUPPORT_MASTER_MODE == 1U) */
429  l_bool ret_val;
430  prot_state_ptr->diagnostic_mode = DIAG_NONE;
431 
432  /* Call Low level initialization function */
433  ret_val = lin_lld_init(iii);
434  /* Check if low level initialization is successful */
435  if (ret_val == (l_bool)LIN_LLD_OK)
436  {
437  #if (SUPPORT_MASTER_MODE == 1U)
438  if (prot_user_config_ptr->function == (bool)LIN_MASTER)
439  {
440  master_data_ptr = &g_lin_master_data_array[prot_user_config_ptr->master_ifc_handle];
441  /* Init flag offset and frame offset for Master Frame Data Buffer */
442  master_data_ptr->flag_offset = 0xFFU;
443  master_data_ptr->frm_offset = 0xFFFFU;
444  master_data_ptr->flag_size = 0x00U;
445  master_data_ptr->frm_size = 0x00U;
446  master_data_ptr->schedule_start_entry_ptr = &lin_schedule_start_entry[0U];
447  master_data_ptr->send_slave_res_flg = (bool)1;
448  master_data_ptr->send_functional_request_flg = (bool)0;
449  /* For LIN Master, set NULL schedule table after initialization*/
450  /* current schedule reaches its next schedule entry point */
451  master_data_ptr->previous_schedule_id = master_data_ptr->active_schedule_id;
452  /* Insert new schedule at that point of the current schedule */
453  master_data_ptr->active_schedule_id = prot_user_config_ptr->schedule_start;
454  /* Assign the start entry of new schedule table by argument entry */
455  master_data_ptr->schedule_start_entry_ptr[prot_user_config_ptr->schedule_start] = 0;
456  }
457  #endif /* End (SUPPORT_MASTER_MODE == 1U) */
458  }
459 
460  return ret_val;
461 }
462 
463 /*FUNCTION**********************************************************************
464  *
465  * Function Name : l_ifc_wake_up
466  * Description : Transmit the wake up signal.
467  *
468  * Implements : l_ifc_wake_up_Activity
469  *END**************************************************************************/
470 void l_ifc_wake_up(l_ifc_handle iii)
471 {
472  DEV_ASSERT((l_u8)iii < LIN_NUM_OF_IFCS);
473  /* Send wakeup signal */
474  (void)lin_lld_tx_wake_up(iii);
475 }
476 
477 /*FUNCTION**********************************************************************
478  *
479  * Function Name : l_ifc_read_status
480  * Description : This function will return the status of the previous communication.
481  *
482  * Implements : l_ifc_read_status_Activity
483  *END**************************************************************************/
484 l_u16 l_ifc_read_status(l_ifc_handle iii)
485 {
486  DEV_ASSERT((l_u8)iii < LIN_NUM_OF_IFCS);
487 
488  l_u16 tmp_word_status = 0U;
489  lin_protocol_state_t * prot_state_ptr = &g_lin_protocol_state_array[iii];
490  tmp_word_status = (l_u16)(prot_state_ptr->word_status.last_pid << 8);
491  if (prot_state_ptr->word_status.save_config_flg == 1U)
492  {
493  tmp_word_status |= SAVE_CONFIG_SET;
494  }
495 
496  if (prot_state_ptr->word_status.event_trigger_collision_flg == 1U)
497  {
498  tmp_word_status |= EVENT_TRIGGER_COLLISION_SET;
499  }
500 
501  if (prot_state_ptr->word_status.bus_activity == 1U)
502  {
503  tmp_word_status |= BUS_ACTIVITY_SET;
504  }
505 
506  if (prot_state_ptr->word_status.go_to_sleep_flg == 1U)
507  {
508  tmp_word_status |= GO_TO_SLEEP_SET;
509  }
510 
511  if (prot_state_ptr->word_status.overrun == 1U)
512  {
513  tmp_word_status |= OVERRUN;
514  }
515 
516  if (prot_state_ptr->word_status.successful_transfer == 1U)
517  {
518  tmp_word_status |= SUCCESSFULL_TRANSFER;
519  }
520 
521  if (prot_state_ptr->word_status.error_in_res == 1U)
522  {
523  tmp_word_status |= ERROR_IN_RESPONSE;
524  }
525 
526  /* Read-reset call; meaning that after the call has returned,
527  * the status word is set to 0 */
528  /* Clear word status */
529  prot_state_ptr->word_status.last_pid = 0x00U;
530  prot_state_ptr->word_status.reserved = 0U;
531  prot_state_ptr->word_status.save_config_flg = 0U;
532  prot_state_ptr->word_status.event_trigger_collision_flg = 0U;
533  prot_state_ptr->word_status.bus_activity = 0U;
534  prot_state_ptr->word_status.go_to_sleep_flg = 0U;
535  prot_state_ptr->word_status.overrun = 0U;
536  prot_state_ptr->word_status.successful_transfer = 0U;
537  prot_state_ptr->word_status.error_in_res = 0U;
538  /* Clear save configuration flag value */
539  prot_state_ptr->save_config_flg = (bool)0U;
540  /* reset word status flags in g_lin_protocol_state_array for new session*/
541  prot_state_ptr->go_to_sleep_flg = false;
542  prot_state_ptr->overrun_flg = 0U;
543  prot_state_ptr->successful_transfer = 0U;
544 
545  /* Reset number of processed frames to 0 */
546  prot_state_ptr->num_of_processed_frame = 0U;
547 
548  return tmp_word_status;
549 }
550 
551 /*FUNCTION**********************************************************************
552  *
553  * Function Name : l_sys_irq_disable
554  * Description : Disable LIN related IRQ.
555  *
556  * Implements : l_sys_irq_disable_Activity
557  *END**************************************************************************/
558 l_u16 l_sys_irq_disable(l_ifc_handle iii)
559 {
560  DEV_ASSERT((l_u8)iii < LIN_NUM_OF_IFCS);
561 
562  return lin_lld_int_disable(iii);
563 }
564 
565 /*FUNCTION**********************************************************************
566  *
567  * Function Name : l_sys_irq_restore
568  * Description : Enable LIN related IRQ.
569  *
570  * Implements : l_sys_irq_restore_Activity
571  *END**************************************************************************/
572 void l_sys_irq_restore(l_ifc_handle iii)
573 {
574  DEV_ASSERT((l_u8)iii < LIN_NUM_OF_IFCS);
575 
576  (void)lin_lld_int_enable(iii);
577 }
578 
579 #if (SUPPORT_TRANSPORT_LAYER != 1U)
580 /* This function is use when user not use transport layer */
582  lin_tl_event_id_t tl_event_id,
583  l_u8 id)
584 {
585  UNUSED(iii);
586  UNUSED(tl_event_id);
587  UNUSED(id);
588 
589  return TL_ACTION_NONE;
590 }
591 
592 #endif /* if (SUPPORT_TRANSPORT_LAYER != 1U) */
593 
594 /*******************************************************************************
595  * EOF
596  ******************************************************************************/
static void lin_master_update_frame_before_transmit(l_ifc_handle iii, l_u8 cur_id, l_u8 frame_index)
l_u8 overrun_flg
Definition: lin.h:572
l_u16 frm_offset
Definition: lin.h:256
l_u8 * list_identifiers_RAM_ptr
Definition: lin.h:522
lin_sch_tbl_type_t sch_tbl_type
Definition: lin.h:302
lin_tl_event_id_t
Transport layer event IDs Implements : lin_tl_event_id_t_Class.
Definition: lin.h:348
l_ifc_master_handle master_ifc_handle
Definition: lin.h:528
#define EVENT_TRIGGER_COLLISION_SET
unsigned int go_to_sleep_flg
Definition: lin.h:155
#define SAVE_CONFIG_SET
lin_word_status_str_t word_status
Definition: lin.h:573
lin_tl_callback_return_t
Transport layer event IDs Implements : lin_tl_callback_return_t_Class.
Definition: lin.h:364
l_u8 frm_size
Definition: lin.h:549
l_bool save_config_flg
Definition: lin.h:575
l_frame_handle frm_id
Definition: lin.h:290
#define GO_TO_SLEEP_SET
l_u8 l_sch_tick(l_ifc_handle iii)
This function follows a schedule. When a frame becomes due, its transmission is initiated. When the end of the current schedule is reached, this function starts again at the beginning of the schedule.
lin_protocol_state_t g_lin_protocol_state_array[LIN_NUM_OF_IFCS]
Definition: lin.c:50
void l_sch_set(l_ifc_handle iii, l_schedule_handle schedule_iii, l_u8 entry)
Set up the next schedule to be followed by the l_sch_tick function for a certain interface. The new schedule will be activated as soon as the current schedule reaches its next schedule entry point.
LIN schedule structure Implements : lin_schedule_data_t_Class.
Definition: lin.h:288
void lin_collision_resolve(l_ifc_handle iii, l_u8 pid)
Switch to collision resolve table.
#define ERROR_IN_RESPONSE
l_u8 next_transmit_tick
Definition: lin.h:574
lin_master_data_t g_lin_master_data_array[LIN_NUM_OF_MASTER_IFCS]
Definition: lin.c:52
Definition: lin.h:315
void lin_update_word_status_lin21(l_ifc_handle iii, lin_lld_event_id_t event_id)
Update node status flags.
l_u8 lin_lld_tx_header(l_ifc_handle iii, l_u8 id)
This function sends frame header for the input PID.
Definition: lin.c:203
l_diagnostic_mode_t diagnostic_mode
Definition: lin.h:576
l_bool go_to_sleep_flg
Definition: lin.h:568
l_bool send_slave_res_flg
Definition: lin.h:552
l_u8 flag_offset
Definition: lin.h:550
LIN master configuration structure Implements : lin_master_data_t_Class.
Definition: lin.h:541
l_u8 previous_schedule_id
Definition: lin.h:544
Schedule table description Implements : lin_schedule_t_Class.
Definition: lin.h:299
const lin_frame_t * frame_tbl_ptr
Definition: lin.h:519
l_u8 g_lin_frame_data_buffer[LIN_FRAME_BUF_SIZE]
lin_tl_queue_t tl_queue_data
Definition: lin.h:292
#define DEV_ASSERT(x)
Definition: devassert.h:77
lin_tl_descriptor_t g_lin_tl_descriptor_array[LIN_NUM_OF_IFCS]
Definition: lin.c:49
#define SUCCESSFULL_TRANSFER
void lin_switch_sch_table(l_ifc_handle iii)
l_u8 lin_lld_int_disable(l_ifc_handle iii)
Disable the interrupt related to the interface.
Definition: lin.c:287
l_bool lin_lld_init(l_ifc_handle iii)
This function initializes a LIN hardware instance for operation. This function will initialize the ru...
Definition: lin.c:91
unsigned int reserved
Definition: lin.h:159
Configuration structure Implements : lin_protocol_user_config_t_Class.
Definition: lin.h:510
void l_ifc_wake_up(l_ifc_handle iii)
Transmit the wake up signal.
l_bool event_trigger_collision_flg
Definition: lin.h:546
unsigned int error_in_res
Definition: lin.h:152
diag_interleaved_state_t diag_interleave_state
Definition: lin.h:489
l_u8 g_lin_flag_handle_tbl[LIN_FLAG_BUF_SIZE]
void l_sys_irq_restore(l_ifc_handle iii)
Enable LIN related IRQ.
lin_frame_type_t frm_type
Definition: lin.h:253
l_bool l_ifc_init(l_ifc_handle iii)
Initialize the controller specified by name, i.e. sets up internal functions such as the baud rate...
l_u8 * response_buffer_ptr
Definition: lin.h:564
l_bool l_sys_init(void)
This function performs the initialization of the LIN core; is the first call a user must use in the L...
void lin_update_word_status_j2602(l_ifc_handle iii)
Update date word status.
#define LIN_MASTER
Definition: lin.h:168
l_u8 lin_lld_tx_wake_up(l_ifc_handle iii)
This function send a wakeup signal.
Definition: lin.c:236
l_u8 lin_check_sporadic_update(l_ifc_handle iii, l_u8 frm_id)
LIN protocol status structure Implements : lin_protocol_state_t_Class.
Definition: lin.h:560
l_u8 num_of_processed_frame
Definition: lin.h:571
const lin_protocol_user_config_t g_lin_protocol_user_cfg_array[LIN_NUM_OF_IFCS]
volatile l_u8 g_buffer_backup_data[8]
static void lin_master_update_signal(l_ifc_handle iii)
unsigned int last_pid
Definition: lin.h:160
l_u8 delay_integer
Definition: lin.h:291
l_u8 lin_get_frame_index(l_ifc_handle iii, l_u8 id)
unsigned char l_u8
Unsigned 8 bit integer Implements : l_u8_Class.
Definition: lin_types.h:30
lin_tl_callback_return_t lin_tl_callback_handler(l_ifc_handle iii, lin_tl_event_id_t tl_event_id, l_u8 id)
const lin_schedule_t * schedule_tbl
Definition: lin.h:526
#define BUS_ACTIVITY_SET
l_u8 num_slots
Definition: lin.h:301
void l_ifc_goto_sleep(l_ifc_handle iii)
Request slave nodes on the cluster connected to the interface to enter bus sleep mode by issuing one ...
const lin_schedule_data_t * ptr_sch_data_ptr
Definition: lin.h:303
l_bool send_functional_request_flg
Definition: lin.h:553
l_u8 lin_lld_int_enable(l_ifc_handle iii)
Enable the interrupt related to the interface.
Definition: lin.c:264
l_u8 active_schedule_id
Definition: lin.h:543
#define OVERRUN
l_u8 frm_len
Definition: lin.h:254
lin_protocol_handle_t protocol_version
Definition: lin.h:512
bool l_bool
0 is false, and non-zero (>0) is true Implements : l_bool_Class
Definition: lin_types.h:48
l_u16 l_ifc_read_status(l_ifc_handle iii)
This function will return the status of the previous communication.
l_u8 successful_transfer
Definition: lin.h:566
l_u8 flag_size
Definition: lin.h:551
unsigned int event_trigger_collision_flg
Definition: lin.h:157
lin_frame_response_t frm_response
Definition: lin.h:255
l_u8 number_of_configurable_frames
Definition: lin.h:517
#define LIN_LLD_OK
Definition: lin.h:92
volatile l_u8 g_lin_frame_updating_flag_tbl[LIN_NUM_OF_FRMS]
unsigned int save_config_flg
Definition: lin.h:158
l_u16 frm_offset
Definition: lin.h:548
l_u8 master_data_buffer[8]
Definition: lin.h:547
unsigned int successful_transfer
Definition: lin.h:153
unsigned int overrun
Definition: lin.h:154
l_u8 * schedule_start_entry_ptr
Definition: lin.h:545
unsigned short int l_u16
Unsigned 16 bit integer Implements : l_u16_Class.
Definition: lin_types.h:36
Transport layer description Implements : lin_tl_descriptor_t_Class.
Definition: lin.h:464
l_u16 l_sys_irq_disable(l_ifc_handle iii)
Disable LIN related IRQ.
unsigned int bus_activity
Definition: lin.h:156