summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/b100/ctrl_packet.hpp
blob: bab1f0de12ad5ba247171eeaad28d9763e80cb18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// Copyright 2011 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 INCLUDED_CTRL_PACKET_HPP
#define INCLUDED_CTRL_PACKET_HPP

#include <uhd/config.hpp>
#include <boost/cstdint.hpp>
#include <uhd/types/serial.hpp>

typedef std::vector<boost::uint16_t> ctrl_data_t;

/*!
 * Control packet operation type
 */
enum ctrl_pkt_op_t { 
    CTRL_PKT_OP_WRITE = 1,
    CTRL_PKT_OP_READ = 2,
    CTRL_PKT_OP_READBACK = 3
};

/*!
 * Control packet transaction length
 */
const size_t CTRL_PACKET_LENGTH = 32;
const size_t CTRL_PACKET_HEADER_LENGTH = 8;
const size_t CTRL_PACKET_DATA_LENGTH = 24; //=length-header

/*!
 * Control packet header magic value
 */
const boost::uint8_t CTRL_PACKET_HEADER_MAGIC = 0xAA;

/*! 
 * Callback triggers for readback operation
 */
//FIXME: these are not real numbers, callbacks aren't implemented yet
const boost::uint16_t CTRL_PACKET_CALLBACK_SPI = 0x0001;
const boost::uint16_t CTRL_PACKET_CALLBACK_I2C = 0x0002;
//and so on

/*!
 * Metadata structure to describe a control packet
 */
struct UHD_API ctrl_pkt_meta_t {
    ctrl_pkt_op_t op;
    boost::uint8_t callbacks;
    boost::uint8_t seq;
    boost::uint16_t len;
    boost::uint32_t addr;
};

/*! 
 * Full control packet structure
 */
struct UHD_API ctrl_pkt_t {
    ctrl_pkt_meta_t pkt_meta;
    ctrl_data_t data;
};

#endif /* INCLUDED_CTRL_PACKET_HPP */