Import Mbed OS hard-float snapshot

This commit is contained in:
Beslan
2026-06-01 20:15:04 +03:00
commit d3738e2f89
16278 changed files with 10628036 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
/*
* This file is used to set the MAC address in NVRAM.
* The MAC address of the Wi-Fi device may be configured in OTP and/or in NVRAM.
* If both OTP and NVRAM contains the MAC address then OTP programmed MAC address will be used.
* PSOC boards are usually programmed with OTP MAC address.
* MAC address is printed during SCL power up
*/
#define NVRAM_GENERATED_MAC_ADDRESS "macaddr=00:A0:50:45:2e:c8"

View File

@@ -0,0 +1,214 @@
/*
* 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 scl_common.h
* Defines common data types used in SCL
*/
#include <stdint.h>
#include "cy_result.h"
#ifndef INCLUDED_SCL_COMMON_H_
#define INCLUDED_SCL_COMMON_H_
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************
* Constants
******************************************************/
#define SCL_LOG_ENABLE false /**< Flag to enable SCL debug logs */
#define SCL_LOG(x) if (SCL_LOG_ENABLE) \
{ printf x; } /**< SCL log interface */
#define CHECK_BUFFER_NULL(buf) if (buf == NULL)\
{ SCL_LOG(("Buffer pointer is null\n")); \
return SCL_BADARG; } /**< Helper macro to check if the input buffer pointer is null */
#define MODULE_BASE_CODE (0x0080U) /**< Base code for the SCL error status */
#define SCL_RESULT_TYPE (0) /**< SCL Result type */
/*
* scl_result_t Error code format
* |31-18 (14 bit) for module id|17-16 (2 bit) for result type|15-0 for SCL Error code|
* for example, for Error code 1026, the result of SCL_RESULT_CREATE is 33555458.
*/
#define SCL_RESULT_CREATE(x) CY_RSLT_CREATE(SCL_RESULT_TYPE, MODULE_BASE_CODE, (x) ) /**< Create a result value from the specified type, module, and result code */
#define SCL_SUCCESS (0) /**< IPC success */
#define SCL_ERROR (100) /**< IPC error */
#define SCL_PENDING SCL_RESULT_CREATE(1) /**< IPC Pending */
#define SCL_TIMEOUT SCL_RESULT_CREATE(2) /**< Timeout */
#define SCL_BADARG SCL_RESULT_CREATE(5) /**< Bad Arguments */
#define SCL_UNFINISHED SCL_RESULT_CREATE(10) /**< Operation not finished yet (maybe aborted) */
#define SCL_PARTIAL_RESULTS SCL_RESULT_CREATE(1003) /**< Partial results */
#define SCL_INVALID_KEY SCL_RESULT_CREATE(1004) /**< Invalid key */
#define SCL_DOES_NOT_EXIST SCL_RESULT_CREATE(1005) /**< Does not exist */
#define SCL_NOT_AUTHENTICATED SCL_RESULT_CREATE(1006) /**< Not authenticated */
#define SCL_NOT_KEYED SCL_RESULT_CREATE(1007) /**< Not keyed */
#define SCL_IOCTL_FAIL SCL_RESULT_CREATE(1008) /**< IOCTL fail */
#define SCL_BUFFER_UNAVAILABLE_TEMPORARY SCL_RESULT_CREATE(1009) /**< Buffer unavailable temporarily */
#define SCL_BUFFER_UNAVAILABLE_PERMANENT SCL_RESULT_CREATE(1010) /**< Buffer unavailable permanently */
#define SCL_CONNECTION_LOST SCL_RESULT_CREATE(1012) /**< Connection lost */
#define SCL_OUT_OF_EVENT_HANDLER_SPACE SCL_RESULT_CREATE(1013) /**< Cannot add extra event handler */
#define SCL_SEMAPHORE_ERROR SCL_RESULT_CREATE(1014) /**< Error manipulating a semaphore */
#define SCL_FLOW_CONTROLLED SCL_RESULT_CREATE(1015) /**< Packet retrieval cancelled due to flow control */
#define SCL_NO_CREDITS SCL_RESULT_CREATE(1016) /**< Packet retrieval cancelled due to lack of bus credits */
#define SCL_NO_PACKET_TO_SEND SCL_RESULT_CREATE(1017) /**< Packet retrieval cancelled due to no pending packets */
#define SCL_CORE_CLOCK_NOT_ENABLED SCL_RESULT_CREATE(1018) /**< Core disabled due to no clock */
#define SCL_CORE_IN_RESET SCL_RESULT_CREATE(1019) /**< Core disabled - in reset */
#define SCL_UNSUPPORTED SCL_RESULT_CREATE(1020) /**< Unsupported function */
#define SCL_BUS_WRITE_REGISTER_ERROR SCL_RESULT_CREATE(1021) /**< Error writing to WLAN register */
#define SCL_SDIO_BUS_UP_FAIL SCL_RESULT_CREATE(1022) /**< SDIO bus failed to come up */
#define SCL_JOIN_IN_PROGRESS SCL_RESULT_CREATE(1023) /**< Join not finished yet */
#define SCL_NETWORK_NOT_FOUND SCL_RESULT_CREATE(1024) /**< Specified network was not found */
#define SCL_INVALID_JOIN_STATUS SCL_RESULT_CREATE(1025) /**< Join status error */
#define SCL_UNKNOWN_INTERFACE SCL_RESULT_CREATE(1026) /**< Unknown interface specified */
#define SCL_SDIO_RX_FAIL SCL_RESULT_CREATE(1027) /**< Error during SDIO receive */
#define SCL_HWTAG_MISMATCH SCL_RESULT_CREATE(1028) /**< Hardware tag header corrupt */
#define SCL_RX_BUFFER_ALLOC_FAIL SCL_RESULT_CREATE(1029) /**< Failed to allocate a buffer to receive into */
#define SCL_BUS_READ_REGISTER_ERROR SCL_RESULT_CREATE(1030) /**< Error reading a bus hardware register */
#define SCL_THREAD_CREATE_FAILED SCL_RESULT_CREATE(1031) /**< Failed to create a new thread */
#define SCL_QUEUE_ERROR SCL_RESULT_CREATE(1032) /**< Error manipulating a queue */
#define SCL_BUFFER_POINTER_MOVE_ERROR SCL_RESULT_CREATE(1033) /**< Error moving the current pointer of a packet buffer */
#define SCL_BUFFER_SIZE_SET_ERROR SCL_RESULT_CREATE(1034) /**< Error setting size of packet buffer */
#define SCL_THREAD_STACK_NULL SCL_RESULT_CREATE(1035) /**< Null stack pointer passed when non null was required */
#define SCL_THREAD_DELETE_FAIL SCL_RESULT_CREATE(1036) /**< Error deleting a thread */
#define SCL_SLEEP_ERROR SCL_RESULT_CREATE(1037) /**< Error sleeping a thread */
#define SCL_BUFFER_ALLOC_FAIL SCL_RESULT_CREATE(1038) /**< Failed to allocate a packet buffer */
#define SCL_NO_PACKET_TO_RECEIVE SCL_RESULT_CREATE(1039) /**< No Packets waiting to be received */
#define SCL_INTERFACE_NOT_UP SCL_RESULT_CREATE(1040) /**< Requested interface is not active */
#define SCL_DELAY_TOO_LONG SCL_RESULT_CREATE(1041) /**< Requested delay is too long */
#define SCL_INVALID_DUTY_CYCLE SCL_RESULT_CREATE(1042) /**< Duty cycle is outside limit 0 to 100 */
#define SCL_PMK_WRONG_LENGTH SCL_RESULT_CREATE(1043) /**< Returned pmk was the wrong length */
#define SCL_UNKNOWN_SECURITY_TYPE SCL_RESULT_CREATE(1044) /**< AP security type was unknown */
#define SCL_WEP_NOT_ALLOWED SCL_RESULT_CREATE(1045) /**< AP not allowed to use WEP - it is not secure - use Open instead */
#define SCL_WPA_KEYLEN_BAD SCL_RESULT_CREATE(1046) /**< WPA / WPA2 key length must be between 8 & 64 bytes */
#define SCL_FILTER_NOT_FOUND SCL_RESULT_CREATE(1047) /**< Specified filter id not found */
#define SCL_SPI_ID_READ_FAIL SCL_RESULT_CREATE(1048) /**< Failed to read 0xfeedbead SPI id from chip */
#define SCL_SPI_SIZE_MISMATCH SCL_RESULT_CREATE(1049) /**< Mismatch in sizes between SPI header and SDPCM header */
#define SCL_ADDRESS_ALREADY_REGISTERED SCL_RESULT_CREATE(1050) /**< Attempt to register a multicast address twice */
#define SCL_SDIO_RETRIES_EXCEEDED SCL_RESULT_CREATE(1051) /**< SDIO transfer failed too many times. */
#define SCL_NULL_PTR_ARG SCL_RESULT_CREATE(1052) /**< Null Pointer argument passed to function. */
#define SCL_THREAD_FINISH_FAIL SCL_RESULT_CREATE(1053) /**< Error deleting a thread */
#define SCL_WAIT_ABORTED SCL_RESULT_CREATE(1054) /**< Semaphore/mutex wait has been aborted */
#define SCL_SET_BLOCK_ACK_WINDOW_FAIL SCL_RESULT_CREATE(1055) /**< Failed to set block ack window */
#define SCL_DELAY_TOO_SHORT SCL_RESULT_CREATE(1056) /**< Requested delay is too short */
#define SCL_INVALID_INTERFACE SCL_RESULT_CREATE(1057) /**< Invalid interface provided */
#define SCL_WEP_KEYLEN_BAD SCL_RESULT_CREATE(1058) /**< WEP / WEP_SHARED key length must be 5 or 13 bytes */
#define SCL_HANDLER_ALREADY_REGISTERED SCL_RESULT_CREATE(1059) /**< EAPOL handler already registered */
#define SCL_AP_ALREADY_UP SCL_RESULT_CREATE(1060) /**< Soft AP or P2P group owner already up */
#define SCL_EAPOL_KEY_PACKET_M1_TIMEOUT SCL_RESULT_CREATE(1061) /**< Timeout occurred while waiting for EAPOL packet M1 from AP */
#define SCL_EAPOL_KEY_PACKET_M3_TIMEOUT SCL_RESULT_CREATE(1062) /**< Timeout occurred while waiting for EAPOL packet M3 from AP which may indicate incorrect WPA2/WPA passphrase */
#define SCL_EAPOL_KEY_PACKET_G1_TIMEOUT SCL_RESULT_CREATE(1063) /**< Timeout occurred while waiting for EAPOL packet G1 from AP */
#define SCL_EAPOL_KEY_FAILURE SCL_RESULT_CREATE(1064) /**< Unknown failure occurred during the EAPOL key handshake */
#define SCL_MALLOC_FAILURE SCL_RESULT_CREATE(1065) /**< Memory allocation failure */
#define SCL_ACCESS_POINT_NOT_FOUND SCL_RESULT_CREATE(1066) /**< Access point not found */
#define SCL_RTOS_ERROR SCL_RESULT_CREATE(1067) /**< RTOS operation failed */
#define SCL_CLM_BLOB_DLOAD_ERROR SCL_RESULT_CREATE(1068) /**< CLM blob download failed */
#define SCL_HAL_ERROR SCL_RESULT_CREATE(1069) /**< SCL HAL Error */
#define SCL_RTOS_STATIC_MEM_LIMIT SCL_RESULT_CREATE(1070) /**< Exceeding the RTOS static objects memory */
/* Application uses the following constants to allocate the buffer pool: */
#define BDC_HEADER_WITH_PAD 6 /**< BDC Header with padding 4 + 2 */
#define SCL_PAYLOAD_MTU (1500) /**< The maximum size, in bytes, of the data part of an Ethernet frame */
/******************************************************
* Type Definitions
******************************************************/
/**
* Typedef for SCL buffer pointer
*/
typedef void *scl_buffer_t;
/**
* Typedef for SCL result
*/
typedef uint32_t scl_result_t;
/******************************************************
* Structures and Enumerations
******************************************************/
/**
* Typedef for SCL boolean flags
*/
typedef enum {
SCL_FALSE = 0, /**< Boolean False */
SCL_TRUE = 1 /**< Boolean True */
} scl_bool_t;
/**
* Typedef for SCL interface roles
*/
typedef enum {
SCL_INVALID_ROLE = 0, /**< Invalid role */
SCL_STA_ROLE = 1, /**< STA or Client Interface */
SCL_AP_ROLE = 2, /**< softAP Interface */
SCL_P2P_ROLE = 3 /**< P2P Interface */
} scl_interface_role_t;
/**
* Typedef for SCL IPC receive index
*/
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_VERSION_COMPATIBILITY = 4 /**< Get the SCL version compatibility*/
} scl_ipc_rx_t;
/**
* Typedef for SCL IPC transmit index
*/
typedef enum {
SCL_TX_TEST_MSG = 1, /**< Test Message */
SCL_TX_WIFI_INIT = 2, /**< Initialize Wi-Fi */
SCL_TX_CONFIG_PARAMETERS = 3, /**< Configuration parameters */
SCL_TX_GET_MAC = 4, /**< Get MAC address */
SCL_TX_REGISTER_MULTICAST_ADDRESS = 5, /**< Register multicast address */
SCL_TX_SEND_OUT = 6, /**< Transmit buffer */
SCL_TX_TRANSCEIVE_READY = 7, /**< Wi-Fi transmit/receive ready */
SCL_TX_WIFI_ON = 8, /**< Wi-Fi on */
SCL_TX_WIFI_SET_UP = 9, /**< Wi-Fi setup */
SCL_TX_WIFI_NW_PARAM = 10, /**< Get network parameters */
SCL_TX_WIFI_GET_RSSI = 11, /**< Get RSSI */
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_SCL_VERSION_NUMBER = 16 /**< Transmit SCL version number */
} scl_ipc_tx_t;
/**
* Structure for storing a MAC address (Wi-Fi Media Access Control address).
*/
typedef struct {
uint8_t octet[6]; /**< Unique 6-byte MAC address */
} scl_mac_t;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* ifndef INCLUDED_SCL_COMMON_H_ */

