00001
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef _LIN_H_
00050 #define _LIN_H_
00051
00052 #include <avr32/io.h>
00053 #include "compiler.h"
00054 #include "usart.h"
00055
00056 #include "conf_lin.h"
00057
00058
00059
00060
00063
00064 #define LIN_2x 0
00065 #define LIN_1x 1
00066
00067
00068 #ifndef NUMBER_OF_LIN_FRAMES_NODE0
00069 #define NUMBER_OF_LIN_FRAMES_NODE0 8
00070 #endif // NUMBER_OF_LIN_FRAMES_NODE0
00071
00072 #ifdef USART_LIN_NODE1_INSTANCE
00073 #ifndef NUMBER_OF_LIN_FRAMES_NODE1
00074 #define NUMBER_OF_LIN_FRAMES_NODE1 8
00075 #endif // NUMBER_OF_LIN_FRAMES_NODE1
00076 #endif
00077
00086 typedef enum {
00087 PUBLISH,
00088 SUBSCRIBE,
00089 IGNORE
00090 } enum_lin_cmd;
00091
00096 typedef struct {
00098 U8 l_id;
00099
00102 U8 l_dlc;
00103
00105 enum_lin_cmd l_cmd;
00106
00110 U8 l_status;
00111
00114 U8* l_pt_data;
00115
00120 void (*l_pt_function)(U8*);
00121 } st_lin_message;
00122
00125 #define LIN_OVERLOAD_INT ((U16)0x00FF)
00126 #ifndef LIN_LAST_ERR_LENGHT
00127 #define LIN_LAST_ERR_LENGHT 0x04
00128 #endif
00129
00130
00131
00132
00133
00136 extern volatile st_lin_message lin_descript_list_node0[NUMBER_OF_LIN_FRAMES_NODE0];
00137 #ifdef USART_LIN_NODE1_INSTANCE
00138 extern volatile st_lin_message lin_descript_list_node1[NUMBER_OF_LIN_FRAMES_NODE1];
00139 #endif
00140
00144 extern volatile U8 lin_handle_node0;
00145 #ifdef USART_LIN_NODE1_INSTANCE
00146 extern volatile U8 lin_handle_node1;
00147 #endif
00148
00153 extern volatile U16 lin_error_number_node0;
00154 #ifdef USART_LIN_NODE1_INSTANCE
00155 extern volatile U16 lin_error_number_node1;
00156 #endif
00157
00160 extern volatile U16 lin_last_errors_node0[];
00161 #ifdef USART_LIN_NODE1_INSTANCE
00162 extern volatile U16 lin_last_errors_node1[];
00163 #endif
00164
00176 extern U8 lin_init (Bool master, U8 l_node, U16 b_rate, long pba_hz);
00177
00187 extern U8 lin_send_cmd (U8 l_node, U8 l_id, U8 l_len);
00188
00189 #endif // _LIN_H_