/* Write one element into the buffer. 
This function will write one element into the array index specified by the write pointer and increment the write index. */
bool tu_fifo_write(tu_fifo_t *f, const void *data)
/* Write one element into the buffer. 
This function will write one element into the array index specified by the write pointer and increment the write index. */
bool tu_fifo_write(tu_fifo_t *f, const void *data)
{
  _ff_lock(f->mutex_wr);
  bool ret;
  uint16_t const wr_idx = f->wr_idx;
  if ( tu_fifo_full(f) && !f->overwritable )
  {
    ret = false;
  }else
  {
    uint16_t wr_ptr = idx2ptr(f->depth, wr_idx);
    _ff_push(f, data, wr_ptr);
    f->wr_idx = advance_index(f->depth, wr_idx, 1);
    ret = true;
  }
  _ff_unlock(f->mutex_wr);
  return ret;
}