From 1f492d0835423fb6ed3f2be45bdd4dc08c529391 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 8 Dec 2023 21:13:49 -0600 Subject: [PATCH] my first commit --- hello_world/usb/CMakeLists.txt | 7 +++--- hello_world/usb/hello_usb.c | 16 ------------- hello_world/usb/hello_usb.cpp | 44 ++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 19 deletions(-) delete mode 100644 hello_world/usb/hello_usb.c create mode 100644 hello_world/usb/hello_usb.cpp diff --git a/hello_world/usb/CMakeLists.txt b/hello_world/usb/CMakeLists.txt index 01f8d06..929af96 100644 --- a/hello_world/usb/CMakeLists.txt +++ b/hello_world/usb/CMakeLists.txt @@ -1,10 +1,11 @@ if (TARGET tinyusb_device) add_executable(hello_usb - hello_usb.c + hello_usb.cpp ) - + set(PICO_CXX_ENABLE_EXCEPTIONS 1) # pull in common dependencies - target_link_libraries(hello_usb pico_stdlib) + target_link_libraries(hello_usb pico_stdlib pico_multicore pico_util) + target_compile_definitions(hello_usb PRIVATE PARAM_ASSERTIONS_ENABLE_ALL=1) # enable usb output, disable uart output pico_enable_stdio_usb(hello_usb 1) diff --git a/hello_world/usb/hello_usb.c b/hello_world/usb/hello_usb.c deleted file mode 100644 index 8c7b38f..0000000 --- a/hello_world/usb/hello_usb.c +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include "pico/stdlib.h" - -int main() { - stdio_init_all(); - while (true) { - printf("Hello, world!\n"); - sleep_ms(1000); - } -} diff --git a/hello_world/usb/hello_usb.cpp b/hello_world/usb/hello_usb.cpp new file mode 100644 index 0000000..c9bb3b9 --- /dev/null +++ b/hello_world/usb/hello_usb.cpp @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include "pico/stdlib.h" +#include "pico/mutex.h" +#include "pico/multicore.h" +#include "wrappers/Queue.h" +#include + +auto_init_mutex(printf_lock); +Queue queue(10); +//Queue int_queue(10); + +void main1() { + while (true) { + std::string message; + queue.blocking_remove(&message); + printf(message.c_str()); + printf("\n"); + //int count; + //int_queue.blocking_remove(&count); + //printf("%i\n", count); + } +} + +extern "C" +int main() { + stdio_init_all(); + multicore_launch_core1(main1); + int count = 0; + while (true) { + std::string message; + message = std::to_string(count++); + printf("Is wrapped: %i\n", queue.wrapped); + printf("Enqueue %s\n", message.c_str()); + queue.blocking_add(&message); + //int_queue.blocking_add(&count); + sleep_ms(1000); + } +}