Subversion Repositories idreammicro-avr

Rev

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

/**************************************************************************//**
 * \brief USART0 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 usart0.h
 ******************************************************************************/


#ifndef H__IDREAMMICRO__USART0__H
#define H__IDREAMMICRO__USART0__H

#ifdef _cplusplus
extern "C"{
#endif

/******************************************************************************
 * Header file inclusions.
 ******************************************************************************/


#include <usart/usart.h>

#include <stdbool.h>
#include <stdint.h>

/******************************************************************************
 * Public function prototypes.
 ******************************************************************************/


/**************************************************************************//**
 * \fn void usart0__initialize(usart__configuration_t* p_configuration)
 *
 * \brief Initialize USART0.
 *
 * \param[in] p_configuration   USART configuration. If null, default settings
 *                              will be used.
 *
 * Default settings:
 * - baudrate = 9600 bps;
 * - 8 data bits;
 * - 1 stop bit;
 * - no parity.
 ******************************************************************************/

void
usart0__initialize
(
    usart__configuration_t* p_configuration
);

/**************************************************************************//**
 * \fn void usart0__set_baudrate(usart__baudrate_t baudrate)
 *
 * \brief Set USART0 baudrate.
 *
 * \param baudrate baudrate to set (in bauds per second)
 ******************************************************************************/

void
usart0__set_baudrate
(
    usart__baudrate_t baudrate
);

/**************************************************************************//**
 * \fn void usart0__set_mode(usart__mode_t usart_mode)
 *
 * \brief Set USART0 mode.
 *
 * \param usart_mode Mode to set.
 ******************************************************************************/

void
usart0__set_mode
(
    usart__mode_t usart_mode
);

/**************************************************************************//**
 * \fn void usart0__set_data_size(usart__data_size_t data_size)
 *
 * \brief Set USART0 data size.
 *
 * \param data_size data size (in bits)
 ******************************************************************************/

void
usart0__set_data_size
(
    usart__data_size_t data_size
);

/**************************************************************************//**
 * \fn void usart0__set_stop_size(usart__stop_size_t stop_size)
 *
 * \brief Set USART0 stop size.
 *
 * \param stop_size stop size (in bits)
 ******************************************************************************/

void
usart0__set_stop_size
(
    usart__stop_size_t stop_size
);

/**************************************************************************//**
 * \fn void usart0__set_parity(usart__parity_t parity)
 *
 * \brief Set USART0 parity.
 *
 * \param parity parity to set
 ******************************************************************************/

void
usart0__set_parity
(
    usart__parity_t parity
);

/**************************************************************************//**
 * \fn void usart0__set_double_speed(bool double_speed)
 *
 * \brief Set double speed.
 *
 * \param   double_speed    True to set double speed, false otherwise.
 ******************************************************************************/

void
usart0__set_double_speed
(
    bool double_speed
);

/**************************************************************************//**
 * \fn void usart0__enable_receiver(void)
 *
 * \brief Enable USART 0 receiver.
 ******************************************************************************/

void
usart0__enable_receiver
(
    void
);

/**************************************************************************//**
 * \fn void usart0__disable_receiver(void)
 *
 * \brief Disable USART 0 receiver.
 ******************************************************************************/

void
usart0__disable_receiver
(
    void
);

/**************************************************************************//**
 * \fn void usart0__enable_transmitter(void)
 *
 * \brief Enable USART 0 transmitter.
 ******************************************************************************/

void
usart0__enable_transmitter
(
    void
);

/**************************************************************************//**
 * \fn void usart0__disable_transmitter(void)
 *
 * \brief Disable USART 0 transmitter.
 ******************************************************************************/

void
usart0__disable_transmitter
(
    void
);

/**************************************************************************//**
 * \fn uint8_t usart0__receive_byte(void)
 *
 * \brief Receive a byte on USART0.
 *
 * \return received byte
 ******************************************************************************/

uint16_t
usart0__receive_byte
(
    void
);

/**************************************************************************//**
 * \fn usart0__transmit_byte(uint8_t byte_to_transmit)
 *
 * \brief Transmit a byte on USART0.
 *
 * \param byte_to_transmit byte to transmit
 ******************************************************************************/

void
usart0__transmit_byte
(
    uint16_t byte_to_transmit
);

/**************************************************************************//**
 * \fn void usart0__flush(void)
 *
 * \brief Flush USART0 receiver buffer.
 ******************************************************************************/

void
usart0__flush
(
    void
);

/**************************************************************************//**
 * \fn void usart0__enable_rx_complete_interrupt(void)
 *
 * \brief Enable USART 0 receive complete interrupt.
 ******************************************************************************/

void
usart0__enable_rx_complete_interrupt
(
    void
);

/**************************************************************************//**
 * \fn void usart0__disable_rx_complete_interrupt(void)
 *
 * \brief Disable USART 0 receive complete interrupt.
 ******************************************************************************/

void
usart0__disable_rx_complete_interrupt
(
    void
);

/**************************************************************************//**
 * \fn void usart0__set_rx_complete_callback(
 * const usart__rx_complete_callback_t* p_callback)
 *
 * \brief Set a callback to call when receive byte complete interrupt is
 * generated.
 *
 * \param[in]   p_callback  Callback to set.
 ******************************************************************************/

void
usart0__set_rx_complete_callback
(
    const usart__rx_complete_callback_t*  p_callback
);

/**************************************************************************//**
 * \fn void usart0__enable_tx_complete_interrupt(void)
 *
 * \brief Enable interrupt when TX complete.
 ******************************************************************************/

void
usart0__enable_tx_complete_interrupt
(
    void
);

/**************************************************************************//**
 * \fn void usart0__disable_tx_complete_interrupt(void)
 *
 * \brief Disable interrupt when TX complete.
 ******************************************************************************/

void
usart0__disable_tx_complete_interrupt
(
    void
);

/**************************************************************************//**
 * \fn void usart0__set_tx_complete_callback(
 * const usart__tx_complete_callback_t*  p_callback)
 *
 * \brief Set a callback to call when TX is complete.
 *
 * \param[in] p_callback        Function to call.
 ******************************************************************************/

void
usart0__set_tx_complete_callback
(
    const usart__tx_complete_callback_t*  p_callback
);

/**************************************************************************//**
 * \fn void usart0__enable_data_register_empty_interrupt()
 *
 * \brief Enable interrupt when data register is empty.
 ******************************************************************************/

void
usart0__enable_data_register_empty_interrupt
(
    void
);

/**************************************************************************//**
 * \fn void usart0__disable_data_register_empty_interrupt()
 *
 * \brief Disable interrupt when data register is empty.
 ******************************************************************************/

void
usart0__disable_data_register_empty_interrupt
(
    void
);

/**************************************************************************//**
 * \fn void usart0__set_data_register_empty_callback(
 * const usart__data_register_empty_callback_t*  p_callback)
 *
 * \brief Set a callback to call when data register is empty.
 *
 * \param[in] p_callback        Function to call.
 ******************************************************************************/

void
usart0__set_data_register_empty_callback
(
    const usart__data_register_empty_callback_t*  p_callback
);

#ifdef _cplusplus
}
#endif

#endif /* H__IDREAMMICRO__USART0__H */