#include "core_comm.h" #include "pico/multicore.h" #include "pico/platform.h" bool core1_to_core0_try_write(uint64_t data) { hard_assert(get_core_num() == 1); 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(uint64_t data) { hard_assert(get_core_num() == 1); multicore_fifo_push_blocking((uint32_t)data); multicore_fifo_push_blocking((uint32_t)(data >> 32)); } 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); 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; }