diff options
author | Ben Hilburn <ben.hilburn@ettus.com> | 2014-04-07 14:58:25 -0700 |
---|---|---|
committer | Ben Hilburn <ben.hilburn@ettus.com> | 2014-04-07 14:58:25 -0700 |
commit | 642f3fb5823f292ae29cc38c8897327dfbdc3c15 (patch) | |
tree | 3211fe57cbd3d7ee15069dc741f4a65a59b2bb00 /firmware/fx3/ad9361/include | |
parent | 937eae5f4831e16993a2f51e9c8e548fd74a3f13 (diff) | |
download | uhd-642f3fb5823f292ae29cc38c8897327dfbdc3c15.tar.gz uhd-642f3fb5823f292ae29cc38c8897327dfbdc3c15.tar.bz2 uhd-642f3fb5823f292ae29cc38c8897327dfbdc3c15.zip |
b2xx: Pulling FX3 and AD9361 source code into master.
Diffstat (limited to 'firmware/fx3/ad9361/include')
-rw-r--r-- | firmware/fx3/ad9361/include/ad9361_dispatch.h | 16 | ||||
-rw-r--r-- | firmware/fx3/ad9361/include/ad9361_transaction.h | 90 |
2 files changed, 106 insertions, 0 deletions
diff --git a/firmware/fx3/ad9361/include/ad9361_dispatch.h b/firmware/fx3/ad9361/include/ad9361_dispatch.h new file mode 100644 index 000000000..e89a4e0b0 --- /dev/null +++ b/firmware/fx3/ad9361/include/ad9361_dispatch.h @@ -0,0 +1,16 @@ +// +// Copyright 2013-2014 Ettus Research LLC +// + +#ifndef INCLUDED_AD9361_DISPATCH_H +#define INCLUDED_AD9361_DISPATCH_H + +#include <ad9361_transaction.h> + +extern void ad9361_dispatch(const char* request, char* response); + +typedef void (*msgfn)(const char*, ...); + +extern void ad9361_set_msgfn(msgfn pfn); + +#endif /* INCLUDED_AD9361_DISPATCH_H */ diff --git a/firmware/fx3/ad9361/include/ad9361_transaction.h b/firmware/fx3/ad9361/include/ad9361_transaction.h new file mode 100644 index 000000000..2349a5d3d --- /dev/null +++ b/firmware/fx3/ad9361/include/ad9361_transaction.h @@ -0,0 +1,90 @@ +// +// Copyright 2013-2014 Ettus Research LLC +// + +#ifndef INCLUDED_AD9361_TRANSACTION_H +#define INCLUDED_AD9361_TRANSACTION_H + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +//various constants +#define AD9361_TRANSACTION_VERSION 0x4 +#define AD9361_DISPATCH_PACKET_SIZE 64 + +//action types +#define AD9361_ACTION_ECHO 0 +#define AD9361_ACTION_INIT 1 +#define AD9361_ACTION_SET_RX1_GAIN 2 +#define AD9361_ACTION_SET_TX1_GAIN 3 +#define AD9361_ACTION_SET_RX2_GAIN 4 +#define AD9361_ACTION_SET_TX2_GAIN 5 +#define AD9361_ACTION_SET_RX_FREQ 6 +#define AD9361_ACTION_SET_TX_FREQ 7 +#define AD9361_ACTION_SET_CODEC_LOOP 8 +#define AD9361_ACTION_SET_CLOCK_RATE 9 +#define AD9361_ACTION_SET_ACTIVE_CHAINS 10 + +static inline void ad9361_double_pack(const double input, uint32_t output[2]) +{ + const uint32_t *p = (const uint32_t *)&input; + output[0] = p[0]; + output[1] = p[1]; +} + +static inline double ad9361_double_unpack(const uint32_t input[2]) +{ + double output = 0.0; + uint32_t *p = (uint32_t *)&output; + p[0] = input[0]; + p[1] = input[1]; + return output; +} + +typedef struct +{ + //version is expected to be AD9361_TRANSACTION_VERSION + //check otherwise for compatibility + uint32_t version; + + //sequence number - increment every call for sanity + uint32_t sequence; + + //action tells us what to do, see AD9361_ACTION_* + uint32_t action; + + union + { + //enable mask for chains + uint32_t enable_mask; + + //true to enable codec internal loopback + uint32_t codec_loop; + + //freq holds request LO freq and result from tune + uint32_t freq[2]; + + //gain holds request gain and result from action + uint32_t gain[2]; + + //rate holds request clock rate and result from action + uint32_t rate[2]; + + } value; + + //error message comes back as a reply - + //set to null string for no error \0 + char error_msg[]; + +} ad9361_transaction_t; + +#define AD9361_TRANSACTION_MAX_ERROR_MSG (AD9361_DISPATCH_PACKET_SIZE - (sizeof(ad9361_transaction_t)-4)-1) // -4 for 'error_msg' alignment padding, -1 for terminating \0 + +#ifdef __cplusplus +} +#endif + +#endif /* INCLUDED_AD9361_TRANSACTION_H */ |