no-OS
Classes | Macros | Enumerations | Functions
ad9833.h File Reference

Header file of AD9833 Driver for Microblaze processor. More...

#include <stdint.h>
#include "no-os/delay.h"
#include "no-os/gpio.h"
#include "no-os/spi.h"
Include dependency graph for ad9833.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ad9833_dev
 
struct  ad9833_init_param
 
struct  ad9833_chip_info
 

Macros

#define AD9833_CTRLB28   (1 << 13)
 
#define AD9833_CTRLHLB   (1 << 12)
 
#define AD9833_CTRLFSEL   (1 << 11)
 
#define AD9833_CTRLPSEL   (1 << 10)
 
#define AD9834_CTRLPINSW   (1 << 9)
 
#define AD9833_CTRLRESET   (1 << 8)
 
#define AD9833_CTRLSLEEP1   (1 << 7)
 
#define AD9833_CTRLSLEEP12   (1 << 6)
 
#define AD9833_CTRLOPBITEN   (1 << 5)
 
#define AD9834_CTRLSIGNPIB   (1 << 4)
 
#define AD9833_CTRLDIV2   (1 << 3)
 
#define AD9833_CTRLMODE   (1 << 1)
 
#define AD9834_PSEL_OUT
 
#define AD9834_PSEL_LOW
 
#define AD9834_PSEL_HIGH
 
#define AD9834_FSEL_OUT
 
#define AD9834_FSEL_LOW
 
#define AD9834_FSEL_HIGH
 
#define AD9834_RESET_OUT
 
#define AD9834_RESET_LOW
 
#define AD9834_RESET_HIGH
 
#define AD9834_SLEEP_OUT
 
#define AD9834_SLEEP_LOW
 
#define AD9834_SLEEP_HIGH
 
#define BIT_F0ADDRESS   0x4000
 
#define BIT_F1ADDRESS   0x8000
 
#define BIT_P0ADDRESS   0xC000
 
#define BIT_P1ADDRESS   0xE000
 

Enumerations

enum  ad9833_type {
  ID_AD9833,
  ID_AD9834,
  ID_AD9837,
  ID_AD9838
}
 

Functions

int8_t ad9833_init (struct ad9833_dev **device, struct ad9833_init_param init_param)
 Initialize the SPI communication with the device. More...
 
int32_t ad9833_remove (struct ad9833_dev *dev)
 Free the resources allocated by ad9833_init(). More...
 
void ad9833_tx_spi (struct ad9833_dev *dev, int16_t value)
 Transmits 16 bits on SPI. More...
 
int8_t ad9833_out_mode (struct ad9833_dev *dev, uint8_t v_out_mode)
 Selects the type of output. More...
 
void ad9833_set_freq (struct ad9833_dev *dev, uint8_t register_number, uint32_t frequency_value)
 Loads a frequency value in a register. More...
 
void ad9833_set_phase (struct ad9833_dev *dev, uint8_t register_number, float phase_value)
 Loads a phase value in a register. More...
 
void ad9833_select_freq_reg (struct ad9833_dev *dev, uint8_t freq_reg)
 Select the frequency register to be used. More...
 
void ad9833_select_phase_reg (struct ad9833_dev *dev, uint8_t phase_reg)
 Select the phase register to be used. More...
 
void ad9833_sleep_mode (struct ad9833_dev *dev, uint8_t sleep_mode)
 Enable / Disable the sleep function. More...
 
void ad9834_select_prog_method (struct ad9833_dev *dev, uint8_t value)
 Sets the programming method. (only for AD9834 & AD9838) More...
 
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) More...
 

Detailed Description

Header file of AD9833 Driver for Microblaze processor.

Author
Lucian Sin (Lucia.nosp@m.n.Si.nosp@m.n@ana.nosp@m.log..nosp@m.com)

