stuff
This commit is contained in:
37
core_comm.c
37
core_comm.c
@@ -3,18 +3,43 @@
|
||||
#include "pico/multicore.h"
|
||||
#include "pico/platform.h"
|
||||
|
||||
bool core1_to_core0_try_write(uint32_t data) {
|
||||
bool core1_to_core0_try_write(uint64_t data) {
|
||||
hard_assert(get_core_num() == 1);
|
||||
return multicore_fifo_push_timeout_us(data, 0);
|
||||
if (!multicore_fifo_push_timeout_us((uint32_t)data, 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Once the low word is committed, complete the pair to preserve framing.
|
||||
multicore_fifo_push_blocking((uint32_t)(data >> 32));
|
||||
return true;
|
||||
}
|
||||
|
||||
void core1_to_core0_write_blocking(uint32_t data) {
|
||||
void core1_to_core0_write_blocking(uint64_t data) {
|
||||
hard_assert(get_core_num() == 1);
|
||||
multicore_fifo_push_blocking(data);
|
||||
multicore_fifo_push_blocking((uint32_t)data);
|
||||
multicore_fifo_push_blocking((uint32_t)(data >> 32));
|
||||
}
|
||||
|
||||
bool core0_try_read_from_core1(uint32_t *data) {
|
||||
bool core0_try_read_from_core1(uint64_t *data) {
|
||||
static bool have_low_word;
|
||||
static uint32_t low_word;
|
||||
|
||||
hard_assert(get_core_num() == 0);
|
||||
hard_assert(data != NULL);
|
||||
return multicore_fifo_pop_timeout_us(0, data);
|
||||
|
||||
if (!have_low_word) {
|
||||
if (!multicore_fifo_pop_timeout_us(0, &low_word)) {
|
||||
return false;
|
||||
}
|
||||
have_low_word = true;
|
||||
}
|
||||
|
||||
uint32_t high_word;
|
||||
if (!multicore_fifo_pop_timeout_us(0, &high_word)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*data = (uint64_t)low_word | ((uint64_t)high_word << 32);
|
||||
have_low_word = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user