my first commit

This commit is contained in:
2023-12-08 21:13:49 -06:00
parent eca13acf57
commit 1f492d0835
3 changed files with 48 additions and 19 deletions

View File

@@ -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)

View File

@@ -1,16 +0,0 @@
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include "pico/stdlib.h"
int main() {
stdio_init_all();
while (true) {
printf("Hello, world!\n");
sleep_ms(1000);
}
}

View File

@@ -0,0 +1,44 @@
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/mutex.h"
#include "pico/multicore.h"
#include "wrappers/Queue.h"
#include <string>
auto_init_mutex(printf_lock);
Queue<std::string> queue(10);
//Queue<int> 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);
}
}