View File

@@ -0,0 +1,124 @@
/*
* 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 SCL functionality to communicate with Network Processor
*/
#include "scl_common.h"
#include "cy_device.h"
#include "cy_sysint.h"
#include "cy_ipc_drv.h"
#include "scl_wifi_api.h"
#include "ip4_addr.h"
#ifndef INCLUDED_SCL_IPC_H
#define INCLUDED_SCL_IPC_H
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************
* Macros
******************************************************/
/**
* Hardware address of IPC_DATA0 register
*/
#define REG_IPC_STRUCT_DATA0(base) (((IPC_STRUCT_V2_Type*)(base))->DATA0)
/**
* Default timeout value (in ms) for SCL operations
*/
#define TIMER_DEFAULT_VALUE (100)
/**
* Default timeout value (in ms) for Wi-Fi on
*/
#define WIFI_ON_TIMEOUT (5000)
/**
* Default timeout value (in seconds) for Wi-Fi connection
*/
#define NW_CONNECT_TIMEOUT (30)
/**
* Default timeout value (in seconds) for Wi-Fi disconnection
*/
#define NW_DISCONNECT_TIMEOUT (30)
/**
* Default interval (in micro seconds) for polling the Network Processor
*/
#define NW_DELAY_TIME_US (3000000)
/**
* Default parameter length
*/
#define PARAM_LEN (20)
/******************************************************
* Variables
******************************************************/
/**
* Network parameters structure.
*/
typedef struct network_params {
char ip_address[PARAM_LEN]; /**< IP address */
char netmask[PARAM_LEN]; /**< Netmask */
char gateway[PARAM_LEN]; /**< Gateway */
int connection_status; /**< Connection status */
} network_params_t;
/******************************************************
* Function Declarations
******************************************************/
/** @addtogroup communication SCL communication API
* APIs for communicating with Network Processor
* @{
*/
/** Initializes the SCL thread and necessary artifacts
*
* @return SCL_SUCCESS on successful initialization or SCL_ERROR otherwise
*/
extern scl_result_t scl_init(void);
/** Sends the SCL data and respective command to Network Processor
*
* @param index Index of the command.
* @param buffer Data to be sent.
* @param timeout The maximum time (in ms) to wait for the Network Processor to release IPC channel.
*
* @return SCL_SUCCESS on successful communication within SCL timeout duration or SCL_ERROR
*/
extern scl_result_t scl_send_data(int index, char *buffer, uint32_t timeout);
/** Terminates the SCL thread and disables the interrupts
*
* @return SCL_SUCCESS on successful termination of SCL thread and disabling of interrupts or SCL_ERROR on timeout
*/
extern scl_result_t scl_end(void);
/** Gets the network parameters like IP Address, Netmask, and Gateway from Network Processor
*
* @param nw_param structure pointer of type @a network_params_t
*
* @return SCL_SUCCESS on successful communication or SCL_ERROR
*/
extern scl_result_t scl_get_nw_parameters(network_params_t *nw_param);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* ifndef INCLUDED_SCL_IPC_H */

