42#define CHIP_NAME "Analog Devices AD9833"
43#define MANUFACTURER_NAME "Analog Devices"
44#define SUPPLY_VOLTAGE_MIN 2.3f
45#define SUPPLY_VOLTAGE_MAX 5.5f
46#define MAX_CURRENT 5.5f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 85.0f
49#define DRIVER_VERSION 1000
64 buf[0] = (reg >> 8) & 0xFF;
65 buf[1] = (reg >> 0) & 0xFF;
100 handle->
debug_print(
"ad9833: spi_init is null.\n");
106 handle->
debug_print(
"ad9833: spi_deinit is null.\n");
112 handle->
debug_print(
"ad9833: spi_write_cmd is null.\n");
118 handle->
debug_print(
"ad9833: delay_ms is null.\n");
133 res = a_ad9833_spi_write(handle, conf);
136 handle->
debug_print(
"ad9833: write config failed.\n");
142 res = a_ad9833_spi_write(handle, conf);
145 handle->
debug_print(
"ad9833: write config failed.\n");
179 handle->
conf &= ~(1 << 7);
180 handle->
conf |= 1 << 7;
181 handle->
conf &= ~(1 << 6);
182 handle->
conf |= 1 << 6;
185 res = a_ad9833_spi_write(handle, conf);
188 handle->
debug_print(
"ad9833: write config failed.\n");
194 handle->
debug_print(
"ad9833: spi deinit failed.\n");
228 handle->
conf &= ~(1 << 11);
229 handle->
conf |= (number << 11);
232 res = a_ad9833_spi_write(handle, conf);
235 handle->
debug_print(
"ad9833: write config failed.\n");
268 handle->
conf &= ~(1 << 10);
269 handle->
conf |= (number << 10);
272 res = a_ad9833_spi_write(handle, conf);
275 handle->
debug_print(
"ad9833: write config failed.\n");
309 if (freq > 0x0FFFFFFF)
311 handle->
debug_print(
"ad9833: freq > 0x0FFFFFFF.\n");
319 res = a_ad9833_spi_write(handle, conf);
322 handle->
debug_print(
"ad9833: write config failed.\n");
329 conf |= freq & 0x3FFF;
330 res = a_ad9833_spi_write(handle, conf);
333 handle->
debug_print(
"ad9833: write config failed.\n");
338 conf |= (freq >> 14) & 0x3FFF;
339 res = a_ad9833_spi_write(handle, conf);
342 handle->
debug_print(
"ad9833: write config failed.\n");
350 conf |= freq & 0x3FFF;
351 res = a_ad9833_spi_write(handle, conf);
354 handle->
debug_print(
"ad9833: write config failed.\n");
359 conf |= (freq >> 14) & 0x3FFF;
360 res = a_ad9833_spi_write(handle, conf);
363 handle->
debug_print(
"ad9833: write config failed.\n");
409 res = a_ad9833_spi_write(handle, conf);
412 handle->
debug_print(
"ad9833: write config failed.\n");
420 res = a_ad9833_spi_write(handle, conf);
423 handle->
debug_print(
"ad9833: write config failed.\n");
432 res = a_ad9833_spi_write(handle, conf);
435 handle->
debug_print(
"ad9833: write config failed.\n");
481 res = a_ad9833_spi_write(handle, conf);
484 handle->
debug_print(
"ad9833: write config failed.\n");
492 res = a_ad9833_spi_write(handle, conf);
495 handle->
debug_print(
"ad9833: write config failed.\n");
504 res = a_ad9833_spi_write(handle, conf);
507 handle->
debug_print(
"ad9833: write config failed.\n");
553 conf |= phase & 0x0FFF;
554 res = a_ad9833_spi_write(handle, conf);
557 handle->
debug_print(
"ad9833: write config failed.\n");
566 conf |= phase & 0x0FFF;
567 res = a_ad9833_spi_write(handle, conf);
570 handle->
debug_print(
"ad9833: write config failed.\n");
606 res = a_ad9833_spi_write(handle, conf);
609 handle->
debug_print(
"ad9833: write config failed.\n");
615 res = a_ad9833_spi_write(handle, conf);
618 handle->
debug_print(
"ad9833: write config failed.\n");
651 handle->
conf &= ~(1 << 6);
652 handle->
conf |= enable << 6;
655 res = a_ad9833_spi_write(handle, conf);
658 handle->
debug_print(
"ad9833: write config failed.\n");
691 handle->
conf &= ~(1 << 7);
692 handle->
conf |= enable << 7;
695 res = a_ad9833_spi_write(handle, conf);
698 handle->
debug_print(
"ad9833: write config failed.\n");
732 handle->
conf &= ~(1 << 5);
733 handle->
conf &= ~(1 << 3);
734 handle->
conf &= ~(1 << 1);
736 handle->
conf |= (((c >> 2) & 0x1) << 5);
737 handle->
conf |= (((c >> 0) & 0x1) << 3);
738 handle->
conf |= (((c >> 1) & 0x1) << 1);
741 res = a_ad9833_spi_write(handle, conf);
744 handle->
debug_print(
"ad9833: write config failed.\n");
774 *reg = (uint32_t)(hz / (25000000.0 / pow(2, 28)));
801 *hz = (double)reg * (25000000.0 / pow(2, 28));
828 *reg = (uint32_t)(rad / ((2.0 * 3.14159265357) / 4096.0));
855 *rad = (double)reg * ((2.0 * 3.14159265357) / 4096.0);
884 res = a_ad9833_spi_write(handle, value);
887 handle->
debug_print(
"ad9833: write config failed.\n");
#define SUPPLY_VOLTAGE_MAX
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
driver ad9833 header file
uint8_t ad9833_set_internal_clock_disable(ad9833_handle_t *handle, ad9833_bool_t enable)
enable or disable internal clock disable
ad9833_bool_t
ad9833 bool enumeration definition
uint8_t ad9833_set_frequency_lsb(ad9833_handle_t *handle, ad9833_number_t number, uint16_t freq)
set the frequency lsb
uint8_t ad9833_frequency_convert_to_register(ad9833_handle_t *handle, double hz, uint32_t *reg)
convert the frequency to the register raw data
ad9833_number_t
ad9833 number enumeration definition
uint8_t ad9833_set_frequency_msb(ad9833_handle_t *handle, ad9833_number_t number, uint16_t freq)
set the frequency msb
uint8_t ad9833_set_dac_power_down(ad9833_handle_t *handle, ad9833_bool_t enable)
enable or disable dac power down
struct ad9833_handle_s ad9833_handle_t
ad9833 handle structure definition
uint8_t ad9833_set_used_frequency_register(ad9833_handle_t *handle, ad9833_number_t number)
set the used frequency register
uint8_t ad9833_phase_convert_to_register(ad9833_handle_t *handle, double rad, uint16_t *reg)
convert the phase to the register raw data
struct ad9833_info_s ad9833_info_t
ad9833 information structure definition
uint8_t ad9833_phase_convert_to_data(ad9833_handle_t *handle, uint16_t reg, double *rad)
convert the register raw data to phase
uint8_t ad9833_set_output_mode(ad9833_handle_t *handle, ad9833_output_mode_t mode)
set output mode
uint8_t ad9833_init(ad9833_handle_t *handle)
initialize the chip
ad9833_output_mode_t
ad9833 output mode enumeration definition
uint8_t ad9833_set_frequency(ad9833_handle_t *handle, ad9833_number_t number, uint32_t freq)
set the frequency
uint8_t ad9833_reset(ad9833_handle_t *handle)
reset the chip
uint8_t ad9833_deinit(ad9833_handle_t *handle)
close the chip
uint8_t ad9833_set_used_phase_register(ad9833_handle_t *handle, ad9833_number_t number)
set the used phase register
uint8_t ad9833_set_phase(ad9833_handle_t *handle, ad9833_number_t number, uint16_t phase)
set the phase
uint8_t ad9833_info(ad9833_info_t *info)
get chip's information
uint8_t ad9833_frequency_convert_to_data(ad9833_handle_t *handle, uint32_t reg, double *hz)
convert the register raw data to frequency
uint8_t ad9833_set_reg(ad9833_handle_t *handle, uint16_t value)
set the chip register
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_deinit)(void)
uint8_t(* spi_write_cmd)(uint8_t *buf, uint16_t len)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v