mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.3.3 AD985X
This commit is contained in:
parent
7a416b7abf
commit
f769a99287
@ -1,32 +1,35 @@
|
||||
//
|
||||
// FILE: AD985X.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.2
|
||||
// VERSION: 0.3.3
|
||||
// DATE: 2019-02-08
|
||||
// PURPOSE: Class for AD9850 and AD9851 function generator
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 2019-03-19 initial version
|
||||
// 0.1.1 2020-12-09 add arduino-ci
|
||||
// 0.1.1 2020-12-09 add Arduino-CI
|
||||
// 0.1.2 2020-12-27 add setAutoMode() + offset
|
||||
// 0.2.0 2020-12-28 major refactor class hierarchy + float frequency
|
||||
// 0.2.1 2021-01-10 add get- and setARCCutOffFreq()
|
||||
// 0.2.2 2021-01-24 add manual updating frequency
|
||||
// get- setManualFQ_UD(), update()
|
||||
// inverted SELECT line as preparation for multidevice.
|
||||
// inverted SELECT line as preparation for multi-device.
|
||||
// 0.3.0 2021-06-06 fix factory bit mask + new examples + some refactor
|
||||
// added multi device document
|
||||
// 0.3.1 2021-08-25 VSPI / HSPI support for ESP32
|
||||
// faster software SPI
|
||||
// minor optimizations / refactor
|
||||
// 0.3.2 2021-10-16 update build-ci
|
||||
// 0.3.2 2021-10-16 update Arduino-CI
|
||||
// 0.3.3 2021-12-10 update library.json, license, readme.md
|
||||
// fix reset() for ESP32 hardware SPI
|
||||
|
||||
|
||||
|
||||
#include "AD985X.h"
|
||||
|
||||
|
||||
// UNO HARDWARE SPI PINS
|
||||
#define SPI_CLOCK 13
|
||||
#define SPI_CLOCK 13 // not portable...
|
||||
#define SPI_MISO 12
|
||||
#define SPI_MOSI 11
|
||||
|
||||
@ -117,7 +120,16 @@ void AD9850::reset()
|
||||
// be sure to select the correct device
|
||||
digitalWrite(_select, HIGH);
|
||||
pulsePin(_reset);
|
||||
if (_hwSPI) pulsePin(SPI_CLOCK);
|
||||
if (_hwSPI)
|
||||
{
|
||||
#if defined(ESP32)
|
||||
if (_useHSPI) pulsePin(14); // HSPI magic number clock
|
||||
else pulsePin(18); // VSPI magic number clock
|
||||
#else
|
||||
// UNO hardware SPI
|
||||
pulsePin(SPI_CLOCK);
|
||||
#endif
|
||||
}
|
||||
else pulsePin(_clock);
|
||||
digitalWrite(_select, LOW);
|
||||
|
||||
@ -173,7 +185,7 @@ void AD9850::writeData()
|
||||
// Serial.println(_config, HEX);
|
||||
uint32_t data = _factor;
|
||||
|
||||
// used for multidevice config only - https://github.com/RobTillaart/AD985X/issues/13
|
||||
// used for multi device configuration only - https://github.com/RobTillaart/AD985X/issues/13
|
||||
digitalWrite(_select, HIGH);
|
||||
if (_hwSPI)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: AD985X.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.2
|
||||
// VERSION: 0.3.3
|
||||
// DATE: 2019-02-08
|
||||
// PURPOSE: Class for AD9850 and AD9851 function generator
|
||||
//
|
||||
@ -14,7 +14,7 @@
|
||||
#include "SPI.h"
|
||||
|
||||
|
||||
#define AD985X_LIB_VERSION (F("0.3.2"))
|
||||
#define AD985X_LIB_VERSION (F("0.3.3"))
|
||||
|
||||
|
||||
#define AD9850_MAX_FREQ (40UL * 1000UL * 1000UL)
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 - 2021 Rob Tillaart
|
||||
Copyright (c) 2019-2022 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -23,6 +23,8 @@ a feature the AD9850 does not have.
|
||||
The library is not suitable for AD9852 as that is a function generator with
|
||||
way more functionality.
|
||||
|
||||
Note: mainly tested on Arduino UNO. Tweaking for other platforms is expected.
|
||||
|
||||
|
||||
## Connection
|
||||
|
||||
@ -48,11 +50,11 @@ way more functionality.
|
||||
XTAL = crystal
|
||||
L = LED
|
||||
C = chip
|
||||
P = potmeter => for duty cycle square wave
|
||||
P = potentiometer => for duty cycle square wave
|
||||
|
||||
```
|
||||
|
||||
### Multidevice
|
||||
### Multi device
|
||||
|
||||
See Multi_AD985X_devices.pdf
|
||||
|
||||
@ -155,7 +157,7 @@ devices at the same time.
|
||||
|
||||
### Common interface
|
||||
|
||||
- **void begin(selectPin, resetPin, FQUDPin, dataOut = 0, clock = 0)**
|
||||
- **void begin(uint8_t selectPin, uint8_t resetPin, uint8_t FQUDPin, uint8_t dataOut = 0, uint8_t clock = 0)**
|
||||
For hardware SPI only use the first three parameters,
|
||||
for SW SPI you need to define the data and clock pin too.
|
||||
- selectPin = chip select. The library uses HIGH as active and LOW as not selected.
|
||||
@ -187,7 +189,7 @@ Default it sets the phase to 0.
|
||||
- **uint32_t getCalibrationOffset()** reads back the offset set.
|
||||
- **uint32_t getFactor()** internal factor, for debugging
|
||||
|
||||
Note: reset() resets the offset to 0..
|
||||
Note: **reset()** resets the offset to 0..
|
||||
Note: setting the offset reduces the range of frequencies (at the ends of scale).
|
||||
|
||||
|
||||
@ -204,16 +206,16 @@ Note: setting the offset reduces the range of frequencies (at the ends of scale)
|
||||
Manual updating allows one to prepare the frequency, and actually apply
|
||||
it at a later moment.
|
||||
|
||||
The default of the flag is true, and will be reset to true by the **reset()** call.
|
||||
|
||||
Note: The default of the autoUpdate flag is true.
|
||||
Note: **reset()** resets the autoUpdateFlag to true.
|
||||
|
||||
|
||||
### Hardware SPI
|
||||
|
||||
To be used only if one needs a specific speed.
|
||||
|
||||
- **void setSPIspeed(uint32_t speed)** set SPI transfer rate
|
||||
- **uint32_t getSPIspeed()** returns SPI transfer rate
|
||||
- **void setSPIspeed(uint32_t speed)** set SPI transfer rate.
|
||||
- **uint32_t getSPIspeed()** returns SPI transfer rate.
|
||||
- **bool usesHWSPI()** returns true if HW SPI is used.
|
||||
|
||||
|
||||
@ -232,8 +234,8 @@ BEFORE the **begin()** function.
|
||||
|
||||
#### ESP32 experimental
|
||||
|
||||
- **void setGPIOpins(clk, miso, mosi, select)** overrule GPIO pins of ESP32 for hardware SPI. needs to be called
|
||||
AFTER the **begin()** function.
|
||||
- **void setGPIOpins(clk, miso, mosi, select)** overrule GPIO pins of ESP32 for hardware SPI.
|
||||
Needs to be called AFTER the **begin()** function.
|
||||
|
||||
```cpp
|
||||
void setup()
|
||||
@ -260,9 +262,9 @@ The AD9850 has no specific functions.
|
||||
to the reference clock of 180 MHz when the frequency is set above 10 MHz and
|
||||
to 30 MHz when the frequency is set to 10 MHz or lower.
|
||||
The initial value is **false** == OFF for backwards compatibility.
|
||||
- **bool getAutoRefClock()** returns true is automode is set.
|
||||
- **bool getAutoRefClock()** returns true if autoRefClock is set.
|
||||
- **void setARCCutOffFreq(uint32_t Hz = 10000000UL )** set cut off frequency
|
||||
for the auto reference clock. max value is 30 MHz, typical 10MHz
|
||||
for the auto reference clock. Maximum value is 30 MHz, typical 10 MHz.
|
||||
- **uint32_t getARCCutOffFreq()** returns cut off frequency set.
|
||||
|
||||
|
||||
@ -272,7 +274,7 @@ for the auto reference clock. max value is 30 MHz, typical 10MHz
|
||||
|
||||
## Operation
|
||||
|
||||
See examples
|
||||
See examples.
|
||||
|
||||
|
||||
### Operational notes
|
||||
@ -288,5 +290,6 @@ The user is also responsible to store it e.g. in EEPROM to make it persistent.
|
||||
## Future
|
||||
|
||||
- examples for ESP32 HWSPI interface
|
||||
- do tests on ESP32
|
||||
- performance measurements
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "AD985X",
|
||||
"keywords": "AD9850 AD9851",
|
||||
"keywords": "AD9850,AD9851,frequency,sinus,square,generator",
|
||||
"description": "Arduino library for AD9850 and AD9851 function generators.",
|
||||
"authors":
|
||||
[
|
||||
@ -15,8 +15,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/AD985X.git"
|
||||
},
|
||||
"version": "0.3.2",
|
||||
"version": "0.3.3",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
"platforms": "*",
|
||||
"headers": "AD985X.h"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=AD985X
|
||||
version=0.3.2
|
||||
version=0.3.3
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for AD9850 and AD9851 function generators. Supports both hardware SPI as software SPI.
|
||||
|
Loading…
x
Reference in New Issue
Block a user