View File

@@ -0,0 +1,115 @@
/*
* 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 scl_types.h
* Defines common data types used in SCL
*
*/
#include <stdint.h>
#include "cy_result.h"
#ifndef INCLUDED_SCL_TYPES_H_
#define INCLUDED_SCL_TYPES_H_
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************
* Macros
******************************************************/
#define SSID_NAME_SIZE (32) /**< SSID Length */
#define WEP_ENABLED 0x0001 /**< Flag to enable WEP Security */
#define TKIP_ENABLED 0x0002 /**< Flag to enable TKIP Encryption */
#define AES_ENABLED 0x0004 /**< Flag to enable AES Encryption */
#define SHARED_ENABLED 0x00008000 /**< Flag to enable Shared key Security */
#define WPA_SECURITY 0x00200000 /**< Flag to enable WPA Security */
#define WPA2_SECURITY 0x00400000 /**< Flag to enable WPA2 Security */
#define WPA3_SECURITY 0x01000000 /**< Flag to enable WPA3 PSK Security */
#define ENTERPRISE_ENABLED 0x02000000 /**< Flag to enable Enterprise Security */
#define WPS_ENABLED 0x10000000 /**< Flag to enable WPS Security */
#define IBSS_ENABLED 0x20000000 /**< Flag to enable IBSS mode */
#define FBT_ENABLED 0x40000000 /**< Flag to enable FBT */
#define NO_POWERSAVE_MODE (0) /**< No Power save mode */
#define PM1_POWERSAVE_MODE (1) /**< Power save mode on specified interface without regard for throughput reduction */
#define PM2_POWERSAVE_MODE (2) /**< Power save mode on specified interface with High throughput */
/**
* Suppresses unused parameter warning
*/
#define UNUSED_PARAMETER(x) ( (void)(x) )
/**
* Suppresses unused variable warning
*/
#define UNUSED_VARIABLE(x) ( (void)(x) )
/**
* Suppresses unused variable warning that occurs due to an assert being disabled in release mode
*/
#define REFERENCE_DEBUG_ONLY_VARIABLE(x) ( (void)(x) )
/******************************************************
* Constants
******************************************************/
/******************************************************
* Structures and Enumerations
******************************************************/
/**
* Enumeration of Wi-Fi security modes
*/
typedef enum {
SCL_SECURITY_OPEN = 0, /**< Open security */
SCL_SECURITY_WEP_PSK = WEP_ENABLED, /**< WEP PSK Security with open authentication */
SCL_SECURITY_WEP_SHARED = (WEP_ENABLED | SHARED_ENABLED), /**< WEP PSK Security with shared authentication */
SCL_SECURITY_WPA_TKIP_PSK = (WPA_SECURITY | TKIP_ENABLED), /**< WPA PSK Security with TKIP */
SCL_SECURITY_WPA_AES_PSK = (WPA_SECURITY | AES_ENABLED), /**< WPA PSK Security with AES */
SCL_SECURITY_WPA_MIXED_PSK = (WPA_SECURITY | AES_ENABLED | TKIP_ENABLED), /**< WPA PSK Security with AES & TKIP */
SCL_SECURITY_WPA2_AES_PSK = (WPA2_SECURITY | AES_ENABLED), /**< WPA2 PSK Security with AES */
SCL_SECURITY_WPA2_TKIP_PSK = (WPA2_SECURITY | TKIP_ENABLED), /**< WPA2 PSK Security with TKIP */
SCL_SECURITY_WPA2_MIXED_PSK = (WPA2_SECURITY | AES_ENABLED | TKIP_ENABLED), /**< WPA2 PSK Security with AES & TKIP */
SCL_SECURITY_WPA2_FBT_PSK = (WPA2_SECURITY | AES_ENABLED | FBT_ENABLED), /**< WPA2 FBT PSK Security with AES & TKIP */
SCL_SECURITY_WPA3_SAE = (WPA3_SECURITY | AES_ENABLED), /**< WPA3 Security with AES */
SCL_SECURITY_WPA3_WPA2_PSK = (WPA3_SECURITY | WPA2_SECURITY | AES_ENABLED), /**< WPA3 WPA2 PSK Security with AES */
SCL_SECURITY_WPA_TKIP_ENT = (ENTERPRISE_ENABLED | WPA_SECURITY | TKIP_ENABLED), /**< WPA Enterprise Security with TKIP */
SCL_SECURITY_WPA_AES_ENT = (ENTERPRISE_ENABLED | WPA_SECURITY | AES_ENABLED), /**< WPA Enterprise Security with AES */
SCL_SECURITY_WPA_MIXED_ENT = (ENTERPRISE_ENABLED | WPA_SECURITY | AES_ENABLED | TKIP_ENABLED), /**< WPA Enterprise Security with AES & TKIP */
SCL_SECURITY_WPA2_TKIP_ENT = (ENTERPRISE_ENABLED | WPA2_SECURITY | TKIP_ENABLED), /**< WPA2 Enterprise Security with TKIP */
SCL_SECURITY_WPA2_AES_ENT = (ENTERPRISE_ENABLED | WPA2_SECURITY | AES_ENABLED), /**< WPA2 Enterprise Security with AES */
SCL_SECURITY_WPA2_MIXED_ENT = (ENTERPRISE_ENABLED | WPA2_SECURITY | AES_ENABLED | TKIP_ENABLED), /**< WPA2 Enterprise Security with AES & TKIP */
SCL_SECURITY_WPA2_FBT_ENT = (ENTERPRISE_ENABLED | WPA2_SECURITY | AES_ENABLED | FBT_ENABLED), /**< WPA2 Enterprise Security with AES & FBT */
SCL_SECURITY_IBSS_OPEN = (IBSS_ENABLED), /**< Open security on IBSS ad-hoc network */
SCL_SECURITY_WPS_OPEN = (WPS_ENABLED), /**< WPS with open security */
SCL_SECURITY_WPS_SECURE = (WPS_ENABLED | AES_ENABLED), /**< WPS with AES security */
SCL_SECURITY_UNKNOWN = -1, /**< Returned by scan function if security is unknown. Do not pass this to the join function! */
SCL_SECURITY_FORCE_32_BIT = 0x7fffffff /**< Exists only to force scl_security_t type to 32 bits */
} scl_security_t;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* ifndef INCLUDED_SCL_TYPES_H_ */

