X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=examples%2Ftriface%2Fprotocol.c;h=eec73684520a0a61c55ca2932535959cfaf1cfbf;hb=8f2036c05d9a8531400c1ab97dca9193e92187d3;hp=fa4c0bad9741bf18a8eed63e01a9a159773b45b1;hpb=24c21c92d29b76a3f0de0a107f4bafef7bb0f812;p=bertos.git diff --git a/examples/triface/protocol.c b/examples/triface/protocol.c index fa4c0bad..eec73684 100644 --- a/examples/triface/protocol.c +++ b/examples/triface/protocol.c @@ -34,8 +34,6 @@ * \brief Implementation of the command protocol between the board and the host * * - * \version $Id$ - * * \author Giovanni Bajo * \author Marco Benelli * \author Bernie Innocenti @@ -45,13 +43,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 +82,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 +281,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 +301,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 +357,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);