26 #ifndef __NFC_BUS_UART_H__
27 # define __NFC_BUS_UART_H__
39 # include <sys/ioctl.h>
42 # include <sys/types.h>
43 # include <sys/stat.h>
45 # include <sys/time.h>
47 # define delay_ms( X ) usleep( X * 1000 )
49 # include "contrib/windows.h"
50 # define delay_ms( X ) Sleep( X )
56 # define DEFAULT_SERIAL_PORTS { "COM1", "COM2", "COM3", "COM4", NULL }
57 # elif defined(__APPLE__)
59 # define DEFAULT_SERIAL_PORTS { "/dev/tty.SLAB_USBtoUART", NULL }
60 # elif defined (__FreeBSD__) || defined (__OpenBSD__)
62 # define DEFAULT_SERIAL_PORTS { "/dev/cuau0", "/dev/cuau1", "/dev/cuau2", "/dev/cuau3", NULL }
63 # elif defined (__linux__)
64 # define DEFAULT_SERIAL_PORTS { "/dev/ttyUSB0", "/dev/ttyUSB1", "/dev/ttyUSB2", "/dev/ttyUSB3", "/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3", NULL }
66 # error "Can't determine serial string for your system"
70 typedef void *serial_port;
71 # define INVALID_SERIAL_PORT (void*)(~1)
72 # define CLAIMED_SERIAL_PORT (void*)(~2)
74 serial_port uart_open (
const char *pcPortName);
75 void uart_close (
const serial_port sp);
77 void uart_set_speed (serial_port sp,
const uint32_t uiPortSpeed);
78 uint32_t uart_get_speed (
const serial_port sp);
80 int uart_receive (serial_port sp, byte_t * pbtRx,
size_t * pszRx);
81 int uart_send (serial_port sp,
const byte_t * pbtTx,
const size_t szTx);
83 #endif // __NFC_BUS_UART_H__