Skip to content

Commit 6111b8d

Browse files
authored
Merge pull request #12828 from dustin-crossman/pr/update-cysbsyskit_01
Update CYSBSYSKIT_01
2 parents aec6303 + d9655da commit 6111b8d

File tree

24 files changed

+1409
-359
lines changed

24 files changed

+1409
-359
lines changed

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_SCL/interface/SclSTAInterface.cpp

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@
3232
/** @file
3333
* Provides SCL interface functions to be used with WiFiInterface or NetworkInterface Objects
3434
*/
35+
#define MIN_SSID_LENGTH (0)
36+
#define MIN_PASSWORD_LENGTH (0)
3537

36-
struct scl_tx_nw_credentials {
38+
struct scl_tx_net_credentials {
3739
nsapi_security_t network_security_type;
3840
int ssid_len;
3941
int pass_len;
4042
const char *network_ssid;
4143
const char *network_passphrase;
42-
} scl_tx_nw_credentials_t;
44+
} scl_tx_network_credentials;
4345

4446
network_params_t network_parameter;
4547

@@ -177,20 +179,24 @@ nsapi_error_t SclSTAInterface::connect()
177179
nsapi_error_t interface_status;
178180
uint32_t connection_status = 0;
179181

180-
scl_tx_nw_credentials_t.network_ssid = _ssid;
181-
if (strlen(_ssid) < MAX_SSID_LENGTH) {
182-
scl_tx_nw_credentials_t.ssid_len = strlen(_ssid);
182+
scl_tx_network_credentials.network_ssid = _ssid;
183+
if ((strlen(_ssid) < MAX_SSID_LENGTH) && (strlen(_ssid) > MIN_SSID_LENGTH)) {
184+
scl_tx_network_credentials.ssid_len = strlen(_ssid);
185+
} else {
186+
return NSAPI_ERROR_PARAMETER;
183187
}
184-
scl_tx_nw_credentials_t.network_passphrase = _pass;
185-
if (strlen(_pass) < MAX_PASSWORD_LENGTH) {
186-
scl_tx_nw_credentials_t.pass_len = strlen(_pass);
188+
scl_tx_network_credentials.network_passphrase = _pass;
189+
if (((strlen(_pass) < MAX_PASSWORD_LENGTH) && (strlen(_pass) > MIN_PASSWORD_LENGTH)) || (_security == NSAPI_SECURITY_NONE)) {
190+
scl_tx_network_credentials.pass_len = strlen(_pass);
191+
} else {
192+
return NSAPI_ERROR_PARAMETER;
187193
}
188-
scl_tx_nw_credentials_t.network_security_type = _security;
194+
scl_tx_network_credentials.network_security_type = _security;
189195

190-
ret_val = scl_send_data(SCL_TX_CONNECT, (char *)&scl_tx_nw_credentials_t, TIMER_DEFAULT_VALUE);
196+
ret_val = scl_send_data(SCL_TX_CONNECT, (char *)&scl_tx_network_credentials, TIMER_DEFAULT_VALUE);
191197

192198
if (ret_val == SCL_SUCCESS) {
193-
SCL_LOG(("wifi provisioning in progress"));
199+
SCL_LOG(("wifi provisioning in progress\r\n"));
194200
}
195201

196202
network_parameter.connection_status = NSAPI_STATUS_DISCONNECTED;
@@ -230,7 +236,9 @@ nsapi_error_t SclSTAInterface::connect()
230236
network_parameter.gateway,
231237
DEFAULT_STACK);
232238

233-
scl_send_data(SCL_TX_CONNECTION_STATUS, (char *)&connection_status, TIMER_DEFAULT_VALUE);
239+
if (interface_status == NSAPI_ERROR_OK) {
240+
scl_send_data(SCL_TX_CONNECTION_STATUS, (char *)&connection_status, TIMER_DEFAULT_VALUE);
241+
}
234242

235243
return interface_status;
236244
}
@@ -246,14 +254,27 @@ nsapi_error_t SclSTAInterface::disconnect()
246254
{
247255
scl_result_t ret_val;
248256
nsapi_error_t disconnect_status;
257+
uint32_t delay_timeout = 0;
258+
249259
ret_val = scl_send_data(SCL_TX_DISCONNECT, (char *)&disconnect_status, TIMER_DEFAULT_VALUE);
250260

251261
if (ret_val == SCL_ERROR) {
252262
return NSAPI_ERROR_TIMEOUT;
253263
}
254264

255265
if (!_interface) {
256-
return NSAPI_STATUS_DISCONNECTED;
266+
return NSAPI_ERROR_NO_CONNECTION;
267+
}
268+
269+
// block till disconnected from network
270+
while ((network_parameter.connection_status != NSAPI_STATUS_DISCONNECTED) && delay_timeout < NW_DISCONNECT_TIMEOUT) {
271+
ret_val = scl_get_nw_parameters(&network_parameter);
272+
wait_us(NW_DELAY_TIME_US);
273+
delay_timeout++;
274+
}
275+
276+
if (delay_timeout >= NW_DISCONNECT_TIMEOUT) {
277+
return NSAPI_ERROR_TIMEOUT;
257278
}
258279

259280
// bring down

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_SCL/interface/scl_emac.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ void SCL_EMAC::power_down()
8989
bool SCL_EMAC::power_up()
9090
{
9191
if (!powered_up) {
92-
if (scl_wifi_on() != true) {
93-
SCL_LOG(("returning False in scl_wifi_on()\n"));
92+
#ifdef MBED_TEST_MODE
93+
scl_init();
94+
#endif
95+
if (!scl_wifi_on()) {
96+
SCL_LOG(("WiFi failed to turn on\r\n"));
9497
return false;
9598
}
9699
powered_up = true;
@@ -109,10 +112,9 @@ bool SCL_EMAC::get_hwaddr(uint8_t *addr) const
109112
memcpy(addr, mac.octet, sizeof(mac.octet));
110113
return true;
111114
} else {
112-
SCL_LOG(("return False in SCL_EMAC::gethwaddr\n"));
115+
SCL_LOG(("Unable to get MAC address\r\n"));
113116
return false;
114117
}
115-
116118
}
117119

118120
void SCL_EMAC::set_hwaddr(const uint8_t *addr)
@@ -150,7 +152,8 @@ bool SCL_EMAC::link_out(emac_mem_buf_t *buf)
150152
if (buf == NULL) {
151153
return false;
152154
}
153-
retval = scl_network_send_ethernet_data(scl_tx_data);
155+
156+
retval = scl_network_send_ethernet_data(scl_tx_data); //Buffer is copied on Network Processor
154157
if (retval != SCL_SUCCESS) {
155158
return false;
156159
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
1819
/** @file scl_common.h
1920
* Defines common data types used in SCL
2021
*/

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ extern "C"
5353
* Default timeout value (in seconds) for Wi-Fi connection
5454
*/
5555
#define NW_CONNECT_TIMEOUT (30)
56+
/**
57+
* Default timeout value (in seconds) for Wi-Fi disconnection
58+
*/
59+
#define NW_DISCONNECT_TIMEOUT (30)
5660
/**
5761
* Default interval (in micro seconds) for polling the Network Processor
5862
*/

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

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
1819
/** @file
1920
* Provides SCL functionality to communicate with Network Processor
2021
*/
@@ -40,6 +41,7 @@
4041
#define DELAY_TIME (1000)
4142
#define SEMAPHORE_MAXCOUNT (1)
4243
#define SEMAPHORE_INITCOUNT (0)
44+
#define INTIAL_VALUE (0)
4345
/******************************************************
4446
** Function Declarations
4547
*******************************************************/
@@ -55,13 +57,13 @@ scl_result_t scl_init(void);
5557
* Variables Definitions
5658
*****************************************************/
5759
/* Structure of SCL thread info
58-
* scl_thread_quit_flag: flag used to determine if thread is to be quit
5960
* scl_inited: flag used to determine if thread is started
60-
* scl_thread: variable for thread handle
61+
* scl_thread_quit_flag: flag used to determine if thread is to be quit
6162
* scl_thread_stack_start: pointer to start of thread stack
63+
* scl_thread: variable for thread handle
64+
* scl_rx_ready: semaphore for blocking the thread
6265
* scl_thread_stack_size: size of thread stack
6366
* scl_thread_priority: priority of thread
64-
* scl_rx_ready: semaphore for blocking the thread
6567
*/
6668
struct scl_thread_info_t {
6769
volatile scl_bool_t scl_inited;
@@ -113,9 +115,10 @@ static void scl_config(void)
113115
*/
114116
static scl_result_t scl_thread_init(void)
115117
{
116-
cy_rslt_t retval, tmp = 0;
118+
cy_rslt_t retval = CY_RSLT_SUCCESS;
119+
cy_rslt_t tmp = INTIAL_VALUE;
117120
memset(&g_scl_thread_info, 0, sizeof(g_scl_thread_info));
118-
g_scl_thread_info.scl_thread_stack_start = (uint8_t *) malloc(SCL_THREAD_STACK_SIZE);;
121+
g_scl_thread_info.scl_thread_stack_start = (uint8_t *) malloc(SCL_THREAD_STACK_SIZE);
119122
g_scl_thread_info.scl_thread_stack_size = (uint32_t) SCL_THREAD_STACK_SIZE;
120123
g_scl_thread_info.scl_thread_priority = (cy_thread_priority_t) SCL_THREAD_PRIORITY;
121124

@@ -141,7 +144,7 @@ static scl_result_t scl_thread_init(void)
141144
scl_result_t scl_init(void)
142145
{
143146
scl_result_t retval = SCL_SUCCESS;
144-
uint32_t configuration_parameters = 0;
147+
uint32_t configuration_parameters = INTIAL_VALUE;
145148
#ifdef MBED_CONF_TARGET_NP_CLOUD_DISABLE
146149
configuration_parameters = (MBED_CONF_TARGET_NP_CLOUD_DISABLE << 1);
147150
#else
@@ -152,12 +155,12 @@ scl_result_t scl_init(void)
152155
#else
153156
configuration_parameters |= false;
154157
#endif
155-
//SCL_LOG("configuration_parameters = %lu\n", configuration_parameters);
158+
//SCL_LOG("configuration_parameters = %lu\r\n", configuration_parameters);
156159
scl_config();
157160
if (g_scl_thread_info.scl_inited != SCL_TRUE) {
158161
retval = scl_thread_init();
159162
if (retval != SCL_SUCCESS) {
160-
SCL_LOG(("Thread init failed\n"));
163+
SCL_LOG(("Thread init failed\r\n"));
161164
return SCL_ERROR;
162165
} else {
163166
retval = scl_send_data(SCL_TX_CONFIG_PARAMETERS, (char *) &configuration_parameters, TIMER_DEFAULT_VALUE);
@@ -173,7 +176,7 @@ scl_result_t scl_send_data(int index, char *buffer, uint32_t timeout)
173176
IPC_STRUCT_Type *scl_send = NULL;
174177
uint32_t delay_timeout;
175178

176-
SCL_LOG(("scl_send_data index = %d\n", index));
179+
SCL_LOG(("scl_send_data index = %d\r\n", index));
177180
scl_send = Cy_IPC_Drv_GetIpcBaseAddress(SCL_TX_CHANNEL);
178181
CHECK_BUFFER_NULL(buffer);
179182
if (!(REG_IPC_STRUCT_LOCK_STATUS(scl_send) & SCL_LOCK_ACQUIRE_STATUS)) {
@@ -198,7 +201,7 @@ scl_result_t scl_send_data(int index, char *buffer, uint32_t timeout)
198201
return SCL_SUCCESS;
199202
}
200203
} else {
201-
SCL_LOG(("unable to acquire lock\n"));
204+
SCL_LOG(("unable to acquire lock\r\n"));
202205
return SCL_ERROR;
203206
}
204207
}
@@ -230,27 +233,22 @@ static void scl_rx_handler(void)
230233
uint32_t index;
231234
IPC_STRUCT_Type *scl_receive = NULL;
232235
scl_buffer_t cp_buffer;
233-
scl_buffer_t scl_buffer;
234236
uint32_t rx_ipc_size;
235-
struct rx_ipc_info {
236-
uint32_t size;
237-
int *buf_alloc;
238-
}*rx_cp = NULL;
239-
237+
int *rx_cp_buffer;
240238
SCL_LOG(("Starting CP Rx thread\r\n"));
241239
scl_receive = Cy_IPC_Drv_GetIpcBaseAddress(SCL_RX_CHANNEL);
242240

243241
while (SCL_TRUE) {
244242
cy_rtos_get_semaphore(&g_scl_thread_info.scl_rx_ready, CY_RTOS_NEVER_TIMEOUT, SCL_FALSE);
245243
index = (uint32_t)REG_IPC_STRUCT_DATA0(scl_receive);
246-
SCL_LOG(("scl_rx_handler index = %lu\n", index));
244+
SCL_LOG(("scl_rx_handler index = %lu\r\n", index));
247245
switch (index) {
248246
case SCL_RX_DATA: {
249-
rx_cp = (struct rx_ipc_info *) REG_IPC_STRUCT_DATA1(scl_receive);
250-
scl_buffer = rx_cp->buf_alloc;
247+
SCL_LOG(("on CP the rxd address = %lx\r\n", REG_IPC_STRUCT_DATA1(scl_receive)));
248+
rx_cp_buffer = (int *) REG_IPC_STRUCT_DATA1(scl_receive);
249+
SCL_LOG(("rx_cp_buffer = %p \r\n", rx_cp_buffer));
251250
REG_IPC_STRUCT_RELEASE(scl_receive) = SCL_RELEASE;
252-
SCL_LOG(("scl_buffer = %p\n", scl_buffer));
253-
scl_network_process_ethernet_data(scl_buffer);
251+
scl_network_process_ethernet_data(rx_cp_buffer);
254252
break;
255253
}
256254
case SCL_RX_TEST_MSG: {
@@ -273,11 +271,11 @@ static void scl_rx_handler(void)
273271
} else {
274272
scl_emac_wifi_link_state_changed(false);
275273
}
276-
SCL_LOG(("connection status = %d\n", connection_status));
274+
SCL_LOG(("connection status = %d\r\n", connection_status));
277275
break;
278276
}
279277
default: {
280-
SCL_LOG(("incorrect IPC from Network Processor\n"));
278+
SCL_LOG(("incorrect IPC from Network Processor\r\n"));
281279
REG_IPC_STRUCT_RELEASE(scl_receive) = SCL_RELEASE;
282280
break;
283281
}

targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/include/scl_buffer_api.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ extern "C"
3636
/******************************************************
3737
* Constants
3838
******************************************************/
39-
/**
40-
* Size of the SDIO block
41-
*/
42-
#define SDIO_BLOCK_SIZE (64U)
4339

4440
/******************************************************
4541
* Macros

targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/scl_buffer_api.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ scl_result_t scl_host_buffer_get(scl_buffer_t *buffer, scl_buffer_dir_t directio
4545
if ((direction == SCL_NETWORK_TX) && (size <= PBUF_POOL_BUFSIZE)) {
4646
p = pbuf_alloc(PBUF_RAW, size, PBUF_POOL);
4747
} else {
48-
p = pbuf_alloc(PBUF_RAW, size + SDIO_BLOCK_SIZE, PBUF_RAM);
48+
p = pbuf_alloc(PBUF_RAW, size, PBUF_RAM);
4949
if (p != NULL) {
5050
p->len = size;
51-
p->tot_len -= SDIO_BLOCK_SIZE;
5251
}
5352
}
5453
if (p != NULL) {

targets/TARGET_Cypress/TARGET_PSOC6/COMPONENT_SCL/src/scl_wifi_api.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ scl_result_t scl_wifi_is_ready_to_transceive(void)
3838

3939
result = scl_send_data(SCL_TX_TRANSCEIVE_READY, (char *)&retval, TIMER_DEFAULT_VALUE);
4040
if (result == SCL_ERROR) {
41-
SCL_LOG(("Ready to tranceive error\n"));
41+
SCL_LOG(("Ready to tranceive error\r\n"));
4242
return SCL_ERROR;
4343
} else {
4444
return retval;
@@ -51,7 +51,7 @@ bool scl_wifi_on(void)
5151
scl_result_t result = SCL_SUCCESS;
5252
result = scl_send_data(SCL_TX_WIFI_ON, (char *)&retval, WIFI_ON_TIMEOUT);
5353
if (result == SCL_ERROR) {
54-
SCL_LOG(("wifi_on Error\n"));
54+
SCL_LOG(("wifi_on Error\r\n"));
5555
return false;
5656
} else {
5757
return retval;
@@ -66,7 +66,7 @@ scl_result_t scl_wifi_set_up(void)
6666
if (result == SCL_SUCCESS) {
6767
return retval;
6868
} else {
69-
SCL_LOG(("Wifi set up error\n"));
69+
SCL_LOG(("Wifi set up error\r\n"));
7070
return SCL_ERROR;
7171
}
7272
}
@@ -85,7 +85,7 @@ scl_result_t scl_wifi_get_mac_address(scl_mac_t *mac)
8585
if (scl_retval == SCL_SUCCESS) {
8686
return scl_mac_data.retval;
8787
} else {
88-
SCL_LOG(("Get MAC address error\n"));
88+
SCL_LOG(("Get MAC address error\r\n"));
8989
return SCL_ERROR;
9090
}
9191
}
@@ -98,15 +98,15 @@ scl_result_t scl_wifi_get_bssid(scl_mac_t *bssid)
9898
} scl_bssid_t;
9999
scl_result_t scl_retval = SCL_SUCCESS;
100100
scl_bssid_t.bssid = bssid;
101-
scl_bssid_t.retval = 0;
101+
scl_bssid_t.retval = SCL_SUCCESS;
102102
if (bssid == NULL) {
103103
return SCL_BADARG;
104104
}
105105
scl_retval = scl_send_data(SCL_TX_WIFI_GET_BSSID, (char *)&scl_bssid_t, TIMER_DEFAULT_VALUE);
106106
if (scl_retval == SCL_SUCCESS) {
107107
return scl_bssid_t.retval;
108108
} else {
109-
SCL_LOG(("get bssid error\n"));
109+
SCL_LOG(("get bssid error\r\n"));
110110
return SCL_ERROR;
111111
}
112112
}
@@ -115,14 +115,14 @@ scl_result_t scl_wifi_register_multicast_address(scl_mac_t *mac)
115115
{
116116
scl_mac scl_mac_t;
117117
scl_mac_t.mac = mac;
118-
scl_mac_t.retval = 0;
118+
scl_mac_t.retval = SCL_SUCCESS;
119119
scl_result_t scl_retval = SCL_SUCCESS;
120120
if (mac == NULL) {
121121
return SCL_BADARG;
122122
}
123123
scl_retval = scl_send_data(SCL_TX_REGISTER_MULTICAST_ADDRESS, (char *)&scl_mac_t, TIMER_DEFAULT_VALUE);
124124
if (scl_retval != SCL_SUCCESS) {
125-
SCL_LOG(("Register Multicast Address IPC Error"));
125+
SCL_LOG(("Register Multicast Address IPC Error\r\n"));
126126
return SCL_ERROR;
127127
}
128128
return (scl_mac_t.retval);
@@ -154,7 +154,7 @@ scl_result_t scl_wifi_get_rssi(int32_t *rssi)
154154
if (scl_retval == SCL_SUCCESS) {
155155
return tx_param_t.retval;
156156
} else {
157-
SCL_LOG(("get rssi error\n"));
157+
SCL_LOG(("get rssi error\r\n"));
158158
return SCL_ERROR;
159159
}
160160
}

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYSBSYSKIT_01/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource/cycfg.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
void init_cycfg_all(void)
3030
{
31-
init_cycfg_routing();
32-
init_cycfg_pins();
31+
init_cycfg_system();
32+
init_cycfg_routing();
33+
init_cycfg_peripherals();
34+
init_cycfg_pins();
3335
}

0 commit comments

Comments
 (0)