forked from F4GOJ/AD9850SPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAD9850SPI.h
64 lines (57 loc) · 1.8 KB
/
AD9850SPI.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
/********************************************************************************************
* Arduino library for AD9850
* Created 23/08/2014
* Christophe Caiveau [email protected]
* Upgrade to SPI Anthony F4GOH
*
* This library uses the Serial Peripheral Interface (SPI) to accelerate the update
* of the AD9850 from 700µs in software serial to 90µs (54µs for the deltaphase
* calculation and 36µs for the transfert)
*
* Use this library freely
*
* Hardware connections :
* W_CLK -> D13 arduino UNO/NANO, D52 MEGA
* FQ_UD -> any pin except 10 and 12 UNO/NANO, 50 and 53 MEGA
* DATA/D7 -> D11 arduino UNO/NANO, D51 MEGA
* RESET -> any pin except 10 and 12 UNO/NANO, 50 and 53 MEGA
*
* Functions :
* DDS.begin(W_CLK pin, FQ_UD pin, RESET pin); Initialize the output pins and master reset the AD9850
* DDS.calibrate(frequency); Compensation of crystal oscillator frequency
* DDS.setfreq(frequency,phase); frequency in Hz, phase coded on 5 bits
* DDS.down(); power down mode reducing the dissipated power from 380mW to 30mW @5V
* DDS.up(); wake-up the AD9850
*
* AD9850 datasheet at http://www.analog.com/static/imported-files/data_sheets/AD9850.pdf
*
*******************************************************************************************/
#ifndef AD9850SPI_H
#define AD9850SPI_H
#include <Arduino.h>
class AD9850SPI
{
public:
AD9850SPI();
void begin(int w_clk, int fq_ud, int reset);
void setfreq(double f, uint8_t p);
void down();
void up();
void calibrate(double TrimFreq);
void powerOn();
void powerOff();
void vna(unsigned long DS_FTW, uint8_t Mode);
private:
int W_CLK;
int FQ_UD;
int RESET;
uint32_t deltaphase;
uint8_t phase;
void update();
void begin_priv();
void pulse(int pin);
void wakeUp();
double calibFreq;
};
extern AD9850SPI DDS;
#endif