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
move xbee user code in a separate file
[protos/xbee-avr.git]
/
cmdline.c
diff --git
a/cmdline.c
b/cmdline.c
index
d9fd836
..
736fa52
100644
(file)
--- a/
cmdline.c
+++ b/
cmdline.c
@@
-30,29
+30,19
@@
#include <parse.h>
#include <rdline.h>
#include <uart.h>
#include <parse.h>
#include <rdline.h>
#include <uart.h>
-#include <clock_time.h>
#include "callout.h"
#include "main.h"
#include "cmdline.h"
#include "callout.h"
#include "main.h"
#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;
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);
uart_send(CMDLINE_UART, c);
-#endif
return 0;
}
return 0;
}
@@
-61,12
+51,7
@@
int cmdline_dev_recv(FILE* f)
int16_t c;
(void)f;
int16_t c;
(void)f;
-#ifdef USE_USB
- /* non-blocking ! */
- c = CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface);
-#else
c = uart_recv_nowait(CMDLINE_UART);
c = uart_recv_nowait(CMDLINE_UART);
-#endif
if (c < 0)
return _FDEV_EOF;
if (c < 0)
return _FDEV_EOF;
@@
-77,11
+62,7
@@
int cmdline_dev_recv(FILE* f)
int xbee_dev_send(char c, FILE* f)
{
(void)f;
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);
uart_send(XBEE_UART, c);
-#endif
return 0;
}
return 0;
}
@@
-90,20
+71,14
@@
int xbee_dev_recv(FILE* f)
int16_t c;
(void)f;
int16_t c;
(void)f;
-#ifdef USE_USB
- /* non-blocking ! */
- c = CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface);
-#else
c = uart_recv_nowait(XBEE_UART);
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)
+void cmdline_valid_buffer(const char *buf, uint8_t size)
{
int8_t ret;
PGM_P ctx = (PGM_P)main_ctx;
{
int8_t ret;
PGM_P ctx = (PGM_P)main_ctx;
@@
-127,7
+102,7
@@
complete_buffer(const char *buf, char *dstbuf, uint8_t dstsize,
}
}
-
static void
write_char(char c)
+
void cmdline_
write_char(char c)
{
cmdline_dev_send(c, NULL);
}
{
cmdline_dev_send(c, NULL);
}
@@
-135,7
+110,7
@@
static void write_char(char c)
void cmdline_init(void)
{
void cmdline_init(void)
{
- rdline_init(&xbeeboard.rdl,
write_char,
valid_buffer, complete_buffer);
+ rdline_init(&xbeeboard.rdl,
cmdline_write_char, cmdline_
valid_buffer, complete_buffer);
snprintf_P(xbeeboard.prompt, sizeof(xbeeboard.prompt), PSTR("mainboard > "));
}
snprintf_P(xbeeboard.prompt, sizeof(xbeeboard.prompt), PSTR("mainboard > "));
}
@@
-151,20
+126,22
@@
void emergency(char c)
i++;
else if ( !(i == 1 && c == 'p') )
i = 0;
i++;
else if ( !(i == 1 && c == 'p') )
i = 0;
- if (i == 3)
- bootloader();
+ if (i == 3) {
+ //bootloader();
+ reset();
+ }
}
/* log function, add a command to configure
* it dynamically */
void mylog(struct error * e, ...)
{
}
/* log function, add a command to configure
* it dynamically */
void mylog(struct error * e, ...)
{
- va_list ap;
#ifndef HOST_VERSION
u16 stream_flags = stdout->flags;
#endif
#ifndef HOST_VERSION
u16 stream_flags = stdout->flags;
#endif
- uint8_t i;
- time_h tv;
+ va_list ap;
+ uint8_t i, flags;
+ uint32_t ms;
if (e->severity > ERROR_SEVERITY_ERROR) {
if (xbeeboard.log_level < e->severity)
if (e->severity > ERROR_SEVERITY_ERROR) {
if (xbeeboard.log_level < e->severity)
@@
-178,8
+155,11
@@
void mylog(struct error * e, ...)
}
va_start(ap, e);
}
va_start(ap, e);
- tv = time_get_time();
- printf_P(PSTR("%d.%.3d: "), (int)tv.s, (int)(tv.us/1000UL));
+ IRQ_LOCK(flags);
+ ms = global_ms;
+ IRQ_UNLOCK(flags);
+
+ printf_P(PSTR("%d.%.3d: "), (int)(ms/1000UL), (int)(ms%1000UL));
vfprintf_P(stdout, e->text, ap);
printf_P(PSTR("\r\n"));
vfprintf_P(stdout, e->text, ap);
printf_P(PSTR("\r\n"));