View File

@@ -0,0 +1,151 @@
/*
* 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
* Prototypes of functions for controlling the Wi-Fi system
*
* This file provides prototypes for end-user functions, which allow
* actions such as scanning for Wi-Fi networks, joining Wi-Fi
* networks, getting the MAC address, and so on.
*
*/
#include <stdbool.h>
#include "scl_common.h"
#ifndef INCLUDED_SCL_WIFI_API_H
#define INCLUDED_SCL_WIFI_API_H
#ifdef __cplusplus
extern "C"
{
#endif
/**
* SCL transmit buffer structure
*/
typedef struct scl_tx_buf {
scl_buffer_t buffer; /**< pointer to the buffer */
uint32_t size; /**< size of the buffer */
} scl_tx_buf_t;
/******************************************************
* Function Declarations
******************************************************/
/** @addtogroup wifi SCL Wi-Fi API
* APIs for controlling the Wi-Fi system
* @{
*/
/** Turn on the Wi-Fi device
*
* @note This API should be called before using any SCL Wi-Fi API.
*
* @return True if initialization is successful, False otherwise.
*/
extern bool scl_wifi_on(void);
/** Brings up the Wi-Fi core
*
* @return SCL_SUCCESS or Error code.
*/
extern scl_result_t scl_wifi_set_up(void);
/** Retrieves the current Media Access Control (MAC) address
* (or Ethernet hardware address) of the 802.11 device
*
* @param mac Pointer to a variable to which the current MAC address will be written.
*
* @return SCL_SUCCESS or Error code.
*/
extern scl_result_t scl_wifi_get_mac_address(scl_mac_t *mac);
/** Gets the BSSID of the interface
*
* @note This API should be used after the device is connected to a network.
*
* @param bssid Returns the BSSID address (mac address), if associated.
*
* @return SCL_SUCCESS or Error code.
*/
extern scl_result_t scl_wifi_get_bssid(scl_mac_t *bssid);
/** Registers interest in a multicast address
*
* Once a multicast address has been registered, all packets detected on the
* medium destined for that address are forwarded to the host.
* Otherwise, the packets are ignored.
*
* @param mac Ethernet MAC address.
*
* @return SCL_SUCCESS If the address was registered successfully or Error code.
*/
extern scl_result_t scl_wifi_register_multicast_address(scl_mac_t *mac);
/** Determines if an interface is ready to transmit/receive ethernet packets.
*
* @note This function must be called after the connection is established; otherwise, it returns Error code.
*
* @return SCL_SUCCESS If the interface is ready to transmit/receive ethernet packets.
* SCL_NOTFOUND If no AP with a matching SSID was found.
* SCL_NOT_AUTHENTICATED If matching AP was found, but it does not let you authenticate.
* @note This can occur if the device is in the blocklist of the AP.
* SCL_NOT_KEYED If the device has authenticated and associated but has not completed the key exchange.
* @note This can occur if the passphrase is incorrect.
* Error code If the interface is not ready to transmit/receive ethernet packets.
*/
extern scl_result_t scl_wifi_is_ready_to_transceive(void);
/** Sends an ethernet frame to SCL (called by the Network Stack)
*
* This function takes ethernet data from the network stack and transmits over the wireless network.
* This function returns immediately after the packet has been queued for transmission,
* NOT after it has been transmitted. Packet buffers passed to the SCL
* are released inside the SCL once they have been transmitted.
*
* @param buffer Handle of the packet buffer to be sent.
*
* @return SCL_SUCCESS or Error code.
*/
extern scl_result_t scl_network_send_ethernet_data(scl_tx_buf_t buffer);
/** Retrieves the latest RSSI value
*
* @note This API must be called after the device is connected to a network.
*
* @param rssi Location where the RSSI value will be stored.
*
* @return SCL_SUCCESS If the RSSI was successfully retrieved or Error code.
*/
extern scl_result_t scl_wifi_get_rssi(int32_t *rssi);
/** Retrieves the RX data packet
*
* @param buffer Pointer to RX buffer.
*/
extern void scl_network_process_ethernet_data(scl_buffer_t buffer);
/** Notifies network stack about the change in network connection state
*
* @param state_up Connection state.
*/
extern void scl_emac_wifi_link_state_changed(bool state_up);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* ifndef INCLUDED_SCL_WIFI_API_H */

View File

@@ -0,0 +1,345 @@
/*
* 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 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"
#include "string.h"
#include "nsapi_types.h"
/******************************************************
** Macros
*******************************************************/
#define SCL_THREAD_STACK_SIZE (1000)
#define SCL_THREAD_PRIORITY (CY_RTOS_PRIORITY_HIGH)
#define SCL_INTR_SRC (cpuss_interrupts_ipc_4_IRQn)
#define SCL_INTR_PRI (1)
#define SCL_RX_CHANNEL (4)
#define SCL_CHANNEL_NOTIFY_INTR ((1 << SCL_RX_CHANNEL) << 16)
#define SCL_NOTIFY (1 << SCL_TX_CHANNEL)
#define SCL_LOCK_ACQUIRE_STATUS (0x80000000)
#define SCL_TX_CHANNEL (3)
#define SCL_RELEASE (0)
#define DELAY_TIME (1000)
#define SEMAPHORE_MAXCOUNT (1)
#define SEMAPHORE_INITCOUNT (0)
#define INTIAL_VALUE (0)
/******************************************************
** Function Declarations
*******************************************************/
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);
scl_result_t scl_init(void);
/******************************************************
* Variables Definitions
*****************************************************/
/* Structure of SCL thread info
* scl_inited: flag used to determine if thread is started
* scl_thread_quit_flag: flag used to determine if thread is to be quit
* scl_thread_stack_start: pointer to start of thread stack
* scl_thread: variable for thread handle
* scl_rx_ready: semaphore for blocking the thread
* scl_thread_stack_size: size of thread stack
* scl_thread_priority: priority of thread
*/
struct scl_thread_info_t {
volatile scl_bool_t scl_inited;
volatile scl_bool_t scl_thread_quit_flag;
void *scl_thread_stack_start;
cy_thread_t scl_thread;
cy_semaphore_t scl_rx_ready;
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;
/******************************************************
* Function Definitions
******************************************************/
/** ISR for the IPC receiver channel interrupt
*/
static void scl_isr(void)
{
IPC_INTR_STRUCT_Type *scl_rx_intr = NULL;
scl_rx_intr = Cy_IPC_Drv_GetIntrBaseAddr(SCL_RX_CHANNEL);
if (REG_IPC_INTR_STRUCT_INTR_MASKED(scl_rx_intr) & SCL_CHANNEL_NOTIFY_INTR) {
REG_IPC_INTR_STRUCT_INTR(scl_rx_intr) |= SCL_CHANNEL_NOTIFY_INTR;
if (g_scl_thread_info.scl_inited == SCL_TRUE) {
cy_rtos_set_semaphore(&g_scl_thread_info.scl_rx_ready, true);
}
}
}
/** Configures the IPC interrupt channel
*/
static void scl_config(void)
{
IPC_INTR_STRUCT_Type *scl_rx_intr = NULL;
cy_stc_sysint_t intrCfg = {
.intrSrc = SCL_INTR_SRC,
.intrPriority = SCL_INTR_PRI
};
scl_rx_intr = Cy_IPC_Drv_GetIntrBaseAddr(SCL_RX_CHANNEL);
REG_IPC_INTR_STRUCT_INTR_MASK(scl_rx_intr) |= SCL_CHANNEL_NOTIFY_INTR;
Cy_SysInt_Init(&intrCfg, &scl_isr);
NVIC_EnableIRQ(intrCfg.intrSrc);
}
/** Create the SCL thread and initialize the semaphore for handling the events from Network Processor
*
* @return SCL_SUCCESS on successful initialization of thread or SCL_ERROR on failure
*/
static scl_result_t scl_thread_init(void)
{
cy_rslt_t retval = CY_RSLT_SUCCESS;
cy_rslt_t tmp = INTIAL_VALUE;
memset(&g_scl_thread_info, 0, sizeof(g_scl_thread_info));
g_scl_thread_info.scl_thread_stack_start = (uint8_t *) malloc(SCL_THREAD_STACK_SIZE);
g_scl_thread_info.scl_thread_stack_size = (uint32_t) SCL_THREAD_STACK_SIZE;
g_scl_thread_info.scl_thread_priority = (cy_thread_priority_t) SCL_THREAD_PRIORITY;
if (g_scl_thread_info.scl_inited != SCL_TRUE) {
retval = cy_rtos_init_semaphore(&g_scl_thread_info.scl_rx_ready, SEMAPHORE_MAXCOUNT, SEMAPHORE_INITCOUNT);
if (retval != SCL_SUCCESS) {
return SCL_ERROR;
}
retval = cy_rtos_create_thread(&g_scl_thread_info.scl_thread, (cy_thread_entry_fn_t) scl_rx_handler,
"SCL_thread", g_scl_thread_info.scl_thread_stack_start,
g_scl_thread_info.scl_thread_stack_size,
g_scl_thread_info.scl_thread_priority, (uint32_t) tmp);
if (retval != SCL_SUCCESS) {
return SCL_ERROR;
}
g_scl_thread_info.scl_inited = SCL_TRUE;
} else {
return SCL_ERROR;
}
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
configuration_parameters = (false << 1);
#endif
#ifdef MBED_CONF_TARGET_NP_WIFI_ENABLE
configuration_parameters |= MBED_CONF_TARGET_NP_WIFI_ENABLE;
#else
configuration_parameters |= false;
#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) {
SCL_LOG(("Thread init failed\r\n"));
return SCL_ERROR;
} else {
retval = scl_send_data(SCL_TX_CONFIG_PARAMETERS, (char *) &configuration_parameters, TIMER_DEFAULT_VALUE);
}
}
return retval;
}
scl_result_t scl_send_data(int index, char *buffer, uint32_t timeout)
{
uint32_t acquire_state;
IPC_STRUCT_Type *scl_send = NULL;
uint32_t delay_timeout;
SCL_LOG(("scl_send_data index = %d\r\n", index));
scl_send = Cy_IPC_Drv_GetIpcBaseAddress(SCL_TX_CHANNEL);
CHECK_BUFFER_NULL(buffer);
if (!(REG_IPC_STRUCT_LOCK_STATUS(scl_send) & SCL_LOCK_ACQUIRE_STATUS)) {
acquire_state = REG_IPC_STRUCT_ACQUIRE(scl_send);
if (!(acquire_state & SCL_LOCK_ACQUIRE_STATUS)) {
SCL_LOG(("IPC Channel 3 Acquired Failed\r\n"));
return SCL_ERROR;
}
REG_IPC_STRUCT_DATA0(scl_send) = index;
REG_IPC_STRUCT_DATA1(scl_send) = (uint32_t) buffer;
REG_IPC_STRUCT_NOTIFY(scl_send) = SCL_NOTIFY;
delay_timeout = 0;
while ((REG_IPC_STRUCT_LOCK_STATUS(scl_send) & SCL_LOCK_ACQUIRE_STATUS) && delay_timeout <= timeout) {
wait_us(DELAY_TIME);
delay_timeout++;
}
if (delay_timeout > timeout) {
REG_IPC_STRUCT_RELEASE(scl_send) = SCL_RELEASE;
delay_timeout = 0;
return SCL_ERROR;
} else {
return SCL_SUCCESS;
}
} else {
SCL_LOG(("unable to acquire lock\r\n"));
return SCL_ERROR;
}
}
scl_result_t scl_end(void)
{
scl_result_t retval = SCL_SUCCESS;
if (g_scl_thread_info.scl_inited == SCL_TRUE) {
retval = (scl_result_t) cy_rtos_terminate_thread(&g_scl_thread_info.scl_thread);
if (retval == SCL_SUCCESS) {
retval = (scl_result_t) cy_rtos_join_thread(&g_scl_thread_info.scl_thread);
if (retval == SCL_SUCCESS) {
retval = (scl_result_t) cy_rtos_deinit_semaphore(&g_scl_thread_info.scl_rx_ready);
if (retval == SCL_SUCCESS) {
g_scl_thread_info.scl_inited = SCL_FALSE;
}
}
}
}
return retval;
}
/** Thread to handle the received buffer
*/
static void scl_rx_handler(void)
{
char *buffer = NULL;
nsapi_connection_status_t connection_status;
uint32_t index;
IPC_STRUCT_Type *scl_receive = NULL;
scl_buffer_t cp_buffer;
uint32_t rx_ipc_size;
int *rx_cp_buffer;
SCL_LOG(("Starting CP Rx thread\r\n"));
scl_receive = Cy_IPC_Drv_GetIpcBaseAddress(SCL_RX_CHANNEL);
while (SCL_TRUE) {
cy_rtos_get_semaphore(&g_scl_thread_info.scl_rx_ready, CY_RTOS_NEVER_TIMEOUT, SCL_FALSE);
index = (uint32_t)REG_IPC_STRUCT_DATA0(scl_receive);
SCL_LOG(("scl_rx_handler index = %lu\r\n", index));
switch (index) {
case SCL_RX_DATA: {
SCL_LOG(("on CP the rxd address = %lx\r\n", REG_IPC_STRUCT_DATA1(scl_receive)));
rx_cp_buffer = (int *) REG_IPC_STRUCT_DATA1(scl_receive);
SCL_LOG(("rx_cp_buffer = %p \r\n", rx_cp_buffer));
REG_IPC_STRUCT_RELEASE(scl_receive) = SCL_RELEASE;
scl_network_process_ethernet_data(rx_cp_buffer);
break;
}
case SCL_RX_TEST_MSG: {
buffer = (char *) REG_IPC_STRUCT_DATA1(scl_receive);
SCL_LOG(("%s\r\n", (char *) buffer));
REG_IPC_STRUCT_RELEASE(scl_receive) = SCL_RELEASE;
break;
}
case SCL_RX_GET_BUFFER: {
rx_ipc_size = (uint32_t) REG_IPC_STRUCT_DATA1(scl_receive);
scl_host_buffer_get(&cp_buffer, SCL_NETWORK_RX, rx_ipc_size, SCL_FALSE);
REG_IPC_STRUCT_DATA1(scl_receive) = (uint32_t)cp_buffer;
REG_IPC_STRUCT_RELEASE(scl_receive) = SCL_RELEASE;
break;
}
case SCL_RX_GET_CONNECTION_STATUS: {
connection_status = (nsapi_connection_status_t) REG_IPC_STRUCT_DATA1(scl_receive);
if (connection_status == NSAPI_STATUS_GLOBAL_UP) {
scl_emac_wifi_link_state_changed(true);
} else {
scl_emac_wifi_link_state_changed(false);
}
SCL_LOG(("connection status = %d\r\n", connection_status));
break;
}
default: {
SCL_LOG(("incorrect IPC from Network Processor\r\n"));
REG_IPC_STRUCT_RELEASE(scl_receive) = SCL_RELEASE;
break;
}
}
}
}
scl_result_t scl_get_nw_parameters(network_params_t *nw_param)
{
scl_result_t status = SCL_ERROR;
status = scl_send_data(SCL_TX_WIFI_NW_PARAM, (char *)nw_param, TIMER_DEFAULT_VALUE);
return status;
}

