1from libcpp cimport bool 2 3ctypedef unsigned int uint32_t 4ctypedef unsigned long long uint64_t 5 6cdef extern from "lime/LimeSuite.h": 7 ctypedef double float_type 8 const int LMS_SUCCESS = 0 9 10 ctypedef void lms_device_t 11 ctypedef char lms_info_str_t[256] 12 13 int LMS_GetDeviceList(lms_info_str_t *dev_list) 14 int LMS_Open(lms_device_t ** device, lms_info_str_t info, void*args) 15 int LMS_Close(lms_device_t *device) 16 17 const bool LMS_CH_TX = True 18 const bool LMS_CH_RX = False 19 20 ctypedef struct lms_range_t: 21 float_type min # Minimum allowed value 22 float_type max # Minimum allowed value 23 float_type step # Minimum value step 24 25 ctypedef enum lms_testsig_t: 26 LMS_TESTSIG_NONE = 0 # Disable test signals. Return to normal operation 27 LMS_TESTSIG_NCODIV8 # Test signal from NCO half scale 28 LMS_TESTSIG_NCODIV4 # Test signal from NCO half scale 29 LMS_TESTSIG_NCODIV8F # Test signal from NCO full scale 30 LMS_TESTSIG_NCODIV4F # Test signal from NCO full scale 31 LMS_TESTSIG_DC # DC test signal 32 33 int LMS_Init(lms_device_t *device) 34 int LMS_Reset(lms_device_t *device) 35 int LMS_Synchronize(lms_device_t *dev, bool to_chip) 36 int LMS_GetNumChannels(lms_device_t *device, bool dir_tx) 37 int LMS_EnableChannel(lms_device_t *device, bool dir_tx, size_t chan, bool enabled) 38 39 int LMS_SaveConfig(lms_device_t *device, const char *filename) 40 int LMS_LoadConfig(lms_device_t *device, const char *filename) 41 42 int LMS_SetSampleRate(lms_device_t *device, float_type rate, size_t oversample) 43 int LMS_GetSampleRate(lms_device_t *device, bool dir_tx, size_t chan, float_type *host_Hz, float_type *rf_Hz) 44 int LMS_GetSampleRateRange(lms_device_t *device, bool dir_tx, lms_range_t *range) 45 46 int LMS_SetLOFrequency(lms_device_t *device, bool dir_tx, size_t chan, float_type frequency) 47 int LMS_GetLOFrequency(lms_device_t *device, bool dir_tx, size_t chan, float_type *frequency) 48 int LMS_GetLOFrequencyRange(lms_device_t *device, bool dir_tx, lms_range_t *range) 49 50 int LMS_SetNormalizedGain(lms_device_t *device, bool dir_tx, size_t chan, float_type gain) 51 int LMS_GetNormalizedGain(lms_device_t *device, bool dir_tx, size_t chan, float_type *gain) 52 53 int LMS_SetLPFBW(lms_device_t *device, bool dir_tx, size_t chan, float_type bandwidth) 54 int LMS_GetLPFBW(lms_device_t *device, bool dir_tx, size_t chan, float_type *bandwidth) 55 int LMS_GetLPFBWRange(lms_device_t *device, bool dir_tx, lms_range_t *range) 56 int LMS_SetLPF(lms_device_t *device, bool dir_tx, size_t chan, bool enabled) 57 int LMS_SetGFIRLPF(lms_device_t *device, bool dir_tx, size_t chan, bool enabled, float_type bandwidth) 58 59 int LMS_Calibrate(lms_device_t *device, bool dir_tx, size_t chan, double bw, unsigned flags) 60 61 int LMS_SetNCOFrequency(lms_device_t *device, bool dir_tx, size_t chan, const float_type *freq, float_type pho) 62 int LMS_GetNCOFrequency(lms_device_t *device, bool dir_tx, size_t chan, float_type *freq, float_type *pho) 63 64 int LMS_GetClockFreq(lms_device_t *dev, size_t clk_id, float_type *freq) 65 int LMS_SetClockFreq(lms_device_t *dev, size_t clk_id, float_type freq) 66 67 ctypedef char lms_name_t[16] 68 int LMS_GetAntennaList(lms_device_t *device, bool dir_tx, size_t chan, lms_name_t *list) 69 int LMS_SetAntenna(lms_device_t *device, bool dir_tx, size_t chan, size_t index) 70 int LMS_GetAntenna(lms_device_t *device, bool dir_tx, size_t chan) 71 int LMS_GetAntennaBW(lms_device_t *device, bool dir_tx, size_t chan, size_t index, lms_range_t *range) 72 73 int LMS_GetChipTemperature(lms_device_t *dev, size_t ind, float_type *temp) 74 75 ctypedef struct lms_stream_meta_t: 76 # Timestamp is a value of HW counter with a tick based on sample rate. 77 # In RX: time when the first sample in the returned buffer was received 78 # In TX: time when the first sample in the submitted buffer should be send 79 uint64_t timestamp 80 81 # In TX: wait for the specified HW timestamp before broadcasting data over the air 82 # In RX: wait for the specified HW timestamp before starting to receive samples 83 bool waitForTimestamp 84 85 # Indicates the end of send/receive transaction. Discards data remainder 86 # in buffer (if there is any) in RX or flushes transfer buffer in TX (even 87 # if the buffer is not full yet) 88 bool flushPartialPacket 89 90 ctypedef enum dataFmt_t: 91 LMS_FMT_F32 "lms_stream_t::LMS_FMT_F32" = 0 92 LMS_FMT_I16 "lms_stream_t::LMS_FMT_I16" 93 LMS_FMT_I12 "lms_stream_t::LMS_FMT_I12" 94 95 ctypedef struct lms_stream_t: 96 # Stream handle. Should not be modified manually. Assigned by LMS_SetupStream() 97 size_t handle 98 99 # Indicates whether stream is TX (true) or RX (false) 100 bool isTx 101 102 # Channel number. Starts at 0. 103 uint32_t channel 104 105 # FIFO size (in samples) used by stream. 106 uint32_t fifoSize 107 108 # Parameter for controlling configuration bias toward low latency or high data throughput range [0,1.0]. 109 # 0 - lowest latency, usually results in lower throughput 110 # 1 - higher throughput, usually results in higher latency 111 float throughputVsLatency 112 113 dataFmt_t dataFmt 114 115 ctypedef struct lms_stream_status_t: 116 bool active # Indicates whether the stream is currently active 117 uint32_t fifoFilledCount # Number of samples in FIFO buffer 118 uint32_t fifoSize # Size of FIFO buffer 119 uint32_t underrun # FIFO underrun count 120 uint32_t overrun # FIFO overrun count 121 uint32_t droppedPackets # Number of dropped packets by HW 122 float_type sampleRate # Sampling rate of the stream 123 float_type linkRate # Combined data rate of all stream of the same direction (TX or RX) 124 uint64_t timestamp # Current HW timestamp 125 126 int LMS_SetupStream(lms_device_t *device, lms_stream_t *stream) 127 int LMS_DestroyStream(lms_device_t *device, lms_stream_t *stream) 128 int LMS_StartStream(lms_stream_t *stream) 129 int LMS_StopStream(lms_stream_t *conf) 130 int LMS_GetStreamStatus(lms_stream_t *stream, lms_stream_status_t*status) 131 int LMS_RecvStream(lms_stream_t *stream, void *samples, size_t sample_count, lms_stream_meta_t *meta, 132 unsigned timeout_ms) 133 int LMS_SendStream(lms_stream_t *stream, const void *samples, size_t sample_count, const lms_stream_meta_t *meta, 134 unsigned timeout_ms) 135 136 const char* LMS_GetLastErrorMessage() 137