Merge pull request #12985 from dustin-crossman/pr/update_cysbsyskit_01

Update CYSBSYSKIT_01
pull/13069/head
Martin Kojtal 2020-06-04 14:35:31 +02:00 committed by GitHub
commit e0c7f25c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 102 additions and 4 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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_ */

View File

@ -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.