git.droids-corp.org
/
protos
/
xbee-avr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
support lolo's board
[protos/xbee-avr.git]
/
cmdline.c
diff --git
a/cmdline.c
b/cmdline.c
index
36d1f31
..
60dc9a6
100644
(file)
--- a/
cmdline.c
+++ b/
cmdline.c
@@
-36,24
+36,33
@@
#include "main.h"
#include "cmdline.h"
#include "main.h"
#include "cmdline.h"
-#include "DualVirtualSerial.h"
+#ifdef USE_USB
+#include "DualVirtualSerial.h"
+#endif
-/******** See in commands.c for the list of commands. */
extern parse_pgm_ctx_t main_ctx[];
extern parse_pgm_ctx_t main_ctx[];
-int
usbserial1
_dev_send(char c, FILE* f)
+int
cmdline
_dev_send(char c, FILE* f)
{
{
+#ifdef USE_USB
CDC_Device_SendByte(&VirtualSerial1_CDC_Interface, (uint8_t)c);
CDC_Device_SendByte(&VirtualSerial1_CDC_Interface, (uint8_t)c);
+#else
+ uart_send(CMDLINE_UART, c);
+#endif
return 0;
}
return 0;
}
-int
usbserial1
_dev_recv(FILE* f)
+int
cmdline
_dev_recv(FILE* f)
{
int16_t c;
{
int16_t c;
+#ifdef USE_USB
/* non-blocking ! */
c = CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface);
/* non-blocking ! */
c = CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface);
+#else
+ c = uart_recv_nowait(CMDLINE_UART);
+#endif
if (c < 0)
return _FDEV_EOF;
if (c < 0)
return _FDEV_EOF;
@@
-61,25
+70,32
@@
int usbserial1_dev_recv(FILE* f)
}
}
-int
usbserial2
_dev_send(char c, FILE* f)
+int
xbee
_dev_send(char c, FILE* f)
{
{
+#ifdef USE_USB
CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)c);
CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)c);
+#else
+ uart_send(XBEE_UART, c);
+#endif
return 0;
}
return 0;
}
-int
usbserial2
_dev_recv(FILE* f)
+int
xbee
_dev_recv(FILE* f)
{
int16_t c;
{
int16_t c;
+#ifdef USE_USB
/* non-blocking ! */
c = CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface);
/* non-blocking ! */
c = CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface);
+#else
+ c = uart_recv_nowait(XBEE_UART);
+#endif
if (c < 0)
return _FDEV_EOF;
return c;
}
if (c < 0)
return _FDEV_EOF;
return c;
}
-
static void
valid_buffer(const char *buf, uint8_t size)
{
static void
valid_buffer(const char *buf, uint8_t size)
{
@@
-104,7
+120,7
@@
complete_buffer(const char *buf, char *dstbuf, uint8_t dstsize,
static void write_char(char c)
{
static void write_char(char c)
{
-
usbserial1
_dev_send(c, NULL);
+
cmdline
_dev_send(c, NULL);
}
}
@@
-170,7
+186,7
@@
int cmdline_poll(void)
int8_t ret, same = 0;
int16_t c;
int8_t ret, same = 0;
int16_t c;
- c =
CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface
);
+ c =
cmdline_dev_recv(NULL
);
if (c < 0)
return -1;
if (c < 0)
return -1;