|
|
/*------------------------------------------------------------------------------
|
|
|
-- This file is a part of the libuc, microcontroler library
|
|
|
-- Copyright (C) 2012, Alexis Jeandet
|
|
|
--
|
|
|
-- 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 : Alexis Jeandet
|
|
|
-- Mail : alexis.jeandet@gmail.com
|
|
|
-------------------------------------------------------------------------------*/
|
|
|
#ifndef UART_H
|
|
|
#define UART_H
|
|
|
#include <stdint.h>
|
|
|
#include <uhandle.h>
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
|
|
|
|
|
|
typedef struct uart_str uart_t;
|
|
|
|
|
|
struct uart_str{
|
|
|
void* _dev;
|
|
|
int cfg;
|
|
|
int speed;
|
|
|
};
|
|
|
|
|
|
typedef enum
|
|
|
{
|
|
|
uartparitynone = 0x1,
|
|
|
uartparityeven = 0x2,
|
|
|
uartparityodd = 0x3
|
|
|
}uartparity_t;
|
|
|
|
|
|
#define UARTPARITYMASK 0x3
|
|
|
|
|
|
typedef enum
|
|
|
{
|
|
|
uart7bits = 0x4,
|
|
|
uart8bits = 0x8,
|
|
|
uart9bits = 0xC
|
|
|
}uartbits_t;
|
|
|
|
|
|
#define UARTBITSMASK 0xC
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
{
|
|
|
uarthalfstop = 0x10,
|
|
|
uartonestop = 0x20,
|
|
|
uartonehalfstop = 0x30,
|
|
|
uarttwostop = 0x40
|
|
|
}uartstopbits_t;
|
|
|
|
|
|
#define UARTSTOPBITSMASK 0x70
|
|
|
|
|
|
extern int uartopen(int,uart_t*);
|
|
|
extern int uartclose(uart_t*);
|
|
|
extern int uartenable(uart_t*);
|
|
|
extern int uartdisable(uart_t*);
|
|
|
extern int uartsetconfig(uart_t*);
|
|
|
extern int uartsetspeed(uart_t*,int);
|
|
|
extern int uartsetparity(uart_t*,uartparity_t);
|
|
|
extern int uartsetdatabits(uart_t*,uartbits_t);
|
|
|
extern int uartsetstopbits(uart_t*,uartstopbits_t);
|
|
|
extern int uartputc(uart_t*,char);
|
|
|
extern char uartgetc(uart_t*);
|
|
|
extern int uartputs(uart_t*,char*);
|
|
|
extern int uartgets(uart_t*,char*);
|
|
|
extern int uartputnc(uart_t*,char*,int);
|
|
|
extern int uartgetnc(uart_t*,char*,int);
|
|
|
extern int uartavailiabledata(uart_t*);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
}
|
|
|
#endif
|
|
|
#endif //GPIO_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|