LibDriver AD9833
Loading...
Searching...
No Matches
driver_ad9833.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_AD9833_H
38#define DRIVER_AD9833_H
39
40#include <math.h>
41#include <stdio.h>
42#include <stdint.h>
43#include <string.h>
44
45#ifdef __cplusplus
46extern "C"{
47#endif
48
54
59
63#ifndef AD9833_CRYSTAL_HZ
64 #define AD9833_CRYSTAL_HZ 25000000.0 /* 25.0MHz */
65#endif
66
70typedef enum
71{
75
79typedef enum
80{
84
95
99typedef struct ad9833_handle_s
100{
101 uint8_t (*spi_init)(void);
102 uint8_t (*spi_deinit)(void);
103 uint8_t (*spi_write_cmd)(uint8_t *buf, uint16_t len);
104 void (*delay_ms)(uint32_t ms);
105 void (*debug_print)(const char *const fmt, ...);
106 uint8_t inited;
107 uint16_t conf;
109
125
129
136
143#define DRIVER_AD9833_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
144
151#define DRIVER_AD9833_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
152
159#define DRIVER_AD9833_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
160
167#define DRIVER_AD9833_LINK_SPI_WRITE_CMD(HANDLE, FUC) (HANDLE)->spi_write_cmd = FUC
168
175#define DRIVER_AD9833_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
176
183#define DRIVER_AD9833_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
184
188
195
204uint8_t ad9833_info(ad9833_info_t *info);
205
217uint8_t ad9833_init(ad9833_handle_t *handle);
218
230uint8_t ad9833_deinit(ad9833_handle_t *handle);
231
244
257
271uint8_t ad9833_set_frequency(ad9833_handle_t *handle, ad9833_number_t number, uint32_t freq);
272
286uint8_t ad9833_set_frequency_lsb(ad9833_handle_t *handle, ad9833_number_t number, uint16_t freq);
287
301uint8_t ad9833_set_frequency_msb(ad9833_handle_t *handle, ad9833_number_t number, uint16_t freq);
302
314uint8_t ad9833_frequency_convert_to_register(ad9833_handle_t *handle, double hz, uint32_t *reg);
315
327uint8_t ad9833_frequency_convert_to_data(ad9833_handle_t *handle, uint32_t reg, double *hz);
328
342uint8_t ad9833_set_phase(ad9833_handle_t *handle, ad9833_number_t number, uint16_t phase);
343
355uint8_t ad9833_phase_convert_to_register(ad9833_handle_t *handle, double rad, uint16_t *reg);
356
368uint8_t ad9833_phase_convert_to_data(ad9833_handle_t *handle, uint16_t reg, double *rad);
369
380uint8_t ad9833_reset(ad9833_handle_t *handle);
381
394
407
420
424
431
443uint8_t ad9833_set_reg(ad9833_handle_t *handle, uint16_t value);
444
448
452
453#ifdef __cplusplus
454}
455#endif
456
457#endif
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
@ AD9833_BOOL_FALSE
@ AD9833_BOOL_TRUE
@ AD9833_NUMBER_0
@ AD9833_NUMBER_1
@ AD9833_OUTPUT_MODE_SIN
@ AD9833_OUTPUT_MODE_DAC_HALF
@ AD9833_OUTPUT_MODE_TRI
@ AD9833_OUTPUT_MODE_DAC
uint8_t ad9833_set_reg(ad9833_handle_t *handle, uint16_t value)
set the chip register
ad9833 handle structure definition
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)
ad9833 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]