Copyright 2013(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ AD9833_CTRLB28

#define AD9833_CTRLB28   (1 << 13)

◆ AD9833_CTRLDIV2

#define AD9833_CTRLDIV2   (1 << 3)

◆ AD9833_CTRLFSEL

#define AD9833_CTRLFSEL   (1 << 11)

◆ AD9833_CTRLHLB

#define AD9833_CTRLHLB   (1 << 12)

◆ AD9833_CTRLMODE

#define AD9833_CTRLMODE   (1 << 1)

◆ AD9833_CTRLOPBITEN

#define AD9833_CTRLOPBITEN   (1 << 5)

◆ AD9833_CTRLPSEL

#define AD9833_CTRLPSEL   (1 << 10)

◆ AD9833_CTRLRESET

#define AD9833_CTRLRESET   (1 << 8)

◆ AD9833_CTRLSLEEP1

#define AD9833_CTRLSLEEP1   (1 << 7)

◆ AD9833_CTRLSLEEP12

#define AD9833_CTRLSLEEP12   (1 << 6)

◆ AD9834_CTRLPINSW

#define AD9834_CTRLPINSW   (1 << 9)

◆ AD9834_CTRLSIGNPIB

#define AD9834_CTRLSIGNPIB   (1 << 4)

◆ AD9834_FSEL_HIGH

#define AD9834_FSEL_HIGH
Value:
gpio_set_value(dev->gpio_fsel, \

◆ AD9834_FSEL_LOW

#define AD9834_FSEL_LOW
Value:
gpio_set_value(dev->gpio_fsel, \

◆ AD9834_FSEL_OUT

#define AD9834_FSEL_OUT
Value:
gpio_direction_output(dev->gpio_fsel, \

◆ AD9834_PSEL_HIGH

#define AD9834_PSEL_HIGH
Value:
gpio_set_value(dev->gpio_psel, \

◆ AD9834_PSEL_LOW

#define AD9834_PSEL_LOW
Value:
gpio_set_value(dev->gpio_psel, \

◆ AD9834_PSEL_OUT

#define AD9834_PSEL_OUT
Value:
gpio_direction_output(dev->gpio_psel, \

◆ AD9834_RESET_HIGH

#define AD9834_RESET_HIGH
Value:
pio_set_value(dev->gpio_reset, \

◆ AD9834_RESET_LOW

#define AD9834_RESET_LOW
Value:
gpio_set_value(dev->gpio_reset, \

◆ AD9834_RESET_OUT

#define AD9834_RESET_OUT
Value:
gpio_direction_output(dev->gpio_reset, \

◆ AD9834_SLEEP_HIGH

#define AD9834_SLEEP_HIGH
Value:
gpio_set_value(dev->gpio_sleep, \

◆ AD9834_SLEEP_LOW

#define AD9834_SLEEP_LOW
Value:
gpio_set_value(dev->gpio_sleep, \

◆ AD9834_SLEEP_OUT

#define AD9834_SLEEP_OUT
Value:
gpio_direction_output(dev->gpio_sleep, \

◆ BIT_F0ADDRESS

#define BIT_F0ADDRESS   0x4000

◆ BIT_F1ADDRESS

#define BIT_F1ADDRESS   0x8000

◆ BIT_P0ADDRESS

#define BIT_P0ADDRESS   0xC000

◆ BIT_P1ADDRESS

#define BIT_P1ADDRESS   0xE000

Enumeration Type Documentation

◆ ad9833_type

Enumerator
ID_AD9833 
ID_AD9834 
ID_AD9837 
ID_AD9838 

Function Documentation

◆ ad9833_init()

int8_t ad9833_init ( struct ad9833_dev **  device,
struct ad9833_init_param  init_param 
)

Initialize the SPI communication with the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
status - Result of the initialization procedure. Example: 0 - if initialization was successful; -1 - if initialization was unsuccessful.

◆ ad9833_out_mode()

int8_t ad9833_out_mode ( struct ad9833_dev dev,
uint8_t  out_mode 
)

Selects the type of output.

Parameters
dev- The device structure.
out_mode- type of output Example AD9833&AD9837: 0 - Sinusoid. 1 - Triangle. 2 - DAC Data MSB/2. 3 - DAC Data MSB. Example AD9834&AD9838: 0 - Sinusoid. 1 - Triangle.
Returns
status - output type could / couldn't be selected. Example: 0 - output type possible for the given configuration. -1 - output type not possible for the given configuration.

◆ ad9833_remove()

int32_t ad9833_remove ( struct ad9833_dev dev)

Free the resources allocated by ad9833_init().

Parameters
dev- The device structure.
Returns
SUCCESS in case of success, negative error code otherwise.

◆ ad9833_select_freq_reg()

void ad9833_select_freq_reg ( struct ad9833_dev dev,
uint8_t  freq_reg 
)

Select the frequency register to be used.

Parameters
dev- The device structure.
freq_reg- Number of frequency register. (0 / 1)
Returns
None.

◆ ad9833_select_phase_reg()

void ad9833_select_phase_reg ( struct ad9833_dev dev,
uint8_t  phase_reg 
)

Select the phase register to be used.

Parameters
dev- The device structure.
phase_reg- Number of phase register. (0 / 1)
Returns
None.

◆ ad9833_set_freq()

void ad9833_set_freq ( struct ad9833_dev dev,
uint8_t  register_number,
uint32_t  frequency_value 
)

Loads a frequency value in a register.

Parameters
dev- The device structure.
register_number- Number of the register (0 / 1).
frequency_value- Frequency value.
Returns
None.
Here is the caller graph for this function:

◆ ad9833_set_phase()

void ad9833_set_phase ( struct ad9833_dev dev,
uint8_t  register_number,
float  phase_value 
)

Loads a phase value in a register.

Parameters
dev- The device structure.
register_number- Number of the register (0 / 1).
phase_value- Phase value.
Returns
none
Here is the caller graph for this function:

◆ ad9833_sleep_mode()

void ad9833_sleep_mode ( struct ad9833_dev dev,
uint8_t  sleep_mode 
)

Enable / Disable the sleep function.

Parameters
dev- The device structure.
sleep_mode- type of sleep Example soft method(all devices): 0 - No power-down. 1 - DAC powered down. 2 - Internal clock disabled. 3 - DAC powered down and Internal clock disabled. Example hard method(AD9834 & AD9838): 0 - No power-down. 1 - DAC powered down.
Returns
None.

◆ ad9833_tx_spi()

void ad9833_tx_spi ( struct ad9833_dev dev,
int16_t  value 
)

Transmits 16 bits on SPI.

Parameters
dev- The device structure.
value- Data which will be transmitted.
Returns
none.
Here is the caller graph for this function:

◆ ad9834_logic_output()

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)

Parameters
dev- The device structure.
opbiten- Enables / disables the logic output.
signpib- Connects comparator / MSB to the SIGN BIT OUT pin.
div2- MSB / MSB/2
Returns
None.

◆ ad9834_select_prog_method()

void ad9834_select_prog_method ( struct ad9833_dev dev,
uint8_t  value 
)

Sets the programming method. (only for AD9834 & AD9838)

Parameters
dev- The device structure.
value- soft or hard method. (0 / 1)
Returns
None.
gpio_direction_output
int32_t gpio_direction_output(struct gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: gpio.c:124
GPIO_LOW
@ GPIO_LOW
Definition: gpio.h:99
gpio_set_value
int32_t gpio_set_value(struct gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: gpio.c:160
GPIO_HIGH
@ GPIO_HIGH
Definition: gpio.h:101