View File

@@ -0,0 +1,109 @@
/*
* 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 declarations for buffer management functionality
*/
#ifndef _SCL_INTERNAL_BUFFER_API_H_
#define _SCL_INTERNAL_BUFFER_API_H_
#include "scl_types.h"
#include "scl_common.h"
#include <stdlib.h>
#include "cy_utils.h"
#include "memp.h"
#include "pbuf.h"
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************
* Constants
******************************************************/
/******************************************************
* Macros
******************************************************/
/******************************************************
* Structures and Enumerations
******************************************************/
/**
* Indicates the transmit/receive direction that the buffer has
* been used for. This is needed if transmit/receive pools are separate.
*/
typedef enum {
SCL_NETWORK_TX = 0, /**< Transmit direction */
SCL_NETWORK_RX = 1 /**< Receive direction */
} scl_buffer_dir_t;
/******************************************************
* Function Prototypes
******************************************************/
/** Allocates the SCL buffer.
*
* Attempts to allocate a buffer of the requested size. A buffer
* is either allocated from a static pool of memory or allocated dynamically.
*
* @param buffer A pointer which receives the allocated buffer.
* @param direction Indicates transmit/receive direction that the buffer is
* used for. This may be needed if transmit/receive pools are separate.
* @param size The number of bytes to allocate.
* @param wait Time to wait for a buffer to be available in milli-seconds.
*
* @return SCL_SUCCESS or Error code
*
*/
scl_result_t scl_host_buffer_get(scl_buffer_t *buffer, scl_buffer_dir_t direction,
uint16_t size, uint32_t wait);
/** Releases the SCL buffer.
*
* This function is used by SCL to indicate that it no longer requires
* the buffer. The buffer can then be released back into a pool for
* reuse or the dynamically allocated memory can be freed.
*
* @param buffer The buffer to be released.
* @param direction Indicates the transmit/receive direction that the buffer has
* been used for. This might be needed if transmit/receive pools are separate.
*
*/
void scl_buffer_release(scl_buffer_t buffer, scl_buffer_dir_t direction);
/** Retrieves the pointer to the payload of the buffer.
*
* @param buffer The buffer whose payload pointer is to be retrieved.
*
* @return Pointer to the payload.
*/
uint8_t *scl_buffer_get_current_piece_data_pointer(scl_buffer_t buffer);
/** Retrieves the size of the buffer.
*
* @param buffer The buffer whose size is to be retrieved.
*
* @return The size of the buffer.
*/
uint16_t scl_buffer_get_current_piece_size(scl_buffer_t buffer);
#ifdef __cplusplus
} /*extern "C" */
#endif
#endif /* ifndef _SCL_INTERNAL_BUFFER_API_H_ */

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

