REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
signal_generator.cpp
Go to the documentation of this file.
1
3
5
6FLASHMEM bool platform::NativeSignalGenerator::init() { return true; }
7
8FLASHMEM void platform::NativeSignalGenerator::set_frequency(float frequency) { _frequency = frequency; }
9
10FLASHMEM void platform::NativeSignalGenerator::set_phase(float phase) { _phase = phase; }
11
12FLASHMEM void platform::NativeSignalGenerator::set_wave_form(WaveForm wave_form) { _wave_form = wave_form; }
13
14FLASHMEM bool platform::NativeSignalGenerator::set_amplitude(float amplitude) {
15 if (amplitude < 0.0f || amplitude > 1.0f)
16 return false;
17 _amplitude = amplitude;
18 return true;
19}
20
22 return set_square_voltage_low(low) && set_square_voltage_high(high);
23}
24
26 if (fabs(low) > 1.0f)
27 return false;
28 _square_low_voltage = low;
29 return true;
30}
31
33 if (fabs(high) > 1.0f)
34 return false;
35 _square_high_voltage = high;
36 return true;
37}
38
40 if (fabs(offset) > 1.0f)
41 return false;
42 _offset = offset;
43 return true;
44}
45
47 throw std::runtime_error("not impl");
48}
49
51 throw std::runtime_error("not impl");
52}
53
54FLASHMEM float platform::NativeSignalGenerator::get_frequency() const { return _frequency; }
55
56FLASHMEM float platform::NativeSignalGenerator::get_phase() const { return _phase; }
57
58FLASHMEM WaveForm platform::NativeSignalGenerator::get_wave_form() const { return _wave_form; }
59
60FLASHMEM float platform::NativeSignalGenerator::get_amplitude() const { return _amplitude; }
61
62FLASHMEM float platform::NativeSignalGenerator::get_square_voltage_low() const { return _square_low_voltage; }
63
65 return _square_high_voltage;
66}
67
68FLASHMEM float platform::NativeSignalGenerator::get_offset() const { return _offset; }
69
70FLASHMEM bool platform::NativeSignalGenerator::get_sleep() const { return _sleep; }
71
72FLASHMEM float platform::NativeSignalGenerator::get_dac_out0() const { return _dac_out0; }
73
74FLASHMEM float platform::NativeSignalGenerator::get_dac_out1() const { return _dac_out1; }
75
76FLASHMEM void platform::NativeSignalGenerator::sleep() { _sleep = true; }
77
78FLASHMEM void platform::NativeSignalGenerator::awake() { _sleep = false; }
79
81 if (fabs(value) > 1.0f)
82 return false;
83 _dac_out0 = value;
84 return true;
85}
86
88 if (fabs(value) > 1.0f)
89 return false;
90 _dac_out1 = value;
91 return true;
92}
93
94// TODO: Implement smart write to hardware for signal generator
96 // TODO: not impl
97 return utils::status::success();
98}
bool set_offset(float offset) override
Sets the constant offset of the sine or triangle output in machine units.
bool set_dac_out1(float value) override
Writes the DACout1 constant voltage output. Possible values are: [-2V, 2V].
float get_offset() const override
float get_real_phase() const override
Returns the actually set phase of the function generator, containing rounding errors.
float get_real_frequency() const override
Returns the actually set frequency of the function generator, containing rounding errors.
float get_dac_out0() const override
utils::status write_to_hardware() override
float get_frequency() const override
void awake() override
Resumes outputs of the function generator to regular operation, according to the previously specified...
void set_wave_form(WaveForm wave_form) override
Sets the wave form of the function generator output.
float get_square_voltage_low() const override
bool init() override
Initializes the signal generator and puts it to sleep.
bool set_dac_out0(float value) override
Writes the DACout0 constant voltage output. Possible values are: [-2V, 2V].
bool set_square_voltage_high(float high) override
Sets the upper value of the square output in machine units.
void sleep() override
Sets the sine / triangle output of the function generator to zero.
WaveForm get_wave_form() const override
void set_phase(float phase) override
Sets the phase of the frequency outputs synchronised to the reset pin.
bool set_amplitude(float amplitude) override
Sets the amplitude of the sine or triangle wave in machine units.
bool set_square_voltage_levels(float low, float high) override
Sets the lower and upper value of the square output in machine units.
bool set_square_voltage_low(float low) override
Sets the lower value of the square output in machine units.
float get_square_voltage_high() const override
void set_frequency(float frequency) override
Sets the frequency of the sine / triangle output in Hz.
float get_dac_out1() const override
float get_amplitude() const override