root / host / lib / usrp / usrp2 / fw_common.h @ 5f651c29
History | View | Annotate | Download (4.47 KB)
| 1 |
//
|
|---|---|
| 2 |
// Copyright 2010 Ettus Research LLC
|
| 3 |
//
|
| 4 |
// This program is free software: you can redistribute it and/or modify
|
| 5 |
// it under the terms of the GNU General Public License as published by
|
| 6 |
// the Free Software Foundation, either version 3 of the License, or
|
| 7 |
// (at your option) any later version.
|
| 8 |
//
|
| 9 |
// This program is distributed in the hope that it will be useful,
|
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
// GNU General Public License for more details.
|
| 13 |
//
|
| 14 |
// You should have received a copy of the GNU General Public License
|
| 15 |
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 16 |
//
|
| 17 |
|
| 18 |
#ifndef INCLUDED_USRP2_FW_COMMON_H
|
| 19 |
#define INCLUDED_USRP2_FW_COMMON_H
|
| 20 |
|
| 21 |
/*!
|
| 22 |
* Structs and constants for usrp2 communication.
|
| 23 |
* This header is shared by the firmware and host code.
|
| 24 |
* Therefore, this header may only contain valid C code.
|
| 25 |
*/
|
| 26 |
#ifdef __cplusplus
|
| 27 |
#include <boost/cstdint.hpp> |
| 28 |
#define __stdint(type) boost::type
|
| 29 |
extern "C" { |
| 30 |
#else
|
| 31 |
#include <stdint.h> |
| 32 |
#define __stdint(type) type
|
| 33 |
#endif
|
| 34 |
|
| 35 |
//fpga and firmware compatibility numbers
|
| 36 |
#define USRP2_FPGA_COMPAT_NUM 4 |
| 37 |
#define USRP2_FW_COMPAT_NUM 8 |
| 38 |
|
| 39 |
//used to differentiate control packets over data port
|
| 40 |
#define USRP2_INVALID_VRT_HEADER 0 |
| 41 |
|
| 42 |
// udp ports for the usrp2 communication
|
| 43 |
// Dynamic and/or private ports: 49152-65535
|
| 44 |
#define USRP2_UDP_CTRL_PORT 49152 |
| 45 |
#define USRP2_UDP_DATA_PORT 49153 |
| 46 |
|
| 47 |
////////////////////////////////////////////////////////////////////////
|
| 48 |
// I2C addresses
|
| 49 |
////////////////////////////////////////////////////////////////////////
|
| 50 |
#define USRP2_I2C_DEV_EEPROM 0x50 // 24LC02[45]: 7-bits 1010xxx |
| 51 |
#define USRP2_I2C_ADDR_MBOARD (USRP2_I2C_DEV_EEPROM | 0x0) |
| 52 |
#define USRP2_I2C_ADDR_TX_DB (USRP2_I2C_DEV_EEPROM | 0x4) |
| 53 |
#define USRP2_I2C_ADDR_RX_DB (USRP2_I2C_DEV_EEPROM | 0x5) |
| 54 |
|
| 55 |
////////////////////////////////////////////////////////////////////////
|
| 56 |
// EEPROM Layout
|
| 57 |
////////////////////////////////////////////////////////////////////////
|
| 58 |
#define USRP2_EE_MBOARD_REV 0x00 //2 bytes, little-endian (historic, don't blame me) |
| 59 |
#define USRP2_EE_MBOARD_MAC_ADDR 0x02 //6 bytes |
| 60 |
#define USRP2_EE_MBOARD_IP_ADDR 0x0C //uint32, big-endian |
| 61 |
#define USRP2_EE_MBOARD_BOOTLOADER_FLAGS 0xF7 |
| 62 |
|
| 63 |
typedef enum{ |
| 64 |
USRP2_CTRL_ID_HUH_WHAT = ' ',
|
| 65 |
//USRP2_CTRL_ID_FOR_SURE, //TODO error condition enums
|
| 66 |
//USRP2_CTRL_ID_SUX_MAN,
|
| 67 |
|
| 68 |
USRP2_CTRL_ID_WAZZUP_BRO = 'a',
|
| 69 |
USRP2_CTRL_ID_WAZZUP_DUDE = 'A',
|
| 70 |
|
| 71 |
USRP2_CTRL_ID_TRANSACT_ME_SOME_SPI_BRO = 's',
|
| 72 |
USRP2_CTRL_ID_OMG_TRANSACTED_SPI_DUDE = 'S',
|
| 73 |
|
| 74 |
USRP2_CTRL_ID_DO_AN_I2C_READ_FOR_ME_BRO = 'i',
|
| 75 |
USRP2_CTRL_ID_HERES_THE_I2C_DATA_DUDE = 'I',
|
| 76 |
|
| 77 |
USRP2_CTRL_ID_WRITE_THESE_I2C_VALUES_BRO = 'h',
|
| 78 |
USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE = 'H',
|
| 79 |
|
| 80 |
USRP2_CTRL_ID_POKE_THIS_REGISTER_FOR_ME_BRO = 'p',
|
| 81 |
USRP2_CTRL_ID_OMG_POKED_REGISTER_SO_BAD_DUDE = 'P',
|
| 82 |
|
| 83 |
USRP2_CTRL_ID_PEEK_AT_THIS_REGISTER_FOR_ME_BRO = 'r',
|
| 84 |
USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE = 'R',
|
| 85 |
|
| 86 |
USRP2_CTRL_ID_HEY_WRITE_THIS_UART_FOR_ME_BRO = 'u',
|
| 87 |
USRP2_CTRL_ID_MAN_I_TOTALLY_WROTE_THAT_UART_DUDE = 'U',
|
| 88 |
|
| 89 |
USRP2_CTRL_ID_SO_LIKE_CAN_YOU_READ_THIS_UART_BRO = 'v',
|
| 90 |
USRP2_CTRL_ID_I_HELLA_READ_THAT_UART_DUDE = 'V',
|
| 91 |
|
| 92 |
USRP2_CTRL_ID_PEACE_OUT = '~'
|
| 93 |
|
| 94 |
} usrp2_ctrl_id_t; |
| 95 |
|
| 96 |
typedef enum{ |
| 97 |
USRP2_DIR_RX = 'r',
|
| 98 |
USRP2_DIR_TX = 't'
|
| 99 |
} usrp2_dir_which_t; |
| 100 |
|
| 101 |
typedef enum{ |
| 102 |
USRP2_CLK_EDGE_RISE = 'r',
|
| 103 |
USRP2_CLK_EDGE_FALL = 'f'
|
| 104 |
} usrp2_clk_edge_t; |
| 105 |
|
| 106 |
typedef struct{ |
| 107 |
__stdint(uint32_t) proto_ver; |
| 108 |
__stdint(uint32_t) id; |
| 109 |
__stdint(uint32_t) seq; |
| 110 |
union{
|
| 111 |
__stdint(uint32_t) ip_addr; |
| 112 |
struct {
|
| 113 |
__stdint(uint32_t) dev; |
| 114 |
__stdint(uint32_t) data; |
| 115 |
__stdint(uint8_t) miso_edge; |
| 116 |
__stdint(uint8_t) mosi_edge; |
| 117 |
__stdint(uint8_t) num_bits; |
| 118 |
__stdint(uint8_t) readback; |
| 119 |
} spi_args; |
| 120 |
struct {
|
| 121 |
__stdint(uint8_t) addr; |
| 122 |
__stdint(uint8_t) bytes; |
| 123 |
__stdint(uint8_t) data[20];
|
| 124 |
} i2c_args; |
| 125 |
struct {
|
| 126 |
__stdint(uint32_t) addr; |
| 127 |
__stdint(uint32_t) data; |
| 128 |
__stdint(uint32_t) addrhi; |
| 129 |
__stdint(uint32_t) datahi; |
| 130 |
__stdint(uint8_t) num_bytes; //1, 2, 4, 8
|
| 131 |
} poke_args; |
| 132 |
struct {
|
| 133 |
__stdint(uint8_t) dev; |
| 134 |
__stdint(uint8_t) bytes; |
| 135 |
__stdint(uint8_t) data[20];
|
| 136 |
} uart_args; |
| 137 |
} data; |
| 138 |
} usrp2_ctrl_data_t; |
| 139 |
|
| 140 |
#undef __stdint
|
| 141 |
#ifdef __cplusplus
|
| 142 |
} |
| 143 |
#endif
|
| 144 |
|
| 145 |
#endif /* INCLUDED_USRP2_FW_COMMON_H */ |