forked from haraldwolff/avr-fw-modules
31 lines
566 B
C
31 lines
566 B
C
|
#include <hwo/fifo.h>
|
||
|
#include <sys/atomic.h>
|
||
|
#include <hwo/threads.h>
|
||
|
#include <hwo/systick.h>
|
||
|
|
||
|
/*! \brief Schreiben von Zeichen "byte" in FIFO "fifo"
|
||
|
*/
|
||
|
void fifo_write(FIFO* fifo,uint8_t byte)
|
||
|
{
|
||
|
wait_async_set(&fifo->wtimeout,fifo->timeout);
|
||
|
do
|
||
|
{
|
||
|
{
|
||
|
ATOMIC
|
||
|
if (fifo_free(fifo)>0)
|
||
|
{
|
||
|
fifo->pBuffer[fifo->pWrite++] = byte;
|
||
|
if (fifo->pWrite == fifo->size)
|
||
|
fifo->pWrite = 0;
|
||
|
return;
|
||
|
};
|
||
|
|
||
|
if (fifo->irq_wr)
|
||
|
return;
|
||
|
}
|
||
|
yield();
|
||
|
}
|
||
|
while (fifo->blocking && ((fifo->timeout == -1) || !wait_async_test(&fifo->wtimeout)));
|
||
|
};
|
||
|
|