diff --git a/Makefile b/Makefile index 606b62c03..d42f9e6da 100644 --- a/Makefile +++ b/Makefile @@ -242,11 +242,12 @@ GENERATOR_DIR = Test/generate COMM_DIR = Examples/Communication/C XADC_DIR = Test/xadc LA_TEST_DIR = api2/test +GENERATE_DC_DIR = generate_DC .PHONY: examples rp_communication -.PHONY: lcr bode monitor monitor_old generator acquire calib calibrate laboardtest +.PHONY: lcr bode monitor monitor_old generator acquire calib calibrate laboardtest generate_DC -examples: lcr bode monitor monitor_old generator acquire calib +examples: lcr bode monitor monitor_old generator acquire calib generate_DC # calibrate laboardtest lcr: @@ -296,6 +297,11 @@ laboardtest: api2 rp_communication: make -C $(COMM_DIR) +generate_DC: api + $(MAKE) -C $(GENERATE_DC_DIR) + cp $(GENERATE_DC_DIR)/generate_DC $(INSTALL_DIR)/bin/ + cp $(GENERATE_DC_DIR)/generate_DC_LO $(INSTALL_DIR)/bin/ + ################################################################################ # Red Pitaya ecosystem and tools ################################################################################ @@ -440,4 +446,5 @@ clean: make -C $(LIBRPAPP_DIR) clean make -C $(LIBRPLCR_DIR) clean make -C $(COMM_DIR) clean + make -C $(GENERATE_DC_DIR) clean apps-free-clean diff --git a/generate_DC/Makefile b/generate_DC/Makefile new file mode 100644 index 000000000..85317db15 --- /dev/null +++ b/generate_DC/Makefile @@ -0,0 +1,17 @@ +CC = $(CROSS_COMPILE)gcc + +CFLAGS = -g -std=gnu99 -Wall -Werror +CFLAGS += -I../api/include +LFLAGS = -L../api/lib +LIBS = -lm -lpthread -lrp + +SRCS=$(wildcard *.c) +OBJS=$(SRCS:.c=) + +all: $(OBJS) + +%: %.c + $(CC) $(CFLAGS) $(LFLAGS) $< -o $@ $(LIBS) + +clean: + $(RM) $(OBJS) diff --git a/generate_DC/generate_DC.c b/generate_DC/generate_DC.c new file mode 100644 index 000000000..6bb94681a --- /dev/null +++ b/generate_DC/generate_DC.c @@ -0,0 +1,44 @@ +/* Red Pitaya C API example Generating continuous signal + * This application generates a specific signal */ + +#include +#include +#include +#include + +#include "redpitaya/rp.h" + +int main(int argc, char **argv){ + + /* Print error, if rp_Init() function failed */ + if(rp_Init() != RP_OK){ + fprintf(stderr, "Rp api init failed!\n"); + } + + /* Generator reset */ + rp_GenReset(); + + /* Generating frequency */ + rp_GenFreq(RP_CH_1, 0); + rp_GenFreq(RP_CH_2, 0); + + /* Generating wave form */ + rp_GenWaveform(RP_CH_1, RP_WAVEFORM_DC); + rp_GenWaveform(RP_CH_2, RP_WAVEFORM_DC); + + /* Generating amplitude */ + rp_GenAmp(RP_CH_1, 0.9); + rp_GenOffset(RP_CH_1, 0); + + rp_GenAmp(RP_CH_2, 0.9); + rp_GenOffset(RP_CH_2, 0); + + /* Enable channel */ + rp_GenOutEnable(RP_CH_1); + rp_GenOutEnable(RP_CH_2); + + /* Releasing resources */ + rp_Release(); + + return 0; +} diff --git a/generate_DC/generate_DC_LO.c b/generate_DC/generate_DC_LO.c new file mode 100644 index 000000000..1d259a1d1 --- /dev/null +++ b/generate_DC/generate_DC_LO.c @@ -0,0 +1,44 @@ +/* Red Pitaya C API example Generating continuous signal + * This application generates a specific signal */ + +#include +#include +#include +#include + +#include "redpitaya/rp.h" + +int main(int argc, char **argv){ + + /* Print error, if rp_Init() function failed */ + if(rp_Init() != RP_OK){ + fprintf(stderr, "Rp api init failed!\n"); + } + + /* Generator reset */ + rp_GenReset(); + + /* Generating frequency */ + rp_GenFreq(RP_CH_1, 0); + rp_GenFreq(RP_CH_2, 0); + + /* Generating wave form */ + rp_GenWaveform(RP_CH_1, RP_WAVEFORM_DC); + rp_GenWaveform(RP_CH_2, RP_WAVEFORM_DC); + + /* Generating amplitude */ + rp_GenAmp(RP_CH_1, 0.45); + rp_GenOffset(RP_CH_1, 0); + + rp_GenAmp(RP_CH_2, 0.45); + rp_GenOffset(RP_CH_2, 0); + + /* Enable channel */ + rp_GenOutEnable(RP_CH_1); + rp_GenOutEnable(RP_CH_2); + + /* Releasing resources */ + rp_Release(); + + return 0; +}