summaryrefslogtreecommitdiffstats
path: root/firmware/microblaze
diff options
context:
space:
mode:
authorNick Foster <nick@nerdnetworks.org>2010-08-16 16:09:52 -0700
committerNick Foster <nick@nerdnetworks.org>2010-08-16 16:11:45 -0700
commit40faee2e6d87f7364a0c0c2cf310f1483c0331cf (patch)
tree990d061eb15272ed995dcfd8982082840473399b /firmware/microblaze
parentf626a4f21d7301e573bcb601f16bf6ba38352c34 (diff)
downloaduhd-40faee2e6d87f7364a0c0c2cf310f1483c0331cf.tar.gz
uhd-40faee2e6d87f7364a0c0c2cf310f1483c0331cf.tar.bz2
uhd-40faee2e6d87f7364a0c0c2cf310f1483c0331cf.zip
Finished GPS driver, more or less.
Should detect any 115kbaud GPS on the serial port, as long as it outputs GPRMC packets. Tweaked the serial driver for a stupid off-by-one mistake.
Diffstat (limited to 'firmware/microblaze')
-rw-r--r--firmware/microblaze/lib/hal_io.c17
-rw-r--r--firmware/microblaze/lib/hal_uart.c2
2 files changed, 10 insertions, 9 deletions
diff --git a/firmware/microblaze/lib/hal_io.c b/firmware/microblaze/lib/hal_io.c
index 261c8cc2a..be4c570c7 100644
--- a/firmware/microblaze/lib/hal_io.c
+++ b/firmware/microblaze/lib/hal_io.c
@@ -237,10 +237,10 @@ int puts(const char *s)
char *
fgets(hal_uart_name_t u, char * const s)
{
- char *x = s;
- while((*x=(char)hal_uart_getc(u)) != '\n') x++;
- *x = 0;
- return s;
+ char *x = s;
+ while((*x=(char)hal_uart_getc(u)) != '\n') x++;
+ *x = 0;
+ return s;
}
int
@@ -248,8 +248,8 @@ fngets(hal_uart_name_t u, char * const s, int len)
{
char *x = s;
while(((*x=(char)hal_uart_getc(u)) != '\n') && ((x-s) < len)) x++;
- *x = 0;
- return (x-s);
+ *x = 0;
+ return (x-s);
}
int
@@ -258,8 +258,9 @@ fngets_timeout(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++;
- *x = 0;
- return (x-s);
+ *x = 0;
+ //printf("Returning from fngets() with string %d of length %d\n", s[0], x-s);
+ return (x-s);
}
char *
diff --git a/firmware/microblaze/lib/hal_uart.c b/firmware/microblaze/lib/hal_uart.c
index 0ac6abd69..7836240fe 100644
--- a/firmware/microblaze/lib/hal_uart.c
+++ b/firmware/microblaze/lib/hal_uart.c
@@ -108,7 +108,7 @@ hal_uart_getc_timeout(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
+ return (timeout >= HAL_UART_TIMEOUT_MS) ? -1 : uart_regs[u].rxchar; //return -1 if nothing there, cause fngets to quit
}
int hal_uart_rx_flush(hal_uart_name_t u)