-
Notifications
You must be signed in to change notification settings - Fork 2
/
wave_gen.h
53 lines (43 loc) · 1.3 KB
/
wave_gen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/** @file wave_gen.h
* @brief WaveGen Control include file
* @author Leong Keit
* @date April 2016
*/
#ifndef WAVE_GEN_H
#define WAVE_GEN_H
#include "dac.h"
#include "dma.h"
#include "timer.h"
/*define DAC channel and DMA channel to use DAC and DMA driver*/
#define DAC_CHN DAC_CHN_1
#define DMA_CHN DMA_CHN_3
#define TIMER_IDX TIMER_IDX_6
/* DAC peripheral limitation defines*/
#define TIMER_TICK_NS 21
#define CLOCK_SPEED 42000000
#define DAC_RESOLUTION 4096
#define DAC_VREF 3.3
/*enum for the waveform types supported*/
enum waveform {
SINE = 0,
SAWTOOTH = 1,
TRIANGLE = 2,
SQUARE = 3
};
/*define for waveform data calculations*/
#define PI_VALUE 3.14159
#define MIN_SAMPLE_PER_CYCLE 50
#define DAC_SAMPLE_WAIT_TIME_NS 10000
#define DAC_SAMPLE_MAX_DRAG_TIME_NS 1000000
#define MAX_MEMORY_ALLOWED 2000
/*waveform parameter limitation defines*/
#define MAX_AMPLITUDE_FLOAT 3.3
#define MIN_AMPLITUDE_FLOAT 1.0
#define MAX_FREQUENCY (1000000000/(DAC_SAMPLE_WAIT_TIME_NS*MIN_SAMPLE_PER_CYCLE))
#define MIN_FREQUENCY 1
extern void generate_waveform(enum waveform waveform, uint32_t frequency, float amplitude);
extern uint32_t get_max_freq(void);
extern uint32_t get_min_freq(void);
extern float get_max_amplitude(void);
extern float get_min_amplitude(void);
#endif /* WAVE_GEN_H */