no-OS
adrf6780.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef ADRF6780_H_
35 #define ADRF6780_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 /* ADRF6780 Register Map */
50 #define ADRF6780_REG_CONTROL 0x00
51 #define ADRF6780_REG_ALARM_READBACK 0x01
52 #define ADRF6780_REG_ALARM_MASKS 0x02
53 #define ADRF6780_REG_ENABLE 0x03
54 #define ADRF6780_REG_LINEARIZE 0x04
55 #define ADRF6780_REG_LO_PATH 0x05
56 #define ADRF6780_REG_ADC_CONTROL 0x06
57 #define ADRF6780_REG_ADC_OUTPUT 0x0C
58 
59 /* ADRF6780_REG_CONTROL Map */
60 #define ADRF6780_PARITY_EN_MSK NO_OS_BIT(15)
61 #define ADRF6780_SOFT_RESET_MSK NO_OS_BIT(14)
62 #define ADRF6780_CHIP_ID_MSK NO_OS_GENMASK(11, 4)
63 #define ADRF6780_CHIP_ID 0xA
64 #define ADRF6780_CHIP_REVISION_MSK NO_OS_GENMASK(3, 0)
65 
66 /* ADRF6780_REG_ALARM_READBACK Map */
67 #define ADRF6780_PARITY_ERROR_MSK NO_OS_BIT(15)
68 #define ADRF6780_TOO_FEW_ERRORS_MSK NO_OS_BIT(14)
69 #define ADRF6780_TOO_MANY_ERRORS_MSK NO_OS_BIT(13)
70 #define ADRF6780_ADDRESS_RANGE_ERROR_MSK NO_OS_BIT(12)
71 
72 /* ADRF6780_REG_ENABLE Map */
73 #define ADRF6780_VGA_BUFFER_EN_MSK NO_OS_BIT(8)
74 #define ADRF6780_DETECTOR_EN_MSK NO_OS_BIT(7)
75 #define ADRF6780_LO_BUFFER_EN_MSK NO_OS_BIT(6)
76 #define ADRF6780_IF_MODE_EN_MSK NO_OS_BIT(5)
77 #define ADRF6780_IQ_MODE_EN_MSK NO_OS_BIT(4)
78 #define ADRF6780_LO_X2_EN_MSK NO_OS_BIT(3)
79 #define ADRF6780_LO_PPF_EN_MSK NO_OS_BIT(2)
80 #define ADRF6780_LO_EN_MSK NO_OS_BIT(1)
81 #define ADRF6780_UC_BIAS_EN_MSK NO_OS_BIT(0)
82 
83 /* ADRF6780_REG_LINEARIZE Map */
84 #define ADRF6780_RDAC_LINEARIZE_MSK NO_OS_GENMASK(7, 0)
85 
86 /* ADRF6780_REG_LO_PATH Map */
87 #define ADRF6780_LO_SIDEBAND_MSK NO_OS_BIT(10)
88 #define ADRF6780_Q_PATH_PHASE_ACCURACY_MSK NO_OS_GENMASK(7, 4)
89 #define ADRF6780_I_PATH_PHASE_ACCURACY_MSK NO_OS_GENMASK(3, 0)
90 
91 /* ADRF6780_REG_ADC_CONTROL Map */
92 #define ADRF6780_VDET_OUTPUT_SELECT_MSK NO_OS_BIT(3)
93 #define ADRF6780_ADC_START_MSK NO_OS_BIT(2)
94 #define ADRF6780_ADC_EN_MSK NO_OS_BIT(1)
95 #define ADRF6780_ADC_CLOCK_EN_MSK NO_OS_BIT(0)
96 
97 /* ADRF6780_REG_ADC_OUTPUT Map */
98 #define ADRF6780_ADC_STATUS_MSK NO_OS_BIT(8)
99 #define ADRF6780_ADC_VALUE_MSK NO_OS_GENMASK(7, 0)
100 
101 /* Specifications */
102 #define ADRF6780_BUFF_SIZE_BYTES 3
103 #define ADRF6780_SPI_READ_CMD NO_OS_BIT(7)
104 #define ADRF6780_SPI_WRITE_CMD (0 << 7)
105 
106 /******************************************************************************/
107 /*************************** Types Declarations *******************************/
108 /******************************************************************************/
109 
118  unsigned long long lo_in;
126  bool lo_x2_en;
128  bool lo_en;
135 };
136 
141 struct adrf6780_dev {
145  unsigned long long lo_in;
153  bool lo_x2_en;
155  bool lo_en;
162 };
163 
164 /******************************************************************************/
165 /************************ Functions Declarations ******************************/
166 /******************************************************************************/
167 
169 int adrf6780_spi_write(struct adrf6780_dev *dev, uint8_t reg_addr,
170  uint16_t data);
171 
172 /* ADRF6780 Register Update */
173 int adrf6780_spi_update_bits(struct adrf6780_dev *dev, uint8_t reg_addr,
174  uint16_t mask, uint16_t data);
175 
177 int adrf6780_spi_read(struct adrf6780_dev *dev, uint8_t reg_addr,
178  uint16_t *data);
179 
181 int adrf6780_set_rdac_linearize(struct adrf6780_dev *dev, uint8_t rdac_lin);
182 
184 int adrf6780_get_rdac_linearize(struct adrf6780_dev *dev, uint8_t *rdac_lin);
185 
188  uint8_t i_data, uint8_t q_data);
189 
192  uint8_t *i_data, uint8_t *q_data);
193 
195 int adrf6780_read_adc_raw(struct adrf6780_dev *dev, uint16_t *data);
196 
197 /* Software Reset */
198 int adrf6780_soft_reset(struct adrf6780_dev *dev);
199 
201 int adrf6780_init(struct adrf6780_dev **device,
203 
205 int adrf6780_remove(struct adrf6780_dev *dev);
206 
207 #endif /* ADRF6780_H_ */
adrf6780_dev::if_mode_en
bool if_mode_en
Definition: adrf6780.h:151
no_os_alloc.h
adrf6780_spi_update_bits
int adrf6780_spi_update_bits(struct adrf6780_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
Update ADRF6780 register.
Definition: adrf6780.c:109
ADRF6780_LO_X2_EN_MSK
#define ADRF6780_LO_X2_EN_MSK
Definition: adrf6780.h:78
ADRF6780_BUFF_SIZE_BYTES
#define ADRF6780_BUFF_SIZE_BYTES
Definition: adrf6780.h:102
adrf6780_spi_write
int adrf6780_spi_write(struct adrf6780_dev *dev, uint8_t reg_addr, uint16_t data)
Writes data to ADRF6780 over SPI.
Definition: adrf6780.c:54
adrf6780_dev::vga_buff_en
bool vga_buff_en
Definition: adrf6780.h:147
adrf6780_dev::lo_x2_en
bool lo_x2_en
Definition: adrf6780.h:153
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
no_os_spi.h
Header file of SPI Interface.
ADRF6780_REG_ADC_OUTPUT
#define ADRF6780_REG_ADC_OUTPUT
Definition: adrf6780.h:57
adrf6780_dev::lo_sideband
bool lo_sideband
Definition: adrf6780.h:159
ADRF6780_LO_BUFFER_EN_MSK
#define ADRF6780_LO_BUFFER_EN_MSK
Definition: adrf6780.h:75
adrf6780_dev::lo_en
bool lo_en
Definition: adrf6780.h:155
adrf6780_init_param::lo_en
bool lo_en
Definition: adrf6780.h:128
adrf6780_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: adrf6780.h:143
ADRF6780_REG_ENABLE
#define ADRF6780_REG_ENABLE
Definition: adrf6780.h:53
ADRF6780_SPI_READ_CMD
#define ADRF6780_SPI_READ_CMD
Definition: adrf6780.h:103
ADRF6780_LO_PPF_EN_MSK
#define ADRF6780_LO_PPF_EN_MSK
Definition: adrf6780.h:79
no_os_delay.h
Header file of Delay functions.
adrf6780_spi_read
int adrf6780_spi_read(struct adrf6780_dev *dev, uint8_t reg_addr, uint16_t *data)
Reads data from ADRF6780 over SPI.
Definition: adrf6780.c:78
adrf6780_init
int adrf6780_init(struct adrf6780_dev **device, struct adrf6780_init_param *init_param)
Initializes the adrf6780.
Definition: adrf6780.c:270
ADRF6780_CHIP_ID
#define ADRF6780_CHIP_ID
Definition: adrf6780.h:63
adrf6780_read_adc_raw
int adrf6780_read_adc_raw(struct adrf6780_dev *dev, uint16_t *data)
Read ADC raw data.
Definition: adrf6780.c:211
adrf6780_spi_read
int adrf6780_spi_read(struct adrf6780_dev *dev, uint8_t reg_addr, uint16_t *data)
Reads data from ADRF6780 over SPI.
Definition: adrf6780.c:78
device
Definition: ad9361_util.h:69
ADRF6780_Q_PATH_PHASE_ACCURACY_MSK
#define ADRF6780_Q_PATH_PHASE_ACCURACY_MSK
Definition: adrf6780.h:88
adrf6780_init_param::lo_x2_en
bool lo_x2_en
Definition: adrf6780.h:126
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
adrf6780_read_adc_raw
int adrf6780_read_adc_raw(struct adrf6780_dev *dev, uint16_t *data)
Read ADC raw data.
Definition: adrf6780.c:211
adrf6780_init_param::vga_buff_en
bool vga_buff_en
Definition: adrf6780.h:120
adrf6780_get_rdac_linearize
int adrf6780_get_rdac_linearize(struct adrf6780_dev *dev, uint8_t *rdac_lin)
Get IMD Performance Improvement.
Definition: adrf6780.c:143
adrf6780_remove
int adrf6780_remove(struct adrf6780_dev *dev)
ADRF6780 Resources Deallocation.
Definition: adrf6780.c:365
adrf6780_spi_update_bits
int adrf6780_spi_update_bits(struct adrf6780_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
Update ADRF6780 register.
Definition: adrf6780.c:109
adrf6780_init_param::lo_sideband
bool lo_sideband
Definition: adrf6780.h:132
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
adrf6780_get_rdac_linearize
int adrf6780_get_rdac_linearize(struct adrf6780_dev *dev, uint8_t *rdac_lin)
Get IMD Performance Improvement.
Definition: adrf6780.c:143
adrf6780_dev::vdet_out_en
bool vdet_out_en
Definition: adrf6780.h:161
ADRF6780_REG_LINEARIZE
#define ADRF6780_REG_LINEARIZE
Definition: adrf6780.h:54
no_os_error.h
Error codes definition.
adrf6780_remove
int adrf6780_remove(struct adrf6780_dev *dev)
ADRF6780 Resources Deallocation.
Definition: adrf6780.c:365
adrf6780_init_param
ADRF6780 Initialization Parameters structure.
Definition: adrf6780.h:114
ADRF6780_SPI_WRITE_CMD
#define ADRF6780_SPI_WRITE_CMD
Definition: adrf6780.h:104
adrf6780_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: adrf6780.h:116
ADRF6780_ADC_EN_MSK
#define ADRF6780_ADC_EN_MSK
Definition: adrf6780.h:94
adrf6780_init_param::lo_buff_en
bool lo_buff_en
Definition: adrf6780.h:122
adrf6780_get_cdac_iq_phase_accuracy
int adrf6780_get_cdac_iq_phase_accuracy(struct adrf6780_dev *dev, uint8_t *i_data, uint8_t *q_data)
Get I/Q Phase Accuracy.
Definition: adrf6780.c:189
adrf6780_dev::lo_in
unsigned long long lo_in
Definition: adrf6780.h:145
ADRF6780_CHIP_ID_MSK
#define ADRF6780_CHIP_ID_MSK
Definition: adrf6780.h:62
adrf6780_init_param::lo_in
unsigned long long lo_in
Definition: adrf6780.h:118
ADRF6780_SOFT_RESET_MSK
#define ADRF6780_SOFT_RESET_MSK
Definition: adrf6780.h:61
adrf6780_get_cdac_iq_phase_accuracy
int adrf6780_get_cdac_iq_phase_accuracy(struct adrf6780_dev *dev, uint8_t *i_data, uint8_t *q_data)
Get I/Q Phase Accuracy.
Definition: adrf6780.c:189
ADRF6780_VDET_OUTPUT_SELECT_MSK
#define ADRF6780_VDET_OUTPUT_SELECT_MSK
Definition: adrf6780.h:92
ADRF6780_LO_SIDEBAND_MSK
#define ADRF6780_LO_SIDEBAND_MSK
Definition: adrf6780.h:87
ADRF6780_ADC_STATUS_MSK
#define ADRF6780_ADC_STATUS_MSK
Definition: adrf6780.h:98
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
adrf6780_init_param::vdet_out_en
bool vdet_out_en
Definition: adrf6780.h:134
ADRF6780_REG_LO_PATH
#define ADRF6780_REG_LO_PATH
Definition: adrf6780.h:55
adrf6780_dev::lo_buff_en
bool lo_buff_en
Definition: adrf6780.h:149
ADRF6780_UC_BIAS_EN_MSK
#define ADRF6780_UC_BIAS_EN_MSK
Definition: adrf6780.h:81
ADRF6780_LO_EN_MSK
#define ADRF6780_LO_EN_MSK
Definition: adrf6780.h:80
adrf6780_init_param::if_mode_en
bool if_mode_en
Definition: adrf6780.h:124
ADRF6780_DETECTOR_EN_MSK
#define ADRF6780_DETECTOR_EN_MSK
Definition: adrf6780.h:74
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
ADRF6780_VGA_BUFFER_EN_MSK
#define ADRF6780_VGA_BUFFER_EN_MSK
Definition: adrf6780.h:73
adrf6780_init_param::uc_bias_en
bool uc_bias_en
Definition: adrf6780.h:130
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
adrf6780_init
int adrf6780_init(struct adrf6780_dev **device, struct adrf6780_init_param *init_param)
Initializes the adrf6780.
Definition: adrf6780.c:270
adrf6780_set_cdac_iq_phase_accuracy
int adrf6780_set_cdac_iq_phase_accuracy(struct adrf6780_dev *dev, uint8_t i_data, uint8_t q_data)
Set I/Q Phase Accuracy.
Definition: adrf6780.c:164
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
ADRF6780_ADC_START_MSK
#define ADRF6780_ADC_START_MSK
Definition: adrf6780.h:93
ADRF6780_ADC_CLOCK_EN_MSK
#define ADRF6780_ADC_CLOCK_EN_MSK
Definition: adrf6780.h:95
adrf6780_dev::uc_bias_en
bool uc_bias_en
Definition: adrf6780.h:157
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
adrf6780_spi_write
int adrf6780_spi_write(struct adrf6780_dev *dev, uint8_t reg_addr, uint16_t data)
Writes data to ADRF6780 over SPI.
Definition: adrf6780.c:54
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
ADRF6780_I_PATH_PHASE_ACCURACY_MSK
#define ADRF6780_I_PATH_PHASE_ACCURACY_MSK
Definition: adrf6780.h:89
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
adrf6780_set_cdac_iq_phase_accuracy
int adrf6780_set_cdac_iq_phase_accuracy(struct adrf6780_dev *dev, uint8_t i_data, uint8_t q_data)
Set I/Q Phase Accuracy.
Definition: adrf6780.c:164
adrf6780_set_rdac_linearize
int adrf6780_set_rdac_linearize(struct adrf6780_dev *dev, uint8_t rdac_lin)
Set IMD Performance Improvement.
Definition: adrf6780.c:131
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
ADRF6780_IF_MODE_EN_MSK
#define ADRF6780_IF_MODE_EN_MSK
Definition: adrf6780.h:76
adrf6780_dev
ADRF6780 Device Descriptor.
Definition: adrf6780.h:141
adrf6780_soft_reset
int adrf6780_soft_reset(struct adrf6780_dev *dev)
Software Reset.
Definition: adrf6780.c:249
no_os_util.h
Header file of utility functions.
ADRF6780_REG_CONTROL
#define ADRF6780_REG_CONTROL
Definition: adrf6780.h:50
ADRF6780_IQ_MODE_EN_MSK
#define ADRF6780_IQ_MODE_EN_MSK
Definition: adrf6780.h:77
adrf6780_soft_reset
int adrf6780_soft_reset(struct adrf6780_dev *dev)
Software Reset.
Definition: adrf6780.c:249
adrf6780.h
Header file for adrf6780 Driver.
ADRF6780_REG_ADC_CONTROL
#define ADRF6780_REG_ADC_CONTROL
Definition: adrf6780.h:56
adrf6780_set_rdac_linearize
int adrf6780_set_rdac_linearize(struct adrf6780_dev *dev, uint8_t rdac_lin)
Set IMD Performance Improvement.
Definition: adrf6780.c:131
chip_id
chip_id
Definition: ad9172.h:51
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
ADRF6780_RDAC_LINEARIZE_MSK
#define ADRF6780_RDAC_LINEARIZE_MSK
Definition: adrf6780.h:84