apb_uart_Driver.h
117 lines
| 4.0 KiB
| text/x-c
|
CLexer
martin
|
r59 | /*------------------------------------------------------------------------------ | ||
-- This file is a part of the LPP VHDL IP LIBRARY | ||||
-- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS | ||||
-- | ||||
-- This program is free software; you can redistribute it and/or modify | ||||
-- it under the terms of the GNU General Public License as published by | ||||
-- the Free Software Foundation; either version 3 of the License, or | ||||
-- (at your option) any later version. | ||||
-- | ||||
-- This program 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 General Public License for more details. | ||||
-- | ||||
-- You should have received a copy of the GNU General Public License | ||||
-- along with this program; if not, write to the Free Software | ||||
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
------------------------------------------------------------------------------- | ||||
-- Author : Martin Morlot | ||||
-- Mail : martin.morlot@lpp.polytechnique.fr | ||||
alexis
|
r66 | -----------------------------------------------------------------------------*/ | ||
martin
|
r59 | #ifndef APB_UART_DRIVER_H | ||
alexis
|
r66 | #define APB_UART_DRIVER_H | ||
/*! \file apb_uart_Driver.h | ||||
\brief LPP Uart driver. | ||||
martin
|
r69 | |||
This library is written to work with LPP_APB_UART VHDL module from LPP's FreeVHDLIB. It help you to print and get, | ||||
martin
|
r86 | char or strings over uart. | ||
martin
|
r69 | \author Martin Morlot martin.morlot@lpp.polytechnique.fr | ||
alexis
|
r66 | */ | ||
martin
|
r69 | #define BaudGenOnDuty 0 /**< Used to reset the Baud Generator (Capture Flag) */ | ||
#define DataSended 0x10 /**< Used to know when the data was send */ | ||||
#define NewData 0x100 /**< Used to know if a New data is ready to be send */ | ||||
alexis
|
r66 | |||
martin
|
r59 | /*=================================================== | ||
T Y P E S D E F | ||||
alexis
|
r66 | ====================================================*/ | ||
martin
|
r69 | |||
/*! \struct UART_Driver | ||||
\brief Sturcture representing the uart registers | ||||
*/ | ||||
alexis
|
r66 | struct UART_Driver | ||
{ | ||||
martin
|
r69 | int ConfigReg; /**< \brief Configuration register composed of Capture Flag [HEX 0] | ||
Sended Flag [HEX 1] | ||||
NewData Flag [HEX 2] | ||||
Dummy "E" [HEX 3/4] | ||||
BTrig Freq [HEX 5/6/7] */ | ||||
int DataWReg; /**< \brief Data Write register */ | ||||
int DataRReg; /**< \brief Data Read register */ | ||||
alexis
|
r66 | }; | ||
martin
|
r86 | typedef volatile struct UART_Driver UART_Device; | ||
alexis
|
r66 | |||
martin
|
r59 | /*=================================================== | ||
F U N C T I O N S | ||||
alexis
|
r66 | ====================================================*/ | ||
/*! \fn UART_Device* openUART(int count); | ||||
martin
|
r69 | \brief Return count UART. | ||
This Function scans APB devices table and returns count UART. | ||||
\param count The number of the UART you whant to get. For example if you have 3 UARTS on your SOC you want | ||||
martin
|
r86 | to use UART1 so count = 1. | ||
alexis
|
r66 | \return The pointer to the device. | ||
*/ | ||||
UART_Device* openUART(int count); | ||||
/*! \fn void uartputc(UART_Device* dev,char c); | ||||
\brief Print char over given UART. | ||||
martin
|
r69 | |||
alexis
|
r66 | This Function puts the given char over the given UART. | ||
martin
|
r69 | |||
alexis
|
r66 | \param dev The UART pointer. | ||
\param c The char you whant to print. | ||||
*/ | ||||
void uartputc(UART_Device* dev,char c); | ||||
/*! \fn void uartputs(UART_Device* dev,char* s); | ||||
\brief Print string over given UART. | ||||
martin
|
r69 | |||
alexis
|
r66 | This Function puts the given string over the given UART. | ||
martin
|
r69 | |||
alexis
|
r66 | \param dev The UART pointer. | ||
\param s The string you whant to print. | ||||
*/ | ||||
void uartputs(UART_Device* dev,char* s); | ||||
/*! \fn char uartgetc(UART_Device* dev); | ||||
\brief Get char from given UART. | ||||
martin
|
r69 | |||
alexis
|
r66 | This Function get char from the given UART. | ||
martin
|
r69 | |||
alexis
|
r66 | \param dev The UART pointer. | ||
\return The read char. | ||||
*/ | ||||
char uartgetc(UART_Device* dev); | ||||
/*! \fn void uartgets(UART_Device* dev,char* s); | ||||
\brief Get string from given UART. | ||||
martin
|
r69 | |||
alexis
|
r66 | This Function get string from the given UART. | ||
martin
|
r69 | |||
alexis
|
r66 | \param dev The UART pointer. | ||
\param s The read string. | ||||
*/ | ||||
void uartgets(UART_Device* dev,char* s); | ||||
#endif | ||||