aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/avr/serial.c1
-rw-r--r--src/command.c28
-rw-r--r--src/sam3x8e/serial.c1
3 files changed, 16 insertions, 14 deletions
diff --git a/src/avr/serial.c b/src/avr/serial.c
index 6bd88598..8c0da553 100644
--- a/src/avr/serial.c
+++ b/src/avr/serial.c
@@ -141,6 +141,7 @@ console_get_output(uint8_t len)
void
console_push_output(uint8_t len)
{
+ barrier();
writeb(&transmit_max, readb(&transmit_max) + len);
enable_tx_irq();
}
diff --git a/src/command.c b/src/command.c
index 069dfe57..2d00aaf4 100644
--- a/src/command.c
+++ b/src/command.c
@@ -4,12 +4,9 @@
//
// This file may be distributed under the terms of the GNU GPLv3 license.
-#include <ctype.h> // isspace
#include <stdarg.h> // va_start
-#include <stdio.h> // vsnprintf
-#include <stdlib.h> // strtod
-#include <string.h> // strcasecmp
-#include "board/irq.h" // irq_disable
+#include <string.h> // memcpy
+#include "board/io.h" // readb
#include "board/misc.h" // crc16_ccitt
#include "board/pgm.h" // READP
#include "command.h" // output_P
@@ -110,20 +107,17 @@ error:
shutdown("Command parser error");
}
+static uint8_t in_sendf;
+
// Encode a message and transmit it
void
_sendf(uint8_t parserid, ...)
{
- static uint8_t in_sendf;
- irqstatus_t flag = irq_save();
- if (in_sendf) {
+ if (readb(&in_sendf))
// This sendf call was made from an irq handler while the main
// code was already in sendf - just drop this sendf request.
- irq_restore(flag);
return;
- }
- in_sendf = 1;
- irq_restore(flag);
+ writeb(&in_sendf, 1);
const struct command_encoder *cp = &command_encoders[parserid];
uint8_t max_size = READP(cp->max_size);
@@ -194,12 +188,19 @@ _sendf(uint8_t parserid, ...)
*p++ = MESSAGE_SYNC;
console_push_output(msglen);
done:
- in_sendf = 0;
+ writeb(&in_sendf, 0);
return;
error:
shutdown("Message encode error");
}
+static void
+sendf_shutdown(void)
+{
+ writeb(&in_sendf, 0);
+}
+DECL_SHUTDOWN(sendf_shutdown);
+
/****************************************************************
* Command routing
@@ -306,6 +307,5 @@ command_task(void)
func(args);
}
console_pop_input(msglen);
- return;
}
DECL_TASK(command_task);
diff --git a/src/sam3x8e/serial.c b/src/sam3x8e/serial.c
index d07fc734..35a7d35c 100644
--- a/src/sam3x8e/serial.c
+++ b/src/sam3x8e/serial.c
@@ -146,6 +146,7 @@ console_get_output(uint8_t len)
void
console_push_output(uint8_t len)
{
+ barrier();
writeb(&transmit_max, readb(&transmit_max) + len);
enable_tx_irq();
}