1# Copyright (c) 2022 Cypress Semiconductor Corporation.
2#
3# SPDX-License-Identifier: Apache-2.0
4
5set(hal_dir             ${ZEPHYR_HAL_INFINEON_MODULE_DIR})
6set(btstack_integration ${hal_dir}/btstack-integration)
7set(hal_blobs_dir       ${hal_dir}/zephyr/blobs/img/bluetooth/firmware)
8set(blob_gen_inc_file   ${ZEPHYR_BINARY_DIR}/include/generated/bt_firmware.hcd.inc)
9
10#########################################################################################
11# btstack integration assets sources for cyw208xx
12#########################################################################################
13
14if(CONFIG_BT_CYW208XX)
15
16  zephyr_include_directories(${btstack_integration}/../btstack/wiced_include)
17  zephyr_include_directories(${btstack_integration}/COMPONENT_BTSS-IPC/platform/include)
18  zephyr_include_directories(${btstack_integration}/COMPONENT_BTSS-IPC/platform/ipc/include)
19
20  zephyr_library_sources(${btstack_integration}/COMPONENT_BTSS-IPC/platform/ipc/cybt_platform_freertos.c)
21  zephyr_library_sources(${btstack_integration}/COMPONENT_BTSS-IPC/platform/ipc/cybt_platform_hci.c)
22  zephyr_library_sources(${btstack_integration}/COMPONENT_BTSS-IPC/platform/ipc/cybt_bt_task.c)
23  zephyr_library_sources(${btstack_integration}/COMPONENT_BTSS-IPC/platform/ipc/cybt_host_stack_platform_interface.c)
24  zephyr_library_sources(${btstack_integration}/COMPONENT_BTSS-IPC/platform/ipc/cybt_platform_task.c)
25
26  zephyr_library_sources(${btstack_integration}/COMPONENT_BTSS-IPC/platform/common/cybt_platform_main.c)
27  zephyr_library_sources(${btstack_integration}/COMPONENT_BTSS-IPC/platform/common/cybt_platform_trace.c)
28  zephyr_library_sources(${btstack_integration}/COMPONENT_BTSS-IPC/platform/common/cybt_prm.c)
29
30  #zephyr_library_sources(${btstack_integration}/COMPONENT_BTSS-IPC/platform/common/cybt_patchram_download.c)
31endif()
32
33#########################################################################################
34# BT firmware
35#########################################################################################
36
37# HCD files for CYW43xx devices
38# CYW43012 modules
39if(CONFIG_CYW43012_MURATA_1LV)
40  set(blob_hcd_file  ${hal_blobs_dir}/COMPONENT_43012/COMPONENT_MURATA-1LV/bt_firmware.hcd)
41endif()
42
43# CYW4343W modules
44if(CONFIG_CYW4343W_MURATA_1DX)
45  set(blob_hcd_file  ${hal_blobs_dir}/COMPONENT_4343W/COMPONENT_MURATA-1DX/bt_firmware.hcd)
46endif()
47
48# CYW43439 modules
49if(CONFIG_CYW43439_MURATA_1YN)
50  set(blob_hcd_file  ${hal_blobs_dir}/COMPONENT_43439/COMPONENT_MURATA-1YN/bt_firmware.hcd)
51endif()
52
53# CYW4373 modules
54if(CONFIG_CYW4373_STERLING_LWB5PLUS)
55  set(blob_hcd_file  ${hal_blobs_dir}/COMPONENT_4373/COMPONENT_STERLING-LWB5plus/bt_firmware.hcd)
56endif()
57
58# HCD files for CYW208xx
59
60# CYW20829 device (FW patch for 0dBm TX Power)
61if(CONFIG_CYW20829_BT_FW_TX0)
62  set(blob_hcd_file  ${hal_blobs_dir}/COMPONENT_CYW20829B0/COMPONENT_BTFW-TX0/bt_firmware.hcd)
63endif()
64
65# CYW20829 device (FW patch for 10dBm TX Power)
66if(CONFIG_CYW20829_BT_FW_TX10)
67  set(blob_hcd_file  ${hal_blobs_dir}/COMPONENT_CYW20829B0/COMPONENT_BTFW-TX10/bt_firmware.hcd)
68endif()
69
70# CYW20829 device (FW patch with PAwR support for 0dBm TX Power)
71if(CONFIG_CYW20829_BT_FW_PAWR_TX0)
72  set(blob_hcd_file  ${hal_blobs_dir}/COMPONENT_CYW20829B0/COMPONENT_BTFW-PAWR-TX0/bt_firmware.hcd)
73endif()
74
75# CYW20829 device (FW patch with PAwR support for 10dBm TX Power)
76if(CONFIG_CYW20829_BT_FW_PAWR_TX10)
77  set(blob_hcd_file  ${hal_blobs_dir}/COMPONENT_CYW20829B0/COMPONENT_BTFW-PAWR-TX10/bt_firmware.hcd)
78endif()
79
80# CYW20829 device (FW patch with ISOC support for 0dBm TX Power)
81if(CONFIG_CYW20829_BT_FW_ISOC_TX0)
82  set(blob_hcd_file  ${hal_blobs_dir}/COMPONENT_CYW20829B0/COMPONENT_BTFW-ISOC-TX0/bt_firmware.hcd)
83endif()
84
85# CYW20829 device (FW patch with ISOC support for 10dBm TX Power)
86if(CONFIG_CYW20829_BT_FW_ISOC_TX10)
87  set(blob_hcd_file  ${hal_blobs_dir}/COMPONENT_CYW20829B0/COMPONENT_BTFW-ISOC-TX10/bt_firmware.hcd)
88endif()
89
90# use user provided FIRMWARE HCD file (path must be defined in CONFIG_AIROC_CUSTOM_FIRMWARE_HCD_BLOB)
91if(CONFIG_AIROC_CUSTOM_FIRMWARE_HCD_BLOB)
92  # Allowed to pass absolute path to HCD blob file, or relative path from Application folder.
93  if(IS_ABSOLUTE ${CONFIG_AIROC_CUSTOM_FIRMWARE_HCD_BLOB})
94    set(blob_hcd_file  ${CONFIG_AIROC_CUSTOM_FIRMWARE_HCD_BLOB})
95  else()
96    set(blob_hcd_file  ${APPLICATION_SOURCE_DIR}/${CONFIG_AIROC_CUSTOM_FIRMWARE_HCD_BLOB})
97  endif()
98endif()
99
100# generate Bluetooth include blob from HCD binary
101if(EXISTS ${blob_hcd_file})
102  message(INFO " generate include of blob Bluetooth file: ${blob_hcd_file}")
103
104  generate_inc_file_for_target(app ${blob_hcd_file} ${blob_gen_inc_file})
105  zephyr_library_sources(${CMAKE_CURRENT_SOURCE_DIR}/w_bt_firmware_controller.c)
106endif()
107