diff --git a/.gitmodules b/.gitmodules index 06be901..75c3f9d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,9 @@ [submodule "lib/vult"] path = lib/vult url = https://github.com/vult-dsp/vult.git +[submodule "lib/FreeRTOS-Kernel"] + path = lib/FreeRTOS-Kernel + url = https://github.com/raspberrypi/FreeRTOS-Kernel.git +[submodule "lib/pico-sdk"] + path = lib/pico-sdk + url = https://github.com/DatanoiseTV/pico-sdk diff --git a/.vscode/settings.json b/.vscode/settings.json index b21d8e3..00c51a8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,5 +19,8 @@ "cmake.buildBeforeRun": true, "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", "nrf-connect.topdir": "/home/syso/dev/ztry", - "nrf-connect.toolchain.path": "PATH" + "nrf-connect.toolchain.path": "PATH", + "files.associations": { + "__locale": "cpp" + } } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 75a83c0..51d6f09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,32 +6,15 @@ set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 14) set(PICO_EXTRAS_PATH "../lib/pico-extras") +set(PICO_BOARD datanoisetv_rp2350_dsp) +set(PICO_PLATFORM "rp2350-arm-s") +set(FREERTOS_KERNEL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib/FreeRTOS-Kernel") +set(PICO_SDK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib/pico-sdk") # Pull in Raspberry Pi Pico SDK (must be before project) include(pico_sdk_import.cmake) include(pico_extras_import.cmake) - -set(PICO_BOARD datanoisetv_rp2040_dsp) - -set(FREERTOS_SRC_DIRECTORY "${PICO_SDK_PATH}/lib/tinyusb/lib/FreeRTOS-Kernel") - -add_library(FreeRTOS STATIC - ${FREERTOS_SRC_DIRECTORY}/event_groups.c - ${FREERTOS_SRC_DIRECTORY}/list.c - ${FREERTOS_SRC_DIRECTORY}/queue.c - ${FREERTOS_SRC_DIRECTORY}/stream_buffer.c - ${FREERTOS_SRC_DIRECTORY}/tasks.c - ${FREERTOS_SRC_DIRECTORY}/timers.c - ${FREERTOS_SRC_DIRECTORY}/portable/MemMang/heap_3.c - ${FREERTOS_SRC_DIRECTORY}/portable/GCC/ARM_CM0/port.c -) - -target_include_directories(FreeRTOS PUBLIC - ${FREERTOS_CFG_DIRECTORY}/ - ${FREERTOS_SRC_DIRECTORY}/include - ${FREERTOS_SRC_DIRECTORY}/portable/GCC/ARM_CM0 -) - +include(FreeRTOS_Kernel_import.cmake) project(main C CXX ASM) @@ -42,28 +25,40 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_D add_subdirectory(lib/audio) add_subdirectory(lib/oled) -message("CMAKE_HOST_SYSTEM_PROCESSOR: ${CMAKE_HOST_SYSTEM_PROCESSOR}") -message("CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME}") +# Set the real flag based on the PICO_PLATFORM variable +if (DEFINED PICO_PLATFORM AND PICO_PLATFORM STREQUAL "rp2350-arm-s") + set(REAL_TYPE_FLAG "float") + message("Using float for real type") +else() + set(REAL_TYPE_FLAG "fixed") + message("Using fixed for real type") +endif() + +set(VULT_EXAMPLE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib/vult/examples") -# Generate Vult C++ code from Vult Code every time -set(VULT_EXAMPLE_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/vult/examples") add_custom_command( - OUTPUT ALL ${CMAKE_CURRENT_BINARY_DIR}/vult.cpp - COMMAND vultc ${CMAKE_CURRENT_LIST_DIR}/vultsrc/dsp.vult - -i ${VULT_EXAMPLE_PATH}/osc - -i ${VULT_EXAMPLE_PATH}/util - -i ${VULT_EXAMPLE_PATH}/filters - -i ${VULT_EXAMPLE_PATH}/env - -i ${VULT_EXAMPLE_PATH}/midi - -i ${VULT_EXAMPLE_PATH}/effects - -i ${VULT_EXAMPLE_PATH}/units - -ccode - -real fixed - -samplerate 44140 - -o vult - COMMENT "Transcompiling Vult DSP Code to C++." + OUTPUT ALL ${CMAKE_CURRENT_BINARY_DIR}/vult.cpp + COMMAND vultc ${CMAKE_CURRENT_LIST_DIR}/vultsrc/dsp.vult + -i ${VULT_EXAMPLE_PATH}/osc + -i ${VULT_EXAMPLE_PATH}/util + -i ${VULT_EXAMPLE_PATH}/filters + -i ${VULT_EXAMPLE_PATH}/env + -i ${VULT_EXAMPLE_PATH}/midi + -i ${VULT_EXAMPLE_PATH}/effects + -i ${VULT_EXAMPLE_PATH}/units + -ccode + -real ${REAL_TYPE_FLAG} + -samplerate 44100 + -o vult + COMMENT "Transcompiling Vult DSP Code to C++." ) + +if (NOT FREERTOS_KERNEL_PATH AND NOT DEFINED ENV{FREERTOS_KERNEL_PATH}) + message("Skipping FreeRTOS examples as FREERTOS_KERNEL_PATH not defined") + return() +endif() + add_executable(main vultsrc/dsp.vult src/usb_descriptors.c @@ -72,6 +67,7 @@ add_executable(main src/vultin.cpp src/midi_input_usb.cpp src/get_serial.c + lib/FreeRTOS-Kernel/portable/MemMang/heap_3.c ${CMAKE_CURRENT_BINARY_DIR}/vult.cpp) pico_set_program_name(main "main") @@ -94,6 +90,8 @@ target_link_libraries(main hardware_timer hardware_watchdog hardware_clocks + hardware_sync_spin_lock + hardware_sync pico_unique_id pico_bootsel_via_double_reset pico_util_buffer @@ -103,11 +101,12 @@ target_link_libraries(main tinyusb_board Audio #Oled - FreeRTOS + FreeRTOS-Kernel ) target_compile_definitions(main PRIVATE USE_AUDIO_I2S=1 + PICO_USE_SW_SPIN_LOCKS=1 ) target_link_options(main PRIVATE @@ -122,9 +121,14 @@ endforeach() add_compile_options("-Wall" "-Wredundant-decls") +# compile the following thins only if rp2040 is used +if (PICO_PLATFORM STREQUAL "rp2040") pico_define_boot_stage2(slower_boot2 ${PICO_DEFAULT_BOOT_STAGE2_FILE}) target_compile_definitions(slower_boot2 PRIVATE PICO_FLASH_SPI_CLKDIV=4) pico_set_boot_stage2(main slower_boot2) +else() +message("Skipping slower_boot2 as PICO_PLATFORM is not rp2040") +endif() pico_add_extra_outputs(main) diff --git a/FreeRTOS_Kernel_import.cmake b/FreeRTOS_Kernel_import.cmake new file mode 100644 index 0000000..abd33b4 --- /dev/null +++ b/FreeRTOS_Kernel_import.cmake @@ -0,0 +1,70 @@ +# This is a copy of /portable/ThirdParty/GCC/RP2040/FREERTOS_KERNEL_import.cmake + +# This can be dropped into an external project to help locate the FreeRTOS kernel +# It should be include()ed prior to project(). Alternatively this file may +# or the CMakeLists.txt in this directory may be included or added via add_subdirectory +# respectively. + +if (DEFINED ENV{FREERTOS_KERNEL_PATH} AND (NOT FREERTOS_KERNEL_PATH)) + set(FREERTOS_KERNEL_PATH $ENV{FREERTOS_KERNEL_PATH}) + message("Using FREERTOS_KERNEL_PATH from environment ('${FREERTOS_KERNEL_PATH}')") +endif () + +if(PICO_PLATFORM STREQUAL "rp2040") + set(FREERTOS_KERNEL_RP2040_RELATIVE_PATH "portable/ThirdParty/GCC/RP2040") +else() + if (PICO_PLATFORM STREQUAL "rp2350-riscv") + set(FREERTOS_KERNEL_RP2040_RELATIVE_PATH "portable/ThirdParty/GCC/RP2350_RISC-V") + else() + set(FREERTOS_KERNEL_RP2040_RELATIVE_PATH "portable/ThirdParty/GCC/RP2350_ARM_NTZ") + endif() +endif() + +# undo the above +set(FREERTOS_KERNEL_RP2040_BACK_PATH "../../../..") + +if (NOT FREERTOS_KERNEL_PATH) + # check if we are inside the FreeRTOS kernel tree (i.e. this file has been included directly) + get_filename_component(_ACTUAL_PATH ${CMAKE_CURRENT_LIST_DIR} REALPATH) + get_filename_component(_POSSIBLE_PATH ${CMAKE_CURRENT_LIST_DIR}/${FREERTOS_KERNEL_RP2040_BACK_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH} REALPATH) + if (_ACTUAL_PATH STREQUAL _POSSIBLE_PATH) + get_filename_component(FREERTOS_KERNEL_PATH ${CMAKE_CURRENT_LIST_DIR}/${FREERTOS_KERNEL_RP2040_BACK_PATH} REALPATH) + endif() + if (_ACTUAL_PATH STREQUAL _POSSIBLE_PATH) + get_filename_component(FREERTOS_KERNEL_PATH ${CMAKE_CURRENT_LIST_DIR}/${FREERTOS_KERNEL_RP2040_BACK_PATH} REALPATH) + message("Setting FREERTOS_KERNEL_PATH to ${FREERTOS_KERNEL_PATH} based on location of FreeRTOS-Kernel-import.cmake") + elseif (PICO_SDK_PATH AND EXISTS "${PICO_SDK_PATH}/../FreeRTOS-Kernel") + set(FREERTOS_KERNEL_PATH ${PICO_SDK_PATH}/../FreeRTOS-Kernel) + message("Defaulting FREERTOS_KERNEL_PATH as sibling of PICO_SDK_PATH: ${FREERTOS_KERNEL_PATH}") + endif() +endif () + +if (NOT FREERTOS_KERNEL_PATH) + foreach(POSSIBLE_SUFFIX Source FreeRTOS-Kernel FreeRTOS/Source) + # check if FreeRTOS-Kernel exists under directory that included us + set(SEARCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) + get_filename_component(_POSSIBLE_PATH ${SEARCH_ROOT}/${POSSIBLE_SUFFIX} REALPATH) + if (EXISTS ${_POSSIBLE_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}/CMakeLists.txt) + get_filename_component(FREERTOS_KERNEL_PATH ${_POSSIBLE_PATH} REALPATH) + message("Setting FREERTOS_KERNEL_PATH to '${FREERTOS_KERNEL_PATH}' found relative to enclosing project") + break() + endif() + endforeach() +endif() + +if (NOT FREERTOS_KERNEL_PATH) + message(FATAL_ERROR "FreeRTOS location was not specified. Please set FREERTOS_KERNEL_PATH.") +endif() + +set(FREERTOS_KERNEL_PATH "${FREERTOS_KERNEL_PATH}" CACHE PATH "Path to the FreeRTOS Kernel") + +get_filename_component(FREERTOS_KERNEL_PATH "${FREERTOS_KERNEL_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") +if (NOT EXISTS ${FREERTOS_KERNEL_PATH}) + message(FATAL_ERROR "Directory '${FREERTOS_KERNEL_PATH}' not found") +endif() +if (NOT EXISTS ${FREERTOS_KERNEL_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}/CMakeLists.txt) + message(FATAL_ERROR "Directory '${FREERTOS_KERNEL_PATH}' does not contain a '${PICO_PLATFORM}' port here: ${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}") +endif() +set(FREERTOS_KERNEL_PATH ${FREERTOS_KERNEL_PATH} CACHE PATH "Path to the FreeRTOS_KERNEL" FORCE) + +add_subdirectory(${FREERTOS_KERNEL_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH} FREERTOS_KERNEL) diff --git a/include/FreeRTOSConfig.h b/include/FreeRTOSConfig.h index a699380..5c26bb4 100644 --- a/include/FreeRTOSConfig.h +++ b/include/FreeRTOSConfig.h @@ -26,47 +26,42 @@ #ifndef FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H - -/* Use Pico SDK ISR handlers */ -#define vPortSVCHandler isr_svcall -#define xPortPendSVHandler isr_pendsv -#define xPortSysTickHandler isr_systick - -#define configUSE_PREEMPTION 1 // Allow tasks to be pre-empted -#define configUSE_TIME_SLICING 1 // Allow FreeRTOS to switch tasks at each tick -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +/* Scheduler Related */ +#define configUSE_PREEMPTION 1 #define configUSE_TICKLESS_IDLE 0 -#define configCPU_CLOCK_HZ 402000000 // 133MHz for RP2040 -#define configTICK_RATE_HZ 1000 // FreeRTOS beats per second -#define configMAX_PRIORITIES 5 // Max number of priority values (0-24) -#define configMINIMAL_STACK_SIZE 128 -#define configMAX_TASK_NAME_LEN 16 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) +#define configMAX_PRIORITIES 32 +#define configMINIMAL_STACK_SIZE ( configSTACK_DEPTH_TYPE ) 512 #define configUSE_16_BIT_TICKS 0 + #define configIDLE_SHOULD_YIELD 1 -#define configUSE_TASK_NOTIFICATIONS 1 -#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3 + +/* Synchronization Related */ #define configUSE_MUTEXES 1 -#define configUSE_RECURSIVE_MUTEXES 0 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_APPLICATION_TASK_TAG 0 #define configUSE_COUNTING_SEMAPHORES 1 -#define configQUEUE_REGISTRY_SIZE 10 -#define configUSE_QUEUE_SETS 0 +#define configQUEUE_REGISTRY_SIZE 8 +#define configUSE_QUEUE_SETS 1 +#define configUSE_TIME_SLICING 1 #define configUSE_NEWLIB_REENTRANT 0 -#define configENABLE_BACKWARD_COMPATIBILITY 0 +// todo need this for lwip FreeRTOS sys_arch to compile +#define configENABLE_BACKWARD_COMPATIBILITY 1 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 -#define configSTACK_DEPTH_TYPE uint16_t -#define configMESSAGE_BUFFER_LENGTH_TYPE size_t // Defaults to size_t for backward compatibility, - // but can be changed if lengths will always be less - // than the number of bytes in a size_t. +/* System */ +#define configSTACK_DEPTH_TYPE uint32_t +#define configMESSAGE_BUFFER_LENGTH_TYPE size_t /* Memory allocation related definitions. */ #define configSUPPORT_STATIC_ALLOCATION 0 -#define configSUPPORT_DYNAMIC_ALLOCATION 1 // Get FreeRTOS to allocation task memory -#define configAPPLICATION_ALLOCATED_HEAP 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configTOTAL_HEAP_SIZE (128*1024) +#define configAPPLICATION_ALLOCATED_HEAP 0 /* Hook function related definitions. */ -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 #define configCHECK_FOR_STACK_OVERFLOW 0 #define configUSE_MALLOC_FAILED_HOOK 0 #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 @@ -74,7 +69,7 @@ /* Run time and task stats gathering related definitions. */ #define configGENERATE_RUN_TIME_STATS 0 #define configUSE_TRACE_FACILITY 1 -#define configUSE_STATS_FORMATTING_FUNCTIONS 1 +#define configUSE_STATS_FORMATTING_FUNCTIONS 0 /* Co-routine related definitions. */ #define configUSE_CO_ROUTINES 0 @@ -82,32 +77,64 @@ /* Software timer related definitions. */ #define configUSE_TIMERS 1 -#define configTIMER_TASK_PRIORITY 3 +#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) #define configTIMER_QUEUE_LENGTH 10 -#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE +#define configTIMER_TASK_STACK_DEPTH 1024 + +/* Interrupt nesting behaviour configuration. */ +/* +#define configKERNEL_INTERRUPT_PRIORITY [dependent of processor] +#define configMAX_SYSCALL_INTERRUPT_PRIORITY [dependent on processor and application] +#define configMAX_API_CALL_INTERRUPT_PRIORITY [dependent on processor and application] +*/ + +#if FREE_RTOS_KERNEL_SMP // set by the RP2040 SMP port of FreeRTOS +/* SMP port only */ +#ifndef configNUMBER_OF_CORES +#define configNUMBER_OF_CORES 2 +#endif +#define configNUM_CORES configNUMBER_OF_CORES +#define configTICK_CORE 0 +#define configRUN_MULTIPLE_PRIORITIES 1 +#if configNUMBER_OF_CORES > 1 +#define configUSE_CORE_AFFINITY 1 +#endif +#define configUSE_PASSIVE_IDLE_HOOK 0 +#endif + +/* RP2040 specific */ +#define configSUPPORT_PICO_SYNC_INTEROP 1 +#define configSUPPORT_PICO_TIME_INTEROP 1 +#include /* Define to trap errors during development. */ -#define configASSERT( x ) +#define configASSERT(x) assert(x) -/* Optional functions - most linkers will remove unused functions anyway. */ +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ #define INCLUDE_vTaskPrioritySet 1 #define INCLUDE_uxTaskPriorityGet 1 #define INCLUDE_vTaskDelete 1 #define INCLUDE_vTaskSuspend 1 -#define INCLUDE_xResumeFromISR 1 #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 #define INCLUDE_xTaskGetSchedulerState 1 #define INCLUDE_xTaskGetCurrentTaskHandle 1 -#define INCLUDE_uxTaskGetStackHighWaterMark 0 -#define INCLUDE_xTaskGetIdleTaskHandle 0 -#define INCLUDE_eTaskGetState 0 -#define INCLUDE_xEventGroupSetBitFromISR 1 -#define INCLUDE_xTimerPendFunctionCall 0 -#define INCLUDE_xTaskAbortDelay 0 -#define INCLUDE_xTaskGetHandle 0 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_xTaskGetIdleTaskHandle 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskAbortDelay 1 +#define INCLUDE_xTaskGetHandle 1 #define INCLUDE_xTaskResumeFromISR 1 +#define INCLUDE_xQueueGetMutexHolder 1 -/* A header file that defines trace macro can be included here. */ +#if PICO_RP2350 +#define configENABLE_MPU 0 +#define configENABLE_TRUSTZONE 0 +#define configRUN_FREERTOS_SECURE_ONLY 1 +#define configENABLE_FPU 1 +#define configMAX_SYSCALL_INTERRUPT_PRIORITY 16 +#endif #endif /* FREERTOS_CONFIG_H */ diff --git a/include/helper.h b/include/helper.h index cdb512b..e3800a4 100644 --- a/include/helper.h +++ b/include/helper.h @@ -4,6 +4,15 @@ #include "vultin.h" +#if PICO_RP2350 +#define VULT_DATA_TYPE float +#define VULT_DATA_CONVERT(x) float_to_int32(x) +#else +#define VULT_DATA_TYPE fix16_t +#define VULT_DATA_CONVERT(x) fix16_to_int32(x) +#endif + + static inline int32_t fix16_to_int32(fix16_t x) { fix16_t out; @@ -16,6 +25,23 @@ static inline int32_t fix16_to_int32(fix16_t x) return out << 15u; } +static inline int32_t float_to_int32(float input) { + // Simple conversion from float to int32 + // This assumes that the input float is within the range that can be represented by int32 + // Typically, audio samples are normalized between -1.0 and 1.0, so we multiply by the max int32 value + int32_t output; + + if (input >= 1.0f) { + output = INT32_MAX; + } else if (input <= -1.0f) { + output = INT32_MIN; + } else { + output = (int32_t)(input * (float)INT32_MAX); + } + + return output; +} + static inline int rev_log_scale(int x) { // Calculate reverse logarithmic value from linear input diff --git a/include/vultin.h b/include/vultin.h index d96e1da..e3f1cb1 100644 --- a/include/vultin.h +++ b/include/vultin.h @@ -91,8 +91,13 @@ static_inline fix16_t fix_mul(fix16_t x, fix16_t y) { static_inline fix16_t fix_div(fix16_t a, fix16_t b) { if (b == 0) return 0; + #if PICO_RP2040 fix16_t result = div_s64s64(((int64_t)a) << 16, (int64_t)b); // This function is specific to the RP2040 - // fix16_t result = (((int64_t)a) << 16) / ((int64_t)b); + #warning "Using RP2040 hardware division" + #else + fix16_t result = (((int64_t)a) << 16) / ((int64_t)b); + #warning "Using native division" + #endif return result; } diff --git a/lib/FreeRTOS-Kernel b/lib/FreeRTOS-Kernel new file mode 160000 index 0000000..4f7299d --- /dev/null +++ b/lib/FreeRTOS-Kernel @@ -0,0 +1 @@ +Subproject commit 4f7299d6ea746b27a9dd19e87af568e34bd65b15 diff --git a/lib/pico-sdk b/lib/pico-sdk new file mode 160000 index 0000000..af9af35 --- /dev/null +++ b/lib/pico-sdk @@ -0,0 +1 @@ +Subproject commit af9af35933b8888b8b91a86bc7e9f5f4481afba0 diff --git a/src/main.cpp b/src/main.cpp index 3f40af1..155d1b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,25 +37,6 @@ extern "C" volatile long dsp_start; volatile long dsp_end; - // This task prints the statistics about the running FreeRTOS tasks - // and how long it takes for the I2S callback to run. - void print_task(void *p) - { - char ptrTaskList[2048]; - while (1) - { - vTaskList(ptrTaskList); - printf("\033[2J"); - printf("\033[0;0HTask\t\tState\tPrio\tStack\tNum\n%s\n", ptrTaskList); - printf("======================================================\n"); - printf("B = Blocked, R = Ready, D = Deleted, S = Suspended\n"); - printf("Milliseconds since boot: %d\n", xTaskGetTickCount() * portTICK_PERIOD_MS); - printf("dsp task took %d uS\n", dsp_end - dsp_start); - watchdog_update(); - vTaskDelay(pdMS_TO_TICKS(2000)); - } - } - // MIDI callbacks void note_on_callback(uint8_t note, uint8_t level, uint8_t channel) { @@ -189,7 +170,6 @@ extern "C" // Create FreeRTOS Tasks for USB MIDI and printing statistics xTaskCreate(usb_midi_task, "USBMIDI", 4096, NULL, configMAX_PRIORITIES, NULL); - xTaskCreate(print_task, "TASKLIST", 1024, NULL, configMAX_PRIORITIES - 1, NULL); xTaskCreate(blinker_task, "BLINKER", 128, NULL, configMAX_PRIORITIES - 1, NULL); #if PLAY_RANDOM_NOTES xTaskCreate(play_task, "PLAY", 1024, NULL, configMAX_PRIORITIES - 1, NULL); @@ -233,10 +213,18 @@ extern "C" // smp should be the output of your processing code. // In case of the Vult Example, this is Dsp_process(ctx); Dsp_process(ctx, cv0, cv1, cv2, cv3); - fix16_t left_out = Dsp_process_ret_0(ctx); - fix16_t right_out = Dsp_process_ret_1(ctx); - samples[i * 2 + 0] = fix16_to_int32(left_out); // LEFT - samples[i * 2 + 1] = fix16_to_int32(right_out); // RIGHT + VULT_DATA_TYPE left_out = Dsp_process_ret_0(ctx); + VULT_DATA_TYPE right_out = Dsp_process_ret_1(ctx); + samples[i * 2 + 0] = VULT_DATA_CONVERT(left_out); // LEFT + samples[i * 2 + 1] = VULT_DATA_CONVERT(right_out); // RIGHT + + /* + Dsp_process(ctx, cv0, cv1, cv2, cv3); + float left_out = Dsp_process_ret_0(ctx); + float right_out = Dsp_process_ret_1(ctx); + samples[i * 2 + 0] = float_to_int32(left_out); // LEFT + samples[i * 2 + 1] = float_to_int32(right_out); // RIGHT + */ } dsp_end = to_us_since_boot(get_absolute_time()); diff --git a/src/picoadk_hw.cpp b/src/picoadk_hw.cpp index 6b61e08..7642d43 100644 --- a/src/picoadk_hw.cpp +++ b/src/picoadk_hw.cpp @@ -4,9 +4,13 @@ void picoadk_init() { // Overclock the CPU to 402 MHz. + #if PICO_RP2040 vreg_set_voltage(VREG_VOLTAGE_1_30); sleep_ms(1); set_sys_clock_khz(402000, true); + #else + #warning "No overclocking will performed, as this is untested on plaftorms other than the RP2040." + #endif // Initialize TinyUSB board_init();