@@ -0,0 +1,81 @@
/*
* 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.
*/
#include "scl_buffer_api.h"
/******************************************************
** @cond Constants
*******************************************************/
/******************************************************
** Enumerations
*******************************************************/
/******************************************************
** Function Declarations
*******************************************************/
/******************************************************
* Variables Definitions
*****************************************************/
/******************************************************
* Function Definitions
******************************************************/
scl_result_t scl_host_buffer_get(scl_buffer_t *buffer, scl_buffer_dir_t direction,
uint16_t size, uint32_t wait)
{
UNUSED_PARAMETER(direction);
struct pbuf *p = NULL;
if ((direction == SCL_NETWORK_TX) && (size <= PBUF_POOL_BUFSIZE)) {
p = pbuf_alloc(PBUF_RAW, size, PBUF_POOL);
} else {
p = pbuf_alloc(PBUF_RAW, size, PBUF_RAM);
if (p != NULL) {
p->len = size;
}
}
if (p != NULL) {
*buffer = p;
return SCL_SUCCESS;
} else {
return SCL_BUFFER_ALLOC_FAIL;
}
}
void scl_buffer_release(scl_buffer_t buffer, scl_buffer_dir_t direction)
{
UNUSED_PARAMETER(direction);
(void) pbuf_free((struct pbuf *)buffer);
}
uint8_t *scl_buffer_get_current_piece_data_pointer(scl_buffer_t buffer)
{
CY_ASSERT(buffer != NULL);
struct pbuf *pbuffer = (struct pbuf *) buffer;
return (uint8_t *) pbuffer->payload;
}
uint16_t scl_buffer_get_current_piece_size(scl_buffer_t buffer)
{
CY_ASSERT(buffer != NULL);
struct pbuf *pbuffer = (struct pbuf *) buffer;
return (uint16_t) pbuffer->len;
}

