Some fix and paste. Use putchar instead a write in protocol module.
[bertos.git] / examples / triface / protocol.c
index fa4c0bad9741bf18a8eed63e01a9a159773b45b1..397e8d0b2575460d9213751e24974e1df4cdcb25 100644 (file)
 #include "protocol.h"
 #include "cmd_ctor.h"  // MAKE_CMD, REGISTER_CMD
 #include "verstag.h"
+
 #include "hw/hw_adc.h"
 #include "hw/hw_input.h"
 
 #include <drv/timer.h>
 #include <drv/ser.h>
 #include <drv/sipo.h>
-#include <drv/wdt.h>
+#include <avr/wdt.h>
 #include <drv/buzzer.h>
 
 #include <mware/readline.h>
@@ -83,6 +84,8 @@ static bool interactive;
 /// Readline context, used for interactive mode.
 static struct RLContext rl_ctx;
 
+static Sipo fd_sipo;
+
 uint8_t reg_status_dout;
 /**
  * Send a NAK asking the host to send the current message again.
@@ -280,7 +283,7 @@ MAKE_CMD(ping, "", "",
 /* Dout  */
 MAKE_CMD(dout, "d", "",
 ({
-       sipo_putchar((uint8_t)args[1].l);
+       kfile_putc((uint8_t)&args[1].l, &fd_sipo.fd);
 
        //Store status of dout ports.
        reg_status_dout = (uint8_t)args[1].l;
@@ -300,8 +303,7 @@ MAKE_CMD(reset, "", "",
 ({
        //Silence "args not used" warning.
        (void)args;
-       wdt_init(7);
-       wdt_start();
+       wdt_enable(WDTO_2S);
 
        /*We want to have an infinite loop that lock access on watchdog timer.
        This piece of code it's equivalent to a while(true), but we have done this because
@@ -357,6 +359,9 @@ static void protocol_registerCmds(void)
 /* Initialization: readline context, parser and register commands.  */
 void protocol_init(KFile *fd)
 {
+       /* SPI Port Initialization */
+       sipo_init(&fd_sipo);
+
        interactive = FORCE_INTERACTIVE;
 
        rl_init_ctx(&rl_ctx);