0.1.3 DAC8550

This commit is contained in:
rob tillaart 2022-10-31 16:21:38 +01:00
parent 7ba35e7a00
commit 9fc027bdf3
7 changed files with 73 additions and 32 deletions

View File

@ -1,3 +1,18 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
@ -8,4 +23,6 @@ compile:
- m4
- esp32
# - esp8266
# - mega2560
# - mega2560
- rpipico

View File

@ -0,0 +1,23 @@
# Change Log DAC8550
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.3] - 2022-10-31
- add changelog.md
- add rp2040 to build-CI
## [0.1.2] - 2021-12-15
- update library.json
- update license
- minor edits.
## [0.1.1] - 2021-08-29
- add support for HSPI/VSPI ESP32
- some performance improvements
## [0.1.0] - 2021-02-04
- initial version (based upon DAC8551)

View File

@ -2,14 +2,10 @@
// FILE: DAC8550.cpp
// AUTHOR: Rob Tillaart
// PURPOSE: Arduino library for DAC8550 SPI Digital Analog Convertor
// VERSION: 0.1.2
// VERSION: 0.1.3
// URL: https://github.com/RobTillaart/DAC8550
//
// HISTORY:
// 0.1.0 2021-02-04 initial version (based upon DAC8551)
// 0.1.1 2021-08-29 add support for HSPI/VSPI ESP32
// some performance improvements.
// 0.1.2 2021-12-15 update library.json, license, minor edits.
// HISTORY: see changelog.md
#include "DAC8550.h"
@ -31,8 +27,8 @@ DAC8550::DAC8550(uint8_t spiData, uint8_t spiClock, uint8_t slaveSelect)
}
// initializes the SPI
// and sets internal state
// initializes the SPI
// and sets internal state
void DAC8550::begin()
{
pinMode(_select, OUTPUT);
@ -43,26 +39,26 @@ void DAC8550::begin()
if(_hwSPI)
{
#if defined(ESP32)
if (_useHSPI) // HSPI
if (_useHSPI) // HSPI
{
mySPI = new SPIClass(HSPI);
mySPI->end();
mySPI->begin(14, 12, 13, _select); // CLK=14 MISO=12 MOSI=13
mySPI->begin(14, 12, 13, _select); // CLK=14 MISO=12 MOSI=13
}
else // VSPI
else // VSPI
{
mySPI = new SPIClass(VSPI);
mySPI->end();
mySPI->begin(18, 19, 23, _select); // CLK=18 MISO=19 MOSI=23
mySPI->begin(18, 19, 23, _select); // CLK=18 MISO=19 MOSI=23
}
#else // generic hardware SPI
#else // generic hardware SPI
mySPI = &SPI;
mySPI->end();
mySPI->begin();
#endif
delay(1);
}
else // software SPI
else // software SPI
{
pinMode(_dataOut, OUTPUT);
pinMode(_clock, OUTPUT);
@ -84,13 +80,13 @@ void DAC8550::setGPIOpins(uint8_t clk, uint8_t miso, uint8_t mosi, uint8_t selec
pinMode(_select, OUTPUT);
digitalWrite(_select, HIGH);
mySPI->end(); // disable SPI
mySPI->end(); // disable SPI
mySPI->begin(clk, miso, mosi, select);
}
#endif
// value = 0..65535
// value = 0..65535
void DAC8550::setValue(uint16_t value)
{
_value = value;
@ -98,7 +94,7 @@ void DAC8550::setValue(uint16_t value)
}
// returns 0..65535
// returns 0..65535
uint16_t DAC8550::getValue()
{
return _value;
@ -127,7 +123,7 @@ void DAC8550::setSPIspeed(uint32_t speed)
//////////////////////////////////////////////////////////////////
//
// PRIVATE
// PRIVATE
//
void DAC8550::updateDevice()
{
@ -152,7 +148,7 @@ void DAC8550::updateDevice()
}
// simple one mode version
// simple one mode version
void DAC8550::swSPI_transfer(uint8_t value)
{
uint8_t clk = _clock;

View File

@ -3,7 +3,7 @@
// FILE: DAC8550.h
// AUTHOR: Rob Tillaart
// PURPOSE: Arduino library for DAC8550 SPI Digital Analog Convertor
// VERSION: 0.1.2
// VERSION: 0.1.3
// HISTORY: See DAC8550.cpp
// URL: https://github.com/RobTillaart/DAC8550
//
@ -13,7 +13,7 @@
#include "SPI.h"
#define DAC8550_LIB_VERSION (F("0.1.2"))
#define DAC8550_LIB_VERSION (F("0.1.3"))
#define DAC8550_POWERDOWN_NORMAL 0
@ -42,14 +42,14 @@ public:
bool usesHWSPI() { return _hwSPI; };
// ESP32 specific
// ESP32 specific
#if defined(ESP32)
void selectHSPI() { _useHSPI = true; };
void selectVSPI() { _useHSPI = false; };
bool usesHSPI() { return _useHSPI; };
bool usesVSPI() { return !_useHSPI; };
// to overrule ESP32 default hardware pins
// to overrule ESP32 default hardware pins
void setGPIOpins(uint8_t clk, uint8_t miso, uint8_t mosi, uint8_t select);
#endif
@ -76,4 +76,6 @@ private:
#endif
};
// -- END OF FILE --

View File

@ -72,13 +72,16 @@ check datasheet for details.
| DAC8550_POWERDOWN_HIGH_IMP | 3 |
## Future
- testing with real hardware
## Operation
See examples
## Future
- testing with real hardware
- improve documentation
- improve code incl readability
- spiData => spiDataOut

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/DAC8550"
},
"version": "0.1.2",
"version": "0.1.3",
"frameworks": "arduino",
"platforms": "*",
"headers": "DAC8550.h"

View File

@ -1,5 +1,5 @@
name=DAC8550
version=0.1.2
version=0.1.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for DAC8550 SPI DAC Digital Analog Convertor