Permalink
Browse files

Bridge enhancement (#50)

  • Loading branch information...
Baldanos authored and bvernoux committed Apr 26, 2016
1 parent b9fe7ad commit 81f925c54b42fe450e49802184bde9c365248dd1
Showing with 16 additions and 10 deletions.
  1. +16 −10 hydrabus/hydrabus_mode_uart.c
@@ -86,33 +86,39 @@ msg_t bridge_thread (void *arg)
{
t_hydra_console *con;
con = arg;
chRegSetThreadName("UART bridge");
chRegSetThreadName("UART reader");
chThdSleepMilliseconds(10);
uint8_t rx_data;
uint8_t tx_data;
mode_config_proto_t* proto = &con->mode->proto;
while (!USER_BUTTON) {
if(bsp_uart_rxne(proto->dev_num)) {
bsp_uart_read_u8(proto->dev_num, &rx_data ,1);
chSequentialStreamWrite(con->sdu, &rx_data, 1);
}
if(chnReadTimeout(con->sdu, &tx_data, 1, 1)) {
bsp_uart_write_u8(proto->dev_num, &tx_data, 1);
//chSequentialStreamWrite(con->sdu, &tx_data, 1);
bsp_uart_read_u8(proto->dev_num, &rx_data , 1);
cprint(con, (char *)&rx_data, 1);
} else {
chThdYield();
}
}
return (msg_t)1;
}
static void bridge(t_hydra_console *con)
{
uint8_t tx_data;
mode_config_proto_t* proto = &con->mode->proto;
cprintf(con, "Interrupt by pressing user button.\r\n");
cprint(con, "\r\n", 2);
thread_t *bthread = chThdCreateFromHeap(NULL, CONSOLE_WA_SIZE, NORMALPRIO, bridge_thread, con);
thread_t *bthread = chThdCreateFromHeap(NULL, CONSOLE_WA_SIZE,
LOWPRIO, bridge_thread, con);
while(!USER_BUTTON) {
if(chSequentialStreamRead(con->sdu, &tx_data, 1) == 1) {
bsp_uart_write_u8(proto->dev_num, &tx_data, 1);
}
}
chThdTerminate(bthread);
chThdWait(bthread);
}
static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)

0 comments on commit 81f925c

Please sign in to comment.