no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad9833.h
Go to the documentation of this file.
1/***************************************************************************/
33#ifndef _AD9833_H_
34#define _AD9833_H_
35
36#include <stdint.h>
37#include "no_os_delay.h"
38#include "no_os_gpio.h"
39#include "no_os_spi.h"
40
41#define AD9833_CTRLB28 (1 << 13)
42#define AD9833_CTRLHLB (1 << 12)
43#define AD9833_CTRLFSEL (1 << 11)
44#define AD9833_CTRLPSEL (1 << 10)
45#define AD9834_CTRLPINSW (1 << 9)
46#define AD9833_CTRLRESET (1 << 8)
47#define AD9833_CTRLSLEEP1 (1 << 7)
48#define AD9833_CTRLSLEEP12 (1 << 6)
49#define AD9833_CTRLOPBITEN (1 << 5)
50#define AD9834_CTRLSIGNPIB (1 << 4)
51#define AD9833_CTRLDIV2 (1 << 3)
52#define AD9833_CTRLMODE (1 << 1)
53
54/* GPIOs */
55#define AD9834_PSEL_OUT no_os_gpio_direction_output(dev->gpio_psel, \
56 NO_OS_GPIO_HIGH)
57#define AD9834_PSEL_LOW no_os_gpio_set_value(dev->gpio_psel, \
58 NO_OS_GPIO_LOW)
59#define AD9834_PSEL_HIGH no_os_gpio_set_value(dev->gpio_psel, \
60 NO_OS_GPIO_HIGH)
61
62#define AD9834_FSEL_OUT no_os_gpio_direction_output(dev->gpio_fsel, \
63 NO_OS_GPIO_HIGH)
64#define AD9834_FSEL_LOW no_os_gpio_set_value(dev->gpio_fsel, \
65 NO_OS_GPIO_LOW)
66#define AD9834_FSEL_HIGH no_os_gpio_set_value(dev->gpio_fsel, \
67 NO_OS_GPIO_HIGH)
68
69#define AD9834_RESET_OUT no_os_gpio_direction_output(dev->gpio_reset, \
70 NO_OS_GPIO_HIGH)
71#define AD9834_RESET_LOW no_os_gpio_set_value(dev->gpio_reset, \
72 NO_OS_GPIO_LOW)
73#define AD9834_RESET_HIGH pio_set_value(dev->gpio_reset, \
74 NO_OS_GPIO_HIGH)
75
76#define AD9834_SLEEP_OUT no_os_gpio_direction_output(dev->gpio_sleep, \
77 NO_OS_GPIO_HIGH)
78#define AD9834_SLEEP_LOW no_os_gpio_set_value(dev->gpio_sleep, \
79 NO_OS_GPIO_LOW)
80#define AD9834_SLEEP_HIGH no_os_gpio_set_value(dev->gpio_sleep, \
81 NO_OS_GPIO_HIGH)
82
83
84#define BIT_F0ADDRESS 0x4000 // Frequency Register 0 address.
85#define BIT_F1ADDRESS 0x8000 // Frequency Register 1 address.
86#define BIT_P0ADDRESS 0xC000 // Phase Register 0 address.
87#define BIT_P1ADDRESS 0xE000 // Phase Register 1 address.
88
89/* Supported devices */
96
97struct ad9833_dev {
98 /* SPI */
100 /* GPIO */
105 /* Device Settings */
107 uint8_t prog_method;
109 uint16_t test_opbiten;
110};
111
123
125 uint32_t mclk;
127};
128
129/* Initialize the SPI communication with the device. */
130int8_t ad9833_init(struct ad9833_dev **device,
132/* Free the resources allocated by adf7023_init(). */
133int32_t ad9833_remove(struct ad9833_dev *dev);
134/* Transmits 16 bits on SPI. */
135void ad9833_tx_spi(struct ad9833_dev *dev,
136 int16_t value);
137/* Selects the type of output. */
138int8_t ad9833_out_mode(struct ad9833_dev *dev,
139 uint8_t v_out_mode);
140/* Loads a frequency value in a register. */
141void ad9833_set_freq(struct ad9833_dev *dev,
142 uint8_t register_number,
143 uint32_t frequency_value);
144/* Loads a phase value in a register. */
145void ad9833_set_phase(struct ad9833_dev *dev,
146 uint8_t register_number,
147 float phase_value);
148/* Select the frequency register to be used. */
149void ad9833_select_freq_reg(struct ad9833_dev *dev,
150 uint8_t freq_reg);
151/* Select the phase register to be used. */
152void ad9833_select_phase_reg(struct ad9833_dev *dev,
153 uint8_t phase_reg);
154/* Enable / Disable the sleep function. */
155void ad9833_sleep_mode(struct ad9833_dev *dev,
156 uint8_t sleep_mode);
157
159 uint8_t value);
160
161void ad9834_logic_output(struct ad9833_dev *dev,
162 uint8_t opbiten,
163 uint8_t signpib,
164 uint8_t div2);
165
166#endif /* _AD9833_H_ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
void ad9834_select_prog_method(struct ad9833_dev *dev, uint8_t value)
Sets the programming method. (only for AD9834 & AD9838)
Definition ad9833.c:438
void ad9833_select_phase_reg(struct ad9833_dev *dev, uint8_t phase_reg)
Select the phase register to be used.
Definition ad9833.c:403
void ad9833_select_freq_reg(struct ad9833_dev *dev, uint8_t freq_reg)
Select the frequency register to be used.
Definition ad9833.c:368
void ad9833_set_phase(struct ad9833_dev *dev, uint8_t register_number, float phase_value)
Loads a phase value in a register.
Definition ad9833.c:345
int32_t ad9833_remove(struct ad9833_dev *dev)
Free the resources allocated by ad9833_init().
Definition ad9833.c:135
void ad9833_tx_spi(struct ad9833_dev *dev, int16_t value)
Transmits 16 bits on SPI.
Definition ad9833.c:158
int8_t ad9833_out_mode(struct ad9833_dev *dev, uint8_t v_out_mode)
Selects the type of output.
Definition ad9833.c:194
int8_t ad9833_init(struct ad9833_dev **device, struct ad9833_init_param init_param)
Initialize the SPI communication with the device.
Definition ad9833.c:71
void ad9833_set_freq(struct ad9833_dev *dev, uint8_t register_number, uint32_t frequency_value)
Loads a frequency value in a register.
Definition ad9833.c:310
ad9833_type
Definition ad9833.h:90
@ ID_AD9837
Definition ad9833.h:93
@ ID_AD9838
Definition ad9833.h:94
@ ID_AD9834
Definition ad9833.h:92
@ ID_AD9833
Definition ad9833.h:91
void ad9833_sleep_mode(struct ad9833_dev *dev, uint8_t sleep_mode)
Enable / Disable the sleep function.
Definition ad9833.c:262
void ad9834_logic_output(struct ad9833_dev *dev, uint8_t opbiten, uint8_t signpib, uint8_t div2)
Configures the control register for logic output. (only for AD9834 & AD9838)
Definition ad9833.c:463
Header file of Delay functions.
Header file of GPIO Interface.
Header file of SPI Interface.
Definition ad9833.h:124
uint32_t mclk
Definition ad9833.h:125
float freq_const
Definition ad9833.h:126
Definition ad9833.h:97
struct no_os_gpio_desc * gpio_fsel
Definition ad9833.h:102
uint16_t test_opbiten
Definition ad9833.h:109
struct no_os_gpio_desc * gpio_sleep
Definition ad9833.h:104
struct no_os_gpio_desc * gpio_psel
Definition ad9833.h:101
uint16_t ctrl_reg_value
Definition ad9833.h:108
uint8_t prog_method
Definition ad9833.h:107
struct no_os_gpio_desc * gpio_reset
Definition ad9833.h:103
struct no_os_spi_desc * spi_desc
Definition ad9833.h:99
enum ad9833_type act_device
Definition ad9833.h:106
Definition ad9833.h:112
enum ad9833_type act_device
Definition ad9833.h:121
struct no_os_spi_init_param spi_init
Definition ad9833.h:114
struct no_os_gpio_init_param gpio_sleep
Definition ad9833.h:119
struct no_os_gpio_init_param gpio_psel
Definition ad9833.h:116
struct no_os_gpio_init_param gpio_reset
Definition ad9833.h:118
struct no_os_gpio_init_param gpio_fsel
Definition ad9833.h:117
Definition ad9361_util.h:63
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128