PS_Fgen_FW  4da88f4073c1cc65ea45c3a652a2751e495e50db
Firmware for an Power Supply and Function Generator build from an ATX power supply
Loading...
Searching...
No Matches
DDS_Channel.h
Go to the documentation of this file.
1
7
8#ifndef DDS_CHANNEL_H_
9#define DDS_CHANNEL_H_
10
11#include "DDS.h"
12#include "Channel.h"
13#include "../Configuration.h"
14
19typedef enum SignalForms
20{
27 #ifdef DDS_USER_DEFINED_WAVEFORMS_ENABLED
28 SIGNALFORM_USER_SIGNAL,
29 #endif
32
33
34#ifdef DDS_SUBSYSTEM_ENABLED
35
36extern const char* SignalFormsNames[NUM_SIGNALFORM_ELEMENTS];
37
42class DDS_Channel : public Channel
43{
44 public:
46
52
54
55 volatile const uint16_t* OriginalWaveTable;
56 volatile uint16_t* p_WaveTable;
57 volatile uint32_t* p_Increment;
58
59 #ifdef DDS_USER_DEFINED_WAVEFORMS_ENABLED
60 uint16_t UserWaveTable[(1 << DDS_QUANTIZER_BITS)];
61 int UserWaveTableReceiveIndex = 0;
62 #endif
63
74 DDS_Channel(uint8_t ddsChannelNumber, float minFreq, float maxFreq, float minAmpl, float maxAmpl, float minOffset, float maxOffset);
75
77 void UpdateIncrement();
78
80 void UpdateWaveTable();
81
84
90 bool SetEnabled(bool enabled);
95 inline bool GetEnabled() { return Enabled.Val; }
96
102 bool SetFrequency(float frequency);
107 inline float GetFrequency() { return Frequency.Val; }
108
114 bool SetAmplitude(float amplitude);
119 inline float GetAmplitude() { return Amplitude.Val; }
120
126 bool SetOffset(float offset);
131 inline float GetOffset() { return Offset.Val; }
132
138 bool SetSignalForm(SignalForms_t signalForm);
143 inline SignalForms_t GetSignalForm() { return SignalForm.Val; }
144
150 bool SetPWMValue(float pwmValue);
155 inline float GetPWMValue() { return PWM_Value.Val; }
156
161 static void DDSFrequencyChanged(void* channel);
162
167 static void DDSAmplitudeChanged(void* channel);
168
173 static void DDSOffsetChanged(void* channel);
174
179 static void DDSSignalFormChanged(void* channel);
180
185 static void DDSPWMValueChanged(void* channel);
186
191 static void DDSEnabledChanged(void* channel);
192};
193
194#endif /* DDS_CHANNEL_H_ */
195
196#endif /* DDS_SUBSYSTEM_ENABLED */
Containing the base class for all channels.
Containing different defines for device configuration.
#define DDS_QUANTIZER_BITS
Number of bits that are used to index into the look up tables.
Definition Configuration.h:54
Containing everything needed for the direct digital synthesis.
SignalForms
Available DDS signal forms.
Definition DDS_Channel.h:20
@ SIGNALFORM_SAWTOOTH
Sawtooth wave type.
Definition DDS_Channel.h:24
@ NUM_SIGNALFORM_ELEMENTS
The last element is used to determine the number of elements in the enumeration.
Definition DDS_Channel.h:30
@ SIGNALFORM_PWM
PWM wave type.
Definition DDS_Channel.h:26
@ SIGNALFORM_TRIANGLE
Triangle wave type.
Definition DDS_Channel.h:23
@ SIGNALFORM_SINE
Sine wave type.
Definition DDS_Channel.h:21
@ SIGNALFORM_DC
Direct current wave type.
Definition DDS_Channel.h:25
@ SIGNALFORM_RECTANGLE
Rectange wave type.
Definition DDS_Channel.h:22
enum SignalForms SignalForms_t
Available DDS signal forms.
Channel(ChannelTypes_t channelType)
Constructor of the Channel class.
Definition Channel.h:48
Parameter< bool > Enabled
Is the channel enabled or not.
Definition DDS_Channel.h:47
uint8_t DdsChannelNumber
1-based channel number (DDS1 => 1, DDS2 => 2)
Definition DDS_Channel.h:45
static void DDSSignalFormChanged(void *channel)
Callback function that can be used for user interface controls modifying the SignalForm property.
Definition DDS_Channel.cpp:228
bool SetPWMValue(float pwmValue)
Set the PWM_Value property of the DDS channel.
Definition DDS_Channel.cpp:190
static void DDSOffsetChanged(void *channel)
Callback function that can be used for user interface controls modifying the Offset property.
Definition DDS_Channel.cpp:220
static void DDSPWMValueChanged(void *channel)
Callback function that can be used for user interface controls modifying the PWM_Value property.
Definition DDS_Channel.cpp:237
bool SetEnabled(bool enabled)
Set the Enabled property of the DDS channel.
Definition DDS_Channel.cpp:125
bool SetAmplitude(float amplitude)
Set the Amplitude property of the DDS channel.
Definition DDS_Channel.cpp:148
float GetFrequency()
Get the Frequency property of the DDS channel.
Definition DDS_Channel.h:107
DDS_Channel(uint8_t ddsChannelNumber, float minFreq, float maxFreq, float minAmpl, float maxAmpl, float minOffset, float maxOffset)
Constructor of the DDS_Channel.
Definition DDS_Channel.cpp:19
bool SetOffset(float offset)
Set the Offset property of the DDS channel.
Definition DDS_Channel.cpp:162
volatile uint16_t * p_WaveTable
Pointer to the wave table array holding the modified waveform points (adapted to waveform and offset)
Definition DDS_Channel.h:56
volatile uint32_t * p_Increment
Pointer to the increment variable (calculated from the Frequency setting)
Definition DDS_Channel.h:57
float GetPWMValue()
Get the PWM_Value property of the DDS channel.
Definition DDS_Channel.h:155
static void DDSFrequencyChanged(void *channel)
Callback function that can be used for user interface controls modifying the Frequency property.
Definition DDS_Channel.cpp:204
SignalForms_t GetSignalForm()
Get the SignalForm property of the DDS channel.
Definition DDS_Channel.h:143
Parameter< SignalForms_t > SignalForm
Signalform of the DDS channel.
Definition DDS_Channel.h:51
bool SetSignalForm(SignalForms_t signalForm)
Set the SignalForm property of the DDS channel.
Definition DDS_Channel.cpp:176
bool SetFrequency(float frequency)
Set the Frequency property of the DDS channel.
Definition DDS_Channel.cpp:134
Parameter< float > PWM_Value
PWM value of the DDS channel.
Definition DDS_Channel.h:53
Parameter< float > Amplitude
Amplitude of the DDS channel.
Definition DDS_Channel.h:49
void UpdateIncrement()
Update the increment value based on the Frequency.
Definition DDS_Channel.cpp:43
float GetAmplitude()
Get the Amplitude property of the DDS channel.
Definition DDS_Channel.h:119
void UpdateOriginalWaveTable()
Update the pointer to the original WaveTable based on the SignalForm.
Definition DDS_Channel.cpp:106
static void DDSAmplitudeChanged(void *channel)
Callback function that can be used for user interface controls modifying the Amplitude property.
Definition DDS_Channel.cpp:212
Parameter< float > Offset
Offset of the DDS channel.
Definition DDS_Channel.h:50
Parameter< float > Frequency
Frequency of the DDS channel.
Definition DDS_Channel.h:48
bool GetEnabled()
Get the Enabled property of the DDS channel.
Definition DDS_Channel.h:95
static void DDSEnabledChanged(void *channel)
Callback function that can be used for user interface controls modifying the Enabled property.
Definition DDS_Channel.cpp:246
volatile const uint16_t * OriginalWaveTable
Pointer to the constant wave table holding the unmodified points of the signal determined by the Sign...
Definition DDS_Channel.h:55
float GetOffset()
Get the Offset property of the DDS channel.
Definition DDS_Channel.h:131
void UpdateWaveTable()
Update the WaveTable based on the SignalForm, Amplitude and Offset.
Definition DDS_Channel.cpp:48
Class used to bundle min, max, default and the current values for parameters.
Definition Parameter.h:17