aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/avr/serial.c3
-rw-r--r--src/avr/usbserial.c4
-rw-r--r--src/command.c2
-rw-r--r--src/pru/main.c6
-rw-r--r--src/sam3x8e/serial.c3
-rw-r--r--src/sched.c10
-rw-r--r--src/sched.h1
7 files changed, 25 insertions, 4 deletions
diff --git a/src/avr/serial.c b/src/avr/serial.c
index 10b95992..8b9dd14a 100644
--- a/src/avr/serial.c
+++ b/src/avr/serial.c
@@ -65,6 +65,8 @@ DECL_INIT(serial_init);
ISR(USART0_RX_vect)
{
uint8_t data = UDR0;
+ if (data == MESSAGE_SYNC)
+ sched_wake_tasks();
if (receive_pos >= sizeof(receive_buf))
// Serial overflow - ignore it as crc error will force retransmit
return;
@@ -104,6 +106,7 @@ console_pop_input(uint8_t len)
memmove(&receive_buf[copied], &receive_buf[copied + len]
, needcopy - copied);
copied = needcopy;
+ sched_wake_tasks();
}
irqstatus_t flag = irq_save();
if (rpos != readb(&receive_pos)) {
diff --git a/src/avr/usbserial.c b/src/avr/usbserial.c
index 1b42d6d3..cc7bb12c 100644
--- a/src/avr/usbserial.c
+++ b/src/avr/usbserial.c
@@ -42,8 +42,10 @@ static void
console_pop_input(uint8_t len)
{
uint8_t needcopy = receive_pos - len;
- if (needcopy)
+ if (needcopy) {
memmove(receive_buf, &receive_buf[len], needcopy);
+ sched_wake_tasks();
+ }
receive_pos = needcopy;
}
diff --git a/src/command.c b/src/command.c
index 53263a8f..87284ee8 100644
--- a/src/command.c
+++ b/src/command.c
@@ -11,7 +11,7 @@
#include "board/misc.h" // crc16_ccitt
#include "board/pgm.h" // READP
#include "command.h" // output_P
-#include "sched.h" // DECL_TASK
+#include "sched.h" // sched_is_shutdown
static uint8_t next_sequence = MESSAGE_DEST;
diff --git a/src/pru/main.c b/src/pru/main.c
index 3c2a2725..04d440df 100644
--- a/src/pru/main.c
+++ b/src/pru/main.c
@@ -85,7 +85,10 @@ timer_kick(void)
static void
_irq_poll(void)
{
- if (CT_INTC.SECR0 & (1 << IEP_EVENT)) {
+ uint32_t secr0 = CT_INTC.SECR0;
+ if (secr0 & (1 << KICK_PRU1_EVENT))
+ sched_wake_tasks();
+ if (secr0 & (1 << IEP_EVENT)) {
CT_IEP.TMR_CMP_STS = 0xff;
uint32_t next = timer_dispatch_many();
timer_set(next);
@@ -121,7 +124,6 @@ console_task(void)
const struct command_parser *cp = SHARED_MEM->next_command;
if (!cp)
return;
- barrier();
if (sched_is_shutdown() && !(cp->flags & HF_IN_SHUTDOWN)) {
sched_report_shutdown();
diff --git a/src/sam3x8e/serial.c b/src/sam3x8e/serial.c
index 713c6337..7741d6f8 100644
--- a/src/sam3x8e/serial.c
+++ b/src/sam3x8e/serial.c
@@ -56,6 +56,8 @@ UART_Handler(void)
uint32_t status = UART->UART_SR;
if (status & UART_SR_RXRDY) {
uint8_t data = UART->UART_RHR;
+ if (data == MESSAGE_SYNC)
+ sched_wake_tasks();
if (receive_pos >= sizeof(receive_buf))
// Serial overflow - ignore it as crc error will force retransmit
return;
@@ -94,6 +96,7 @@ console_pop_input(uint32_t len)
memmove(&receive_buf[copied], &receive_buf[copied + len]
, needcopy - copied);
copied = needcopy;
+ sched_wake_tasks();
}
irqstatus_t flag = irq_save();
if (rpos != readl(&receive_pos)) {
diff --git a/src/sched.c b/src/sched.c
index 0aadcc75..a2f5fea8 100644
--- a/src/sched.c
+++ b/src/sched.c
@@ -28,6 +28,9 @@ static struct timer sentinel_timer, deleted_timer;
static uint_fast8_t
periodic_event(struct timer *t)
{
+ // Make sure the stats task runs periodically
+ sched_wake_tasks();
+ // Reschedule timer
periodic_timer.waketime += timer_from_us(100000);
sentinel_timer.waketime = periodic_timer.waketime + 0x80000000;
return SF_RESCHEDULE;
@@ -177,10 +180,17 @@ sched_timer_reset(void)
* Task waking
****************************************************************/
+// Note that at least one task is ready to run
+void
+sched_wake_tasks(void)
+{
+}
+
// Note that a task is ready to run
void
sched_wake_task(struct task_wake *w)
{
+ sched_wake_tasks();
writeb(&w->wake, 1);
}
diff --git a/src/sched.h b/src/sched.h
index bb6bb975..ba883778 100644
--- a/src/sched.h
+++ b/src/sched.h
@@ -29,6 +29,7 @@ struct task_wake {
void sched_add_timer(struct timer*);
void sched_del_timer(struct timer *del);
unsigned int sched_timer_dispatch(void);
+void sched_wake_tasks(void);
void sched_wake_task(struct task_wake *w);
uint8_t sched_check_wake(struct task_wake *w);
uint8_t sched_is_shutdown(void);