Quantcast
Viewing all articles
Browse latest Browse all 4921

SDK • Re: Cmake only a single pico_examples project

Here is my solution:

Set up a directory bt_test with the following files. "build" is an empty directory:
  • btstack_config.h FreeRTOSConfig.h pico_sdk_import.cmake picow_bt_example_poll.c
    build (this is a directory) FreeRTOS_Kernel_import.cmake picow_bt_example_background.c
    CMakeLists.txt gatt_counter.c picow_bt_example_common.c
    gatt_counter.gatt picow_bt_example_common.h
    FreeRTOSConfig_examples_common.h picow_bt_example_freertos.c
Next, use the following CMakeLists.cmake file. Adapt for the particular btstack example desired.

Code:

# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==if(WIN32)    set(USERHOME $ENV{USERPROFILE})else()    set(USERHOME $ENV{HOME})endif()set(sdkVersion 2.0.0)set(toolchainVersion 13_2_Rel1)set(picotoolVersion 2.0.0)set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)if (EXISTS ${picoVscode})    include(${picoVscode})endif()# ====================================================================================# Arbitrary CMake version number to avoid warningcmake_minimum_required(VERSION 3.25)# Define the boardset(PICO_BOARD pico_w CACHE STRING "Board type")# Pull in and initialize Raspberry Pi Pico SDK (must be before project)include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)#include(pico_sdk_import.cmake)pico_sdk_init()# Set up FreeRTOSset(FREERTOS_KERNEL_PATH "/home/paulbjork/pico/vscode-projects/freertos/FreeRTOS/FreeRTOS/Source")include(FreeRTOS_Kernel_import.cmake)# Declare the gatt_counter projectproject(picow_ble_gatt_counter_freertos C CXX ASM)# Set up all the active source code# The source for most of the Bluetooth examples is stored in `pico-sdk/lib/btstack/example`.add_executable(picow_ble_gatt_counter_freertospicow_bt_example_common.cgatt_counter.c picow_bt_example_freertos.c)# Link all the librariestarget_link_libraries(picow_ble_gatt_counter_freertos    pico_stdlib    pico_btstack_ble    pico_btstack_cyw43    pico_cyw43_arch_none    hardware_adc    pico_async_context_freertos    FreeRTOS-Kernel-Heap4)# Define the header include directory pathstarget_include_directories(picow_ble_gatt_counter_freertos PRIVATE    ${CMAKE_CURRENT_LIST_DIR} # For btstack config    ${CMAKE_CURRENT_LIST_DIR}/..#for freertos?    ${BT_EXAMPLE_COMMON_DIR}/config # Use our ( Raspberry pi?) own config#    ${BTSTACK_EXAMPLE_PATH}/)# Set up any pre-compile macros needed for FreeRTOS.target_compile_definitions(picow_ble_gatt_counter_freertos PRIVATE    configNUMBER_OF_CORES=1)# Make the GATT Services and Characteristics header file from the list of requirements#pico_btstack_make_gatt_header(picow_ble_gatt_counter_freertos PRIVATE "gatt_counter.gatt")pico_btstack_make_gatt_header(picow_ble_gatt_counter_freertos PRIVATE "${CMAKE_CURRENT_LIST_DIR}/gatt_counter.gatt")# Add any needed subdirectories with their own CMakeLists# add_subdirectory(standalone)# Make all needed debug and release filespico_add_extra_outputs(picow_ble_gatt_counter_freertos)# Does the app need a URL?# example_auto_set_url(${TARGET_NAME}_freertos)# Bluetooth stack setup from /home/paulbjork/.pico-sdk/examples/pico_w/bt/README.md# suppress_btstack_warnings()set(BTSTACK_ROOT ${PICO_SDK_PATH}/lib/btstack)set(BTSTACK_EXAMPLE_PATH ${BTSTACK_ROOT}/example)set(BTSTACK_3RD_PARTY_PATH ${BTSTACK_ROOT}/3rd-party)set(BT_EXAMPLE_COMMON_DIR "${CMAKE_CURRENT_LIST_DIR}")# To debug Bluetooth issues you can enable [btstack](https://github.com/bluekitchen/btstack)#   debug output which also enables packet logging.#   Define `WANT_HCI_DUMP=1` in your CMakeLists.txt file. #   Uncomment this line to enable debug in the btstack examples.target_compile_definitions(picow_ble_gatt_counter_freertos INTERFACE    WANT_HCI_DUMP=1 # This enables btstack debug    PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS=3000    )
Open the directory bt_test in VSCode as an import project under the pico SDK extension. Debug should work just fine with an attached pico_probe.

Statistics: Posted by paulbjork — Mon Nov 18, 2024 4:59 pm



Viewing all articles
Browse latest Browse all 4921

Trending Articles