Skip to content

Commit

Permalink
Refactor CYW43xxx wi-fi driver to better work with CMake and move cod…
Browse files Browse the repository at this point in the history
…e out of the Portenta target folder (#292)

* Refactor Cypress WHD wifi & bluetooth drivers to work better with CMake and be vendor agnostic

* Fix some missed changes that belong in the other branch

* Fix build of Cypress targets that use the RTOS adapter.  Make it possible to build Cypress targets in baremetal mode via CMake.

* Try and fix check failures

* Fix a couple unintentional changes
  • Loading branch information
multiplemonomials authored Jul 5, 2024
1 parent de882e6 commit 25dbf7c
Show file tree
Hide file tree
Showing 107 changed files with 854 additions and 3,071 deletions.
3 changes: 0 additions & 3 deletions cmsis/device/rtos/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@
"NUVOTON": {
"idle-thread-stack-size-debug-extra": 512
},
"MCU_PSOC6_M4": {
"target.macros_add": ["CY_RTOS_AWARE"]
},
"ARM_MUSCA_B1": {
"mutex-num": 4
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ if("PSOC6" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_PSOC6)
endif()

if("STM32H747_ARDUINO" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_STM32H747_ARDUINO)
endif()

add_subdirectory(firmware)

target_include_directories(mbed-ble
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(firmware)
target_sources(mbed-ble
PRIVATE
cy_bt_cordio_cfg.cpp
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ if("4343W" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(COMPONENT_4343W)
endif()

if("4343W_FS" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(COMPONENT_4343W_FS)
endif()

if("CYW9P62S1_43012EVB_01" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_CYW9P62S1_43012EVB_01)
endif()
4 changes: 0 additions & 4 deletions connectivity/drivers/emac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ elseif("Silicon_Labs" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_Silicon_Labs)
endif()

if("WHD" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(COMPONENT_WHD)
endif()

target_link_libraries(mbed-emac
PUBLIC
mbed-netsocket-api
Expand Down
149 changes: 8 additions & 141 deletions connectivity/drivers/wifi/COMPONENT_WHD/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,144 +1,11 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(whd-bsp-integration EXCLUDE_FROM_ALL)

add_library(mbed-cy-psoc6-whd-43012 STATIC EXCLUDE_FROM_ALL)
target_include_directories(mbed-cy-psoc6-whd-43012
PUBLIC
wifi-host-driver/resources/firmware/COMPONENT_43012
)
target_sources(mbed-cy-psoc6-whd-43012
PRIVATE
wifi-host-driver/resources/firmware/COMPONENT_43012/43012C0-mfgtest_bin.c
wifi-host-driver/resources/firmware/COMPONENT_43012/43012C0-mfgtest_clm_blob.c
wifi-host-driver/resources/firmware/COMPONENT_43012/43012C0_bin.c
wifi-host-driver/resources/firmware/COMPONENT_43012/43012C0_clm_blob.c
)

add_library(mbed-cy-psoc6-whd-43438 STATIC EXCLUDE_FROM_ALL)
target_include_directories(mbed-cy-psoc6-whd-43438
PUBLIC
wifi-host-driver/resources/firmware/COMPONENT_43438
)
target_sources(mbed-cy-psoc6-whd-43438
PRIVATE
wifi-host-driver/resources/firmware/COMPONENT_43438/43438A1-mfgtest_bin.c
wifi-host-driver/resources/firmware/COMPONENT_43438/43438A1-mfgtest_clm_blob.c
wifi-host-driver/resources/firmware/COMPONENT_43438/43438A1_bin.c
wifi-host-driver/resources/firmware/COMPONENT_43438/43438A1_clm_blob.c
)

add_library(mbed-cy-psoc6-whd-4343w STATIC EXCLUDE_FROM_ALL)
target_include_directories(mbed-cy-psoc6-whd-4343w
PUBLIC
wifi-host-driver/resources/firmware/COMPONENT_4343W
)
target_sources(mbed-cy-psoc6-whd-4343w
PRIVATE
wifi-host-driver/resources/firmware/COMPONENT_4343W/4343WA1-mfgtest_bin.c
wifi-host-driver/resources/firmware/COMPONENT_4343W/4343WA1-mfgtest_clm_blob.c
wifi-host-driver/resources/firmware/COMPONENT_4343W/4343WA1_bin.c
wifi-host-driver/resources/firmware/COMPONENT_4343W/4343WA1_clm_blob.c
)

add_library(mbed-cy8ckit-062s2-43012-whd INTERFACE)
target_include_directories(mbed-cy8ckit-062s2-43012-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CKIT_062S2_43012)

add_library(mbed-cy8ckit-062s2-4343w-whd INTERFACE)
target_include_directories(mbed-cy8ckit-062s2-4343w-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CKIT_062S2_4343W)

add_library(mbed-cy8ckit-062-4343w-whd INTERFACE)
target_include_directories(mbed-cy8ckit-062-4343w-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CKIT_062_4343W)

add_library(mbed-cy8ckit-062-wifi-bt-whd INTERFACE)
target_include_directories(mbed-cy8ckit-062-wifi-bt-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CKIT_062_WIFI_BT)

add_library(mbed-cy8ckit-064s1-4343w-whd INTERFACE)
target_include_directories(mbed-cy8ckit-064s1-4343w-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CKIT_064S1_4343W)

add_library(mbed-cy8ckit-064s2-4343w-whd INTERFACE)
target_include_directories(mbed-cy8ckit-064s2-4343w-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CKIT_064S2_4343W)

add_library(mbed-cy8cmod-062s2-43012-whd INTERFACE)
target_include_directories(mbed-cy8cmod-062s2-43012-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CMOD_062S2_43012)

add_library(mbed-cy8cmod-062s3-4343w-whd INTERFACE)
target_include_directories(mbed-cy8cmod-062s3-4343w-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CMOD_062S3_4343W)

add_library(mbed-cy8cmod-062-4343w-whd INTERFACE)
target_include_directories(mbed-cy8cmod-062-4343w-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CMOD_062_4343W)

add_library(mbed-cy8cproto-062s3-4343w-whd INTERFACE)
target_include_directories(mbed-cy8cproto-062s3-4343w-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CPROTO_062S3_4343W)

add_library(mbed-cy8cproto-062-4343w-whd INTERFACE)
target_include_directories(mbed-cy8cproto-062-4343w-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CPROTO_062_4343W)

add_library(mbed-cytfm-064b0s2-4343w-whd INTERFACE)
target_include_directories(mbed-cytfm-064b0s2-4343w-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CYTFM_064B0S2_4343W)

add_library(mbed-cyw943012p6evb-01-whd INTERFACE)
target_include_directories(mbed-cyw943012p6evb-01-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CYW943012P6EVB_01)

add_library(mbed-cyw943012wcd2-whd INTERFACE)
target_include_directories(mbed-cyw943012wcd2-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CYW943012WCD2)

add_library(mbed-cyw9p62s1-43012car-01-whd INTERFACE)
target_include_directories(mbed-cyw9p62s1-43012car-01-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CYW9P62S1_43012CAR_01)

add_library(mbed-cyw9p62s1-43012evb-01-whd INTERFACE)
target_include_directories(mbed-cyw9p62s1-43012evb-01-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CYW9P62S1_43012EVB_01)

add_library(mbed-cyw9p62s1-43438evb-01-whd INTERFACE)
target_include_directories(mbed-cyw9p62s1-43438evb-01-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CYW9P62S1_43438EVB_01)

add_library(mbed-cy8ckit-064b0s2-4343w-whd INTERFACE)
target_include_directories(mbed-cy8ckit-064b0s2-4343w-whd INTERFACE wifi-host-driver/resources/nvram/TARGET_CY8CKIT_064B0S2_4343W)


add_library(mbed-cy-psoc6-whd STATIC EXCLUDE_FROM_ALL)

target_include_directories(mbed-cy-psoc6-whd
PUBLIC
wifi-host-driver
wifi-host-driver/inc
wifi-host-driver/resources/resource_imp
wifi-host-driver/src
wifi-host-driver/src/include
wifi-host-driver/src/bus_protocols
)

target_sources(mbed-cy-psoc6-whd
PRIVATE
wifi-host-driver/resources/resource_imp/whd_resources.c

wifi-host-driver/src/whd_ap.c
wifi-host-driver/src/whd_buffer_api.c
wifi-host-driver/src/whd_cdc_bdc.c
wifi-host-driver/src/whd_chip.c
wifi-host-driver/src/whd_chip_constants.c
wifi-host-driver/src/whd_clm.c
wifi-host-driver/src/whd_debug.c
wifi-host-driver/src/whd_events.c
wifi-host-driver/src/whd_logging.c
wifi-host-driver/src/whd_management.c
wifi-host-driver/src/whd_network_if.c
wifi-host-driver/src/whd_resource_if.c
wifi-host-driver/src/whd_sdpcm.c
wifi-host-driver/src/whd_thread.c
wifi-host-driver/src/whd_utils.c
wifi-host-driver/src/whd_wifi.c
wifi-host-driver/src/whd_wifi_api.c
wifi-host-driver/src/whd_wifi_p2p.c

wifi-host-driver/src/bus_protocols/whd_bus.c
wifi-host-driver/src/bus_protocols/whd_bus_common.c
wifi-host-driver/src/bus_protocols/whd_bus_sdio_protocol.c
wifi-host-driver/src/bus_protocols/whd_bus_spi_protocol.c
)

target_compile_definitions(mbed-cy-psoc6-whd
PUBLIC
MBED_CONF_CY_PSOC6_WHD_PRESENT=1
)
# If not running on a Cypress chip, we need to build the CyHAL support library.
if(NOT "Cypress" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(minimal-cyhal)
endif()

add_subdirectory(whd-bsp-integration)
add_subdirectory(wifi-host-driver)
add_subdirectory(whd_mac)
2 changes: 1 addition & 1 deletion connectivity/drivers/wifi/COMPONENT_WHD/mbed_lib.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cy_psoc6_whd",
"config": {
"present": 1
"present": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) 2024 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# In order to use the Cypress WHD driver, we need some level of Cypress HAL functionality available.
# However, for non-Cypress chips, these functions aren't available from the target code.
# This directory contains a minimal implementation of Cypress HAL designed to work on generic chips.
# Note that currently some of this has to be implemented on a per-target level, as Mbed
# does not have an SDIO HAL API. Hopefully this can be fixed someday...

add_library(mbed-minimal-cyhal STATIC
cy_hal.c
cyhal_spi.c
cyhal_system.c
cyhal_gpio.cpp
wiced_filesystem.cpp)
target_include_directories(mbed-minimal-cyhal PUBLIC .)
target_link_libraries(mbed-minimal-cyhal PUBLIC
mbed-core-flags
mbed-cy-rtos-abstraction)

# This is needed in order to make cybsp_wifi.h include cycfg.h
target_compile_definitions(mbed-minimal-cyhal PUBLIC COMPONENT_CUSTOM_DESIGN_MODUS)

# This is needed in order to make cyabs_rtos_internal.h include cyhal.h
target_compile_definitions(mbed-minimal-cyhal PUBLIC CY_USING_HAL)

if(STM32H7 IN_LIST MBED_TARGET_LABELS)
target_sources(mbed-minimal-cyhal PRIVATE
TARGET_STM32H7/cyhal_sdio.c)
target_include_directories(mbed-minimal-cyhal PUBLIC TARGET_STM32H7)

if(STM32H747_ARDUINO IN_LIST MBED_TARGET_LABELS)
target_include_directories(mbed-minimal-cyhal PUBLIC TARGET_STM32H7/TARGET_STM32H747_ARDUINO)
target_sources(mbed-minimal-cyhal PRIVATE
TARGET_STM32H7/TARGET_STM32H747_ARDUINO/wiced_filesystem_setup.cpp)
target_link_libraries(mbed-minimal-cyhal PRIVATE
mbed-storage-qspif
mbed-storage-blockdevice
mbed-storage-fat)
endif()
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#ifndef __WHD_CONFIG__
#define __WHD_CONFIG__

#include "whd_types.h"
#include "stm32h7xx_hal.h"
#include <stdint.h>

Expand All @@ -39,12 +38,12 @@
#define CYBSP_WIFI_HOST_WAKE_IRQ_EVENT CYHAL_GPIO_IRQ_FALL
#define CYBSP_WIFI_HOST_WAKE CYBSP_SDIO_OOB_IRQ

#define BSP_LED1 {GPIOK,{.Pin= GPIO_PIN_5 , .Mode = GPIO_MODE_OUTPUT_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_LOW}}
#define BSP_LED2 {GPIOK,{.Pin= GPIO_PIN_6 , .Mode = GPIO_MODE_OUTPUT_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_LOW}}
#define BSP_LED3 {GPIOK,{.Pin= GPIO_PIN_7 , .Mode = GPIO_MODE_OUTPUT_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_LOW}}
// Wifi firmware settings
#define WIFI_DEFAULT_FIRMWARE_PATH "/wlan/4343WA1.BIN"
#define WIFI_DEFAULT_MOUNT_NAME "wlan"
#define WIFI_DEFAULT_PARTITION 1
#define WIFI_DEFAULT_FS 0

/* power pin */
#define WIFI_WL_REG_ON {GPIOJ,{.Pin= GPIO_PIN_1, .Mode = GPIO_MODE_OUTPUT_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_LOW}}
//#define WIFI_32K_CLK {GPIOA,{.Pin= GPIO_PIN_8, .Mode = GPIO_MODE_AF_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_LOW , .Alternate = GPIO_AF0_MCO}}

#define WIFI_SDIO_CMD {GPIOD,{.Pin= GPIO_PIN_2 , .Mode = GPIO_MODE_AF_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_VERY_HIGH, .Alternate = GPIO_AF12_SDIO1}}
Expand All @@ -53,6 +52,19 @@
#define WIFI_SDIO_D1 {GPIOC,{.Pin= GPIO_PIN_9 , .Mode = GPIO_MODE_AF_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_VERY_HIGH, .Alternate = GPIO_AF12_SDIO1}}
#define WIFI_SDIO_D2 {GPIOC,{.Pin= GPIO_PIN_10, .Mode = GPIO_MODE_AF_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_VERY_HIGH, .Alternate = GPIO_AF12_SDIO1}}
#define WIFI_SDIO_D3 {GPIOC,{.Pin= GPIO_PIN_11, .Mode = GPIO_MODE_AF_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_VERY_HIGH, .Alternate = GPIO_AF12_SDIO1}}
#define WIFI_SDIO_OOB_IRQ {GPIOJ,{.Pin= GPIO_PIN_5, .Mode = GPIO_MODE_IT_FALLING , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_VERY_HIGH}}

#ifdef TARGET_ARDUINO_GIGA
#define WIFI_SDIO_OOB_IRQ PI_8
#define WIFI_WL_REG_ON PB_10
#define BSP_LED1 PI_12
#define BSP_LED2 PE_3
#define BSP_LED3 PJ_13
#elif TARGET_ARDUINO_PORTENTA
#define WIFI_SDIO_OOB_IRQ PJ_5
#define WIFI_WL_REG_ON PJ_1
#define BSP_LED1 PK_5
#define BSP_LED2 PK_6
#define BSP_LED3 PK_7
#endif

#endif
Loading

0 comments on commit 25dbf7c

Please sign in to comment.