Newer
Older
ubScopin / sample / src / dac.h
@Christopher W. Olsen Christopher W. Olsen on 16 May 2019 864 bytes Sample
#pragma once

#include <stdint.h>
#include <wiringPi.h>


class Dac {
public:
    void Setup();
    void SetXY(int dacX, int dacY);
    void SetZ(uint8_t dacZ);
};

#define MCP4726_CMD_WRITEDAC            (0x40)  // Writes data to the DAC
#define MCP4726_CMD_WRITEDACEEPROM      (0x60)  // Writes data to the DAC and the EEPROM (persisting the assigned value after reset)

class MCP4725{
 public:
  MCP4725();
  void begin(uint8_t a);  
  void setVoltage( uint16_t output, bool writeEEPROM );
  void setVoltageFast( uint16_t output);
  void setVoltageNew(int voltage, int persist);

 private:
  uint8_t _i2caddr;
  int fd;
};

extern Dac xyz;
extern MCP4725 xDac;
extern MCP4725 yDac;

extern "C" int wiringPiI2CSetup          (const int devId);
extern "C" int wiringPiI2CWrite (int fd, int data);
extern "C" int wiringPiI2CWriteReg8 (int fd, int reg, int data) ;