Initial Release
This commit is contained in:
14
multicore/hello_multicore/CMakeLists.txt
Normal file
14
multicore/hello_multicore/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
add_executable(hello_multicore
|
||||
multicore.c
|
||||
)
|
||||
|
||||
# Add pico_multicore which is required for multicore functionality
|
||||
target_link_libraries(hello_multicore
|
||||
pico_stdlib
|
||||
pico_multicore)
|
||||
|
||||
# create map/bin/hex file etc.
|
||||
pico_add_extra_outputs(hello_multicore)
|
||||
|
||||
# add url via pico_set_program_url
|
||||
example_auto_set_url(hello_multicore)
|
||||
48
multicore/hello_multicore/multicore.c
Normal file
48
multicore/hello_multicore/multicore.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/multicore.h"
|
||||
|
||||
#define FLAG_VALUE 123
|
||||
|
||||
void core1_entry() {
|
||||
|
||||
multicore_fifo_push_blocking(FLAG_VALUE);
|
||||
|
||||
uint32_t g = multicore_fifo_pop_blocking();
|
||||
|
||||
if (g != FLAG_VALUE)
|
||||
printf("Hmm, that's not right on core 1!\n");
|
||||
else
|
||||
printf("Its all gone well on core 1!");
|
||||
|
||||
while (1)
|
||||
tight_loop_contents();
|
||||
}
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
printf("Hello, multicore!\n");
|
||||
|
||||
///tag::setup_multicore[]
|
||||
|
||||
multicore_launch_core1(core1_entry);
|
||||
|
||||
// Wait for it to start up
|
||||
|
||||
uint32_t g = multicore_fifo_pop_blocking();
|
||||
|
||||
if (g != FLAG_VALUE)
|
||||
printf("Hmm, that's not right on core 0!\n");
|
||||
else {
|
||||
multicore_fifo_push_blocking(FLAG_VALUE);
|
||||
printf("It's all gone well on core 0!");
|
||||
}
|
||||
|
||||
///end::setup_multicore[]
|
||||
}
|
||||
Reference in New Issue
Block a user