# include/console/driver.h File Reference

Console driver interface. More...

`#include <ring.h>`
`#include <stddef.h>`

Include dependency graph for driver.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | console_buffer
| Buffer holding input or output data for a console. More...
struct | console_driver
| A console driver. More...
## Defines
#define | CONSOLE_BUF_SIZE 64
| The size of the console ring buffer in bytes.
## Functions
static void | console_buf_insert_char (struct console_buffer *buf, char c)
| Add a character to the console ring buffer.
static char | console_buf_extract_char (struct console_buffer *buf)
| Extract a character from the console ring buffer.
static unsigned long | console_buf_unused (struct console_buffer *buf)
| Get the number of unused character slots in the console ring buffer.
static unsigned long | console_buf_unused_before_end (struct console_buffer *buf)
| Get the number of unused character slots in the console ring buffer before it wraps.
static unsigned long | console_buf_used (struct console_buffer *buf)
| Get the number of used character slots in the console ring buffer.

## Detailed Description

Console driver interface.

- Compiler: IAR EWAVR32 and GNU GCC for AVR32
- Supported devices: All devices
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file driver.h.

## Define Documentation

#define CONSOLE_BUF_SIZE 64

The size of the console ring buffer in bytes.

Definition at line 50 of file driver.h.

Referenced by console_buf_extract_char(), console_buf_insert_char(), console_buf_unused(), console_buf_unused_before_end(), console_buf_used(), and console_drv_write().

## Function Documentation

static char console_buf_extract_char | ( | struct console_buffer * | buf | ) | `[inline, static]`

Extract a character from the console ring buffer.

Parameters:

  | buf | The console buffer.

Returns:
  The oldest unseen character in buf

Precondition:
  buf must contain at least one character

Definition at line 84 of file driver.h.

References CONSOLE_BUF_SIZE, console_buffer::data, console_buffer::ring, ring_extract_entries(), ring_get_tail(), and ring_head::tail.

Here is the call graph for this function:

static void console_buf_insert_char | ( | struct console_buffer * | buf,
|  | char | c |
| ) |  |  | `[inline, static]`

Add a character to the console ring buffer.

Parameters:

  | buf | The console buffer.
  | c | The character to be added to buf.

Precondition:
  buf must have room for at least one character

Definition at line 70 of file driver.h.

References CONSOLE_BUF_SIZE, console_buffer::data, console_buffer::ring, ring_get_head(), and ring_insert_entries().

Referenced by console_drv_putchar().

Here is the call graph for this function:

static unsigned long console_buf_unused | ( | struct console_buffer * | buf | ) | `[inline, static]`

Get the number of unused character slots in the console ring buffer.

Parameters:

  | buf | The console buffer.

Returns:
  The number of characters that can be inserted into buf before it is full.

Definition at line 99 of file driver.h.

References CONSOLE_BUF_SIZE, console_buffer::ring, and ring_entries_unused().

Referenced by console_drv_putchar(), and console_drv_write().

Here is the call graph for this function:

static unsigned long console_buf_unused_before_end | ( | struct console_buffer * | buf | ) | `[inline, static]`

Get the number of unused character slots in the console ring buffer before it wraps.

Parameters:

  | buf | The console buffer.

Returns:
  The number of characters that can be inserted into buf before it is full or wraps around to the beginning.

Definition at line 112 of file driver.h.

References CONSOLE_BUF_SIZE, console_buffer::ring, and ring_entries_unused_before_end().

Referenced by console_drv_write().

Here is the call graph for this function:

static unsigned long console_buf_used | ( | struct console_buffer * | buf | ) | `[inline, static]`

Get the number of used character slots in the console ring buffer.

Parameters:

  | buf | The console buffer.

Returns:
  The number of characters that can be extracted from buf before it is empty.

Definition at line 126 of file driver.h.

References CONSOLE_BUF_SIZE, console_buffer::ring, and ring_entries_used().

Here is the call graph for this function: