my first commit
This commit is contained in:
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