ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
Functions
queue.c File Reference

Ring buffer code. More...

#include "user_config.h"
#include "lib/queue.h"

Go to the source code of this file.

Functions

queue_tqueue_new (size_t size)
 Create a ring buffer of a given size. More...
 
void queue_del (queue_t *q)
 Delete a ring buffer and free memory. More...
 
void queue_flush (queue_t *q)
 Flush ring buffer. More...
 
size_t queue_used (queue_t *q)
 Find the number of bytes used by the ring buffer. More...
 
size_t queue_empty (queue_t *q)
 Is the ring buffer empty ? More...
 
size_t queue_space (queue_t *q)
 Find the amount of free space remaining in the ring buffer. More...
 
size_t queue_full (queue_t *q)
 Is the ring buffer full ? More...
 
size_t queue_push_buffer (queue_t *q, uint8_t *src, size_t size)
 Add a data buffer to the ring buffer Note: This function does not wait/block util there is enough free space to meet the request. So you must check that the return value matches the size. More...
 
size_t queue_pop_buffer (queue_t *q, uint8_t *dst, size_t size)
 Get a data buffer from the ring buffer. Note: This function does not wait/block until there is enough data to fill the request. So you must check that the return value matches the size. More...
 
int queue_pushc (queue_t *q, uint8_t c)
 Add a byte to the ring buffer Note: This function does not wait/block util there is enough free space to meet the request. We assume you check queue_full() before calling this function! Otherwise you must check that the return value matches 1. More...
 
int queue_popc (queue_t *q)
 Remove a byte from the ring buffer Note: This function does not wait/block util there is data to meet the request. We assume you check queue_empty() before calling this function! More...
 

Detailed Description

Ring buffer code.

Copyright © 2015 Mike Gore, GPL License
You are free to use this code under the terms of GPL
Please retain a copy of this notice in any code you use it in.

This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file queue.c.

Function Documentation

void queue_del ( queue_t q)

Delete a ring buffer and free memory.

Parameters
[in]*qring buffer pointer
Returns
void

Definition at line 62 of file queue.c.

size_t queue_empty ( queue_t q)

Is the ring buffer empty ?

Parameters
[in]*qring buffer pointer
Returns
1 if empty, 0 otherwise

Definition at line 114 of file queue.c.

Referenced by kbhit(), kbhiteol(), and uart_flush().

void queue_flush ( queue_t q)

Flush ring buffer.

Parameters
[in]*qring buffer pointer
Returns
void

Definition at line 87 of file queue.c.

size_t queue_full ( queue_t q)

Is the ring buffer full ?

Parameters
[in]*qring buffer pointer
Returns
1 if full, 0 otherwise

Definition at line 140 of file queue.c.

Referenced by uart_flush().

queue_t* queue_new ( size_t  size)

Create a ring buffer of a given size.

Parameters
[in]sizesize of rin buffer
Returns
popinter to ring buffer structure

Definition at line 38 of file queue.c.

size_t queue_pop_buffer ( queue_t q,
uint8_t dst,
size_t  size 
)

Get a data buffer from the ring buffer. Note: This function does not wait/block until there is enough data to fill the request. So you must check that the return value matches the size.

Parameters
[in]*qring buffer pointer
[in]*dstoutout buffer
[in]sizesize of input buffer
Returns
number of bytes actually added to the buffer - may not be size!

Definition at line 186 of file queue.c.

int queue_popc ( queue_t q)

Remove a byte from the ring buffer Note: This function does not wait/block util there is data to meet the request. We assume you check queue_empty() before calling this function!

Parameters
[in]*qring buffer pointer
Returns
byte , or 0 if ring buffer was empty (user error)

Definition at line 244 of file queue.c.

Referenced by uart_flush().

size_t queue_push_buffer ( queue_t q,
uint8_t src,
size_t  size 
)

Add a data buffer to the ring buffer Note: This function does not wait/block util there is enough free space to meet the request. So you must check that the return value matches the size.

Parameters
[in]*qring buffer pointer
[in]*srcinput buffer
[in]sizesize of input buffer
Returns
number of bytes actually added to the buffer - may not be size!

Definition at line 157 of file queue.c.

int queue_pushc ( queue_t q,
uint8_t  c 
)

Add a byte to the ring buffer Note: This function does not wait/block util there is enough free space to meet the request. We assume you check queue_full() before calling this function! Otherwise you must check that the return value matches 1.

Parameters
[in]*qring buffer pointer
[in]cvyte to add
Returns
number of bytes actually added to the buffer - may not be 1!

Definition at line 216 of file queue.c.

Referenced by uart_flush().

size_t queue_space ( queue_t q)

Find the amount of free space remaining in the ring buffer.

Parameters
[in]*qring buffer pointer
Returns
bytes remining in ring buffer

Definition at line 128 of file queue.c.

Referenced by queue_full(), and queue_push_buffer().

size_t queue_used ( queue_t q)

Find the number of bytes used by the ring buffer.

Parameters
[in]*qring buffer pointer
Returns
the number of bytes used in the ring buffer

Definition at line 102 of file queue.c.