2009-10-12 14:52:26 +00:00
|
|
|
/**
|
|
|
|
* Public platform independent Near Field Communication (NFC) library
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009, Roel Verdult
|
|
|
|
*
|
|
|
|
* This program 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 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 Lesser General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*
|
2009-11-04 10:14:17 +00:00
|
|
|
* @file uart.h
|
2009-10-12 14:52:26 +00:00
|
|
|
* @brief
|
|
|
|
*/
|
2009-06-11 09:12:00 +00:00
|
|
|
|
2009-11-09 11:23:33 +00:00
|
|
|
#ifndef __NFC_BUS_UART_H__
|
|
|
|
#define __NFC_BUS_UART_H__
|
2009-06-11 09:12:00 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2009-11-09 11:23:33 +00:00
|
|
|
|
|
|
|
#include "nfc-defines.h"
|
|
|
|
#include "nfc-types.h"
|
2009-06-11 09:12:00 +00:00
|
|
|
|
|
|
|
// Handle platform specific includes
|
|
|
|
#ifndef _WIN32
|
|
|
|
#include <termios.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <limits.h>
|
2009-06-11 10:16:27 +00:00
|
|
|
#include <sys/time.h>
|
2009-06-11 09:12:00 +00:00
|
|
|
#else
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Define shortcut to types to make code more readable
|
|
|
|
typedef void* serial_port;
|
|
|
|
#define INVALID_SERIAL_PORT (void*)(~1)
|
|
|
|
#define CLAIMED_SERIAL_PORT (void*)(~2)
|
|
|
|
|
2009-11-04 10:14:17 +00:00
|
|
|
serial_port uart_open(const char* pcPortName);
|
|
|
|
void uart_close(const serial_port sp);
|
2009-09-14 15:05:02 +00:00
|
|
|
|
2009-11-04 10:14:17 +00:00
|
|
|
void uart_set_speed(serial_port sp, const uint32_t uiPortSpeed);
|
|
|
|
uint32_t uart_get_speed(const serial_port sp);
|
2009-09-14 15:05:02 +00:00
|
|
|
|
2009-11-04 10:14:17 +00:00
|
|
|
bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen);
|
|
|
|
bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen);
|
2009-06-11 09:12:00 +00:00
|
|
|
|
2009-11-09 11:23:33 +00:00
|
|
|
#endif // __NFC_BUS_UART_H__
|
2009-06-11 09:12:00 +00:00
|
|
|
|
|
|
|
|