On this page
article
peary/hardware/components/DAC7678.hpp
peary/hardware/components/DAC7678.hpp
DAC7678 Component Class. More…
Namespaces
| Name |
|---|
| peary |
| peary::component |
Classes
| Name | |
|---|---|
| class | peary::component::DAC7678 DAC7678 Digital-to-Analog Converter Component. |
Detailed Description
DAC7678 Component Class.
Copyright: Copyright (c) 2016-2025 CERN and the Peary Caribou authors. This software is distributed under the terms of the LGPL-3.0-only License, copied verbatim in the file “LICENSE.md”. SPDX-License-Identifier: LGPL-3.0-only
Source code
#pragma once
#include <cstdint>
#include <string>
#include "peary/hal/Components.hpp"
#include "peary/interfaces/I2C/i2c.hpp"
namespace peary::component {
class DAC7678 : public hal::Component {
public:
// Commands
enum class Command {
// Write commands
WR_DAC_IN = 0x00, // Set DAC; last four bit indicate the channel number
WR_UPDATE = 0x10, // Update DAC; last four bit indicate the channel number
WR_GLOBAL_LDAC = 0x20, // Set DAC & update all; last four bit indicate the channel number
WR_SINGLE_LDAC = 0x30, // Set & update DAC; last four bit indicate the channel number
WR_POWER_DOWN = 0x40, // Power on/off DAC
WR_CLEAR_CODE = 0x50, // Write to clear code reg
WR_LDAC = 0x60, // Write to LDAC reg
WR_RESET = 0x70, // Software reset
WR_STATIC_MODE = 0x80, // Internal reference (static mode)
WR_FLEX_MODE = 0x90, // Internal reference (flexible mode)
// Power commands
POWER_UP = 0x00, // Power up DAC(s)
POWER_DOWN_1K = 0x20, // Power down DAC(s) with 1KOhm to GND
POWER_DOWN_100K = 0x40, // Power down DAC(s) with 100KOhm to GND
POWER_DOWN_HZ = 0x60, // Power down DAC(s), Vout is High-Z
// Read commands
RD_DAC_IN = 0x00, // Read DAC input register; last four bit indicate the channel number
RD_DAC = 0x10, // Read DAC register; last four bit indicate the channel number
RD_POWER_DOWN = 0x40, // Read power on/off DAC
RD_CLEAR_CODE = 0x50, // Read clear code reg
RD_LDAC = 0x60, // Read LDAC reg
RD_STATIC_MODE = 0x80, // Read internal reference (static mode)
RD_FLEX_MODE = 0x90 // Read internal reference (flexible mode)
};
// Channels
enum class Channel {
VOUTA = 0x00,
VOUTB = 0x01,
VOUTC = 0x02,
VOUTD = 0x03,
VOUTE = 0x04,
VOUTF = 0x05,
VOUTG = 0x06,
VOUTH = 0x07,
ALL = 0x0F
};
using enum Channel;
DAC7678(const std::string& i2c_bus, uint8_t device_address, double vref);
void setVoltage(Channel channel, double voltage);
double getVoltage(Channel channel);
void setOutput(Channel channel, bool enable);
private:
std::string _bus;
uint8_t _address;
double _vref;
};
} // namespace peary::component
Updated on 2025-11-14 at 11:31:23 +0100