my first commit
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
if (TARGET tinyusb_device)
|
if (TARGET tinyusb_device)
|
||||||
add_executable(hello_usb
|
add_executable(hello_usb
|
||||||
hello_usb.c
|
hello_usb.cpp
|
||||||
)
|
)
|
||||||
|
set(PICO_CXX_ENABLE_EXCEPTIONS 1)
|
||||||
# pull in common dependencies
|
# 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
|
# enable usb output, disable uart output
|
||||||
pico_enable_stdio_usb(hello_usb 1)
|
pico_enable_stdio_usb(hello_usb 1)
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
44
hello_world/usb/hello_usb.cpp
Normal file
44
hello_world/usb/hello_usb.cpp
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user