no-OS
admv1013.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef ADMV1013_H_
35 #define ADMV1013_H_
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 #include <stdint.h>
41 #include <stdbool.h>
42 #include "no_os_spi.h"
43 #include "no_os_util.h"
44 
45 /******************************************************************************/
46 /********************** Macros and Constants Definitions **********************/
47 /******************************************************************************/
48 
49 /* ADMV1013 Register Map */
50 #define ADMV1013_REG_SPI_CONTROL 0x00
51 #define ADMV1013_REG_ALARM 0x01
52 #define ADMV1013_REG_ALARM_MASKS 0x02
53 #define ADMV1013_REG_ENABLE 0x03
54 #define ADMV1013_REG_LO_AMP_I 0x05
55 #define ADMV1013_REG_LO_AMP_Q 0x06
56 #define ADMV1013_REG_OFFSET_ADJUST_I 0x07
57 #define ADMV1013_REG_OFFSET_ADJUST_Q 0x08
58 #define ADMV1013_REG_QUAD 0x09
59 #define ADMV1013_REG_VVA_TEMP_COMP 0x0A
60 
61 /* ADMV1013_REG_SPI_CONTROL Map */
62 #define ADMV1013_PARITY_EN_MSK NO_OS_BIT(15)
63 #define ADMV1013_SPI_SOFT_RESET_MSK NO_OS_BIT(14)
64 #define ADMV1013_CHIP_ID_MSK NO_OS_GENMASK(11, 4)
65 #define ADMV1013_CHIP_ID 0xA
66 #define ADMV1013_REVISION_ID_MSK NO_OS_GENMASK(3, 0)
67 
68 /* ADMV1013_REG_ALARM Map */
69 #define ADMV1013_PARITY_ERROR_MSK NO_OS_BIT(15)
70 #define ADMV1013_TOO_FEW_ERRORS_MSK NO_OS_BIT(14)
71 #define ADMV1013_TOO_MANY_ERRORS_MSK NO_OS_BIT(13)
72 #define ADMV1013_ADDRESS_RANGE_ERROR_MSK NO_OS_BIT(12)
73 
74 /* ADMV1013_REG_ENABLE Map */
75 #define ADMV1013_VGA_PD_MSK NO_OS_BIT(15)
76 #define ADMV1013_MIXER_PD_MSK NO_OS_BIT(14)
77 #define ADMV1013_QUAD_PD_MSK NO_OS_GENMASK(13, 11)
78 #define ADMV1013_BG_PD_MSK NO_OS_BIT(10)
79 #define ADMV1013_MIXER_IF_EN_MSK NO_OS_BIT(7)
80 #define ADMV1013_DET_EN_MSK NO_OS_BIT(5)
81 
82 /* ADMV1013_REG_LO_AMP Map */
83 #define ADMV1013_LOAMP_PH_ADJ_FINE_MSK NO_OS_GENMASK(13, 7)
84 #define ADMV1013_MIXER_VGATE_MSK NO_OS_GENMASK(6, 0)
85 
86 /* ADMV1013_REG_OFFSET_ADJUST Map */
87 #define ADMV1013_MIXER_OFF_ADJ_P_MSK NO_OS_GENMASK(15, 9)
88 #define ADMV1013_MIXER_OFF_ADJ_N_MSK NO_OS_GENMASK(8, 2)
89 
90 /* ADMV1013_REG_QUAD Map */
91 #define ADMV1013_QUAD_SE_MODE_MSK NO_OS_GENMASK(9, 6)
92 #define ADMV1013_QUAD_FILTERS_MSK NO_OS_GENMASK(3, 0)
93 
94 /* ADMV1013_REG_VVA_TEMP_COMP Map */
95 #define ADMV1013_VVA_TEMP_COMP_MSK NO_OS_GENMASK(15, 0)
96 
97 /* Specifications */
98 #define ADMV1013_BUFF_SIZE_BYTES 3
99 #define ADMV1013_SPI_READ_CMD NO_OS_BIT(7)
100 #define ADMV1013_SPI_WRITE_CMD (0 << 7)
101 
102 #define MIXER_GATE_0_to_1_8_V(x) ((2389 * x/ 1000000 + 8100) / 100)
103 #define MIXER_GATE_1_8_to_2_6_V(x) ((2375 * x/ 1000000 + 125) / 100)
104 
105 /******************************************************************************/
106 /*************************** Types Declarations *******************************/
107 /******************************************************************************/
108 
116 };
117 
126 };
127 
137 };
138 
147  unsigned long long lo_in;
153  bool det_en;
155  unsigned int vcm_uv;
156 };
157 
162 struct admv1013_dev {
166  unsigned long long lo_in;
172  bool det_en;
174  unsigned int vcm_uv;
175 };
176 
177 /******************************************************************************/
178 /************************ Functions Declarations ******************************/
179 /******************************************************************************/
180 
182 int admv1013_spi_write(struct admv1013_dev *dev, uint8_t reg_addr,
183  uint16_t data);
184 
185 /* ADMV1013 Register Update */
186 int admv1013_spi_update_bits(struct admv1013_dev *dev, uint8_t reg_addr,
187  uint16_t mask, uint16_t data);
188 
190 int admv1013_spi_read(struct admv1013_dev *dev, uint8_t reg_addr,
191  uint16_t *data);
192 
194 int admv1013_set_iq_phase(struct admv1013_dev *dev, uint8_t i_phase,
195  uint8_t q_phase);
196 
198 int admv1013_get_iq_phase(struct admv1013_dev *dev, uint8_t *i_phase,
199  uint8_t *q_phase);
200 
202 int admv1013_set_iq_offset(struct admv1013_dev *dev, uint8_t i_offset_p,
203  uint8_t i_offset_n, uint8_t q_offset_p,
204  uint8_t q_offset_n);
205 
207 int admv1013_get_iq_offset(struct admv1013_dev *dev, uint8_t *i_offset_p,
208  uint8_t *i_offset_n, uint8_t *q_offset_p,
209  uint8_t *q_offset_n);
210 
212 int admv1013_init(struct admv1013_dev **device,
214 
216 int admv1013_remove(struct admv1013_dev *dev);
217 
218 #endif /* ADMV1013_H_ */
ADMV1013_REG_OFFSET_ADJUST_I
#define ADMV1013_REG_OFFSET_ADJUST_I
Definition: admv1013.h:56
ADMV1013_REG_LO_AMP_Q
#define ADMV1013_REG_LO_AMP_Q
Definition: admv1013.h:55
ADMV1013_QUAD_FILTERS_MSK
#define ADMV1013_QUAD_FILTERS_MSK
Definition: admv1013.h:92
admv1013_quad_se_mode
admv1013_quad_se_mode
Switch Differential/Single-Ended Modes.
Definition: admv1013.h:122
no_os_alloc.h
admv1013_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: admv1013.h:145
ADMV1013_MIXER_VGATE_MSK
#define ADMV1013_MIXER_VGATE_MSK
Definition: admv1013.h:84
ADMV1013_QUAD_SE_MODE_MSK
#define ADMV1013_QUAD_SE_MODE_MSK
Definition: admv1013.h:91
ADMV1013_IF_MODE
@ ADMV1013_IF_MODE
Definition: admv1013.h:115
admv1013_init_param::lo_in
unsigned long long lo_in
Definition: admv1013.h:147
ADMV1013_SPI_READ_CMD
#define ADMV1013_SPI_READ_CMD
Definition: admv1013.h:99
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:159
ADMV1013_IQ_MODE
@ ADMV1013_IQ_MODE
Definition: admv1013.h:114
no_os_spi.h
Header file of SPI Interface.
ADMV1013_SPI_WRITE_CMD
#define ADMV1013_SPI_WRITE_CMD
Definition: admv1013.h:100
admv1013_init
int admv1013_init(struct admv1013_dev **device, struct admv1013_init_param *init_param)
Initializes the admv1013.
Definition: admv1013.c:294
admv1013_spi_update_bits
int admv1013_spi_update_bits(struct admv1013_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
Update ADMV1013 register.
Definition: admv1013.c:108
LO_BAND_8_62_TO_10_25_GHZ
@ LO_BAND_8_62_TO_10_25_GHZ
Definition: admv1013.h:133
admv1013_dev::vcm_uv
unsigned int vcm_uv
Definition: admv1013.h:174
admv1013_get_iq_phase
int admv1013_get_iq_phase(struct admv1013_dev *dev, uint8_t *i_phase, uint8_t *q_phase)
Get I/Q Phase Accuracy.
Definition: admv1013.c:204
admv1013.h
Header file for admv1013 Driver.
device
Definition: ad9361_util.h:69
admv1013_get_iq_offset
int admv1013_get_iq_offset(struct admv1013_dev *dev, uint8_t *i_offset_p, uint8_t *i_offset_n, uint8_t *q_offset_p, uint8_t *q_offset_n)
Get I/Q Offset Accuracy.
Definition: admv1013.c:264
admv1013_spi_write
int admv1013_spi_write(struct admv1013_dev *dev, uint8_t reg_addr, uint16_t data)
Writes data to ADMV1013 over SPI.
Definition: admv1013.c:53
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
ADMV1013_CHIP_ID_MSK
#define ADMV1013_CHIP_ID_MSK
Definition: admv1013.h:64
admv1013_dev::input_mode
enum admv1013_input_mode input_mode
Definition: admv1013.h:168
admv1013_get_iq_offset
int admv1013_get_iq_offset(struct admv1013_dev *dev, uint8_t *i_offset_p, uint8_t *i_offset_n, uint8_t *q_offset_p, uint8_t *q_offset_n)
Get I/Q Offset Accuracy.
Definition: admv1013.c:264
admv1013_remove
int admv1013_remove(struct admv1013_dev *dev)
ADMV1013 Resources Deallocation.
Definition: admv1013.c:382
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
admv1013_set_iq_offset
int admv1013_set_iq_offset(struct admv1013_dev *dev, uint8_t i_offset_p, uint8_t i_offset_n, uint8_t q_offset_p, uint8_t q_offset_n)
Set I/Q Offset Accuracy.
Definition: admv1013.c:234
ADMV1013_DET_EN_MSK
#define ADMV1013_DET_EN_MSK
Definition: admv1013.h:80
no_os_error.h
Error codes definition.
admv1013_dev::quad_se_mode
enum admv1013_quad_se_mode quad_se_mode
Definition: admv1013.h:170
admv1013_spi_read
int admv1013_spi_read(struct admv1013_dev *dev, uint8_t reg_addr, uint16_t *data)
Reads data from ADMV1013 over SPI.
Definition: admv1013.c:77
admv1013_spi_read
int admv1013_spi_read(struct admv1013_dev *dev, uint8_t reg_addr, uint16_t *data)
Reads data from ADMV1013 over SPI.
Definition: admv1013.c:77
ADMV1013_REG_LO_AMP_I
#define ADMV1013_REG_LO_AMP_I
Definition: admv1013.h:54
ADMV1013_SE_MODE_NEG
@ ADMV1013_SE_MODE_NEG
Definition: admv1013.h:124
admv1013_init_param
ADMV1013 Initialization Parameters structure.
Definition: admv1013.h:143
ADMV1013_REG_QUAD
#define ADMV1013_REG_QUAD
Definition: admv1013.h:58
LO_BAND_6_6_TO_9_2_GHZ
@ LO_BAND_6_6_TO_9_2_GHZ
Definition: admv1013.h:134
admv1013_set_iq_offset
int admv1013_set_iq_offset(struct admv1013_dev *dev, uint8_t i_offset_p, uint8_t i_offset_n, uint8_t q_offset_p, uint8_t q_offset_n)
Set I/Q Offset Accuracy.
Definition: admv1013.c:234
ADMV1013_SE_MODE_DIFF
@ ADMV1013_SE_MODE_DIFF
Definition: admv1013.h:125
LO_BAND_5_4_TO_8_GHZ
@ LO_BAND_5_4_TO_8_GHZ
Definition: admv1013.h:135
admv1013_dev::lo_in
unsigned long long lo_in
Definition: admv1013.h:166
admv1013_init
int admv1013_init(struct admv1013_dev **device, struct admv1013_init_param *init_param)
Initializes the admv1013.
Definition: admv1013.c:294
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
ADMV1013_SE_MODE_POS
@ ADMV1013_SE_MODE_POS
Definition: admv1013.h:123
admv1013_dev
ADMV1013 Device Descriptor.
Definition: admv1013.h:162
admv1013_set_iq_phase
int admv1013_set_iq_phase(struct admv1013_dev *dev, uint8_t i_phase, uint8_t q_phase)
Set I/Q Phase Accuracy.
Definition: admv1013.c:178
admv1013_dev::det_en
bool det_en
Definition: admv1013.h:172
admv1013_get_iq_phase
int admv1013_get_iq_phase(struct admv1013_dev *dev, uint8_t *i_phase, uint8_t *q_phase)
Get I/Q Phase Accuracy.
Definition: admv1013.c:204
admv1013_init_param::input_mode
enum admv1013_input_mode input_mode
Definition: admv1013.h:149
admv1013_init_param::quad_se_mode
enum admv1013_quad_se_mode quad_se_mode
Definition: admv1013.h:151
ADMV1013_REG_SPI_CONTROL
#define ADMV1013_REG_SPI_CONTROL
Definition: admv1013.h:50
ADMV1013_REG_OFFSET_ADJUST_Q
#define ADMV1013_REG_OFFSET_ADJUST_Q
Definition: admv1013.h:57
ADMV1013_LOAMP_PH_ADJ_FINE_MSK
#define ADMV1013_LOAMP_PH_ADJ_FINE_MSK
Definition: admv1013.h:83
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
ADMV1013_MIXER_OFF_ADJ_P_MSK
#define ADMV1013_MIXER_OFF_ADJ_P_MSK
Definition: admv1013.h:87
admv1013_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: admv1013.h:164
admv1013_input_mode
admv1013_input_mode
Switch Intermediate Frequency or I/Q Mode.
Definition: admv1013.h:113
admv1013_init_param::det_en
bool det_en
Definition: admv1013.h:153
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
ADMV1013_BUFF_SIZE_BYTES
#define ADMV1013_BUFF_SIZE_BYTES
Definition: admv1013.h:98
admv1013_set_iq_phase
int admv1013_set_iq_phase(struct admv1013_dev *dev, uint8_t i_phase, uint8_t q_phase)
Set I/Q Phase Accuracy.
Definition: admv1013.c:178
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
admv1013_init_param::vcm_uv
unsigned int vcm_uv
Definition: admv1013.h:155
admv1013_quad_filters
admv1013_quad_filters
LO Filters BW Selection.
Definition: admv1013.h:132
ADMV1013_SPI_SOFT_RESET_MSK
#define ADMV1013_SPI_SOFT_RESET_MSK
Definition: admv1013.h:63
ADMV1013_REG_VVA_TEMP_COMP
#define ADMV1013_REG_VVA_TEMP_COMP
Definition: admv1013.h:59
ADMV1013_MIXER_IF_EN_MSK
#define ADMV1013_MIXER_IF_EN_MSK
Definition: admv1013.h:79
admv1013_spi_write
int admv1013_spi_write(struct admv1013_dev *dev, uint8_t reg_addr, uint16_t data)
Writes data to ADMV1013 over SPI.
Definition: admv1013.c:53
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
MIXER_GATE_1_8_to_2_6_V
#define MIXER_GATE_1_8_to_2_6_V(x)
Definition: admv1013.h:103
ADMV1013_CHIP_ID
#define ADMV1013_CHIP_ID
Definition: admv1013.h:65
admv1013_remove
int admv1013_remove(struct admv1013_dev *dev)
ADMV1013 Resources Deallocation.
Definition: admv1013.c:382
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
no_os_util.h
Header file of utility functions.
MIXER_GATE_0_to_1_8_V
#define MIXER_GATE_0_to_1_8_V(x)
Definition: admv1013.h:102
ADMV1013_REG_ENABLE
#define ADMV1013_REG_ENABLE
Definition: admv1013.h:53
ADMV1013_MIXER_OFF_ADJ_N_MSK
#define ADMV1013_MIXER_OFF_ADJ_N_MSK
Definition: admv1013.h:88
admv1013_spi_update_bits
int admv1013_spi_update_bits(struct admv1013_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
Update ADMV1013 register.
Definition: admv1013.c:108
LO_BAND_5_4_TO_7_GHZ
@ LO_BAND_5_4_TO_7_GHZ
Definition: admv1013.h:136
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140