Subversion Repositories idreammicro-avr

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/**************************************************************************//**
 * \brief USART library
 * \author Copyright (C) 2011  Julien Le Sech - www.idreammicro.com
 * \version 1.0
 * \date 20090426
 *
 * This file is part of the iDreamMicro library.
 *
 * This library is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This library 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 Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 ******************************************************************************/


/**************************************************************************//**
 * \headerfile usart.h
 ******************************************************************************/


#ifndef H__IDREAMMICRO__USART__H
#define H__IDREAMMICRO__USART__H

#ifdef _cplusplus
extern "C"{
#endif

/******************************************************************************
 * Public types.
 ******************************************************************************/


/**************************************************************************//**
 * \enum        usart__baudrates
 * \brief       USART baudrates (in baud per second).
 *
 * \typedef     usart__baudrate_t
 * \brief       USART baudrate (in baud per second).
 ******************************************************************************/

typedef enum usart__baudrates
{
    USART__BAUDRATE__2400       = 2400,     /*!<  2400 bps. */
    USART__BAUDRATE__4800       = 4800,     /*!<  4800 bps. */
    USART__BAUDRATE__9600       = 9600,     /*!<  9600 bps. */
    USART__BAUDRATE__14400      = 14400,    /*!<  14400 bps. */
    USART__BAUDRATE__19200      = 19200,    /*!<  19200 bps. */
    USART__BAUDRATE__28800      = 28800,    /*!<  28800 bps. */
    USART__BAUDRATE__38400      = 38400,    /*!<  38400 bps. */
    USART__BAUDRATE__57600      = 57600,    /*!<  57600 bps. */
    USART__BAUDRATE__76800      = 76800,    /*!<  76800 bps. */
    USART__BAUDRATE__115200     = 115200,   /*!<  115200 bps. */
    USART__BAUDRATE__230400     = 230400,   /*!<  230400 bps. */
    USART__BAUDRATE__250000     = 250000,   /*!<  250000 bps. */
    USART__BAUDRATE__500000     = 500000,   /*!<  500000 bps. */
    USART__BAUDRATE__1000000    = 1000000   /*!<  1000000 bps. */
} usart__baudrate_t;

/**************************************************************************//**
 * \enum        usart__modes
 * \brief       USART modes.
 *
 * \typedef     usart__mode_t
 * \brief       USART mode.
 ******************************************************************************/

typedef enum usart__modes
{
    USART__MODE__ASYNCHRONOUS,
    USART__MODE__SYNCHRONOUS,
    USART__MODE__MASTER_SPI,
    USART__MODE__INVALID
} usart__mode_t;

/**************************************************************************//**
 * \enum        usart__data_sizes
 * \brief       USART data sizes.
 *
 * \typedef     usart__data_size_t
 * \brief       USART data size.
 ******************************************************************************/

typedef enum usart__data_sizes
{
    USART__DATA_SIZE__5_BITS,   /*!<  5 data bits. */
    USART__DATA_SIZE__6_BITS,   /*!<  6 data bits. */
    USART__DATA_SIZE__7_BITS,   /*!<  7 data bits. */
    USART__DATA_SIZE__8_BITS,   /*!<  8 data bits. */
    USART__DATA_SIZE__9_BITS    /*!<  9 data bits. */
} usart__data_size_t;

/**************************************************************************//**
 * \enum        usart__stop_sizes
 * \brief       USART stop bits.
 *
 * \typedef     usart__stop_size_t
 * \brief       USART stop bits.
 ******************************************************************************/

typedef enum usart__stop_sizes
{
    USART__STOP_SIZE__1_BIT,    /*!<  1 stop bit. */
    USART__STOP_SIZE__2_BITS    /*!<  2 stop bits. */
} usart__stop_size_t;

/**************************************************************************//**
 * \enum usart__parities
 * \brief USART parities.
 *
 * \typedef     usart__parity_t
 * \brief       USART parity.
 ******************************************************************************/

typedef enum usart__parities
{
    USART__PARITY__DISABLED,    /*!<  Parity disabled. */
    USART__PARITY__EVEN,        /*!<  Even parity. */
    USART__PARITY__ODD          /*!<  Odd parity. */
} usart__parity_t;

/**************************************************************************//**
 * \struct      usart__configuration
 * \brief       USART configuration.
 *
 * \typedef     usart__configuration_t
 * \brief       USART configuration.
 ******************************************************************************/

typedef struct usart__configuration
{
    usart__mode_t       mode;
    usart__baudrate_t   baudrate;
    usart__data_size_t  data_size;
    usart__stop_size_t  stop_size;
    usart__parity_t     parity;
} usart__configuration_t;

/**************************************************************************//**
 * \typedef     usart__rx_complete_callback_t
 * \brief       RX complete callback.
 ******************************************************************************/

typedef
void
usart__rx_complete_callback_t
(
    void
);

/**************************************************************************//**
 * \typedef     usart__tx_complete_callback_t
 * \brief       TX complete callback.
 ******************************************************************************/

typedef
void
usart__tx_complete_callback_t
(
    void
);

/**************************************************************************//**
 * \typedef     usart__data_register_empty_callback_t
 * \brief       Data register empty callback.
 ******************************************************************************/

typedef
void
usart__data_register_empty_callback_t
(
    void
);

#ifdef _cplusplus
}
#endif

#endif /* H__IDREAMMICRO__USART__H */