dac.h
1 /*
2  * EEZ PSU Firmware
3  * Copyright (C) 2015-present, Envox d.o.o.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 namespace eez {
22 namespace psu {
23 
26 public:
27  static const uint8_t DATA_BUFFER_A = 0B00010000;
28  static const uint8_t DATA_BUFFER_B = 0B00100100;
29 
30  static const uint16_t DAC_MIN = 0;
31  static const uint16_t DAC_MAX = (1L << DAC_RES) - 1;
32 
33  psu::TestResult g_testResult;
34 
36 
37  void init();
38  bool test();
39 
40  void set_voltage(float voltage);
41  void set_current(float voltage);
42 
43 private:
44  Channel &channel;
45 
46  void set_value(uint8_t buffer, float value);
47 };
48 
49 }
50 } // namespace eez::psu
Namespace for the everything from the EEZ.
Definition: actions.cpp:41
PSU channel.
Definition: channel.h:62
#define DAC_RES
DAC chip resolution in number of bits.
Definition: conf_advanced.h:41
Digital to analog converter HW used by the channel.
Definition: dac.h:25