NNP STM Generic Remote Module git-main
Loading...
Searching...
No Matches
lss.h
Go to the documentation of this file.
1
8#ifndef INC_LSS_H_
9#define INC_LSS_H_
10
11#define SLSS_ADRESS 0x7E4
12#define MLSS_ADRESS 0x7E5
13
14#define SDELAY_OFF 0
15#define SDELAY_FIRST 1
16#define SDELAY_SECOND 2
17
18#define LSS_WAITING_MODE 0
19#define LSS_CONFIGURATION_MODE 1
20
21/* Switch mode services */
22#define LSS_SM_GLOBAL 4
23#define LSS_SM_SELECTIVE_VENDOR 64
24#define LSS_SM_SELECTIVE_PRODUCT 65
25#define LSS_SM_SELECTIVE_REVISION 66
26#define LSS_SM_SELECTIVE_SERIAL 67
27#define LSS_SM_SELECTIVE_RESP 68
28/* Configuration services */
29#define LSS_CONF_NODE_ID 17
30#define LSS_CONF_BIT_TIMING 19
31#define LSS_CONF_ACT_BIT_TIMING 21
32#define LSS_CONF_STORE 23
33/* Inquire services */
34#define LSS_INQ_VENDOR_ID 90
35#define LSS_INQ_PRODUCT_CODE 91
36#define LSS_INQ_REV_NUMBER 92
37#define LSS_INQ_SERIAL_NUMBER 93
38#define LSS_INQ_NODE_ID 94
39/* Identification services */
40#define LSS_IDENT_REMOTE_VENDOR 70
41#define LSS_IDENT_REMOTE_PRODUCT 71
42#define LSS_IDENT_REMOTE_REV_LOW 72
43#define LSS_IDENT_REMOTE_REV_HIGH 73
44#define LSS_IDENT_REMOTE_SERIAL_LOW 74
45#define LSS_IDENT_REMOTE_SERIAL_HIGH 75
46#define LSS_IDENT_REMOTE_NON_CONF 76
47#define LSS_IDENT_SLAVE 79
48#define LSS_IDENT_NON_CONF_SLAVE 80
49#define LSS_IDENT_FASTSCAN 81
50
51/*FastScan State Machine*/
52#define LSS_FS_RESET 0
53#define LSS_FS_PROCESSING 1
54#define LSS_FS_CONFIRMATION 2
55
56
57typedef void (*LSSCallback_t)(CO_Data* d, UNS8 command);
58
59typedef void (*lss_StoreConfiguration_t)(CO_Data* d,UNS8*,UNS8*);
60//void _lss_StoreConfiguration(UNS8 *error, UNS8 *spec_error);
61
62//typedef void (*lss_ChangeBaudRate_t)(CO_Data* d,char*);
63//void _lss_ChangeBaudRate(char *BaudRate);
64
65
67
68//#include "timer.h"
69
70#ifdef CO_ENABLE_LSS_FS
71struct struct_lss_fs_transfer {
72 UNS32 FS_LSS_ID[4];
73 UNS8 FS_BitChecked[4];
74};
75
76typedef struct struct_lss_fs_transfer lss_fs_transfer_t;
77#endif
78
79/* The Transfer structure
80* Used to store the different fields of the internal state of the LSS
81*/
82
84 UNS8 state; /* state of the transmission : Takes the values LSS_... */
85 UNS8 command; /* the LSS command of the transmision */
86 UNS8 mode; /* LSS mode */
87
88 UNS32 dat1; /* the data from the last msg received */
89 UNS8 dat2;
90
91 UNS8 nodeID; /* the new nodeid stored to update the nodeid when switching to LSS operational*/
92 UNS8 addr_sel_match; /* the matching mask for the LSS Switch Mode Selective service */
93 UNS8 addr_ident_match; /* the matching mask for the LSS Identify Remote Slaves service*/
94
95 char *baudRate; /* the new baudrate stored to update the node baudrate when a Activate Bit
96 * Timing Parameters is received*/
97 UNS16 switchDelay; /* the period of the two delay */
98 UNS8 switchDelayState; /* the state machine for the switchDelay */
99 CAN_HandleTypeDef canHandle_t;
100
101 /* Time counters to implement a timeout in milliseconds.*/
102 TIMER_HANDLE timerMSG; /* timerMSG is automatically incremented whenever
103 * the lss state is in LSS_TRANS_IN_PROGRESS, and reseted to 0
104 * when the response LSS have been received.
105 */
106
107 TIMER_HANDLE timerSDELAY; /* timerSDELAY is automatically incremented whenever
108 * the lss switchDelayState is in SDELAY_FIRST or SDELAY_SECOND, and reseted to 0
109 * when the two periods have been expired.
110 */
111
112 LSSCallback_t Callback; /* The user callback func to be called at LSS transaction end */
113
114 UNS8 LSSanswer; /* stores if a message has been received during a timer period */
115
116#ifdef CO_ENABLE_LSS_FS
117 UNS32 IDNumber; /* in the master, the LSS address parameter which it currently tries to identify.
118 * in the slave, the LSS address parameter which is being checked (LSS-ID[sub]). */
119 UNS8 BitChecked; /* bits of the current IDNumber that are currently checked */
120 UNS8 LSSSub; /* which part of the LSS-ID is currently checked in IDNumber */
121 UNS8 LSSNext; /* which LSSSub value will be used in the next request */
122 UNS8 LSSPos; /* in the slave, which part of the LSS-ID is currently processed*/
123 UNS8 FastScan_SM; /* the state machine for the FastScan protocol */
124 TIMER_HANDLE timerFS; /* timerFS is automatically incremented when the FastScan service
125 * has been requested and reseted to 0 when the protocol ends.
126 */
127#ifdef CO_ENABLE_LSS_FS
128 lss_fs_transfer_t lss_fs_transfer;
129#endif
130
131#endif
132};
133
134#ifdef CO_ENABLE_LSS
135typedef struct struct_lss_transfer lss_transfer_t;
136#else
137typedef UNS8 lss_transfer_t;
138#endif
139
140
141
142void startLSS(CO_Data* d);
143void stopLSS(CO_Data* d);
144UNS8 sendLSS (CO_Data* d, UNS8 command,void *dat1, void *dat2);
145UNS8 proceedLSS_Master (CO_Data* d, Message* m );
146UNS8 proceedLSS_Slave (CO_Data* d, Message* m );
147//UNS8 configNetworkNode(CO_Data* d, UNS8 command, void *dat1, void* dat2);
148UNS8 configNetworkNode (CO_Data* d, UNS8 command, void *dat1, void* dat2, LSSCallback_t Callback);
149UNS8 getConfigResultNetworkNode (CO_Data* d, UNS8 command, UNS32* dat1, UNS8* dat2);
150
151#endif /* INC_LSS_H_ */
#define UNS8
Unsigned int8 representation in CANFest.
Definition applicfg.h:25
#define UNS16
Unsigned int16 representation in CANFest.
Definition applicfg.h:26
#define UNS32
Unsigned int32 representation in CANFest.
Definition applicfg.h:27
Definition can.h:13
This structure contains all necessary informations to define a CANOpen node.
Definition data.h:44