20
20
* Provides SCL functionality to communicate with Network Processor
21
21
*/
22
22
#include "scl_ipc.h"
23
+ #include "scl_version.h"
23
24
#include "scl_buffer_api.h"
24
25
#include "cyabs_rtos.h"
25
26
#include "mbed_wait_api.h"
@@ -49,6 +50,7 @@ static void scl_isr(void);
49
50
static void scl_config (void );
50
51
static void scl_rx_handler (void );
51
52
static scl_result_t scl_thread_init (void );
53
+ static scl_result_t scl_check_version_compatibility (void );
52
54
scl_result_t scl_get_nw_parameters (network_params_t * nw_param );
53
55
scl_result_t scl_send_data (int index , char * buffer , uint32_t timeout );
54
56
scl_result_t scl_end (void );
@@ -74,6 +76,28 @@ struct scl_thread_info_t {
74
76
uint32_t scl_thread_stack_size ;
75
77
cy_thread_priority_t scl_thread_priority ;
76
78
};
79
+
80
+ /*
81
+ * Enumeration of SCL version compatibility
82
+ */
83
+ typedef enum {
84
+ NOT_COMPATIBLE = 0 , /**< Current SCL version on CP may cause issues because of newer verison on NP */
85
+ NEW_FEATURES_AVAILABLE = 1 , /**< A new SCL version with enhanced features is available */
86
+ NEW_BUG_FIXES_AVAILABLE = 2 , /**< A new SCL version with minor bug fixes is available */
87
+ SCL_IS_COMPATIBLE = 3 /**< SCL versions are compatible */
88
+ } scl_version_compatibility_value ;
89
+
90
+ /* Structure of SCL version info
91
+ * major: SCL major version
92
+ * minor: SCL minor version
93
+ * patch: SCL patch version
94
+ */
95
+ struct scl_version {
96
+ uint8_t major ;
97
+ uint8_t minor ;
98
+ uint8_t patch ;
99
+ scl_version_compatibility_value scl_version_compatibility ;
100
+ };
77
101
struct scl_thread_info_t g_scl_thread_info ;
78
102
79
103
/******************************************************
@@ -140,11 +164,35 @@ static scl_result_t scl_thread_init(void)
140
164
}
141
165
return SCL_SUCCESS ;
142
166
}
167
+ static scl_result_t scl_check_version_compatibility (void ) {
168
+ struct scl_version scl_version_number = {SCL_MAJOR_VERSION , SCL_MINOR_VERSION , SCL_PATCH_VERSION , NOT_COMPATIBLE };
169
+ scl_result_t retval = SCL_SUCCESS ;
170
+
171
+ printf ("SCL Version: %d.%d.%d\r\n" ,scl_version_number .major ,scl_version_number .minor ,scl_version_number .patch );
172
+
173
+ retval = scl_send_data (SCL_TX_SCL_VERSION_NUMBER , (char * ) & scl_version_number , TIMER_DEFAULT_VALUE );
143
174
175
+ if (retval == SCL_SUCCESS ) {
176
+ if (scl_version_number .scl_version_compatibility == NOT_COMPATIBLE ) {
177
+ printf ("Current SCL version may cause issues due to new firmware on NP please update SCL\n" );
178
+ }
179
+ else if (scl_version_number .scl_version_compatibility == NEW_FEATURES_AVAILABLE ) {
180
+ printf ("A new SCL version with enhanced features is available\n" );
181
+ }
182
+ else if (scl_version_number .scl_version_compatibility == NEW_BUG_FIXES_AVAILABLE ) {
183
+ printf ("A new SCL version with minor bug fixes is available\n" );
184
+ }
185
+ else if (scl_version_number .scl_version_compatibility == SCL_IS_COMPATIBLE ) {
186
+ printf ("SCL version is compatible\n" );
187
+ }
188
+ }
189
+ return retval ;
190
+ }
144
191
scl_result_t scl_init (void )
145
192
{
146
193
scl_result_t retval = SCL_SUCCESS ;
147
194
uint32_t configuration_parameters = INTIAL_VALUE ;
195
+
148
196
#ifdef MBED_CONF_TARGET_NP_CLOUD_DISABLE
149
197
configuration_parameters = (MBED_CONF_TARGET_NP_CLOUD_DISABLE << 1 );
150
198
#else
@@ -157,17 +205,23 @@ scl_result_t scl_init(void)
157
205
#endif
158
206
//SCL_LOG("configuration_parameters = %lu\r\n", configuration_parameters);
159
207
scl_config ();
208
+
209
+ retval = scl_check_version_compatibility ();
210
+ if (retval != SCL_SUCCESS ) {
211
+ printf ("SCL handshake failed, please try again\n" );
212
+ return retval ;
213
+ }
214
+
160
215
if (g_scl_thread_info .scl_inited != SCL_TRUE ) {
161
216
retval = scl_thread_init ();
162
217
if (retval != SCL_SUCCESS ) {
163
218
SCL_LOG (("Thread init failed\r\n" ));
164
219
return SCL_ERROR ;
165
220
} else {
166
221
retval = scl_send_data (SCL_TX_CONFIG_PARAMETERS , (char * ) & configuration_parameters , TIMER_DEFAULT_VALUE );
167
- return retval ;
168
222
}
169
223
}
170
- return SCL_SUCCESS ;
224
+ return retval ;
171
225
}
172
226
173
227
scl_result_t scl_send_data (int index , char * buffer , uint32_t timeout )
0 commit comments