BINARIES:= mTaskExamples mTaskInterpret miTask
all: $(BINARIES) int/mTaskSymbols.h
+ make -C CleanSerial
int/mTaskSymbols.h: mTaskMakeSymbols
./$< -nr > $@
#\r
\r
# List all user C define here, like -D_DEBUG=1\r
-UDEFS = -DSTM\r
+UDEFS = -DSTM #-DDEBUG\r
\r
# Define ASM defines here\r
UADEFS =\r
* default configuration.\r
*/\r
#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)\r
-#define SERIAL_DEFAULT_BITRATE 38400\r
+#define SERIAL_DEFAULT_BITRATE 9600\r
#endif\r
\r
/**\r
* buffers.\r
*/\r
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)\r
-#define SERIAL_BUFFERS_SIZE 16\r
+#define SERIAL_BUFFERS_SIZE 256\r
#endif\r
\r
/*===========================================================================*/\r
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
#include "interface.h"
#include "ch.h"
#include "hal.h"
-//char buf[1024];
-
//Globals
bool input_available(void)
{
- return qSizeX(&(&SD3)->iqueue) > 0;
+ return iqGetFullI(&(&SD3)->iqueue)>0;
}
uint8_t read_byte(void)
void write_apin(uint8_t i, uint8_t a)
{
- (void)i;
- (void)a;
+ if(a){
+ if(i == 0){
+ palSetLine(LINE_LED1);
+ } else if(i == 1){
+ palSetLine(LINE_LED2);
+ } else if(i == 2){
+ palSetLine(LINE_LED3);
+ }
+ } else {
+ if(i == 0){
+ palClearLine(LINE_LED1);
+ } else if(i == 1){
+ palClearLine(LINE_LED2);
+ } else if(i == 2){
+ palClearLine(LINE_LED3);
+ }
+ }
}
uint8_t read_apin(uint8_t i)
sdStart(&SD3, NULL);
}
-void test(void)
+void debug(char *fmt, ...)
+{
+ unsigned int i;
+ write_byte('m');
+ for(i = 0; i<strlen(fmt); i++){
+ write_byte((uint8_t)fmt[i]);
+ }
+ write_byte('\n');
+#ifdef DEBUG
+#endif
+ (void)fmt;
+}
+
+void pdie(char *s)
+{
+ (void)s;
+}
+
+void die(char *fmt, ...)
{
+ (void)fmt;
}
#include <stdbool.h>
#include <stdint.h>
+#include <stdarg.h>
#ifndef STM
extern int gargc;
void delay(long ms);
void setup(void);
-void test(void);
-
-#ifdef STM
-#define debug(s, ...) {};
-#define pdie(s) {};
-#define die(s, ...) {};
-#else
-#define debug(s, ...) printf(s "\n", ##__VA_ARGS__);
-#define pdie(s) {perror(s); exit(1);}
-#define die(s, ...) {fprintf(stderr, s "\n", ##__VA_ARGS__); exit(1);}
-#endif
+void debug(char *fmt, ...);
+void pdie(char *s);
+void die(char *fmt, ...);
#endif
pdie("accept");
}
-void test(void)
+void debug(char *fmt, ...)
{
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+void pdie(char *s)
+{
+ perror(s);
+ die("");
+}
+
+void die(char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ exit(EXIT_FAILURE);
}
#include "task.h"
#include "sds.h"
-#ifdef STM32F767xx
+#ifdef STM
#define trace(op, ...) ;
#else
#define trace(op, ...) ;
debug("Current task to run: %d", ct);
run_task(curtask);
curtask->lastrun = cyclestart;
- write_byte('\n');
+// write_byte('\n');
}
}
gargv = argv;
#endif
+ read_byte();
//Initialize systems
setup();
sds_init();
task_init();
+ while(!input_available()){
+ delay(100);
+ }
debug("booting up");
while(true){
//Check for newetasks
debug("loop");
loop();
- input_available();
delay(100);
}
return 0;
#include <stdlib.h>
#include <string.h>
-#ifndef STM32F767xx
+#ifndef STM
#include <unistd.h>
#include <stdio.h>
#endif
sdss[cs].value = read16();
debug("Received sds update %d: %d",
sdss[cs].id, sdss[cs].value);
- printf("Received sds update %d: %d",
- sdss[cs].id, sdss[cs].value);
return true;
}
}
#include <stdlib.h>
#include <string.h>
-#ifndef STM32F767xx
+#ifndef STM
#include <unistd.h>
#include <stdio.h>
#endif
mTaskTask :: (Shared ([MTaskMSGRecv],Bool,[MTaskMSGSend],Bool)) -> Task ()
mTaskTask ch =
- deviceSelectorNetwork >>= \(p,h)->syncNetworkChannel h p "\n" decode encode ch ||-
-// deviceSelectorSerial >>= \(s,set)->syncSerialChannel s set decode encode ch ||-
+// deviceSelectorNetwork >>= \(p,h)->syncNetworkChannel h p "\n" decode encode ch ||-
+ deviceSelectorSerial >>= \(s,set)->syncSerialChannel s set decode encode ch ||-
sendMsg msgs ch ||-
(
(