Permalink
Browse files

Add SUMP mode autodetection (#72)

This patch adds the possibility to automatically switch to SUMP mode
when Hydrabus is polled by a SUMP client (tested with OLS client and
Sigrok).
  • Loading branch information...
Baldanos authored and bvernoux committed Mar 3, 2017
1 parent e08a6b0 commit ca90ec2a30b7e80f157d30756444a9b279ad2f90
Showing with 29 additions and 9 deletions.
  1. +13 −6 hydrabus/hydrabus_sump.c
  2. +1 −0 hydrabus/hydrabus_sump.h
  3. +15 −3 main.c
View
@@ -153,8 +153,19 @@ static void sump_deinit(void)
}
}
int cmd_sump(t_hydra_console *con, __attribute__((unused)) t_tokenline_parsed *p) __attribute__((optimize("-O3")));
int cmd_sump(t_hydra_console *con, __attribute__((unused)) t_tokenline_parsed *p)
int cmd_sump(t_hydra_console *con, t_tokenline_parsed *p)
{
(void) p;
cprintf(con, "Interrupt by pressing user button.\r\n");
cprint(con, "\r\n", 2);
sump(con);
return TRUE;
}
void sump(t_hydra_console *con) __attribute__((optimize("-O3")));
void sump(t_hydra_console *con)
{
sump_init();
@@ -164,9 +175,6 @@ int cmd_sump(t_hydra_console *con, __attribute__((unused)) t_tokenline_parsed *p
uint8_t sump_parameters[4] = {0};
uint32_t index=0;
cprintf(con, "Interrupt by pressing user button.\r\n");
cprint(con, "\r\n", 2);
while (!palReadPad(GPIOA, 0)) {
if(chnReadTimeout(con->sdu, &sump_command, 1, 1)) {
switch(sump_command) {
@@ -296,6 +304,5 @@ int cmd_sump(t_hydra_console *con, __attribute__((unused)) t_tokenline_parsed *p
}
}
sump_deinit();
return TRUE;
}
View
@@ -48,3 +48,4 @@ typedef struct {
uint8_t state;
uint8_t channels;
} sump_config;
void sump(t_hydra_console *con);
View
18 main.c
@@ -35,6 +35,7 @@
#include "hydrabus.h"
#include "hydranfc.h"
#include "hydrabus/hydrabus_bbio.h"
#include "hydrabus/hydrabus_sump.h"
#include "bsp.h"
@@ -73,7 +74,7 @@ THD_FUNCTION(console, arg)
con = arg;
chRegSetThreadName(con->thread_name);
tl_init(con->tl, tl_tokens, tl_dict, print, con);
tl_set_prompt(con->tl, PROMPT);
con->tl->prompt = PROMPT;
tl_set_callback(con->tl, execute);
if(is_file_present(INIT_SCRIPT_NAME)) {
@@ -82,11 +83,22 @@ THD_FUNCTION(console, arg)
while (1) {
input = get_char(con);
if(input == 0) {
switch(input) {
case 0:
if (++i == 20) {
cmd_bbio(con);
return;
}
} else {
break;
/* SUMP identification is 5*\x00 \x02 */
/* Allows to enter SUMP mode autmomatically */
case 2:
if(i == 5) {
cprintf(con, "1ALS");
sump(con);
}
break;
default:
i=0;
tl_input(con->tl, input);
}

0 comments on commit ca90ec2

Please sign in to comment.