S32 SDK
lin_j2602_proto.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  */
28 #include "lin_j2602_proto.h"
29 
30 /*******************************************************************************
31  * Code
32  ******************************************************************************/
33 /*FUNCTION**********************************************************************
34  *
35  * Function Name : lin_update_word_status_j2602
36  * Description : Update date word status.
37  *
38  * Implements : lin_update_word_status_j2602_Activity
39  *END**************************************************************************/
40 void lin_update_word_status_j2602(l_ifc_handle iii)
41 {
42  l_u8 err_in_res;
43  l_u8 suc_in_tras;
44  l_u8 overrun_flg;
45  lin_word_status_str_t * word_status_ptr;
46  lin_protocol_state_t * prot_state_ptr = &g_lin_protocol_state_array[iii];
47 
48  err_in_res = prot_state_ptr->error_in_response;
49  prot_state_ptr->error_in_response = 0;
50  suc_in_tras = prot_state_ptr->successful_transfer;
51  overrun_flg = prot_state_ptr->overrun_flg;
52 
53  word_status_ptr = &prot_state_ptr->word_status;
54 
55  /* values for all processed frames */
56  word_status_ptr->error_in_res |= err_in_res;
57  word_status_ptr->successful_transfer |= suc_in_tras;
58 
59 
60  word_status_ptr->overrun = overrun_flg;
61  word_status_ptr->last_pid = prot_state_ptr->last_pid;
62 
63  if(prot_state_ptr->go_to_sleep_flg == true)
64  {
65  /* Set go to sleep flag for word status*/
66  word_status_ptr->go_to_sleep_flg = 1;
67  }
68 }
69 
70 #if (SUPPORT_SLAVE_MODE == 1U)
71 #if (SUPPORT_PROTOCOL_J2602 == 1U)
72 /*FUNCTION**********************************************************************
73  *
74  * Function Name : lin_update_status_byte
75  * Description : The function is to perform the update of error signal in J2602 system.
76  *
77  * Implements : lin_update_status_byte_Activity
78  *END**************************************************************************/
79 void lin_update_status_byte(l_ifc_handle iii,
80  lin_lld_event_id_t event_id)
81 {
82  l_u8 i;
83  l_u8 signal_data;
84  l_u8* byte_offset_temp_ptr;
85  l_u8* bit_offset_temp_ptr;
86  l_u8 set_error_signal = 0U;
87  const lin_node_attribute_t * node_attr_ptr;
88  const lin_protocol_user_config_t * prot_user_config_ptr = &g_lin_protocol_user_cfg_array[iii];
89  node_attr_ptr = &g_lin_node_attribute_array[prot_user_config_ptr->slave_ifc_handle];
90  signal_data = 0;
91  switch (event_id)
92  {
93  /* Parity error */
94  case LIN_LLD_PID_ERR:
95  /* Set ID Parity Error 0x07 */
96  signal_data = 0x07U;
97  set_error_signal = 1;
98  break;
99  /* Byte Field Framing Error */
100  case LIN_LLD_FRAME_ERR:
101  /* Set Byte Field Framing Error 0x06 */
102  signal_data = 0x06U;
103  set_error_signal = 1;
104  break;
105  /* Checksum error */
107  /* Set Checksum error 0x05 */
108  signal_data = 0x05U;
109  set_error_signal = 1;
110  break;
111  /* Data error */
113  /* Set Data error 0x04 */
114  signal_data = 0x04U;
115  set_error_signal = 1;
116  break;
117  default:
118  /* do nothing */
119  break;
120  }
121 
122  if (set_error_signal == 1U)
123  {
124  for (i = 0; i < node_attr_ptr->num_frame_have_esignal; i++)
125  {
126  /* Get pointer to Byte and bit offset values in each frame that contains the error signal */
127  byte_offset_temp_ptr = node_attr_ptr->response_error_byte_offset_ptr + i;
128  bit_offset_temp_ptr = node_attr_ptr->response_error_bit_offset_ptr + i;
129  /* Set error signal equal to error in response */
130  g_lin_frame_data_buffer[*byte_offset_temp_ptr] = (l_u8)((g_lin_frame_data_buffer[*byte_offset_temp_ptr] & (~(0x07U << (*bit_offset_temp_ptr)))) |
131  (signal_data << (*bit_offset_temp_ptr)));
132  }
133  }
134 }
135 
136 #endif /* End (SUPPORT_PROTOCOL_J2602 == 1U) */
137 #endif /* End (SUPPORT_SLAVE_MODE == 1U) */
138 
139 /*******************************************************************************
140  * EOF
141  ******************************************************************************/
l_u8 overrun_flg
Definition: lin.h:572
unsigned int go_to_sleep_flg
Definition: lin.h:155
lin_word_status_str_t word_status
Definition: lin.h:573
lin_protocol_state_t g_lin_protocol_state_array[LIN_NUM_OF_IFCS]
Definition: lin.c:50
l_ifc_slave_handle slave_ifc_handle
Definition: lin.h:527
l_bool go_to_sleep_flg
Definition: lin.h:568
const lin_node_attribute_t g_lin_node_attribute_array[LIN_NUM_OF_SLAVE_IFCS]
l_u8 g_lin_frame_data_buffer[LIN_FRAME_BUF_SIZE]
void lin_update_status_byte(l_ifc_handle iii, lin_lld_event_id_t event_id)
The function is to perform the update of error signal in J2602 system.
l_u8 num_frame_have_esignal
Definition: lin.h:196
Configuration structure Implements : lin_protocol_user_config_t_Class.
Definition: lin.h:510
unsigned int error_in_res
Definition: lin.h:152
l_u8 * response_error_bit_offset_ptr
Definition: lin.h:199
void lin_update_word_status_j2602(l_ifc_handle iii)
Update date word status.
l_u8 error_in_response
Definition: lin.h:567
LIN protocol status structure Implements : lin_protocol_state_t_Class.
Definition: lin.h:560
l_u8 * response_error_byte_offset_ptr
Definition: lin.h:198
const lin_protocol_user_config_t g_lin_protocol_user_cfg_array[LIN_NUM_OF_IFCS]
unsigned int last_pid
Definition: lin.h:160
unsigned char l_u8
Unsigned 8 bit integer Implements : l_u8_Class.
Definition: lin_types.h:30
Attributes of LIN node Implements : lin_node_attribute_t_Class.
Definition: lin.h:189
l_u8 successful_transfer
Definition: lin.h:566
status of LIN bus Implements : lin_word_status_str_t_Class
Definition: lin.h:150
unsigned int successful_transfer
Definition: lin.h:153
lin_lld_event_id_t
Event id Implements : lin_lld_event_id_t_Class.
Definition: lin.h:109
unsigned int overrun
Definition: lin.h:154