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
63typedef enum
64{
68
72typedef enum
73{
77
88
92typedef struct ad9833_handle_s
93{
94 uint8_t (*spi_init)(void);
95 uint8_t (*spi_deinit)(void);
96 uint8_t (*spi_write_cmd)(uint8_t *buf, uint16_t len);
97 void (*delay_ms)(uint32_t ms);
98 void (*debug_print)(const char *const fmt, ...);
99 uint8_t inited;
100 uint16_t conf;
102
118
122
129
136#define DRIVER_AD9833_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
137
144#define DRIVER_AD9833_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
145
152#define DRIVER_AD9833_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
153
160#define DRIVER_AD9833_LINK_SPI_WRITE_CMD(HANDLE, FUC) (HANDLE)->spi_write_cmd = FUC
161
168#define DRIVER_AD9833_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
169
176#define DRIVER_AD9833_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
177
181
188
197uint8_t ad9833_info(ad9833_info_t *info);
198
210uint8_t ad9833_init(ad9833_handle_t *handle);
211
223uint8_t ad9833_deinit(ad9833_handle_t *handle);
224
237
250
264uint8_t ad9833_set_frequency(ad9833_handle_t *handle, ad9833_number_t number, uint32_t freq);
265
279uint8_t ad9833_set_frequency_lsb(ad9833_handle_t *handle, ad9833_number_t number, uint16_t freq);
280
294uint8_t ad9833_set_frequency_msb(ad9833_handle_t *handle, ad9833_number_t number, uint16_t freq);
295
307uint8_t ad9833_frequency_convert_to_register(ad9833_handle_t *handle, double hz, uint32_t *reg);
308
320uint8_t ad9833_frequency_convert_to_data(ad9833_handle_t *handle, uint32_t reg, double *hz);
321
335uint8_t ad9833_set_phase(ad9833_handle_t *handle, ad9833_number_t number, uint16_t phase);
336
348uint8_t ad9833_phase_convert_to_register(ad9833_handle_t *handle, double rad, uint16_t *reg);
349
361uint8_t ad9833_phase_convert_to_data(ad9833_handle_t *handle, uint16_t reg, double *rad);
362
373uint8_t ad9833_reset(ad9833_handle_t *handle);
374
387
400
413
417
424
436uint8_t ad9833_set_reg(ad9833_handle_t *handle, uint16_t value);
437
441
445
446#ifdef __cplusplus
447}
448#endif
449
450#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]