File syn_dds.h¶
Go to the source code of this file
Direct Digital Synthesis (DDS) Waveform Synthesizer. More...
#include "../common/syn_defs.h"#include "../util/syn_qmath.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_DDS DDS Generator State Instance. |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_DDS_Waveform DDS Waveform Types. |
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_dds_fill_q16 (SYN_DDS * dds, q16_t * buf, size_t count) Fill a Q16.16 buffer with consecutive DDS samples. |
| SYN_Status | syn_dds_fill_u16 (SYN_DDS * dds, uint16_t * buf, size_t count, uint16_t dac_center, uint16_t dac_span) Fill a unsigned 16-bit integer buffer for DAC DMA output. |
| SYN_Status | syn_dds_init (SYN_DDS * dds, SYN_DDS_Waveform type, uint32_t freq_hz, uint32_t sample_rate_hz) Initialize a DDS Generator instance. |
| SYN_Status | syn_dds_set_duty (SYN_DDS * dds, float duty_pct) Set PWM duty cycle (for SYN_DDS_SQUARE mode). |
| SYN_Status | syn_dds_set_freq (SYN_DDS * dds, uint32_t freq_hz, uint32_t sample_rate_hz) Set the output frequency of the DDS generator. |
| SYN_Status | syn_dds_set_gain (SYN_DDS * dds, q16_t amplitude, q16_t offset) Set the peak amplitude and DC offset. |
| q16_t | syn_dds_step (SYN_DDS * dds) Compute and advance the DDS generator by one sample step. |
Detailed Description¶
Implements a zero-malloc Q16.16 fixed-point DDS signal generator supporting Sine, Triangle, Sawtooth, Square/PWM, and Noise waveforms.
Public Types Documentation¶
enum SYN_DDS_Waveform¶
DDS Waveform Types.
enum SYN_DDS_Waveform {
SYN_DDS_SINE = 0,
SYN_DDS_TRIANGLE = 1,
SYN_DDS_SAWTOOTH = 2,
SYN_DDS_SQUARE = 3,
SYN_DDS_NOISE = 4
};
Public Functions Documentation¶
function syn_dds_fill_q16¶
Fill a Q16.16 buffer with consecutive DDS samples.
Parameters:
ddsPointer to DDS instance.bufOutput Q16.16 buffer.countNumber of samples to generate.
Returns:
SYN_OK on success.
function syn_dds_fill_u16¶
Fill a unsigned 16-bit integer buffer for DAC DMA output.
SYN_Status syn_dds_fill_u16 (
SYN_DDS * dds,
uint16_t * buf,
size_t count,
uint16_t dac_center,
uint16_t dac_span
)
Parameters:
ddsPointer to DDS instance.bufOutput 16-bit DAC buffer.countNumber of samples.dac_centerCenter DAC value (e.g. 2048 for 12-bit DAC).dac_spanMaximum peak-to-peak DAC range (e.g. 2047).
Returns:
SYN_OK on success.
function syn_dds_init¶
Initialize a DDS Generator instance.
SYN_Status syn_dds_init (
SYN_DDS * dds,
SYN_DDS_Waveform type,
uint32_t freq_hz,
uint32_t sample_rate_hz
)
Parameters:
ddsPointer to DDS instance.typeWaveform type.freq_hzTarget output frequency in Hz.sample_rate_hzSample rate in Hz.
Returns:
SYN_OK on success, or SYN_INVALID_PARAM.
function syn_dds_set_duty¶
Set PWM duty cycle (for SYN_DDS_SQUARE mode).
Parameters:
ddsPointer to DDS instance.duty_pctDuty cycle percentage (0.0 to 100.0%).
Returns:
SYN_OK on success.
function syn_dds_set_freq¶
Set the output frequency of the DDS generator.
Parameters:
ddsPointer to DDS instance.freq_hzOutput frequency in Hz.sample_rate_hzSample rate in Hz.
Returns:
SYN_OK on success.
function syn_dds_set_gain¶
Set the peak amplitude and DC offset.
Parameters:
ddsPointer to DDS instance.amplitudeQ16.16 peak amplitude.offsetQ16.16 DC offset.
Returns:
SYN_OK on success.
function syn_dds_step¶
Compute and advance the DDS generator by one sample step.
Parameters:
ddsPointer to DDS instance.
Returns:
Generated sample in Q16.16 fixed-point format.
The documentation for this class was generated from the following file src/syntropic/dsp/syn_dds.h