View File

@@ -0,0 +1,160 @@
/*
* 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.
*/
#include "scl_wifi_api.h"
#include "scl_ipc.h"
/******************************************************
* Variables Definitions
*****************************************************/
typedef struct {
scl_mac_t *mac;
uint32_t retval;
} scl_mac;
/******************************************************
* Function Definitions
******************************************************/
scl_result_t scl_wifi_is_ready_to_transceive(void)
{
scl_result_t result = SCL_SUCCESS;
scl_result_t retval = SCL_SUCCESS;
result = scl_send_data(SCL_TX_TRANSCEIVE_READY, (char *)&retval, TIMER_DEFAULT_VALUE);
if (result == SCL_ERROR) {
SCL_LOG(("Ready to tranceive error\r\n"));
return SCL_ERROR;
} else {
return retval;
}
}
bool scl_wifi_on(void)
{
bool retval = false;
scl_result_t result = SCL_SUCCESS;
result = scl_send_data(SCL_TX_WIFI_ON, (char *)&retval, WIFI_ON_TIMEOUT);
if (result == SCL_ERROR) {
SCL_LOG(("wifi_on Error\r\n"));
return false;
} else {
return retval;
}
}
scl_result_t scl_wifi_set_up(void)
{
scl_result_t retval = SCL_SUCCESS;
scl_result_t result = SCL_SUCCESS;
result = scl_send_data(SCL_TX_WIFI_SET_UP, (char *)&retval, TIMER_DEFAULT_VALUE);
if (result == SCL_SUCCESS) {
return retval;
} else {
SCL_LOG(("Wifi set up error\r\n"));
return SCL_ERROR;
}
}
scl_result_t scl_wifi_get_mac_address(scl_mac_t *mac)
{
scl_mac scl_mac_data;
scl_result_t scl_retval = SCL_SUCCESS;
scl_mac_data.mac = mac;
scl_mac_data.retval = SCL_SUCCESS;
if (mac == NULL) {
return SCL_BADARG;
}
scl_retval = scl_send_data(SCL_TX_GET_MAC, (char *)&scl_mac_data, TIMER_DEFAULT_VALUE);
if (scl_retval == SCL_SUCCESS) {
return scl_mac_data.retval;
} else {
SCL_LOG(("Get MAC address error\r\n"));
return SCL_ERROR;
}
}
scl_result_t scl_wifi_get_bssid(scl_mac_t *bssid)
{
struct scl_bssid {
scl_mac_t *bssid;
uint32_t retval;
} scl_bssid_t;
scl_result_t scl_retval = SCL_SUCCESS;
scl_bssid_t.bssid = bssid;
scl_bssid_t.retval = SCL_SUCCESS;
if (bssid == NULL) {
return SCL_BADARG;
}
scl_retval = scl_send_data(SCL_TX_WIFI_GET_BSSID, (char *)&scl_bssid_t, TIMER_DEFAULT_VALUE);
if (scl_retval == SCL_SUCCESS) {
return scl_bssid_t.retval;
} else {
SCL_LOG(("get bssid error\r\n"));
return SCL_ERROR;
}
}
scl_result_t scl_wifi_register_multicast_address(scl_mac_t *mac)
{
scl_mac scl_mac_t;
scl_mac_t.mac = mac;
scl_mac_t.retval = SCL_SUCCESS;
scl_result_t scl_retval = SCL_SUCCESS;
if (mac == NULL) {
return SCL_BADARG;
}
scl_retval = scl_send_data(SCL_TX_REGISTER_MULTICAST_ADDRESS, (char *)&scl_mac_t, TIMER_DEFAULT_VALUE);
if (scl_retval != SCL_SUCCESS) {
SCL_LOG(("Register Multicast Address IPC Error\r\n"));
return SCL_ERROR;
}
return (scl_mac_t.retval);
}
scl_result_t scl_network_send_ethernet_data(scl_tx_buf_t scl_buffer)
{
scl_result_t retval = SCL_SUCCESS;
if (scl_buffer.buffer == NULL) {
return SCL_BADARG;
}
retval = scl_send_data(SCL_TX_SEND_OUT, (char *)&scl_buffer, TIMER_DEFAULT_VALUE);
return retval;
}
scl_result_t scl_wifi_get_rssi(int32_t *rssi)
{
struct tx_param {
uint32_t retval;
int32_t *get_rssi;
} tx_param_t;
scl_result_t scl_retval = SCL_SUCCESS;
if (rssi == NULL) {
return SCL_BADARG;
}
tx_param_t.get_rssi = rssi;
scl_retval = scl_send_data(SCL_TX_WIFI_GET_RSSI, (char *) &tx_param_t, TIMER_DEFAULT_VALUE);
if (scl_retval == SCL_SUCCESS) {
return tx_param_t.retval;
} else {
SCL_LOG(("get rssi error\r\n"));
return SCL_ERROR;
}
}