mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-05-12 11:42:13 -04:00
Signal SD card write thread from M4 event.
This commit is contained in:
parent
daa2f7aed0
commit
8e14d2f4e8
3 changed files with 19 additions and 3 deletions
|
@ -67,11 +67,23 @@ public:
|
|||
|
||||
~AudioThread() {
|
||||
chThdTerminate(thread);
|
||||
chEvtSignal(thread, EVT_FIFO_HIGHWATER);
|
||||
chThdWait(thread);
|
||||
}
|
||||
|
||||
static void check_fifo_isr() {
|
||||
if( (shared_memory.FIFO_HACK != nullptr) && (thread != nullptr) ) {
|
||||
auto fifo = reinterpret_cast<FIFO<uint8_t>*>(shared_memory.FIFO_HACK);
|
||||
if( fifo->len() >= write_size ) {
|
||||
chEvtSignalI(thread, EVT_FIFO_HIGHWATER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr size_t write_size = 4096;
|
||||
static constexpr eventmask_t EVT_FIFO_HIGHWATER = 1;
|
||||
|
||||
const std::string file_path;
|
||||
|
||||
File file;
|
||||
|
@ -95,7 +107,7 @@ private:
|
|||
}
|
||||
|
||||
while( !chThdShouldTerminate() ) {
|
||||
// SUCH A HACK!!!
|
||||
chEvtWaitAny(EVT_FIFO_HIGHWATER);
|
||||
|
||||
auto fifo = reinterpret_cast<FIFO<uint8_t>*>(shared_memory.FIFO_HACK);
|
||||
if( !fifo ) {
|
||||
|
@ -117,8 +129,6 @@ private:
|
|||
}
|
||||
led_usb.off();
|
||||
}
|
||||
|
||||
chThdSleepMilliseconds(25);
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue