Skip to content

Commit e0c7f25

Browse files
authored
Merge pull request #12985 from dustin-crossman/pr/update_cysbsyskit_01
Update CYSBSYSKIT_01
2 parents 2f5c98d + 96052c3 commit e0c7f25

File tree

4 files changed

+102
-4
lines changed

4 files changed

+102
-4
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/inc/scl_common.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ typedef enum {
174174
SCL_RX_DATA = 0, /**< Received buffer */
175175
SCL_RX_TEST_MSG = 1, /**< Test message */
176176
SCL_RX_GET_BUFFER = 2, /**< Get the buffer */
177-
SCL_RX_GET_CONNECTION_STATUS = 3 /**< Get the connection status */
177+
SCL_RX_GET_CONNECTION_STATUS = 3, /**< Get the connection status */
178+
SCL_RX_VERSION_COMPATIBILITY = 4 /**< Get the SCL version compatibility*/
178179
} scl_ipc_rx_t;
179180

180181
/**
@@ -195,7 +196,8 @@ typedef enum {
195196
SCL_TX_WIFI_GET_BSSID = 12, /**< Get BSSID */
196197
SCL_TX_CONNECT = 13, /**< Wi-Fi connect */
197198
SCL_TX_DISCONNECT = 14, /**< Wi-Fi disconnect */
198-
SCL_TX_CONNECTION_STATUS = 15 /**< Transmit connection status */
199+
SCL_TX_CONNECTION_STATUS = 15, /**< Transmit connection status */
200+
SCL_TX_SCL_VERSION_NUMBER = 16 /**< Transmit SCL version number */
199201
} scl_ipc_tx_t;
200202

201203

targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/IPC/scl_ipc.c

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
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);
4950
static void scl_config(void);
5051
static void scl_rx_handler(void);
5152
static scl_result_t scl_thread_init(void);
53+
static scl_result_t scl_check_version_compatibility(void);
5254
scl_result_t scl_get_nw_parameters(network_params_t *nw_param);
5355
scl_result_t scl_send_data(int index, char *buffer, uint32_t timeout);
5456
scl_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+
};
77101
struct 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+
}
144191
scl_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

173227
scl_result_t scl_send_data(int index, char *buffer, uint32_t timeout)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2018-2020 Cypress Semiconductor Corporation
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/** @file
19+
* Provides version number of SCL
20+
*/
21+
#ifndef INCLUDED_SCL_VERSION_H_
22+
#define INCLUDED_SCL_VERSION_H_
23+
24+
#ifdef __cplusplus
25+
extern "C"
26+
{
27+
#endif
28+
29+
#define SCL_MAJOR_VERSION (1) /**< SCL major version */
30+
#define SCL_MINOR_VERSION (0) /**< SCL minor version */
31+
#define SCL_PATCH_VERSION (0) /**< SCL patch version */
32+
33+
#ifdef __cplusplus
34+
} /* extern "C" */
35+
#endif
36+
#endif /* ifndef INCLUDED_SCL_VERSION_H_ */

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYSBSYSKIT_01/cybsp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ cy_rslt_t cybsp_init(void)
101101
sleep_manager_lock_deep_sleep();
102102
#endif
103103

104+
/* Reserve clock dividers used by NP. */
105+
cyhal_clock_divider_t clock1;
106+
cyhal_hwmgr_allocate_clock(&clock1, CY_SYSCLK_DIV_16_BIT, true);
107+
cyhal_clock_divider_t clock2;
108+
cyhal_hwmgr_allocate_clock(&clock2, CY_SYSCLK_DIV_16_BIT, true);
109+
104110
/* CYHAL_HWMGR_RSLT_ERR_INUSE error code could be returned if any needed for BSP resource was reserved by
105111
* user previously. Please review the Device Configurator (design.modus) and the BSP reservation list
106112
* (cyreservedresources.list) to make sure no resources are reserved by both.

0 commit comments

Comments
 (0)