11/*
22 * AD9833.h
3- *
3+ *
44 * Copyright 2016 Bill Williams <wlwilliams1952@gmail.com, github/BillWilliams1952>
5- *
5+ *
66 * This program is free software; you can redistribute it and/or modify
77 * it under the terms of the GNU General Public License as published by
88 * the Free Software Foundation; either version 2 of the License, or
99 * (at your option) any later version.
10- *
10+ *
1111 * This program is distributed in the hope that it will be useful,
1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414 * GNU General Public License for more details.
15- *
15+ *
1616 * You should have received a copy of the GNU General Public License
1717 * along with this program; if not, write to the Free Software
1818 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
1919 * MA 02110-1301, USA.
20- *
21- *
20+ *
21+ *
2222 */
2323
24+ // update
25+
2426#ifndef __AD9833__
2527
2628#define __AD9833__
5254
5355#define PHASE_WRITE_CMD 0xC000 // Setup for Phase write
5456#define PHASE1_WRITE_REG 0x2000 // Which phase register
55- #define FREQ0_WRITE_REG 0x4000 //
57+ #define FREQ0_WRITE_REG 0x4000 //
5658#define FREQ1_WRITE_REG 0x8000
5759#define PHASE1_OUTPUT_REG 0x0400 // Output is based off REG0/REG1
5860#define FREQ1_OUTPUT_REG 0x0800 // ditto
5961
6062typedef enum { SINE_WAVE = 0x2000 , TRIANGLE_WAVE = 0x2002 ,
6163 SQUARE_WAVE = 0x2028 , HALF_SQUARE_WAVE = 0x2020 } WaveformType;
62-
64+
6365typedef enum { REG0 , REG1 , SAME_AS_REG0 } Registers;
6466
6567class AD9833 {
6668
6769public:
68-
70+
6971 AD9833 ( uint8_t FNCpin, uint32_t referenceFrequency = 25000000UL );
7072
7173 // Must be the first command after creating the AD9833 object.
72- void Begin ( void );
73-
74+ // Must be the first command after creating the AD9833 object.
75+ // if nothing is given (i.e. NULL) default SPI is used
76+ void Begin (SPIClass *spiBus = NULL );
77+
7478 // Setup and apply a signal. Note that any calls to EnableOut,
7579 // SleepMode, DisableDAC, or DisableInternalClock remain in effect
7680 void ApplySignal ( WaveformType waveType, Registers freqReg,
@@ -112,13 +116,13 @@ class AD9833 {
112116 // Enable / Disable Internal Clock
113117 void DisableInternalClock ( bool enable );
114118
115- // Return actual frequency programmed in register
119+ // Return actual frequency programmed in register
116120 float GetActualProgrammedFrequency ( Registers reg );
117121
118122 // Return actual phase programmed in register
119123 float GetActualProgrammedPhase ( Registers reg );
120124
121- // Return frequency resolution
125+ // Return frequency resolution
122126 float GetResolution ( void );
123127
124128private:
@@ -133,7 +137,7 @@ class AD9833 {
133137 uint32_t refFrequency;
134138 float frequency0, frequency1, phase0, phase1;
135139 Registers activeFreq, activePhase;
140+ SPIClass *_spiBus;
136141};
137142
138143#endif
139-
0 commit comments