X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=examples%2Ftriface%2Fprotocol.c;h=254880e5657287ffb19dd9fde352940559a6f7a1;hb=165ee3ab958eaab69c819853d527408e96a92ace;hp=3e4197e0c4fbde8c68eaf52b3b1713b94068f525;hpb=3013f4949f0ea1816a3865d47be9216adb75d74a;p=bertos.git diff --git a/examples/triface/protocol.c b/examples/triface/protocol.c index 3e4197e0..254880e5 100644 --- a/examples/triface/protocol.c +++ b/examples/triface/protocol.c @@ -45,13 +45,14 @@ #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 #include #include -#include +#include #include #include @@ -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,9 +303,7 @@ MAKE_CMD(reset, "", "", ({ //Silence "args not used" warning. (void)args; - wdt_init(); - wdt_setTimeout(7); - wdt_enable(true); + 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 @@ -358,6 +359,14 @@ static void protocol_registerCmds(void) /* Initialization: readline context, parser and register commands. */ void protocol_init(KFile *fd) { + /* SPI Port Initialization */ + fd_sipo.load_device = TRIFACE_DOUT; + fd_sipo.bit_order = SIPO_DATAORDER_LSB; + fd_sipo.clock_pol = SIPO_START_LOW; + fd_sipo.load_pol = SIPO_LOW_TO_HIGH; + + sipo_init(&fd_sipo); + interactive = FORCE_INTERACTIVE; rl_init_ctx(&rl_ctx);