From a4c64481eaa9fbf4d52c6ff67e4947bf8d0a8e7e Mon Sep 17 00:00:00 2001 From: Dustin Crossman Date: Fri, 15 May 2020 15:52:09 -0700 Subject: [PATCH 1/2] Update COMPONENT_SCL to version 1.0.0 --- .../COMPONENT_SCL/inc/scl_common.h | 6 +- .../COMPONENT_SCL/src/IPC/scl_ipc.c | 58 ++++++++++++++++++- .../COMPONENT_SCL/src/include/scl_version.h | 36 ++++++++++++ 3 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/include/scl_version.h diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/inc/scl_common.h b/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/inc/scl_common.h index 6231462fb10..f2bc0742232 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/inc/scl_common.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/inc/scl_common.h @@ -174,7 +174,8 @@ typedef enum { SCL_RX_DATA = 0, /**< Received buffer */ SCL_RX_TEST_MSG = 1, /**< Test message */ SCL_RX_GET_BUFFER = 2, /**< Get the buffer */ - SCL_RX_GET_CONNECTION_STATUS = 3 /**< Get the connection status */ + SCL_RX_GET_CONNECTION_STATUS = 3, /**< Get the connection status */ + SCL_RX_VERSION_COMPATIBILITY = 4 /**< Get the SCL version compatibility*/ } scl_ipc_rx_t; /** @@ -195,7 +196,8 @@ typedef enum { SCL_TX_WIFI_GET_BSSID = 12, /**< Get BSSID */ SCL_TX_CONNECT = 13, /**< Wi-Fi connect */ SCL_TX_DISCONNECT = 14, /**< Wi-Fi disconnect */ - SCL_TX_CONNECTION_STATUS = 15 /**< Transmit connection status */ + SCL_TX_CONNECTION_STATUS = 15, /**< Transmit connection status */ + SCL_TX_SCL_VERSION_NUMBER = 16 /**< Transmit SCL version number */ } scl_ipc_tx_t; diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/IPC/scl_ipc.c b/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/IPC/scl_ipc.c index 66143d0418d..aa907453334 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/IPC/scl_ipc.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/IPC/scl_ipc.c @@ -20,6 +20,7 @@ * Provides SCL functionality to communicate with Network Processor */ #include "scl_ipc.h" +#include "scl_version.h" #include "scl_buffer_api.h" #include "cyabs_rtos.h" #include "mbed_wait_api.h" @@ -49,6 +50,7 @@ static void scl_isr(void); static void scl_config(void); static void scl_rx_handler(void); static scl_result_t scl_thread_init(void); +static scl_result_t scl_check_version_compatibility(void); scl_result_t scl_get_nw_parameters(network_params_t *nw_param); scl_result_t scl_send_data(int index, char *buffer, uint32_t timeout); scl_result_t scl_end(void); @@ -74,6 +76,28 @@ struct scl_thread_info_t { uint32_t scl_thread_stack_size; cy_thread_priority_t scl_thread_priority; }; + +/* + * Enumeration of SCL version compatibility + */ +typedef enum { + NOT_COMPATIBLE = 0, /**< Current SCL version on CP may cause issues because of newer verison on NP */ + NEW_FEATURES_AVAILABLE = 1, /**< A new SCL version with enhanced features is available */ + NEW_BUG_FIXES_AVAILABLE = 2, /**< A new SCL version with minor bug fixes is available */ + SCL_IS_COMPATIBLE = 3 /**< SCL versions are compatible */ +} scl_version_compatibility_value; + +/* Structure of SCL version info + * major: SCL major version + * minor: SCL minor version + * patch: SCL patch version + */ +struct scl_version { + uint8_t major; + uint8_t minor; + uint8_t patch; + scl_version_compatibility_value scl_version_compatibility; +}; struct scl_thread_info_t g_scl_thread_info; /****************************************************** @@ -140,11 +164,35 @@ static scl_result_t scl_thread_init(void) } return SCL_SUCCESS; } +static scl_result_t scl_check_version_compatibility(void) { + struct scl_version scl_version_number = {SCL_MAJOR_VERSION, SCL_MINOR_VERSION, SCL_PATCH_VERSION, NOT_COMPATIBLE}; + scl_result_t retval = SCL_SUCCESS; + + printf("SCL Version: %d.%d.%d\r\n",scl_version_number.major,scl_version_number.minor,scl_version_number.patch); + + retval = scl_send_data(SCL_TX_SCL_VERSION_NUMBER, (char *) &scl_version_number, TIMER_DEFAULT_VALUE); + if (retval == SCL_SUCCESS) { + if (scl_version_number.scl_version_compatibility == NOT_COMPATIBLE) { + printf("Current SCL version may cause issues due to new firmware on NP please update SCL\n"); + } + else if (scl_version_number.scl_version_compatibility == NEW_FEATURES_AVAILABLE) { + printf("A new SCL version with enhanced features is available\n"); + } + else if (scl_version_number.scl_version_compatibility == NEW_BUG_FIXES_AVAILABLE) { + printf("A new SCL version with minor bug fixes is available\n"); + } + else if (scl_version_number.scl_version_compatibility == SCL_IS_COMPATIBLE) { + printf("SCL version is compatible\n"); + } + } + return retval; +} scl_result_t scl_init(void) { scl_result_t retval = SCL_SUCCESS; uint32_t configuration_parameters = INTIAL_VALUE; + #ifdef MBED_CONF_TARGET_NP_CLOUD_DISABLE configuration_parameters = (MBED_CONF_TARGET_NP_CLOUD_DISABLE << 1); #else @@ -157,6 +205,13 @@ scl_result_t scl_init(void) #endif //SCL_LOG("configuration_parameters = %lu\r\n", configuration_parameters); scl_config(); + + retval = scl_check_version_compatibility(); + if (retval != SCL_SUCCESS) { + printf("SCL handshake failed, please try again\n"); + return retval; + } + if (g_scl_thread_info.scl_inited != SCL_TRUE) { retval = scl_thread_init(); if (retval != SCL_SUCCESS) { @@ -164,10 +219,9 @@ scl_result_t scl_init(void) return SCL_ERROR; } else { retval = scl_send_data(SCL_TX_CONFIG_PARAMETERS, (char *) &configuration_parameters, TIMER_DEFAULT_VALUE); - return retval; } } - return SCL_SUCCESS; + return retval; } scl_result_t scl_send_data(int index, char *buffer, uint32_t timeout) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/include/scl_version.h b/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/include/scl_version.h new file mode 100644 index 00000000000..ff1215b51f1 --- /dev/null +++ b/targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/include/scl_version.h @@ -0,0 +1,36 @@ +/* + * Copyright 2018-2020 Cypress Semiconductor Corporation + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** @file + * Provides version number of SCL + */ +#ifndef INCLUDED_SCL_VERSION_H_ +#define INCLUDED_SCL_VERSION_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define SCL_MAJOR_VERSION (1) /**< SCL major version */ +#define SCL_MINOR_VERSION (0) /**< SCL minor version */ +#define SCL_PATCH_VERSION (0) /**< SCL patch version */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* ifndef INCLUDED_SCL_VERSION_H_ */ From 96052c334742afc8f08ccffaf26cb001186e9bea Mon Sep 17 00:00:00 2001 From: Dustin Crossman Date: Fri, 15 May 2020 15:52:44 -0700 Subject: [PATCH 2/2] Update CYSBSYSKIT_01 board init --- .../TARGET_PSOC6/TARGET_CYSBSYSKIT_01/cybsp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYSBSYSKIT_01/cybsp.c b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYSBSYSKIT_01/cybsp.c index c96177402fc..58fbf17f102 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYSBSYSKIT_01/cybsp.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYSBSYSKIT_01/cybsp.c @@ -101,6 +101,12 @@ cy_rslt_t cybsp_init(void) sleep_manager_lock_deep_sleep(); #endif + /* Reserve clock dividers used by NP. */ + cyhal_clock_divider_t clock1; + cyhal_hwmgr_allocate_clock(&clock1, CY_SYSCLK_DIV_16_BIT, true); + cyhal_clock_divider_t clock2; + cyhal_hwmgr_allocate_clock(&clock2, CY_SYSCLK_DIV_16_BIT, true); + /* CYHAL_HWMGR_RSLT_ERR_INUSE error code could be returned if any needed for BSP resource was reserved by * user previously. Please review the Device Configurator (design.modus) and the BSP reservation list * (cyreservedresources.list) to make sure no resources are reserved by both.