73 #define LSS_FS_CONFIRMATION 2 |
69 #define LSS_FS_CONFIRMATION 2 |
74 |
70 |
75 |
71 |
76 typedef void (*LSSCallback_t)(CO_Data* d, UNS8 command); |
72 typedef void (*LSSCallback_t)(CO_Data* d, UNS8 command); |
77 |
73 |
78 typedef void (*lss_StoreConfiguration_t)(UNS8*,UNS8*); |
74 typedef void (*lss_StoreConfiguration_t)(CO_Data* d,UNS8*,UNS8*); |
79 //void _lss_StoreConfiguration(UNS8 *error, UNS8 *spec_error); |
75 //void _lss_StoreConfiguration(UNS8 *error, UNS8 *spec_error); |
80 |
76 |
81 typedef void (*lss_ChangeBaudRate_t)(char*); |
77 typedef void (*lss_ChangeBaudRate_t)(CO_Data* d,char*); |
82 //void _lss_ChangeBaudRate(char *BaudRate); |
78 //void _lss_ChangeBaudRate(char *BaudRate); |
83 |
79 |
84 |
80 |
85 struct struct_lss_transfer; |
81 struct struct_lss_transfer; |
86 |
82 |
96 UNS8 mode; /* LSS mode */ |
92 UNS8 mode; /* LSS mode */ |
97 |
93 |
98 UNS32 dat1; /* the data from the last msg received */ |
94 UNS32 dat1; /* the data from the last msg received */ |
99 UNS8 dat2; |
95 UNS8 dat2; |
100 |
96 |
101 e_nodeState currentState; /* the state of the node before switching to LSSTimingDelay*/ |
|
102 UNS8 nodeID; /* the new nodeid stored to update the nodeid when switching to LSS operational*/ |
97 UNS8 nodeID; /* the new nodeid stored to update the nodeid when switching to LSS operational*/ |
103 UNS8 addr_sel_match; /* the matching mask for the LSS Switch Mode Selective service */ |
98 UNS8 addr_sel_match; /* the matching mask for the LSS Switch Mode Selective service */ |
104 UNS8 addr_ident_match; /* the matching mask for the LSS Identify Remote Slaves service*/ |
99 UNS8 addr_ident_match; /* the matching mask for the LSS Identify Remote Slaves service*/ |
105 |
100 |
106 char *baudRate; /* the new baudrate stored to update the node baudrate when a Activate Bit |
101 char *baudRate; /* the new baudrate stored to update the node baudrate when a Activate Bit |
107 * Timing Parameters is received*/ |
102 * Timing Parameters is received*/ |
108 UNS16 switchDelay; /* the period of the two delay */ |
103 UNS16 switchDelay; /* the period of the two delay */ |
109 UNS8 switchDelayState; /* the state machine for the switchDelay */ |
104 UNS8 switchDelayState; /* the state machine for the switchDelay */ |
110 |
105 CAN_HANDLE canHandle_t; |
111 TIMER_HANDLE timers[3]; /* Time counters to implement a timeout in milliseconds. |
106 |
112 * LSS_MSG_TIMER (index 0) is automatically incremented whenever |
107 /* Time counters to implement a timeout in milliseconds.*/ |
|
108 TIMER_HANDLE timerMSG; /* timerMSG is automatically incremented whenever |
113 * the lss state is in LSS_TRANS_IN_PROGRESS, and reseted to 0 |
109 * the lss state is in LSS_TRANS_IN_PROGRESS, and reseted to 0 |
114 * when the response LSS have been received. |
110 * when the response LSS have been received. |
115 * LSS_SWITCH_DELAY_TIMER (index 1) is automatically incremented whenever |
111 */ |
|
112 |
|
113 TIMER_HANDLE timerSDELAY; /* timerSDELAY is automatically incremented whenever |
116 * the lss switchDelayState is in SDELAY_FIRST or SDELAY_SECOND, and reseted to 0 |
114 * the lss switchDelayState is in SDELAY_FIRST or SDELAY_SECOND, and reseted to 0 |
117 * when the two periods have been expired. |
115 * when the two periods have been expired. |
118 */ |
116 */ |
|
117 |
119 LSSCallback_t Callback; /* The user callback func to be called at LSS transaction end */ |
118 LSSCallback_t Callback; /* The user callback func to be called at LSS transaction end */ |
120 |
119 |
121 UNS8 LSSanswer; /* stores if a message has been received during a timer period */ |
120 UNS8 LSSanswer; /* stores if a message has been received during a timer period */ |
122 |
121 |
|
122 #ifdef CO_ENABLE_LSS_FS |
123 UNS32 IDNumber; /* in the master, the LSS address parameter which it currently tries to identify. |
123 UNS32 IDNumber; /* in the master, the LSS address parameter which it currently tries to identify. |
124 * in the slave, the LSS address parameter which is being checked (LSS-ID[sub]). */ |
124 * in the slave, the LSS address parameter which is being checked (LSS-ID[sub]). */ |
125 UNS8 BitChecked; /* bits of the current IDNumber that are currently checked */ |
125 UNS8 BitChecked; /* bits of the current IDNumber that are currently checked */ |
126 UNS8 LSSSub; /* which part of the LSS-ID is currently checked in IDNumber */ |
126 UNS8 LSSSub; /* which part of the LSS-ID is currently checked in IDNumber */ |
127 UNS8 LSSNext; /* which LSSSub value will be used in the next request */ |
127 UNS8 LSSNext; /* which LSSSub value will be used in the next request */ |
128 UNS8 LSSPos; /* in the slave, which part of the LSS-ID is currently processed*/ |
128 UNS8 LSSPos; /* in the slave, which part of the LSS-ID is currently processed*/ |
129 UNS8 FastScan_SM; /* the state machine for the FastScan protocol */ |
129 UNS8 FastScan_SM; /* the state machine for the FastScan protocol */ |
|
130 TIMER_HANDLE timerFS; /* timerFS is automatically incremented when the FastScan service |
|
131 * has been requested and reseted to 0 when the protocol ends. |
|
132 */ |
|
133 #endif |
130 }; |
134 }; |
131 |
135 |
132 #ifdef CO_ENABLE_LSS |
136 #ifdef CO_ENABLE_LSS |
133 typedef struct struct_lss_transfer lss_transfer_t; |
137 typedef struct struct_lss_transfer lss_transfer_t; |
134 #else |
138 #else |
139 void startLSS(CO_Data* d); |
143 void startLSS(CO_Data* d); |
140 void stopLSS(CO_Data* d); |
144 void stopLSS(CO_Data* d); |
141 |
145 |
142 |
146 |
143 /** transmit a LSS message |
147 /** transmit a LSS message |
144 * Checks if the msg can be transmited (i.e. we are not in LssTimingDelay state) |
|
145 * command is the LSS command specifier |
148 * command is the LSS command specifier |
146 * dat1 and dat2 are pointers to optional data (depend on command) |
149 * dat1 and dat2 are pointers to optional data (depend on command) |
147 * return sendLSSMessage(d,command,dat1,dat2) |
150 * return sendLSSMessage(d,command,dat1,dat2) |
148 */ |
151 */ |
149 UNS8 sendLSS (CO_Data* d, UNS8 command,void *dat1, void *dat2); |
152 UNS8 sendLSS (CO_Data* d, UNS8 command,void *dat1, void *dat2); |
173 /** Used by the Master application to send a LSS command, WITHOUT response, to the slave. |
176 /** Used by the Master application to send a LSS command, WITHOUT response, to the slave. |
174 * command: the LSS command. LSS_... |
177 * command: the LSS command. LSS_... |
175 * dat1 and dat2: pointers to optional data (depend on command). |
178 * dat1 and dat2: pointers to optional data (depend on command). |
176 * return sendLSS(d,command,dat1,dat2) |
179 * return sendLSS(d,command,dat1,dat2) |
177 */ |
180 */ |
178 UNS8 configNetworkNode(CO_Data* d, UNS8 command, void *dat1, void* dat2); |
181 //UNS8 configNetworkNode(CO_Data* d, UNS8 command, void *dat1, void* dat2); |
179 |
182 |
180 /** Used by the Master application to send a LSS command, WITH response, to the slave. |
183 /** Used by the Master application to send a LSS command, WITH response, to the slave. |
181 * The function Callback, which must be defined in the user code, is called at the |
184 * The function Callback, which must be defined in the user code, is called at the |
182 * end of the exchange (on succes or abort) and can be NULL. |
185 * end of the exchange (on succes or abort) and can be NULL. |
183 * The LSS_MSG_TIMER timer is started to control the timeout |
186 * The LSS_MSG_TIMER timer is started to control the timeout |
184 * return sendLSS(d,command,dat1,dat2) |
187 * return sendLSS(d,command,dat1,dat2) |
185 */ |
188 */ |
186 UNS8 configNetworkNodeCallBack (CO_Data* d, UNS8 command, void *dat1, void* dat2, LSSCallback_t Callback); |
189 UNS8 configNetworkNode (CO_Data* d, UNS8 command, void *dat1, void* dat2, LSSCallback_t Callback); |
187 |
190 |
188 /** Use this function after a configNetworkNode or configNetworkNodeCallBack to get the result. |
191 /** Use this function after a configNetworkNode or configNetworkNodeCallBack to get the result. |
189 Returns : LSS_RESET // Transmission not started. Init state. |
192 Returns : LSS_RESET // Transmission not started. Init state. |
190 LSS_FINISHED // data are available |
193 LSS_FINISHED // data are available |
191 LSS_ABORTED_INTERNAL // Aborted but not because of an abort message. |
194 LSS_ABORTED_INTERNAL // Aborted but not because of an abort message. |