From 21414f1cc386f976b33636429aafbe7d9a02674e Mon Sep 17 00:00:00 2001 From: George Norton Date: Wed, 14 Jun 2023 23:47:09 +0100 Subject: [PATCH] Fix broken audio when changing a filter type. --- firmware/code/.gitignore | 3 ++- firmware/code/CMakeLists.txt | 34 ++++++++++++++++++++++++++++++++-- firmware/code/version.h.in | 5 +++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 firmware/code/version.h.in diff --git a/firmware/code/.gitignore b/firmware/code/.gitignore index 65a2f78..e735bc1 100644 --- a/firmware/code/.gitignore +++ b/firmware/code/.gitignore @@ -1,4 +1,5 @@ .vscode/ inc/ lib/ -build/ \ No newline at end of file +build/ +version.h \ No newline at end of file diff --git a/firmware/code/CMakeLists.txt b/firmware/code/CMakeLists.txt index 24cad20..bbcac28 100644 --- a/firmware/code/CMakeLists.txt +++ b/firmware/code/CMakeLists.txt @@ -19,18 +19,48 @@ add_executable(ploopy_headphones configuration_manager.c ) -target_include_directories(ploopy_headphones PRIVATE ${CMAKE_SOURCE_DIR}) +target_include_directories(ploopy_headphones PRIVATE + ${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR}/generated + ) pico_generate_pio_header(ploopy_headphones ${CMAKE_CURRENT_LIST_DIR}/i2s.pio) +# in case Git is not available, we default to "unknown" +set(GIT_HASH "unknown") + +# find Git and if available set GIT_HASH variable +find_package(Git QUIET) +if(GIT_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --always --dirty + OUTPUT_VARIABLE GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) +endif() + +message(STATUS "Git hash is ${GIT_HASH}") + +# generate file version.hpp based on version.hpp.in +configure_file( + ${CMAKE_CURRENT_LIST_DIR}/version.h.in + ${CMAKE_BINARY_DIR}/generated/version.h + @ONLY + ) + +list(APPEND SOURCES "${CMAKE_CURRENT_BINARY_DIR}/version.cc" version.hh) + target_compile_definitions(ploopy_headphones PRIVATE # ours are zero based, so say so PICO_USBDEV_USE_ZERO_BASED_INTERFACES=1 # need large descriptor PICO_USBDEV_MAX_DESCRIPTOR_SIZE=256 - PICO_USBDEV_ISOCHRONOUS_BUFFER_STRIDE_TYPE=1 + + # make the git hash available to the firmware + GIT_HASH="${GIT_HASH}" ) pico_enable_stdio_usb(ploopy_headphones 0) diff --git a/firmware/code/version.h.in b/firmware/code/version.h.in new file mode 100644 index 0000000..63f20d2 --- /dev/null +++ b/firmware/code/version.h.in @@ -0,0 +1,5 @@ +#ifndef VERSION_H +#define VERSION_H +/** This template is populated by cmake at build time. */ +static const char* FIRMWARE_GIT_HASH = "@GIT_HASH@"; +#endif \ No newline at end of file