Factorise UART-relative macros definitions.
This commit is contained in:
parent
8e5d235cd2
commit
d7c16d6d1a
3 changed files with 26 additions and 46 deletions
|
@ -43,8 +43,34 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
// unistd.h is needed for usleep() fct.
|
||||||
|
#include <unistd.h>
|
||||||
|
#define delay_ms( X ) usleep( X * 1000 )
|
||||||
#else
|
#else
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define snprintf _snprintf
|
||||||
|
#define strdup _strdup
|
||||||
|
#define delay_ms( X ) Sleep( X )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Path to the serial port is OS-dependant.
|
||||||
|
// Try to guess what we should use.
|
||||||
|
//
|
||||||
|
// XXX: Some review from users cross-compiling is welcome!
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#define SERIAL_STRING "COM"
|
||||||
|
//#elif defined(__APPLE__)
|
||||||
|
// TODO: find UART connection string for PN53X device on Mac OS X
|
||||||
|
// #define SERIAL_STRING ""
|
||||||
|
#elif defined (__FreeBSD__) || defined (__OpenBSD__)
|
||||||
|
// XXX: Not tested
|
||||||
|
#define SERIAL_STRING "/dev/cuau"
|
||||||
|
#elif defined (__linux__)
|
||||||
|
#define SERIAL_STRING "/dev/ttyUSB"
|
||||||
|
#else
|
||||||
|
#error "Can't determine serial string for your system"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Define shortcut to types to make code more readable
|
// Define shortcut to types to make code more readable
|
||||||
|
|
|
@ -41,25 +41,6 @@
|
||||||
// Bus
|
// Bus
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define SERIAL_STRING "COM"
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#define strdup _strdup
|
|
||||||
#define delay_ms( X ) Sleep( X )
|
|
||||||
#else
|
|
||||||
// unistd.h is needed for usleep() fct.
|
|
||||||
#include <unistd.h>
|
|
||||||
#define delay_ms( X ) usleep( X * 1000 )
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// MacOS
|
|
||||||
#define SERIAL_STRING "/dev/tty.SLAB_USBtoUART"
|
|
||||||
#else
|
|
||||||
// *BSD, Linux and others POSIX systems
|
|
||||||
#define SERIAL_STRING "/dev/ttyUSB"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BUFFER_LENGTH 256
|
#define BUFFER_LENGTH 256
|
||||||
|
|
||||||
/** @def DEV_ARYGON_PROTOCOL_ARYGON_ASCII
|
/** @def DEV_ARYGON_PROTOCOL_ARYGON_ASCII
|
||||||
|
|
|
@ -38,33 +38,6 @@
|
||||||
// Bus
|
// Bus
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define SERIAL_STRING "COM"
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#define strdup _strdup
|
|
||||||
#define delay_ms( X ) Sleep( X )
|
|
||||||
#else
|
|
||||||
// unistd.h is needed for usleep() fct.
|
|
||||||
#include <unistd.h>
|
|
||||||
#define delay_ms( X ) usleep( X * 1000 )
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// MacOS
|
|
||||||
// TODO: find UART connection string for PN53X device on Mac OS X
|
|
||||||
#define SERIAL_STRING ""
|
|
||||||
#elif defined(__FreeBSD__)
|
|
||||||
// XXX: Not tested
|
|
||||||
#define SERIAL_STRING "/dev/cuau"
|
|
||||||
#else
|
|
||||||
// Linux and maybe some operating systems
|
|
||||||
// FIXME: We'd rather have an #elif defined(__linux__) or something like
|
|
||||||
// that and an #else that triggers an error at compile time instead
|
|
||||||
// of "falling-back" on a value that is likely to not be suitable
|
|
||||||
// for most operating systems.
|
|
||||||
#define SERIAL_STRING "/dev/ttyUSB"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BUFFER_LENGTH 256
|
#define BUFFER_LENGTH 256
|
||||||
|
|
||||||
#define SERIAL_DEFAULT_PORT_SPEED 115200
|
#define SERIAL_DEFAULT_PORT_SPEED 115200
|
||||||
|
|
Loading…
Add table
Reference in a new issue