39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
74#define WAVEFORM4_REG_SPI_CONFIG 0x0000
75#define WAVEFORM4_REG_POWER_CONFIG 0x0001
76#define WAVEFORM4_REG_CLOCK_CONFIG 0x0002
77#define WAVEFORM4_REG_REF_ADJ 0x0003
78#define WAVEFORM4_REG_DAC4_AGAIN 0x0004
79#define WAVEFORM4_REG_DAC3_AGAIN 0x0005
80#define WAVEFORM4_REG_DAC2_AGAIN 0x0006
81#define WAVEFORM4_REG_DAC1_AGAIN 0x0007
82#define WAVEFORM4_REG_DACX_RANGE 0x0008
83#define WAVEFORM4_REG_DAC4_RSET 0x0009
84#define WAVEFORM4_REG_DAC3_RSET 0x000A
85#define WAVEFORM4_REG_DAC2_RSET 0x000B
86#define WAVEFORM4_REG_DAC1_RSET 0x000C
87#define WAVEFORM4_REG_CAL_CONFIG 0x000D
88#define WAVEFORM4_REG_COMP_OFFSET 0x000E
89#define WAVEFORM4_REG_RAM_UPDATE 0x001D
90#define WAVEFORM4_REG_PAT_STATUS 0x001E
91#define WAVEFORM4_REG_PAT_TYPE 0x001F
92#define WAVEFORM4_REG_PATTERN_DLY 0x0020
93#define WAVEFORM4_REG_DAC4_DOF 0x0022
94#define WAVEFORM4_REG_DAC3_DOF 0x0023
95#define WAVEFORM4_REG_DAC2_DOF 0x0024
96#define WAVEFORM4_REG_DAC1_DOF 0x0025
97#define WAVEFORM4_REG_WAV43_CONFIG 0x0026
98#define WAVEFORM4_REG_WAV21_CONFIG 0x0027
99#define WAVEFORM4_REG_PAT_TIMEBASE 0x0028
100#define WAVEFORM4_REG_PAT_PERIOD 0x0029
101#define WAVEFORM4_REG_DAC43_PATX 0x002A
102#define WAVEFORM4_REG_DAC21_PATX 0x002B
103#define WAVEFORM4_REG_DOUT_START_DLY 0x002C
104#define WAVEFORM4_REG_DOUT_CONFIG 0x002D
105#define WAVEFORM4_REG_DAC4_CST 0x002E
106#define WAVEFORM4_REG_DAC3_CST 0x002F
107#define WAVEFORM4_REG_DAC2_CST 0x0030
108#define WAVEFORM4_REG_DAC1_CST 0x0031
109#define WAVEFORM4_REG_DAC4_DGAIN 0x0032
110#define WAVEFORM4_REG_DAC3_DGAIN 0x0033
111#define WAVEFORM4_REG_DAC2_DGAIN 0x0034
112#define WAVEFORM4_REG_DAC1_DGAIN 0x0035
113#define WAVEFORM4_REG_SAW43_CONFIG 0x0036
114#define WAVEFORM4_REG_SAW21_CONFIG 0x0037
115#define WAVEFORM4_REG_DDS_TW32 0x003E
116#define WAVEFORM4_REG_DDS_TW1 0x003F
117#define WAVEFORM4_REG_DDS4_PW 0x0040
118#define WAVEFORM4_REG_DDS3_PW 0x0041
119#define WAVEFORM4_REG_DDS2_PW 0x0042
120#define WAVEFORM4_REG_DDS1_PW 0x0043
121#define WAVEFORM4_REG_TRIG_TW_SEL 0x0044
122#define WAVEFORM4_REG_DDSX_CONFIG 0x0045
123#define WAVEFORM4_REG_TW_RAM_CONFIG 0x0047
124#define WAVEFORM4_REG_START_DLY4 0x0050
125#define WAVEFORM4_REG_START_ADDR4 0x0051
126#define WAVEFORM4_REG_STOP_ADDR4 0x0052
127#define WAVEFORM4_REG_DDS_CYC4 0x0053
128#define WAVEFORM4_REG_START_DLY3 0x0054
129#define WAVEFORM4_REG_START_ADDR3 0x0055
130#define WAVEFORM4_REG_STOP_ADDR3 0x0056
131#define WAVEFORM4_REG_DDS_CYC3 0x0057
132#define WAVEFORM4_REG_START_DLY2 0x0058
133#define WAVEFORM4_REG_START_ADDR2 0x0059
134#define WAVEFORM4_REG_STOP_ADDR2 0x005A
135#define WAVEFORM4_REG_DDS_CYC2 0x005B
136#define WAVEFORM4_REG_START_DLY1 0x005C
137#define WAVEFORM4_REG_START_ADDR1 0x005D
138#define WAVEFORM4_REG_STOP_ADDR1 0x005E
139#define WAVEFORM4_REG_DDS_CYC1 0x005F
140#define WAVEFORM4_REG_CFG_ERROR 0x0060
141#define WAVEFORM4_SRAM_ADDRESS_MIN 0x6000
142#define WAVEFORM4_SRAM_ADDRESS_MAX 0x6FFF
160#define WAVEFORM4_WAV_CFG_PRESTORE_CST 0x00
161#define WAVEFORM4_WAV_CFG_PRESTORE_SAWTOOTH 0x10
162#define WAVEFORM4_WAV_CFG_PRESTORE_PSEUDO 0x20
163#define WAVEFORM4_WAV_CFG_PRESTORE_DDS 0x30
164#define WAVEFORM4_WAV_CFG_WAVE_FROM_RAM 0x00
165#define WAVEFORM4_WAV_CFG_WAVE_PRESTORED 0x01
166#define WAVEFORM4_WAV_CFG_WAVE_PRESTORED_DELAY 0x02
167#define WAVEFORM4_WAV_CFG_WAVE_PRESTORED_RAM 0x03
168#define WAVEFORM4_DDSX_CFG_ENABLE_COSINE 0x08
169#define WAVEFORM4_SAW_CFG_RAMP_UP 0x00
170#define WAVEFORM4_SAW_CFG_RAMP_DOWN 0x01
171#define WAVEFORM4_SAW_CFG_TRIANGLE 0x02
172#define WAVEFORM4_SAW_CFG_NO_WAVE 0x03
173#define WAVEFORM4_SAW_CFG_STEP_1 0x04
179#define WAVEFORM4_DEFAULT_GAIN 0.5
180#define WAVEFORM4_DEFAULT_FREQUENCY 100000
186#define WAVEFORM4_UPDATE_SETTINGS 0x01
187#define WAVEFORM4_MEM_ACCESS_ENABLE 0x04
188#define WAVEFORM4_MEM_ACCESS_DISABLE 0x00
189#define WAVEFORM4_BUF_READ 0x08
190#define WAVEFORM4_START_PATTERN 0x01
191#define WAVEFORM4_STOP_PATTERN 0x00
197#define WAVEFORM4_CHANNEL_1 0x00
198#define WAVEFORM4_CHANNEL_2 0x01
199#define WAVEFORM4_CHANNEL_3 0x02
200#define WAVEFORM4_CHANNEL_4 0x03
206#define WAVEFORM4_WAVE_SINE 0x00
207#define WAVEFORM4_WAVE_COSINE 0x01
208#define WAVEFORM4_WAVE_TRIANGLE 0x02
209#define WAVEFORM4_WAVE_POSITIVE_SAWTOOTH 0x03
210#define WAVEFORM4_WAVE_NEGATIVE_SAWTOOTH 0x04
216#define WAVEFORM4_GAIN_MAX 2.0
217#define WAVEFORM4_GAIN_MIN (-2.0)
218#define WAVEFORM4_GAIN_RESOLUTION 1024
224#define WAVEFORM4_MASTER_CLOCK 125000000
225#define WAVEFORM4_FREQ_RESOLUTION 0x1000000
231#define WAVEFORM4_SPI_READ_MASK 0x80
232#define WAVEFORM4_SPI_WRITE_MASK 0x7F
242#define WAVEFORM4_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
243#define WAVEFORM4_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
261#define WAVEFORM4_MAP_MIKROBUS( cfg, mikrobus ) \
262 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
263 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
264 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
265 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
266 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
267 cfg.trg = MIKROBUS( mikrobus, MIKROBUS_PWM );
uint8_t channel
Definition main.c:36
uint32_t freq
Definition main.c:34
float gain
Definition main.c:35
uint8_t wave
Definition main.c:37
This file contains SPI specific macros, functions, etc.