Simple library for SPI DAC MCP4801

Dependents:   DAC_MCP4801_example

Committer:
JohnnyK
Date:
Tue Mar 03 20:08:59 2020 +0000
Revision:
0:886b1ee1370b
First release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JohnnyK 0:886b1ee1370b 1 /*MCP4801.h - Library for Microchip MCP4801 8-Bit Voltage Output Digital-to-Analog Converter with SPI Interface.*/
JohnnyK 0:886b1ee1370b 2 //http://ww1.microchip.com/downloads/en/devicedoc/22244b.pdf
JohnnyK 0:886b1ee1370b 3 #ifndef _MCP4801_H_INCLUDED
JohnnyK 0:886b1ee1370b 4 #define _MCP4801_H_INCLUDED
JohnnyK 0:886b1ee1370b 5 #include "mbed.h"
JohnnyK 0:886b1ee1370b 6
JohnnyK 0:886b1ee1370b 7 #define VREF 2.048
JohnnyK 0:886b1ee1370b 8 #define RES8BIT 256
JohnnyK 0:886b1ee1370b 9
JohnnyK 0:886b1ee1370b 10 class MCP4801{
JohnnyK 0:886b1ee1370b 11 public:
JohnnyK 0:886b1ee1370b 12 MCP4801(SPI &spi, PinName ssel, PinName ldacLowPin = NC,PinName shutdownLowPin = NC);
JohnnyK 0:886b1ee1370b 13
JohnnyK 0:886b1ee1370b 14 //Configuration
JohnnyK 0:886b1ee1370b 15 void setOutput_state(uint8_t state, bool soft);
JohnnyK 0:886b1ee1370b 16 void updateOutput();
JohnnyK 0:886b1ee1370b 17
JohnnyK 0:886b1ee1370b 18 //Functionality
JohnnyK 0:886b1ee1370b 19 int setVOutput(float voltage);
JohnnyK 0:886b1ee1370b 20
JohnnyK 0:886b1ee1370b 21 private:
JohnnyK 0:886b1ee1370b 22 DigitalOut _slaveSelectLow;
JohnnyK 0:886b1ee1370b 23 DigitalOut _shutdownLow;
JohnnyK 0:886b1ee1370b 24 DigitalOut _ldacLow;
JohnnyK 0:886b1ee1370b 25 SPI* _spi;
JohnnyK 0:886b1ee1370b 26 uint8_t shutdown = 1;
JohnnyK 0:886b1ee1370b 27 };
JohnnyK 0:886b1ee1370b 28 #endif