include/serial.h
author Tero Marttila <terom@paivola.fi>
Wed, 08 Oct 2014 23:20:34 +0300
changeset 11 a383e22204f2
parent 5 652c31c10f91
permissions -rw-r--r--
adxl345: control/data registers read/write
#ifndef QMSK_SERIAL_H
#define QMSK_SERIAL_H

/** Serial modes */
enum serial_mode {
    SERIAL_MODE_ASYNC   = 0b00,

    SERIAL_MODE_DEFAULT = SERIAL_MODE_ASYNC
};

enum serial_baud {
    SERIAL_BAUD_9600    = 103,
};

enum serial_parity {
    SERIAL_PARITY_N     = 0b00,
};

enum serial_stopbits {
    SERIAL_STOPBITS_1   = 0b0,
};

enum serial_chars {
    SERIAL_CHARS_8      = 0b011,
};

/* Size of RX buffer */
#define SERIAL_BUF 64


/*
 * Setup the UART for serial mode.
 */
void serial_init (
    enum serial_baud baud,
    enum serial_parity parity,
    enum serial_stopbits stopbits
);

/*
 * Read a single input char from the rx buffer.
 *
 * Returns 0 if the rx buf is empty.
 */
char serial_read ();

/*
 * Write a single output char, either directly or via the tx "buffer".
 *
 * XXX: currently only has a tx buffer of 1 byte.
 */
void serial_write (char c);

#endif