0.2.4 DAC8552

This commit is contained in:
rob tillaart 2022-10-31 16:47:29 +01:00
parent 0edc75ad8b
commit bb018852dc
7 changed files with 95 additions and 42 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,44 @@
# Change Log DAC8552
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.2.4] - 2022-10-30
- add changelog.md
- add rp2040 to build-CI
## [0.2.3] - 2021-12-15
- update library.json
- update license
- update unit test
- minor edits
## [0.2.2] - 2021-08-29
- add support for HSPI / VSPI ESP32 ++
## [0.2.1] - 2021-06-02
- compile ESP32 + fix for channel B
## [0.2.0] - 2020-12-18
- add arduino-ci + unit test
- add slave select pin for HW constructor
----
## [0.1.3] - 2020-06-07
- fix library.json
## [0.1.2] - 2020-04-06
- minor refactor
- update readme.md
## [0.1.1] - 2017-12-19
- fix begin() bug
## [0.1.0] - 2017-12-14
- initial version

View File

@ -2,19 +2,10 @@
// FILE: DAC8552.cpp
// AUTHOR: Rob Tillaart
// PURPOSE: Arduino library for DAC8552 SPI Digital Analog Convertor
// VERSION: 0.2.3
// VERSION: 0.2.4
// URL: https://github.com/RobTillaart/DAC8552
//
// HISTORY:
// 0.1.0: 2017-12-14 initial version
// 0.1.1: 2017-12-19 fix begin() bug
// 0.1.2 2020-04-06 minor refactor, readme.md
// 0.1.3 2020-06-07 fix library.json
// 0.2.0 2020-12-18 add arduino-ci + unit test
// add slave select pin for HW constructor
// 0.2.1 2021-06-02 compile ESP32 + fix for channel B
// 0.2.2 2021-08-29 add support for HSPI / VSPI ESP32 ++
// 0.2.3 2021-12-15 update library.json, license, unit test, minor edits
// HISTORY: see changelog.md
#include "DAC8552.h"
@ -40,8 +31,8 @@ DAC8552::DAC8552(uint8_t spiData, uint8_t spiClock, uint8_t slaveSelect)
}
// initializes the SPI
// and sets internal state
// initializes the SPI
// and sets internal state
void DAC8552::begin()
{
pinMode(_select, OUTPUT);
@ -52,26 +43,26 @@ void DAC8552::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);
@ -95,14 +86,14 @@ void DAC8552::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
// channel = 0, 1, 2, 3 depending on type
// value = 0..65535
// channel = 0, 1, 2, 3 depending on type
// value = 0..65535
void DAC8552::bufferValue(uint8_t channel, uint16_t value)
{
_value[channel] = value;
@ -110,8 +101,8 @@ void DAC8552::bufferValue(uint8_t channel, uint16_t value)
}
// channel = 0, 1, 2, 3 depending on type
// value = 0..65535
// channel = 0, 1, 2, 3 depending on type
// value = 0..65535
void DAC8552::setValue(uint8_t channel, uint16_t value)
{
_value[channel] = value;
@ -119,8 +110,8 @@ void DAC8552::setValue(uint8_t channel, uint16_t value)
}
// channel = 0, 1, 2, 3 depending on type
// returns 0..65535
// channel = 0, 1, 2, 3 depending on type
// returns 0..65535
uint16_t DAC8552::getValue(uint8_t channel)
{
return _value[channel];
@ -158,12 +149,12 @@ void DAC8552::setSPIspeed(uint32_t speed)
//////////////////////////////////////////////////////////////////
//
// PRIVATE
// PRIVATE
//
// channel = 0, 1, 2, 3 depending on type
// direct = true ==> write buffers to both channel A and channel B
// direct = false ==> buffer value
// channel = 0, 1, 2, 3 depending on type
// direct = true ==> write buffers to both channel A and channel B
// direct = false ==> buffer value
void DAC8552::updateDevice(uint8_t channel, bool directWrite)
{
uint8_t configRegister = _register[channel];
@ -188,7 +179,7 @@ void DAC8552::updateDevice(uint8_t channel, bool directWrite)
}
// simple one mode version
// simple one mode version
void DAC8552::swSPI_transfer(uint8_t value)
{
uint8_t clk = _clock;

View File

@ -3,7 +3,7 @@
// FILE: DAC8552.h
// AUTHOR: Rob Tillaart
// PURPOSE: Arduino library for DAC8552 SPI Digital Analog Convertor
// VERSION: 0.2.3
// VERSION: 0.2.4
// HISTORY: See DAC8552.cpp
// URL: https://github.com/RobTillaart/DAC8552
//
@ -13,7 +13,7 @@
#include "SPI.h"
#define DAC8552_LIB_VERSION (F("0.2.3"))
#define DAC8552_LIB_VERSION (F("0.2.4"))
#define DAC8552_POWERDOWN_NORMAL 0
@ -44,14 +44,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

View File

@ -75,10 +75,6 @@ but waits until (TODO CHECK DATASHEET)
| DAC8552_POWERDOWN_HIGH_IMP | 3 |
## Future
- testing
## Operation
@ -101,3 +97,8 @@ See examples
**demo_powerdown.ino**
- idem
## Future
- testing

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/DAC8552"
},
"version": "0.2.3",
"version": "0.2.4",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

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