mirror of https://github.com/ARMmbed/mbed-os.git
Update whd-bsp-integration to v1.0.1
parent
c87682167b
commit
ac8e8229a8
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2018-2019 Cypress Semiconductor Corporation
|
||||
* Copyright 2018-2020 Cypress Semiconductor Corporation
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -23,12 +23,12 @@
|
|||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "cy_network_buffer.h"
|
||||
#include "cy_utils.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/memp.h"
|
||||
|
||||
#define SDIO_BLOCK_SIZE (64U)
|
||||
|
||||
whd_result_t cy_host_buffer_get(whd_buffer_t *buffer, whd_buffer_dir_t direction, unsigned short size, unsigned long timeout_ms)
|
||||
|
@ -38,21 +38,21 @@ whd_result_t cy_host_buffer_get(whd_buffer_t *buffer, whd_buffer_dir_t direction
|
|||
struct pbuf *p = NULL;
|
||||
if ( ( direction == WHD_NETWORK_TX) && ( size <= PBUF_POOL_BUFSIZE ) )
|
||||
{
|
||||
p = pbuf_alloc(PBUF_RAW, size, PBUF_POOL);
|
||||
p = pbuf_alloc(PBUF_RAW, size, PBUF_POOL);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = pbuf_alloc(PBUF_RAW, size+SDIO_BLOCK_SIZE, PBUF_RAM);
|
||||
if ( p != NULL )
|
||||
{
|
||||
p->len = size;
|
||||
p->tot_len -= SDIO_BLOCK_SIZE;
|
||||
}
|
||||
p = pbuf_alloc(PBUF_RAW, size+SDIO_BLOCK_SIZE, PBUF_RAM);
|
||||
if ( p != NULL )
|
||||
{
|
||||
p->len = size;
|
||||
p->tot_len -= SDIO_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
if (p != NULL )
|
||||
{
|
||||
*buffer = p;
|
||||
return WHD_SUCCESS;
|
||||
return WHD_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -108,5 +108,3 @@ whd_result_t cy_buffer_add_remove_at_front(whd_buffer_t *buffer, int32_t add_rem
|
|||
|
||||
return WHD_SUCCESS;
|
||||
}
|
||||
|
||||
#endif /* defined(CYBSP_WIFI_CAPABLE) */
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2018-2019 Cypress Semiconductor Corporation
|
||||
* Copyright 2018-2020 Cypress Semiconductor Corporation
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -27,30 +27,21 @@
|
|||
* \addtogroup group_bsp_network_buffer Buffer management
|
||||
* \{
|
||||
* Basic set of APIs for dealing with network packet buffers
|
||||
*
|
||||
* \defgroup group_bsp_network_buffer_functions Functions
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "cy_result.h"
|
||||
#include "whd.h"
|
||||
#include "whd_network_types.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_network_buffer_functions
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Allocates a packet buffer
|
||||
*
|
||||
* Attempts to allocate a packet buffer of the size requested. It can do this
|
||||
|
@ -136,7 +127,7 @@ whd_result_t cy_buffer_set_size(whd_buffer_t buffer, unsigned short size);
|
|||
* buffer - a negative value increases the space for headers at the front
|
||||
* of the packet, a positive value decreases the space.
|
||||
*
|
||||
* @return : CY_RSLT_SUCCESS or WHD_PMK_WRONG_LENGTH if the added amount is outside
|
||||
* @return : CY_RSLT_SUCCESS or WHD_PMK_WRONG_LENGTH if the added amount is outside
|
||||
* the size of the buffer
|
||||
*/
|
||||
whd_result_t cy_buffer_add_remove_at_front(whd_buffer_t *buffer, int32_t add_remove_amount);
|
||||
|
@ -170,12 +161,9 @@ whd_result_t cy_buffer_add_remove_at_front(whd_buffer_t *buffer, int32_t add_rem
|
|||
*/
|
||||
void cy_network_process_ethernet_data(whd_interface_t interface, whd_buffer_t buffer);
|
||||
|
||||
/** \} group_bsp_network_buffer_functions */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* defined(CYBSP_WIFI_CAPABLE) */
|
||||
|
||||
/** \} group_bsp_network_buffer */
|
|
@ -3,10 +3,10 @@
|
|||
*
|
||||
* \brief
|
||||
* Provides utility functions that are used by board support packages.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2018-2019 Cypress Semiconductor Corporation
|
||||
* Copyright 2018-2020 Cypress Semiconductor Corporation
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -21,7 +21,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
#if defined(CYBSP_WIFI_CAPABLE)
|
||||
|
||||
#include "cybsp.h"
|
||||
#include "cybsp_wifi.h"
|
||||
|
@ -35,33 +34,33 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define THREAD_STACK_SIZE 5120
|
||||
#define THREAD_PRIORITY CY_RTOS_PRIORITY_HIGH
|
||||
#define COUNTRY WHD_COUNTRY_AUSTRALIA
|
||||
#define DEFAULT_OOB_PIN 0
|
||||
#define WLAN_POWER_UP_DELAY_MS 250
|
||||
#define THREAD_STACK_SIZE 5120
|
||||
#define THREAD_PRIORITY CY_RTOS_PRIORITY_HIGH
|
||||
#define COUNTRY WHD_COUNTRY_AUSTRALIA
|
||||
#define DEFAULT_OOB_PIN 0
|
||||
#define WLAN_POWER_UP_DELAY_MS 250
|
||||
|
||||
#define SDIO_ENUMERATION_TRIES 500
|
||||
#define SDIO_RETRY_DELAY_MS 1
|
||||
#define SDIO_BUS_LEVEL_MAX_RETRIES 5
|
||||
#define SDIO_ENUMERATION_TRIES 500
|
||||
#define SDIO_RETRY_DELAY_MS 1
|
||||
#define SDIO_BUS_LEVEL_MAX_RETRIES 5
|
||||
|
||||
#if !defined(CY_WIFI_OOB_INTR_PRIORITY)
|
||||
#define CY_WIFI_OOB_INTR_PRIORITY 2
|
||||
#endif/* !defined(CY_WIFI_OOB_INTR_PRIORITY) */
|
||||
#define CY_WIFI_OOB_INTR_PRIORITY 2
|
||||
#endif
|
||||
|
||||
/* Determine whether to use the SDIO oob interrupt.
|
||||
* Use CY_WIFI_HOST_WAKE_SW_FORCE to force the enable status.
|
||||
*/
|
||||
#if !defined(CY_WIFI_HOST_WAKE_SW_FORCE)
|
||||
#define CY_SDIO_BUS_USE_OOB_INTR (1u)
|
||||
#define CY_SDIO_BUS_USE_OOB_INTR (1u)
|
||||
#else
|
||||
#define CY_SDIO_BUS_USE_OOB_INTR CY_WIFI_HOST_WAKE_SW_FORCE
|
||||
#define CY_SDIO_BUS_USE_OOB_INTR CY_WIFI_HOST_WAKE_SW_FORCE
|
||||
#endif /* defined(CY_WIFI_HOST_WAKE_SW_FORCE) */
|
||||
|
||||
#if (CY_SDIO_BUS_USE_OOB_INTR != 0)
|
||||
/* Setup configuration based on configurator or BSP, where configurator has precedence. */
|
||||
#if defined(CYCFG_WIFI_HOST_WAKE_ENABLED)
|
||||
#define CY_WIFI_HOST_WAKE_GPIO CYCFG_WIFI_HOST_WAKE_GPIO
|
||||
#define CY_WIFI_HOST_WAKE_GPIO CYCFG_WIFI_HOST_WAKE_GPIO
|
||||
#define CY_WIFI_HOST_WAKE_IRQ_EVENT CYCFG_WIFI_HOST_WAKE_IRQ_EVENT
|
||||
#else
|
||||
/* Setup host-wake pin */
|
||||
|
@ -78,7 +77,7 @@ extern "C" {
|
|||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define CY_WIFI_HOST_WAKE_GPIO CYHAL_NC_PIN_VALUE
|
||||
#define CY_WIFI_HOST_WAKE_GPIO CYHAL_NC_PIN_VALUE
|
||||
#define CY_WIFI_HOST_WAKE_IRQ_EVENT 0
|
||||
#endif /* (CY_SDIO_BUS_USE_OOB_INTR != 0) */
|
||||
|
||||
|
@ -99,7 +98,6 @@ static whd_netif_funcs_t netif_ops =
|
|||
.whd_network_process_ethernet_data = cy_network_process_ethernet_data,
|
||||
};
|
||||
|
||||
//TODO: Need to use resource implemenatation from abstraction layer.
|
||||
extern whd_resource_source_t resource_ops;
|
||||
|
||||
static cy_rslt_t sdio_try_send_cmd(const cyhal_sdio_t *sdio_object, cyhal_transfer_t direction, \
|
||||
|
@ -112,7 +110,7 @@ static cy_rslt_t sdio_try_send_cmd(const cyhal_sdio_t *sdio_object, cyhal_transf
|
|||
result = cyhal_sdio_send_cmd(sdio_object, direction, command, argument, response);
|
||||
if(result != CY_RSLT_SUCCESS)
|
||||
{
|
||||
Cy_SysLib_Delay(SDIO_RETRY_DELAY_MS);
|
||||
cyhal_system_delay_ms(SDIO_RETRY_DELAY_MS);
|
||||
}
|
||||
loop_count++;
|
||||
}
|
||||
|
@ -140,7 +138,7 @@ static cy_rslt_t cybsp_sdio_enumerate(const cyhal_sdio_t *sdio_object)
|
|||
result = sdio_try_send_cmd(sdio_object, CYHAL_READ, CYHAL_SDIO_CMD_SEND_RELATIVE_ADDR, no_argument, &rel_addr);
|
||||
if(result != CY_RSLT_SUCCESS)
|
||||
{
|
||||
Cy_SysLib_Delay(SDIO_RETRY_DELAY_MS);
|
||||
cyhal_system_delay_ms(SDIO_RETRY_DELAY_MS);
|
||||
}
|
||||
loop_count++;
|
||||
} while (result != CY_RSLT_SUCCESS && loop_count <= SDIO_ENUMERATION_TRIES);
|
||||
|
@ -161,7 +159,7 @@ static cy_rslt_t reset_wifi_chip(void)
|
|||
{
|
||||
/* WiFi out of reset */
|
||||
cyhal_gpio_write(CYBSP_WIFI_WL_REG_ON, true);
|
||||
Cy_SysLib_Delay(WLAN_POWER_UP_DELAY_MS);
|
||||
cyhal_system_delay_ms(WLAN_POWER_UP_DELAY_MS);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -179,6 +177,15 @@ static cy_rslt_t init_sdio_bus(void)
|
|||
whd_oob_config_t oob_config;
|
||||
cyhal_sdio_cfg_t config;
|
||||
|
||||
/* If the configurator reserved the pin, we need to release it here since
|
||||
WHD will try to reserve it again. WHD has no idea about configurators
|
||||
and expects it can reserve the pin that it is going to manage.
|
||||
*/
|
||||
#if defined(CYCFG_WIFI_HOST_WAKE_ENABLED)
|
||||
cyhal_resource_inst_t pinRsc = cyhal_utils_get_gpio_resource(CY_WIFI_HOST_WAKE_GPIO);
|
||||
cyhal_hwmgr_free(&pinRsc);
|
||||
#endif
|
||||
|
||||
oob_config.host_oob_pin = CY_WIFI_HOST_WAKE_GPIO;
|
||||
oob_config.dev_gpio_sel = DEFAULT_OOB_PIN;
|
||||
oob_config.is_falling_edge = (CY_WIFI_HOST_WAKE_IRQ_EVENT == CYHAL_GPIO_IRQ_FALL)
|
||||
|
@ -247,5 +254,3 @@ whd_driver_t cybsp_get_wifi_driver(void)
|
|||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* defined(CYBSP_WIFI_CAPABLE) */
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2018-2019 Cypress Semiconductor Corporation
|
||||
* Copyright 2018-2020 Cypress Semiconductor Corporation
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -25,14 +25,10 @@
|
|||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_wifi WiFi
|
||||
* \addtogroup group_bsp_wifi WiFi Initialization
|
||||
* \{
|
||||
* Basic abstraction layer for dealing with boards containing a Cypress MCU. This
|
||||
* API provides convenience methods for initializing and manipulating different
|
||||
* hardware found on the board.
|
||||
*
|
||||
* \defgroup group_bsp_wifi_macros Macros
|
||||
* \defgroup group_bsp_wifi_functions Functions
|
||||
* Basic integration code for interfacing the WiFi Host Driver (WHD) with the Board
|
||||
* Support Packages (BSPs).
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
@ -43,49 +39,40 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_wifi_macros
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Initialization of the WiFi driver failed. */
|
||||
#define CYBSP_RSLT_WIFI_INIT_FAILED (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_BSP, 4))
|
||||
#define CYBSP_RSLT_WIFI_INIT_FAILED (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_WHD_INTEGRATION, 0))
|
||||
|
||||
/** SDIO enumeration failed. */
|
||||
#define CYBSP_RSLT_WIFI_SDIO_ENUM_TIMEOUT (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_BSP, 5))
|
||||
#define CYBSP_RSLT_WIFI_SDIO_ENUM_TIMEOUT (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_WHD_INTEGRATION, 1))
|
||||
|
||||
/** \} group_bsp_board_macros */
|
||||
|
||||
/**
|
||||
* \addtogroup group_bsp_wifi_functions
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** Initializes the primary interface for the WiFi driver on the board. This function
|
||||
* does the following
|
||||
* 1) Initializes the WiFi driver.
|
||||
/** Initializes the primary interface for the WiFi driver on the board. This sets up
|
||||
* the WHD interface to use the \ref group_bsp_network_buffer APIs and to communicate
|
||||
* over the SDIO interface on the board. This function does the following:<br>
|
||||
* 1) Initializes the WiFi driver.<br>
|
||||
* 2) Turns on the WiFi chip.
|
||||
*
|
||||
* @note This function cannot be called multiple times. The user needs to first de-initialize
|
||||
* before calling this function again.
|
||||
*
|
||||
* @param[out] interface Interface to be initialized
|
||||
* @note This function cannot be called multiple times. If the interface needs to be
|
||||
* reinitialized, \ref cybsp_wifi_deinit must be called before calling this function
|
||||
* again.
|
||||
*
|
||||
* @param[out] interface Interface to be initialized
|
||||
* @return CY_RSLT_SUCCESS for successful initialization or error if initialization failed.
|
||||
*/
|
||||
cy_rslt_t cybsp_wifi_init_primary(whd_interface_t* interface);
|
||||
|
||||
/** This function initializes and adds a secondary interface to the WiFi driver.
|
||||
* @note This function does not initialize the WiFi driver or turn on the WiFi chip.
|
||||
* That is required to be done by the primary interface
|
||||
*
|
||||
* That is required to be done by first calling \ref cybsp_wifi_init_primary.
|
||||
*
|
||||
* @param[out] interface Interface to be initialized
|
||||
* @param[in] mac_address Mac address for secondary interface
|
||||
* @return CY_RSLT_SUCCESS for successful initialization or error if initialization failed.
|
||||
*/
|
||||
cy_rslt_t cybsp_wifi_init_secondary(whd_interface_t* interface, whd_mac_t* mac_address);
|
||||
|
||||
/** De-initializes all WiFi interfaces and the WiFi driver. This function does the following
|
||||
* 1) Deinitializes all WiFi interfaces and WiFi driver.
|
||||
/** De-initializes all WiFi interfaces and the WiFi driver. This function does the
|
||||
* following:<br>
|
||||
* 1) Deinitializes all WiFi interfaces and WiFi driver.<br>
|
||||
* 2) Turns off the WiFi chip.
|
||||
*
|
||||
* @param[in] interface Interface to be de-initialized.
|
||||
|
@ -94,14 +81,14 @@ cy_rslt_t cybsp_wifi_init_secondary(whd_interface_t* interface, whd_mac_t* mac_a
|
|||
cy_rslt_t cybsp_wifi_deinit(whd_interface_t interface);
|
||||
|
||||
/** Gets the wifi driver instance initialized by the driver. This should only be called
|
||||
* after the interface is initialized by cybsp_wifi_init_primary().
|
||||
* after being initialized by \ref cybsp_wifi_init_primary() and before being
|
||||
* deinitialized by \ref cybsp_wifi_deinit(). This is also the only time where the
|
||||
* driver reference is valid.
|
||||
*
|
||||
* @return Wifi driver instance pointer.
|
||||
*/
|
||||
whd_driver_t cybsp_get_wifi_driver(void);
|
||||
|
||||
/** \} group_bsp_wifi_functions */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
Loading…
Reference in New Issue