From 22ed61f97815856bf74cec25ae6bca88bfbe5f44 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 22 Dec 2010 19:19:14 -0800 Subject: zpu: renamed the directory for the usrp2 fw to zpu to reflect the cpu type --- firmware/zpu/lib/hal_io.h | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 firmware/zpu/lib/hal_io.h (limited to 'firmware/zpu/lib/hal_io.h') diff --git a/firmware/zpu/lib/hal_io.h b/firmware/zpu/lib/hal_io.h new file mode 100644 index 000000000..574df7d3e --- /dev/null +++ b/firmware/zpu/lib/hal_io.h @@ -0,0 +1,96 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef INCLUDED_HAL_IO_H +#define INCLUDED_HAL_IO_H + +#include "memory_map.h" +#include "hal_uart.h" + +void hal_io_init(void); +void hal_finish(); +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); + +/* + * ------------------------------------------------------------------------ + * control the leds + * + * Low 4-bits are the general purpose leds on the board + * The next bit is the led on the ethernet connector + * ------------------------------------------------------------------------ + */ + +void hal_set_leds(int value, int mask); +void hal_set_led_src(int value, int mask); +void hal_toggle_leds(int mask); + +/* + * ------------------------------------------------------------------------ + * simple timeouts + * ------------------------------------------------------------------------ + */ + + + +static inline void +hal_set_timeout(int delta_ticks) +{ + sr_simple_timer->onetime = delta_ticks; +} + +/* + * ------------------------------------------------------------------------ + * interrupt enable/disable + * ------------------------------------------------------------------------ + */ + +/*! + * \brief Disable interrupts and return previous interrupt enable state. + * [Microblaze specific] + */ +static inline int +hal_disable_ints(void) +{ + return 0; /* NOP */ +} + +/*! + * \brief Enable interrupts and return previous interrupt enable state. + * [Microblaze specific] + */ +static inline int +hal_enable_ints(void) +{ + return 0; /* NOP */ +} + +/*! + * \brief Set interrupt enable state to \p prev_state. + * [Microblaze specific] + */ +static inline void +hal_restore_ints(int prev_state) +{ + /* NOP */ +} + +#endif /* INCLUDED_HAL_IO_H */ -- cgit v1.2.3 From caa911aa270ee4aef7244f3159b9fd402a454069 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 17 Jan 2011 14:51:06 -0800 Subject: next: fngets() fixed for GPS driver. polling/timeout moved to host side. small changes to GPS output text. --- firmware/zpu/apps/txrx_uhd.c | 2 +- firmware/zpu/lib/hal_io.c | 4 ++-- firmware/zpu/lib/hal_io.h | 2 +- firmware/zpu/lib/hal_uart.c | 11 ++++++----- firmware/zpu/lib/hal_uart.h | 6 ++---- host/lib/usrp/usrp2/gps_ctrl.cpp | 3 ++- host/lib/usrp/usrp2/mboard_impl.cpp | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) (limited to 'firmware/zpu/lib/hal_io.h') 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); diff --git a/host/lib/usrp/usrp2/gps_ctrl.cpp b/host/lib/usrp/usrp2/gps_ctrl.cpp index 2273b2cd9..9f9b27954 100644 --- a/host/lib/usrp/usrp2/gps_ctrl.cpp +++ b/host/lib/usrp/usrp2/gps_ctrl.cpp @@ -60,13 +60,14 @@ public: } else if(reply.substr(0, 3) == "$GP") i_heard_some_nmea = true; //but keep looking for that "Command Error" response else if(reply.length() != 0) i_heard_something_weird = true; //probably wrong baud rate + boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); } if((i_heard_some_nmea) && (gps_type != GPS_TYPE_JACKSON_LABS)) gps_type = GPS_TYPE_GENERIC_NMEA; //otherwise, we can try some other common baud rates looking to see if a GPS is connected (todo, later) if((gps_type == GPS_TYPE_NONE) && i_heard_something_weird) { - std::cout << "Invalid reply, possible incorrect baud rate" << std::endl; + std::cout << "GPS invalid reply \"" << reply << "\", assuming none available" << std::endl; } bool found_gprmc = false; diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 6d5652e9e..95a3819b3 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -65,7 +65,7 @@ usrp2_mboard_impl::usrp2_mboard_impl( //contruct the interfaces to mboard perifs _clock_ctrl = usrp2_clock_ctrl::make(_iface); _codec_ctrl = usrp2_codec_ctrl::make(_iface); - //_gps_ctrl = usrp2_gps_ctrl::make(_iface); + _gps_ctrl = usrp2_gps_ctrl::make(_iface); //if(_gps_ctrl->gps_detected()) std::cout << "GPS time: " << _gps_ctrl->get_time() << std::endl; -- cgit v1.2.3