-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSPI_DDS_AD9958.h
82 lines (65 loc) · 2.47 KB
/
SPI_DDS_AD9958.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*! \file SPI_DDS_AD9958.h
\brief Header for SPI DDS (Direct Digital Synthesis) interface.
\author Anthony Marshall
AD9958 Dual DDS Implemented.
*/
#ifndef _SPI_DDS_AD9958_H
#define _SPI_DDS_AD9958_H
#include <stdint.h>
#include <stdbool.h>
/*! typedef enum E_DDS_PWR
\brief DDS Power modes.
*/
typedef enum
{
E_DDS_PWR_POWERED, /*!< Fully powered */
E_DDS_PWR_PARTIAL, /*!< Fast recovery - Powers down digital logic and DAC digital logic */
E_DDS_PWR_DOWN /*!< Full power down - Powers down all functions including DAC and PLL */
} E_DDS_PWR;
/*! typedef enum E_DDS_CHANNEL
\brief DDS Channel.
*/
typedef enum
{
E_DDS_CHANNEL_BOTH, /*!< Select both channels */
E_DDS_CHANNEL_0, /*!< Select channel 0 only */
E_DDS_CHANNEL_1 /*!< Select channel 1 only */
} E_DDS_CHANNEL;
// Pin defines - Change to suit
#define AD9958_PWR_DWN_CTL_PORT GPIOA
#define AD9958_PWR_DWN_CTL_PIN GPIO_PIN_1
#define AD9958_MASTER_RESET_PORT GPIOA
#define AD9958_MASTER_RESET_PIN GPIO_PIN_1
#define AD9958_IO_UPDATE_PORT GPIOA
#define AD9958_IO_UPDATE_PIN GPIO_PIN_1
#define AD9958_SDIO_3_PORT GPIOA
#define AD9958_SDIO_3_PIN GPIO_PIN_1
#define AD9958_CS_GPIO_PORT GPIOA
#define AD9958_CS_PIN GPIO_PIN_1
void AD9958_Initialise_SPI(void);
void AD9958_Initialise_GPIO(void);
void AD9958_TestFunctions(void);
/*! void AD9958_SetFrequency(E_DDS_CHANNEL channel, uint32_t frequency)
\brief Set the frequency output on a given channel of the DDS.
\param channel Which channel to output on.
\param frequency Desired output frequency in Hz.
*/
void AD9958_SetFrequency(E_DDS_CHANNEL channel, uint32_t frequency);
/*! void AD9958_SetAmplitude(E_DDS_CHANNEL channel, uint32_t amplitude)
\brief Set the amplitude scale factor on a given channel of the DDS.
\param channel Which channel to output on.
\param amplitude Desired amplitude scale factor (0-1023).
*/
void AD9958_SetAmplitude(E_DDS_CHANNEL channel, uint32_t amplitude);
/*! void DDS_Set_Phase_Offset(E_DDS_CHANNEL channel, float phase)
\brief Set the phase offset on a given channel of the DDS.
\param channel Which channel to output on.
\param phase Desired phase offset.
*/
void AD9958_SetPhaseOffset(E_DDS_CHANNEL channel, float phase);
/*! void DDS_Set_Power_State(E_DDS_PWR state)
\brief Set the power state of the DDS.
\param state Desired power state.
*/
void AD9958_SetPowerState(E_DDS_PWR state);
#endif