GY-63_MS5611/libraries/DAC8552/README.md

104 lines
3.2 KiB
Markdown
Raw Normal View History

2021-01-29 06:31:58 -05:00
[![Arduino CI](https://github.com/RobTillaart/DAC8552/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
2021-08-30 07:27:26 -04:00
[![Arduino-lint](https://github.com/RobTillaart/DAC8552/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/DAC8552/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/DAC8552/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/DAC8552/actions/workflows/jsoncheck.yml)
2021-01-29 06:31:58 -05:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/DAC8552/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/DAC8552.svg?maxAge=3600)](https://github.com/RobTillaart/DAC8552/releases)
2020-11-27 05:10:47 -05:00
# DAC8552
2021-01-29 06:31:58 -05:00
2021-12-15 06:48:53 -05:00
Arduino library for DAC8552 SPI Digital Analog Convertor.
2021-01-29 06:31:58 -05:00
2020-11-27 05:10:47 -05:00
## Description
2021-01-29 06:31:58 -05:00
The DAC8552 is a SPI based 16 bit DAC with two channels.
2021-12-15 06:48:53 -05:00
**Warning** This library is not tested extensively.
2021-01-29 06:31:58 -05:00
## Interface
### Core
- **DAC8552(uint8_t slaveSelect)** Constructor for hardware SPI,
since 0.2.0 the slaveSelect pin needs to be defined.
- **DAC8552(uint8_t spiData, uint8_t spiClock, uint8_t slaveSelect)** Constructor for the software SPI
- **void begin()** initializes all pins to default state
- **void bufferValue(uint8_t channel, uint16_t value)**
- **void setValue(uint8_t channel, uint16_t value)** set the value of the chosen channel to 0 - 65535
- **uint16_t getValue(uint8_t channel)**returns the last value written.
2021-08-30 07:27:26 -04:00
### 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.
- **bool usesHWSPI()** returns true if HW SPI is used.
### ESP32 specific
- **void selectHSPI()** in case hardware SPI, the ESP32 has two options HSPI and VSPI.
- **void selectVSPI()** see above.
- **bool usesHSPI()** returns true if HSPI is used.
- **bool usesVSPI()** returns true if VSPI is used.
The **selectVSPI()** or the **selectHSPI()** needs to be called
BEFORE the **begin()** function.
#### experimental
2021-12-15 06:48:53 -05:00
- **void setGPIOpins(uint8_t clk, uint8_t miso, uint8_t mosi, uint8_t select)**
overrule GPIO pins of ESP32 for hardware SPI. needs to be called
2021-08-30 07:27:26 -04:00
AFTER the **begin()** function.
2021-01-29 06:31:58 -05:00
### Power down
Check datasheet for details.
- **void bufferPowerDown(uint8_t channel, uint8_t powerDownMode)** ets power down mode. 0 - 3,
but waits until (TODO CHECK DATASHEET)
- **void setPowerDown(uint8_t channel, uint8_t powerDownMode)** sets power down mode. 0 - 3.
- **uint8_t getPowerDownMode(uint8_t channel)** returns last written mode.
2021-08-30 07:27:26 -04:00
| Power down mode | Value |
|:---------------------------|:-----:|
| DAC8552_POWERDOWN_NORMAL | 0 |
| DAC8552_POWERDOWN_1K | 1 |
| DAC8552_POWERDOWN_100K | 2 |
| DAC8552_POWERDOWN_HIGH_IMP | 3 |
## Future
- testing
2021-01-29 06:31:58 -05:00
2020-11-27 05:10:47 -05:00
## Operation
See examples
**demo_hw_spi.ino**
2021-01-29 06:31:58 -05:00
- write a sawtooth to channel A followed by a sinus
- uses HW SPI
2020-11-27 05:10:47 -05:00
**demo_sw_spi.ino**
2021-01-29 06:31:58 -05:00
- write a sawtooth to channel A followed by a sinus
- uses SW SPI
2020-11-27 05:10:47 -05:00
**demo_same_time_write.ino**
2021-01-29 06:31:58 -05:00
- writes two square waves that trigger at the same time
2020-11-27 05:10:47 -05:00
**demo_sequential_write.ino**
2021-01-29 06:31:58 -05:00
- writes two square waves sequentially (slight time difference)
2020-11-27 05:10:47 -05:00
**demo_powerdown.ino**
2021-01-29 06:31:58 -05:00
- idem