aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp_clock/octoclock/common.h
diff options
context:
space:
mode:
authorNicholas Corgan <nick.corgan@ettus.com>2014-07-17 11:50:50 -0700
committerNicholas Corgan <nick.corgan@ettus.com>2014-07-23 07:37:32 -0700
commita6e18604befdb6a954542f7722c8d55424065621 (patch)
tree22168e6f4c41c931e38ccd07ff8881b56c8cd88a /host/lib/usrp_clock/octoclock/common.h
parent7423d1691fff3af08f8e42e3e09d8c8d9ec99fe8 (diff)
downloaduhd-a6e18604befdb6a954542f7722c8d55424065621.tar.gz
uhd-a6e18604befdb6a954542f7722c8d55424065621.tar.bz2
uhd-a6e18604befdb6a954542f7722c8d55424065621.zip
OctoClock firmware upgrade, added host driver
* OctoClock can communicate with UHD over Ethernet * Can read NMEA strings from GPSDO and send to host * Added multi_usrp_clock class for clock devices * uhd::device can now filter to return only USRP devices or clock devices * New OctoClock bootloader can accept firmware download over Ethernet * Added octoclock_burn_eeprom,octoclock_firmware_burner utilities * Added test_clock_synch example to show clock API
Diffstat (limited to 'host/lib/usrp_clock/octoclock/common.h')
-rw-r--r--host/lib/usrp_clock/octoclock/common.h149
1 files changed, 149 insertions, 0 deletions
diff --git a/host/lib/usrp_clock/octoclock/common.h b/host/lib/usrp_clock/octoclock/common.h
new file mode 100644
index 000000000..96acbb30f
--- /dev/null
+++ b/host/lib/usrp_clock/octoclock/common.h
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2014 Ettus Research LLC
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _OCTOCLOCK_COMMON_H_
+#define _OCTOCLOCK_COMMON_H_
+
+#include <stdint.h>
+
+/*
+ * C++ macros used for code cleanliness and extern "C" declaration.
+ */
+#ifdef __cplusplus
+
+#define UHD_OCTOCLOCK_SEND_AND_RECV(xport, pkt_code, pkt_out, len, data) pkt_out.proto_ver = OCTOCLOCK_FW_COMPAT_NUM; \
+ pkt_out.code = pkt_code; \
+ xport->send(boost::asio::buffer(&pkt_out, sizeof(octoclock_packet_t))); \
+ len = xport->recv(boost::asio::buffer(data), 2);
+
+#define UHD_OCTOCLOCK_PACKET_MATCHES(pkt_code, pkt_out, pkt_in, len) (len > offsetof(octoclock_packet_t, data) and \
+ pkt_in->sequence == pkt_out.sequence and \
+ pkt_in->code == pkt_code)
+
+extern "C" {
+#endif
+
+/*
+ * This code is used by both the C firmware and C++ host driver, so
+ * only valid C code should go in this section.
+ */
+
+//These values are placed in the octoclock_packet_t.proto_ver field
+#define OCTOCLOCK_BOOTLOADER_PROTO_VER 1234
+#define OCTOCLOCK_FW_COMPAT_NUM 2
+
+//UDP ports assigned for different tasks
+#define OCTOCLOCK_UDP_CTRL_PORT 50000
+#define OCTOCLOCK_UDP_GPSDO_PORT 50001
+#define OCTOCLOCK_UDP_FW_PORT 50002
+#define OCTOCLOCK_UDP_EEPROM_PORT 50003
+
+typedef enum {
+ NO_CODE,
+
+ OCTOCLOCK_QUERY_CMD,
+ OCTOCLOCK_QUERY_ACK,
+
+ SEND_EEPROM_CMD,
+ SEND_EEPROM_ACK,
+ BURN_EEPROM_CMD,
+ BURN_EEPROM_SUCCESS_ACK,
+ BURN_EEPROM_FAILURE_ACK,
+ CLEAR_EEPROM_CMD,
+ CLEAR_EEPROM_ACK,
+
+ SEND_STATE_CMD,
+ SEND_STATE_ACK,
+
+ RESET_CMD,
+ RESET_ACK,
+
+ HOST_SEND_TO_GPSDO_CMD,
+ HOST_SEND_TO_GPSDO_ACK,
+ SEND_POOLSIZE_CMD,
+ SEND_POOLSIZE_ACK,
+ SEND_CACHE_STATE_CMD,
+ SEND_CACHE_STATE_ACK,
+ SEND_GPSDO_CACHE_CMD,
+ SEND_GPSDO_CACHE_ACK,
+
+ PREPARE_FW_BURN_CMD,
+ FW_BURN_READY_ACK,
+ FILE_TRANSFER_CMD,
+ FILE_TRANSFER_ACK,
+ READ_FW_CMD,
+ READ_FW_ACK,
+ FINALIZE_BURNING_CMD,
+ FINALIZE_BURNING_ACK,
+} packet_code_t;
+
+typedef enum {
+ NO_REF,
+ INTERNAL,
+ EXTERNAL
+} ref_t;
+
+typedef enum {
+ UP,
+ DOWN
+} switch_pos_t;
+
+#pragma pack(push,1)
+
+// Structure of values in EEPROM, starting in location 0
+typedef struct {
+ uint8_t mac_addr[6];
+ uint32_t ip_addr;
+ uint32_t dr_addr;
+ uint32_t netmask;
+ uint8_t serial[10];
+ uint8_t name[10];
+ uint8_t revision;
+} octoclock_fw_eeprom_t;
+
+typedef struct {
+ uint8_t external_detected;
+ uint8_t gps_detected;
+ uint8_t which_ref;
+ uint8_t switch_pos;
+} octoclock_state_t;
+
+typedef struct {
+ uint8_t num_wraps;
+ uint8_t pos;
+} gpsdo_cache_state_t;
+
+typedef struct {
+ uint32_t proto_ver;
+ uint32_t sequence;
+ uint8_t code;
+ union {
+ uint16_t len;
+ gpsdo_cache_state_t state;
+ uint16_t poolsize;
+ uint16_t addr;
+ };
+ uint8_t data[256];
+} octoclock_packet_t;
+
+#pragma pack(pop)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OCTOCLOCK_COMMON_H_ */