#include "cmdline.h"
-#ifdef USE_USB
-#include "DualVirtualSerial.h"
-#endif
-
-
extern const parse_ctx_t PROGMEM main_ctx[];
int cmdline_dev_send(char c, FILE* f)
{
(void)f;
-#ifdef USE_USB
- CDC_Device_SendByte(&VirtualSerial1_CDC_Interface, (uint8_t)c);
-#else
uart_send(CMDLINE_UART, c);
-#endif
return 0;
}
int16_t c;
(void)f;
-#ifdef USE_USB
- /* non-blocking ! */
- c = CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface);
-#else
c = uart_recv_nowait(CMDLINE_UART);
-#endif
if (c < 0)
return _FDEV_EOF;
int xbee_dev_send(char c, FILE* f)
{
(void)f;
-#ifdef USE_USB
- CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)c);
-#else
uart_send(XBEE_UART, c);
-#endif
return 0;
}
int16_t c;
(void)f;
-#ifdef USE_USB
- /* non-blocking ! */
- c = CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface);
-#else
c = uart_recv_nowait(XBEE_UART);
-#endif
if (c < 0)
return _FDEV_EOF;
*/
-#ifdef USE_USB
-#include "DualVirtualSerial.h"
-#else
#define CMDLINE_UART 0
#define XBEE_UART 2
-#endif
void cmdline_init(void);
int xbee_dev_send(char c, FILE* f);
int xbee_dev_recv(FILE* f);
-static inline uint8_t cmdline_keypressed(void) {
-#ifdef USE_USB
- return (CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface) >= 0);
-#else
+static inline uint8_t cmdline_keypressed(void)
+{
return (uart_recv_nowait(CMDLINE_UART) != -1);
-#endif
}
-static inline int16_t cmdline_getchar(void) {
-#ifdef USE_USB
- return CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface);
-#else
+static inline int16_t cmdline_getchar(void)
+{
return uart_recv_nowait(CMDLINE_UART);
-#endif
}
-static inline uint8_t cmdline_getchar_wait(void) {
-#ifdef USE_USB
- int16_t c;
- do {
- c = CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface);
- } while (c < 0);
- return c;
-#else
+static inline uint8_t cmdline_getchar_wait(void)
+{
return uart_recv(CMDLINE_UART);
-#endif
}
},
};
-#ifndef USE_USB
/**********************************************************/
/* this structure is filled when cmd_baudrate is parsed successfully */
NULL,
},
};
-#endif
/* this structure is filled when cmd_test_spi is parsed successfully */
struct cmd_test_spi_result {
&cmd_raw,
&cmd_dump,
&cmd_debug,
-#ifndef USE_USB
&cmd_baudrate,
-#endif
&cmd_test_spi,
NULL,
};
void bootloader(void)
{
-#ifndef USE_USB
#define BOOTLOADER_ADDR 0x3f000
if (pgm_read_byte_far(BOOTLOADER_ADDR) == 0xff) {
printf_P(PSTR("Bootloader is not present\r\n"));
/* __asm__ __volatile__ ("ldi r31,0xf8\n"); */
/* __asm__ __volatile__ ("ldi r30,0x00\n"); */
/* __asm__ __volatile__ ("eijmp\n"); */
-#endif
}
void xbee_mainloop(void)
cmdline_poll();
xbee_proto_rx(xbee_dev);
}
-
-#ifdef USE_USB
- CDC_Device_USBTask(&VirtualSerial1_CDC_Interface);
- CDC_Device_USBTask(&VirtualSerial2_CDC_Interface);
- USB_USBTask();
-#endif
}
}
(void)clt;
(void)dummy;
-#ifdef USE_USB
- if (a & 1)
- LEDs_SetAllLEDs(0);
- else
- LEDs_SetAllLEDs(0xff);
-#else
/* XXX */
-#endif
a++;
}
int8_t err;
struct xbee_dev dev;
-#ifdef USE_USB
- SetupHardware();
-
- LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
-#else
uart_init();
uart_register_rx_event(CMDLINE_UART, emergency);
-#endif
fdevopen(cmdline_dev_send, cmdline_dev_recv);
xbee_file = fdevopen(xbee_dev_send, xbee_dev_recv);
LED_PRIO);
cmdline_init();
spi_servo_init();
-#ifndef USE_USB
- /* in usb mode, it's done in usb callback */
+
printf_P(PSTR("\r\n"));
rdline_newline(&xbeeboard.rdl, xbeeboard.prompt);
-#endif
+
callout_manager_init(&cm, get_time_ms);
callout_reset(&cm, &t1, 500, PERIODICAL, do_led_blink, NULL);