aboutsummaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorNick Foster <nick@nerdnetworks.org>2011-01-17 14:51:06 -0800
committerNick Foster <nick@nerdnetworks.org>2011-01-17 14:51:06 -0800
commitcaa911aa270ee4aef7244f3159b9fd402a454069 (patch)
tree57e85e00e9727aade1a4dafaa6da98eb5e2b4b6c /firmware
parentd521bd1c28acf0ca159f8c84a8189bef11fdf65d (diff)
downloaduhd-caa911aa270ee4aef7244f3159b9fd402a454069.tar.gz
uhd-caa911aa270ee4aef7244f3159b9fd402a454069.tar.bz2
uhd-caa911aa270ee4aef7244f3159b9fd402a454069.zip
next: fngets() fixed for GPS driver. polling/timeout moved to host side. small changes to GPS output text.
Diffstat (limited to 'firmware')
-rw-r--r--firmware/zpu/apps/txrx_uhd.c2
-rw-r--r--firmware/zpu/lib/hal_io.c4
-rw-r--r--firmware/zpu/lib/hal_io.h2
-rw-r--r--firmware/zpu/lib/hal_uart.c11
-rw-r--r--firmware/zpu/lib/hal_uart.h6
5 files changed, 12 insertions, 13 deletions
diff --git a/firmware/zpu/apps/txrx_uhd.c b/firmware/zpu/apps/txrx_uhd.c
index 61a2c1f76..4ccb585e2 100644
--- a/firmware/zpu/apps/txrx_uhd.c
+++ b/firmware/zpu/apps/txrx_uhd.c
@@ -230,7 +230,7 @@ static void handle_udp_ctrl_packet(
//executes a readline()-style read, up to num_bytes long, up to and including newline
int num_bytes = ctrl_data_in->data.uart_args.bytes;
if(num_bytes > 20) num_bytes = 20;
- num_bytes = fngets_timeout(ctrl_data_in->data.uart_args.dev, (char *) ctrl_data_out.data.uart_args.data, num_bytes);
+ num_bytes = fngets_noblock(ctrl_data_in->data.uart_args.dev, (char *) ctrl_data_out.data.uart_args.data, num_bytes);
ctrl_data_out.id = USRP2_CTRL_ID_I_HELLA_READ_THAT_UART_DUDE;
ctrl_data_out.data.uart_args.bytes = num_bytes;
break;
diff --git a/firmware/zpu/lib/hal_io.c b/firmware/zpu/lib/hal_io.c
index be4c570c7..1d137943c 100644
--- a/firmware/zpu/lib/hal_io.c
+++ b/firmware/zpu/lib/hal_io.c
@@ -253,11 +253,11 @@ fngets(hal_uart_name_t u, char * const s, int len)
}
int
-fngets_timeout(hal_uart_name_t u, char * const s, int len)
+fngets_noblock(hal_uart_name_t u, char * const s, int len)
{
char *x = s;
- while(((*x=(char)hal_uart_getc_timeout(u)) != '\n') && (*x != -1) && ((x-s) < len)) x++;
+ while(((*x=(char)hal_uart_getc_noblock(u)) != '\n') && (*x != 255) && ((x-s) < len)) x++;
*x = 0;
//printf("Returning from fngets() with string %d of length %d\n", s[0], x-s);
return (x-s);
diff --git a/firmware/zpu/lib/hal_io.h b/firmware/zpu/lib/hal_io.h
index 574df7d3e..7a617685c 100644
--- a/firmware/zpu/lib/hal_io.h
+++ b/firmware/zpu/lib/hal_io.h
@@ -28,7 +28,7 @@ char *gets(char * const s);
int fputstr(hal_uart_name_t u, const char *s);
int fnputstr(hal_uart_name_t u, const char *s, int len);
int fngets(hal_uart_name_t u, char * const s, int len);
-int fngets_timeout(hal_uart_name_t u, char * const s, int len);
+int fngets_noblock(hal_uart_name_t u, char * const s, int len);
/*
* ------------------------------------------------------------------------
diff --git a/firmware/zpu/lib/hal_uart.c b/firmware/zpu/lib/hal_uart.c
index f0921f4f0..6a37cceb6 100644
--- a/firmware/zpu/lib/hal_uart.c
+++ b/firmware/zpu/lib/hal_uart.c
@@ -103,12 +103,13 @@ hal_uart_getc(hal_uart_name_t u)
}
int
-hal_uart_getc_timeout(hal_uart_name_t u)
+hal_uart_getc_noblock(hal_uart_name_t u)
{
- int timeout = 0;
- while (((uart_regs[u].rxlevel) == 0) && (timeout++ < HAL_UART_TIMEOUT_MS))
- mdelay(1);
- return (timeout >= HAL_UART_TIMEOUT_MS) ? -1 : uart_regs[u].rxchar; //return -1 if nothing there, cause fngets to quit
+// int timeout = 0;
+// while (((uart_regs[u].rxlevel) == 0) && (timeout++ < HAL_UART_TIMEOUT_MS))
+// mdelay(1);
+ if(uart_regs[u].rxlevel == 0) return 255;
+ return uart_regs[u].rxchar;
}
int hal_uart_rx_flush(hal_uart_name_t u)
diff --git a/firmware/zpu/lib/hal_uart.h b/firmware/zpu/lib/hal_uart.h
index 758c8cb5e..793aface0 100644
--- a/firmware/zpu/lib/hal_uart.h
+++ b/firmware/zpu/lib/hal_uart.h
@@ -27,8 +27,6 @@
#define DEFAULT_UART UART_DEBUG //which UART printf, gets, etc. use
-#define HAL_UART_TIMEOUT_MS 300
-
typedef enum {
US_9600 = 0,
US_19200 = 1,
@@ -85,9 +83,9 @@ void hal_uart_putc_nowait(hal_uart_name_t u, int ch);
int hal_uart_getc(hal_uart_name_t u);
/*
- * \brief Blocking read of next char from serial port with timeout
+ * \brief Non-blocking read of next char from serial port, return -1 if nothing available
*/
-int hal_uart_getc_timeout(hal_uart_name_t u);
+int hal_uart_getc_noblock(hal_uart_name_t u);
int hal_uart_rx_flush(hal_uart_name_t u);