no-OS
mwc.h
Go to the documentation of this file.
1 #ifndef MWC_H
2 #define MWC_H
3 
4 #include <assert.h>
5 #include "no_os_gpio.h"
6 #include "no_os_eeprom.h"
7 #include "iio.h"
8 #include "iio_hmc630x.h"
9 #include "hmc630x.h"
10 #include "no_os_pid.h"
11 
16 };
17 
18 struct mwc_iio_dev {
24  unsigned int tx_target;
25  unsigned int tx_tolerance;
27  unsigned int rx_target;
28  unsigned int rx_tolerance;
31  uint8_t (*temp_correlation)[5];
32  struct no_os_pid *tx_pid;
33  struct no_os_pid *rx_pid;
35  bool hbtx;
36  const uint8_t *crc8;
40  char *hw_version;
41  char *hw_serial;
45 };
46 
50  unsigned int tx_target;
51  unsigned int tx_tolerance;
53  unsigned int rx_target;
54  unsigned int rx_tolerance;
57  uint8_t (*temp_correlation)[5];
59  bool hbtx;
60  const uint8_t *crc8;
64 };
65 
77 };
78 
79 struct __attribute__((packed)) nvmp {
80  char hw_version[2];
81  char hw_serial[15];
82  char carrier_model[20];
83  char carrier_version[2];
84  char carrier_serial[15];
86  unsigned int tx_target;
87  unsigned int tx_tolerance;
89  unsigned int rx_target;
90  unsigned int rx_tolerance;
93  uint8_t temp_correlation[2][4][5];
94 
96  uint64_t hmc6300_vco[2]; // {lbtx vco, hbtx vco}
97  uint8_t hmc6300_if_attn;
98  uint8_t hmc6300_rf_attn;
99 
101  uint64_t hmc6301_vco[2]; // {lbtx vco, hbtx vco}
104  enum hmc6301_bb_attn hmc6301_bb_attn1;
105  enum hmc6301_bb_attn hmc6301_bb_attn2;
106  enum hmc6301_bb_attn_fine hmc6301_bb_attni_fine;
107  enum hmc6301_bb_attn_fine hmc6301_bb_attnq_fine;
108 };
109 
110 union nvmp255 {
111  struct nvmp data;
112  char _size[255];
113 };
114 static_assert(sizeof(union nvmp255) == 255,
115  "Non-volatile memory parameters exceed the maximum allowed size.");
116 
117 // The EEPROM has 4096 bytes available that we split into 16 areas
118 // the last one of which holds the factory defaults.
119 #define NVMP_AREA_ADDRESS(n) (256 * (n))
120 
121 extern const union nvmp255 factory_defaults_template;
122 
123 int mwc_iio_init(struct mwc_iio_dev **iio_dev,
125 int mwc_iio_remove(struct mwc_iio_dev *desc);
126 int mwc_tx_rx_reset(struct mwc_iio_dev *mwc);
127 
128 int mwc_algorithms(struct mwc_iio_dev *mwc);
129 int mwc_save_to_eeprom(struct mwc_iio_dev *mwc, uint16_t address);
130 
131 #endif
admv96xx_id
admv96xx_id
Definition: mwc.h:12
mwc_iio_init_param
Definition: mwc.h:47
mwc_iio_dev::rx_pid
struct no_os_pid * rx_pid
Definition: mwc.h:33
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
END_ATTRIBUTES_ARRAY
#define END_ATTRIBUTES_ARRAY
Definition: iio_types.h:116
nvmp::hmc6301_vco
uint64_t hmc6301_vco[2]
Definition: mwc.h:101
mwc_iio_dev::hw_version
char * hw_version
Definition: mwc.h:40
IIO_VAL_INT
@ IIO_VAL_INT
Definition: iio_types.h:50
iio_channel
Struct describing the scan type.
Definition: iio_types.h:168
MWC_IIO_ATTR_RX_TOLERANCE
@ MWC_IIO_ATTR_RX_TOLERANCE
Definition: mwc.h:72
mwc_iio_dev::eeprom
struct no_os_eeprom_desc * eeprom
Definition: mwc.h:37
no_os_eeprom_desc
Structure holding the EEPROM descriptor.
Definition: no_os_eeprom.h:70
mwc_iio_dev::tx_auto_ifvga
bool tx_auto_ifvga
Definition: mwc.h:29
nvmp::hmc6300_if_attn
uint8_t hmc6300_if_attn
Definition: mwc.h:97
nvmp::hmc6300_enabled
bool hmc6300_enabled
Definition: mwc.h:95
no_os_eeprom_write
int32_t no_os_eeprom_write(struct no_os_eeprom_desc *desc, uint32_t address, uint8_t *data, uint16_t bytes)
Write the EEPROM data.
Definition: no_os_eeprom.c:89
mwc_iio_dev::reset_gpio
struct no_os_gpio_desc * reset_gpio
Definition: mwc.h:22
IIO_VAL_FRACTIONAL_LOG2
@ IIO_VAL_FRACTIONAL_LOG2
Definition: iio_types.h:56
no_os_pid.h
Header file for PID control utility.
HMC6301_BB_ATTN_18dB
@ HMC6301_BB_ATTN_18dB
Definition: hmc630x.h:239
iio_ch_info
Structure holding channel attributess.
Definition: iio_types.h:103
nvmp::hmc6301_lna_attn
enum hmc6301_lna_attn hmc6301_lna_attn
Definition: mwc.h:103
ID_ADMV96X3
@ ID_ADMV96X3
Definition: mwc.h:14
nvmp::hmc6301_bb_attnq_fine
enum hmc6301_bb_attn_fine hmc6301_bb_attnq_fine
Definition: mwc.h:107
led_rx_det_green
void led_rx_det_green(bool on)
mwc_iio_init_param::temp_correlation
uint8_t(* temp_correlation)[5]
Definition: mwc.h:57
MWC_IIO_ATTR_TX_TARGET
@ MWC_IIO_ATTR_TX_TARGET
Definition: mwc.h:68
no_os_delay.h
Header file of Delay functions.
nvmp::tx_tolerance
unsigned int tx_tolerance
Definition: mwc.h:87
nvmp255::data
struct nvmp data
Definition: mwc.h:111
no_os_eeprom.h
Header file for EEPROM APIs.
mwc_iio_init
int mwc_iio_init(struct mwc_iio_dev **iiodev, struct mwc_iio_init_param *init_param)
Definition: mwc.c:616
nvmp::tx_autotuning
bool tx_autotuning
Definition: mwc.h:85
device
Definition: ad9361_util.h:69
NO_OS_GPIO_HIGH
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
MWC_IIO_ATTR_RX_AUTOTUNING
@ MWC_IIO_ATTR_RX_AUTOTUNING
Definition: mwc.h:70
no_os_pid_config
Configuration of the PID.
Definition: no_os_pid.h:54
NO_OS_ARRAY_SIZE
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:49
led_tx_det_red
void led_tx_det_red(bool on)
hmc6301_bb_attn
hmc6301_bb_attn
Definition: hmc630x.h:235
mwc_save_to_eeprom
int mwc_save_to_eeprom(struct mwc_iio_dev *mwc, uint16_t address)
Definition: mwc.c:264
nvmp::hmc6301_enabled
bool hmc6301_enabled
Definition: mwc.h:100
bool
bool
Definition: common.h:48
nvmp::hmc6301_if_attn
uint8_t hmc6301_if_attn
Definition: mwc.h:102
no_os_pid_remove
int no_os_pid_remove(struct no_os_pid *pid)
mwc_iio_dev::tx_pid
struct no_os_pid * tx_pid
Definition: mwc.h:32
nvmp::hmc6301_bb_attn2
enum hmc6301_bb_attn hmc6301_bb_attn2
Definition: mwc.h:105
NO_OS_GPIO_LOW
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
mwc_tx_rx_reset
int mwc_tx_rx_reset(struct mwc_iio_dev *mwc)
Definition: mwc.c:251
hmc630x_get_temp
int hmc630x_get_temp(struct hmc630x_dev *dev, uint8_t *temp)
Definition: hmc630x.c:538
hmc6301_get_lna_gain
int hmc6301_get_lna_gain(struct hmc630x_dev *dev, enum hmc6301_lna_attn *gain)
Definition: hmc630x.c:878
nvmp::rx_auto_ifvga_rflna
bool rx_auto_ifvga_rflna
Definition: mwc.h:92
no_os_pid_hysteresis
int no_os_pid_hysteresis(struct no_os_pid *pid, unsigned int hyst)
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
mwc_iio_init_param::rx_autotuning
bool rx_autotuning
Definition: mwc.h:52
hmc6301_set_bb_attn_fine
int hmc6301_set_bb_attn_fine(struct hmc630x_dev *dev, enum hmc6301_bb_attn_fine attn_i, enum hmc6301_bb_attn_fine attn_q)
Definition: hmc630x.c:934
no_os_min
#define no_os_min(x, y)
Definition: no_os_util.h:59
mwc_iio_init_param::rx_target
unsigned int rx_target
Definition: mwc.h:53
mwc_iio_attr_id
mwc_iio_attr_id
Definition: mwc.h:66
iio.h
Header file of iio.
no_os_error.h
Error codes definition.
HMC6301_BB_ATTN_FINE_3dB
@ HMC6301_BB_ATTN_FINE_3dB
Definition: hmc630x.h:250
mwc_tx_rx_reset
int mwc_tx_rx_reset(struct mwc_iio_dev *mwc)
Definition: mwc.c:251
mwc_algorithms
int mwc_algorithms(struct mwc_iio_dev *mwc)
Definition: mwc.c:113
mwc_iio_init_param::tx_auto_ifvga
bool tx_auto_ifvga
Definition: mwc.h:55
iio_attribute::name
const char * name
Definition: iio_types.h:131
mwc_iio_dev
Definition: mwc.h:18
mwc_iio_dev::hw_serial
char * hw_serial
Definition: mwc.h:41
led_tx_det_green
void led_tx_det_green(bool on)
iio_channel::name
const char * name
Definition: iio_types.h:170
mwc_iio_dev::tx_autotuning
bool tx_autotuning
Definition: mwc.h:23
hmc630x.h
hmc6300 and hmc6301 device driver header.
mwc_iio_dev::adin1300
struct adin1300_desc * adin1300
Definition: mwc.h:38
nvmp::hmc6300_vco
uint64_t hmc6300_vco[2]
Definition: mwc.h:96
factory_defaults_template
const union nvmp255 factory_defaults_template
Definition: mwc.c:16
nvmp255
Definition: mwc.h:110
MWC_IIO_ATTR_TX_AUTOTUNING
@ MWC_IIO_ATTR_TX_AUTOTUNING
Definition: mwc.h:67
iio_attribute
Structure holding pointers to show and store functions.
Definition: iio_types.h:129
hmc630x_dev
Definition: hmc630x.c:57
mwc_iio_init_param::tx_target
unsigned int tx_target
Definition: mwc.h:50
mwc_iio_dev::rx_autotuning
bool rx_autotuning
Definition: mwc.h:26
mwc_iio_init_param::reset_gpio_ip
struct no_os_gpio_init_param * reset_gpio_ip
Definition: mwc.h:48
MWC_IIO_ATTR_RX_TARGET
@ MWC_IIO_ATTR_RX_TARGET
Definition: mwc.h:71
mwc_iio_dev::rx_iiodev
struct hmc630x_iio_dev * rx_iiodev
Definition: mwc.h:21
MWC_IIO_ATTR_RX_AUTO_IFVGA_RFLNA
@ MWC_IIO_ATTR_RX_AUTO_IFVGA_RFLNA
Definition: mwc.h:74
mwc_iio_dev::iio_dev
struct iio_device * iio_dev
Definition: mwc.h:19
nvmp255::_size
char _size[255]
Definition: mwc.h:112
mwc.h
mwc_iio_init_param::adin1300
struct adin1300_desc * adin1300
Definition: mwc.h:62
iio_parse_value
int32_t iio_parse_value(char *buf, enum iio_val fmt, int32_t *val, int32_t *val2)
Definition: iio.c:630
hmc6300_get_rf_attn
int hmc6300_get_rf_attn(struct hmc630x_dev *dev, uint8_t *attn)
Definition: hmc630x.c:730
mwc_temp_correlation
void mwc_temp_correlation(uint8_t(*correlation)[5], uint8_t temp, uint8_t *tx_if, uint8_t *rx_if, uint8_t *rx_rflna)
Definition: mwc.c:95
ID_ADMV96X1
@ ID_ADMV96X1
Definition: mwc.h:13
hmc6300_set_rf_attn
int hmc6300_set_rf_attn(struct hmc630x_dev *dev, uint8_t attn)
Definition: hmc630x.c:715
IIO_VOLTAGE
@ IIO_VOLTAGE
Definition: iio_types.h:65
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
nvmp::rx_target
unsigned int rx_target
Definition: mwc.h:89
max24287_desc
Definition: max24287.h:109
led.h
mwc_iio_dev::carrier_serial
char * carrier_serial
Definition: mwc.h:44
mwc_iio_dev::carrier_version
char * carrier_version
Definition: mwc.h:43
nvmp::rx_autotuning
bool rx_autotuning
Definition: mwc.h:88
HMC6301_LNA_ATTN_12dB
@ HMC6301_LNA_ATTN_12dB
Definition: hmc630x.h:230
adin1300_desc
Definition: adin1300.h:157
mwc_iio_init_param::id
enum admv96xx_id id
Definition: mwc.h:58
MWC_IIO_ATTR_RESET
@ MWC_IIO_ATTR_RESET
Definition: mwc.h:75
mwc_iio_dev::tx_iiodev
struct hmc630x_iio_dev * tx_iiodev
Definition: mwc.h:20
hmc630x_set_if_attn
int hmc630x_set_if_attn(struct hmc630x_dev *dev, uint8_t attn)
Definition: hmc630x.c:675
mwc_algorithms
int mwc_algorithms(struct mwc_iio_dev *mwc)
Definition: mwc.c:113
HMC6301_LNA_ATTN_18dB
@ HMC6301_LNA_ATTN_18dB
Definition: hmc630x.h:231
mwc_iio_init_param::max24287
struct max24287_desc * max24287
Definition: mwc.h:63
mwc_iio_remove
int mwc_iio_remove(struct mwc_iio_dev *desc)
Definition: mwc.c:695
hmc6301_bb_attn_fine
hmc6301_bb_attn_fine
Definition: hmc630x.h:243
hmc6301_get_bb_attn
int hmc6301_get_bb_attn(struct hmc630x_dev *dev, enum hmc6301_bb_attn *attn1, enum hmc6301_bb_attn *attn2)
Definition: hmc630x.c:914
MWC_IIO_ATTR_TX_TOLERANCE
@ MWC_IIO_ATTR_TX_TOLERANCE
Definition: mwc.h:69
no_os_pid_config::output_clip
struct no_os_pid_range output_clip
Definition: no_os_pid.h:66
no_os_gpio_get
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:49
hmc630x_get_enable
int hmc630x_get_enable(struct hmc630x_dev *dev, bool *enable)
Definition: hmc630x.c:619
nvmp::temp_correlation
uint8_t temp_correlation[2][4][5]
Definition: mwc.h:93
iio_format_value
int iio_format_value(char *buf, uint32_t len, enum iio_val fmt, int32_t size, int32_t *vals)
Definition: iio.c:686
mwc_iio_dev::rx_target
unsigned int rx_target
Definition: mwc.h:27
mwc_iio_init_param::rx_tolerance
unsigned int rx_tolerance
Definition: mwc.h:54
nvmp::hmc6301_bb_attni_fine
enum hmc6301_bb_attn_fine hmc6301_bb_attni_fine
Definition: mwc.h:106
no_os_crc8
uint8_t no_os_crc8(const uint8_t *table, const uint8_t *pdata, size_t nbytes, uint8_t crc)
no_os_pid_config::Kp
unsigned int Kp
Definition: no_os_pid.h:56
hmc630x_get_if_attn
int hmc630x_get_if_attn(struct hmc630x_dev *dev, uint8_t *attn)
Definition: hmc630x.c:695
iio_ch_info::type
enum iio_chan_type type
Definition: iio_types.h:109
mwc_iio_init
int mwc_iio_init(struct mwc_iio_dev **iio_dev, struct mwc_iio_init_param *init_param)
Definition: mwc.c:616
no_os_pid_init
int no_os_pid_init(struct no_os_pid **pid, struct no_os_pid_config config)
MWC_IIO_ATTR_SAVE
@ MWC_IIO_ATTR_SAVE
Definition: mwc.h:76
hmc630x_dev::address
uint8_t address
Definition: hmc630x.c:59
NULL
#define NULL
Definition: wrapper.h:64
mwc_iio_dev::carrier_model
char * carrier_model
Definition: mwc.h:42
hmc6301_set_lna_gain
int hmc6301_set_lna_gain(struct hmc630x_dev *dev, enum hmc6301_lna_attn gain)
Definition: hmc630x.c:865
no_os_gpio_set_value
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:197
nvmp::tx_auto_ifvga
bool tx_auto_ifvga
Definition: mwc.h:91
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
iio_ch_info::ch_num
int16_t ch_num
Definition: iio_types.h:105
iio_device
Structure holding channels and attributes of a device.
Definition: iio_types.h:247
mwc_iio_init_param::tx_tolerance
unsigned int tx_tolerance
Definition: mwc.h:51
mwc_iio_dev::rx_tolerance
unsigned int rx_tolerance
Definition: mwc.h:28
nvmp::hmc6301_bb_attn1
enum hmc6301_bb_attn hmc6301_bb_attn1
Definition: mwc.h:104
mwc_iio_init_param::crc8
const uint8_t * crc8
Definition: mwc.h:60
mwc_iio_dev::id
enum admv96xx_id id
Definition: mwc.h:34
iio_hmc630x.h
Header file of hmc6300 and hmc6301 driver extension for IIOD.
mwc_iio_init_param::tx_autotuning
bool tx_autotuning
Definition: mwc.h:49
mwc_iio_dev::tx_tolerance
unsigned int tx_tolerance
Definition: mwc.h:25
mwc_iio_init_param::eeprom
struct no_os_eeprom_desc * eeprom
Definition: mwc.h:61
mwc_iio_dev::hbtx
bool hbtx
Definition: mwc.h:35
mwc_iio_remove
int mwc_iio_remove(struct mwc_iio_dev *iiodev)
Definition: mwc.c:695
led_rx_det_red
void led_rx_det_red(bool on)
HMC6301_BB_ATTN_FINE_0dB
@ HMC6301_BB_ATTN_FINE_0dB
Definition: hmc630x.h:244
no_os_gpio.h
Header file of GPIO Interface.
mwc_iio_dev::crc8
const uint8_t * crc8
Definition: mwc.h:36
mwc_iio_dev::rx_auto_ifvga_rflna
bool rx_auto_ifvga_rflna
Definition: mwc.h:30
mwc_iio_init_param::rx_auto_ifvga_rflna
bool rx_auto_ifvga_rflna
Definition: mwc.h:56
hmc630x_iio_dev
Definition: iio_hmc630x.h:39
nvmp::tx_target
unsigned int tx_target
Definition: mwc.h:86
hmc630x_iio_dev::dev
struct hmc630x_dev * dev
Definition: iio_hmc630x.h:40
mwc_iio_dev::temp_correlation
uint8_t(* temp_correlation)[5]
Definition: mwc.h:31
nvmp::hmc6300_rf_attn
uint8_t hmc6300_rf_attn
Definition: mwc.h:98
factory_defaults_template
const union nvmp255 factory_defaults_template
Definition: mwc.c:16
no_os_util.h
Header file of utility functions.
mwc_save_to_eeprom
int mwc_save_to_eeprom(struct mwc_iio_dev *mwc, uint16_t address)
Definition: mwc.c:264
hmc630x_get_vco
int hmc630x_get_vco(struct hmc630x_dev *dev, uint64_t *frequency)
Definition: hmc630x.c:811
nvmp
Definition: mwc.h:79
NVMP_AREA_ADDRESS
#define NVMP_AREA_ADDRESS(n)
Definition: mwc.h:119
no_os_pid_reset
int no_os_pid_reset(struct no_os_pid *pid)
hmc6301_set_bb_attn
int hmc6301_set_bb_attn(struct hmc630x_dev *dev, enum hmc6301_bb_attn attn1, enum hmc6301_bb_attn attn2)
Definition: hmc630x.c:891
nvmp::rx_tolerance
unsigned int rx_tolerance
Definition: mwc.h:90
no_os_gpio_direction_output
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:147
mwc_iio_dev::max24287
struct max24287_desc * max24287
Definition: mwc.h:39
HMC6301_LNA_ATTN_6dB
@ HMC6301_LNA_ATTN_6dB
Definition: hmc630x.h:229
hmc6301_lna_attn
hmc6301_lna_attn
Definition: hmc630x.h:227
mwc_iio_dev::tx_target
unsigned int tx_target
Definition: mwc.h:24
no_os_pid_range::high
int high
Definition: no_os_pid.h:45
ID_ADMV96X5
@ ID_ADMV96X5
Definition: mwc.h:15
no_os_crc8.h
Header file of CRC-8 computation.
hmc6301_get_bb_attn_fine
int hmc6301_get_bb_attn_fine(struct hmc630x_dev *dev, enum hmc6301_bb_attn_fine *attn_i, enum hmc6301_bb_attn_fine *attn_q)
Definition: hmc630x.c:961
nvmp::hw_version
char hw_version[2]
Definition: mwc.h:80
MWC_IIO_ATTR_TX_AUTO_IFVGA
@ MWC_IIO_ATTR_TX_AUTO_IFVGA
Definition: mwc.h:73
iio_device::attributes
struct iio_attribute * attributes
Definition: iio_types.h:256
mwc_iio_init_param::hbtx
bool hbtx
Definition: mwc.h:59
no_os_pid_control
int no_os_pid_control(struct no_os_pid *pid, int SP, int PV, int *output)