2020 * Provides SCL functionality to communicate with Network Processor
2121 */
2222#include "scl_ipc.h"
23+ #include "scl_version.h"
2324#include "scl_buffer_api.h"
2425#include "cyabs_rtos.h"
2526#include "mbed_wait_api.h"
@@ -49,6 +50,7 @@ static void scl_isr(void);
4950static void scl_config (void );
5051static void scl_rx_handler (void );
5152static scl_result_t scl_thread_init (void );
53+ static scl_result_t scl_check_version_compatibility (void );
5254scl_result_t scl_get_nw_parameters (network_params_t * nw_param );
5355scl_result_t scl_send_data (int index , char * buffer , uint32_t timeout );
5456scl_result_t scl_end (void );
@@ -74,6 +76,28 @@ struct scl_thread_info_t {
7476 uint32_t scl_thread_stack_size ;
7577 cy_thread_priority_t scl_thread_priority ;
7678};
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+ };
77101struct scl_thread_info_t g_scl_thread_info ;
78102
79103/******************************************************
@@ -140,11 +164,35 @@ static scl_result_t scl_thread_init(void)
140164 }
141165 return SCL_SUCCESS ;
142166}
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 );
143174
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+ }
144191scl_result_t scl_init (void )
145192{
146193 scl_result_t retval = SCL_SUCCESS ;
147194 uint32_t configuration_parameters = INTIAL_VALUE ;
195+
148196#ifdef MBED_CONF_TARGET_NP_CLOUD_DISABLE
149197 configuration_parameters = (MBED_CONF_TARGET_NP_CLOUD_DISABLE << 1 );
150198#else
@@ -157,17 +205,23 @@ scl_result_t scl_init(void)
157205#endif
158206 //SCL_LOG("configuration_parameters = %lu\r\n", configuration_parameters);
159207 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+
160215 if (g_scl_thread_info .scl_inited != SCL_TRUE ) {
161216 retval = scl_thread_init ();
162217 if (retval != SCL_SUCCESS ) {
163218 SCL_LOG (("Thread init failed\r\n" ));
164219 return SCL_ERROR ;
165220 } else {
166221 retval = scl_send_data (SCL_TX_CONFIG_PARAMETERS , (char * ) & configuration_parameters , TIMER_DEFAULT_VALUE );
167- return retval ;
168222 }
169223 }
170- return SCL_SUCCESS ;
224+ return retval ;
171225}
172226
173227scl_result_t scl_send_data (int index , char * buffer , uint32_t timeout )
0 commit comments