MOS Source Code
Loading...
Searching...
No Matches
serial.h File Reference
#include <mos/types.h>
+ Include dependency graph for serial.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  serial_driver_t
 
struct  serial_device_t
 

Typedefs

typedef struct _serial_device serial_device_t
 

Enumerations

enum  serial_register_t {
  OFFSET_INTERRUPT_ENABLE = 1 , OFFSET_INTERRUPT_ID_FIFO = 2 , OFFSET_LINE_CONTROL = 3 , OFFSET_MODEM_CONTROL = 4 ,
  OFFSET_LINE_STATUS = 5 , OFFSET_MODEM_STATUS = 6 , OFFSET_SCRATCH = 7 , OFFSET_DLAB_DIVISOR_LSB = 0 ,
  OFFSET_DLAB_DIVISOR_MSB = 1
}
 
enum  serial_charlength_t { CHAR_LENGTH_5 = 0x0 , CHAR_LENGTH_6 = 0x1 , CHAR_LENGTH_7 = 0x2 , CHAR_LENGTH_8 = 0x3 }
 
enum  serial_stopbits_t { STOP_BITS_1 , STOP_BITS_15_OR_2 }
 
enum  serial_parity_t {
  PARITY_NONE = 0 , PARITY_ODD = 1 , PARITY_EVEN = 2 , PARITY_MARK = 3 ,
  PARITY_SPACE = 4
}
 
enum  serial_interrupt_t {
  INTERRUPT_DATA_AVAILABLE = 1 << 0 , INTERRUPT_TRANSMITTER_EMPTY = 1 << 1 , INTERRUPT_BREAK_ERROR = 1 << 2 , INTERRUPT_STATUS_CHANGE = 1 << 3 ,
  INTERRUPT_NONE = 0 , INTERRUPT_ALL = INTERRUPT_DATA_AVAILABLE | INTERRUPT_TRANSMITTER_EMPTY | INTERRUPT_BREAK_ERROR | INTERRUPT_STATUS_CHANGE
}
 
enum  serial_baudrate_t {
  BAUD_RATE_115200 = 1 , BAUD_RATE_57600 = 2 , BAUD_RATE_38400 = 3 , BAUD_RATE_19200 = 4 ,
  BAUD_RATE_9600 = 5 , BAUD_RATE_4800 = 6 , BAUD_RATE_2400 = 7 , BAUD_RATE_1200 = 8 ,
  BAUD_RATE_600 = 9 , BAUD_RATE_300 = 10 , BAUD_RATE_110 = 11
}
 

Functions

bool serial_device_setup (serial_device_t *device)
 
int serial_device_read (serial_device_t *device, char *data, size_t length)
 
int serial_device_write (serial_device_t *device, const char *data, size_t length)
 
bool serial_dev_get_data_ready (serial_device_t *device)
 

Typedef Documentation

◆ serial_device_t

typedef struct _serial_device serial_device_t

Definition at line 69 of file serial.h.

Enumeration Type Documentation

◆ serial_register_t

Enumerator
OFFSET_INTERRUPT_ENABLE 
OFFSET_INTERRUPT_ID_FIFO 
OFFSET_LINE_CONTROL 
OFFSET_MODEM_CONTROL 
OFFSET_LINE_STATUS 
OFFSET_MODEM_STATUS 
OFFSET_SCRATCH 
OFFSET_DLAB_DIVISOR_LSB 
OFFSET_DLAB_DIVISOR_MSB 

Definition at line 7 of file serial.h.

◆ serial_charlength_t

Enumerator
CHAR_LENGTH_5 
CHAR_LENGTH_6 
CHAR_LENGTH_7 
CHAR_LENGTH_8 

Definition at line 21 of file serial.h.

◆ serial_stopbits_t

Enumerator
STOP_BITS_1 
STOP_BITS_15_OR_2 

Definition at line 29 of file serial.h.

◆ serial_parity_t

Enumerator
PARITY_NONE 
PARITY_ODD 
PARITY_EVEN 
PARITY_MARK 
PARITY_SPACE 

Definition at line 35 of file serial.h.

◆ serial_interrupt_t

Enumerator
INTERRUPT_DATA_AVAILABLE 
INTERRUPT_TRANSMITTER_EMPTY 
INTERRUPT_BREAK_ERROR 
INTERRUPT_STATUS_CHANGE 
INTERRUPT_NONE 
INTERRUPT_ALL 

Definition at line 44 of file serial.h.

◆ serial_baudrate_t

Enumerator
BAUD_RATE_115200 
BAUD_RATE_57600 
BAUD_RATE_38400 
BAUD_RATE_19200 
BAUD_RATE_9600 
BAUD_RATE_4800 
BAUD_RATE_2400 
BAUD_RATE_1200 
BAUD_RATE_600 
BAUD_RATE_300 
BAUD_RATE_110 

Definition at line 54 of file serial.h.

Function Documentation

◆ serial_device_setup()

bool serial_device_setup ( serial_device_t * device)

Definition at line 112 of file serial.c.

Referenced by serial_console_setup().

+ Here is the call graph for this function:

◆ serial_device_read()

int serial_device_read ( serial_device_t * device,
char * data,
size_t length )

Definition at line 169 of file serial.c.

Referenced by serial_console_irq_handler(), and serial_device_setup().

+ Here is the call graph for this function:

◆ serial_device_write()

int serial_device_write ( serial_device_t * device,
const char * data,
size_t length )

Definition at line 158 of file serial.c.

Referenced by serial_console_clear(), serial_console_irq_handler(), serial_console_set_color(), serial_console_write(), and serial_device_setup().

+ Here is the call graph for this function:

◆ serial_dev_get_data_ready()

bool serial_dev_get_data_ready ( serial_device_t * device)

Definition at line 141 of file serial.c.

Referenced by serial_console_irq_handler(), and serial_dev_wait_ready_to_read().

+ Here is the call graph for this function: