Commit fbbde04d authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Add ad converter block

parent 1b4b001c
/*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2007
Copyright Stichting C.A. Muller Radioastronomiestation, 2007
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <controller/controller_block.h>
struct controller_block_private {
float ain0;
float ain1;
float ain2;
float ain3;
float ain4;
float ain5;
float ain6;
float ain7;
float gain0;
float gain1;
float gain2;
float gain3;
float gain4;
float gain5;
float gain6;
float gain7;
float offset0;
float offset1;
float offset2;
float offset3;
float offset4;
float offset5;
float offset6;
float offset7;
};
static void adc_calculate(struct controller_block *adc)
{
// struct controller_block_private *priv = adc->private;
}
static struct controller_block_outterm_list outterms[] = {
{ "ain0", CONTROLLER_BLOCK_TERM_FLOAT, offsetof(struct controller_block_private, ain0) },
{ "ain1", CONTROLLER_BLOCK_TERM_FLOAT, offsetof(struct controller_block_private, ain1) },
{ "ain2", CONTROLLER_BLOCK_TERM_FLOAT, offsetof(struct controller_block_private, ain2) },
{ "ain3", CONTROLLER_BLOCK_TERM_FLOAT, offsetof(struct controller_block_private, ain3) },
{ "ain4", CONTROLLER_BLOCK_TERM_FLOAT, offsetof(struct controller_block_private, ain4) },
{ "ain5", CONTROLLER_BLOCK_TERM_FLOAT, offsetof(struct controller_block_private, ain5) },
{ "ain6", CONTROLLER_BLOCK_TERM_FLOAT, offsetof(struct controller_block_private, ain6) },
{ "ain7", CONTROLLER_BLOCK_TERM_FLOAT, offsetof(struct controller_block_private, ain7) },
{ NULL }
};
static struct controller_block_param_list params[] = {
{ "gain0", false },
{ "gain1", false },
{ "gain2", false },
{ "gain3", false },
{ "gain4", false },
{ "gain5", false },
{ "gain6", false },
{ "gain7", false },
{ "offset0", false },
{ "offset1", false },
{ "offset2", false },
{ "offset3", false },
{ "offset4", false },
{ "offset5", false },
{ "offset6", false },
{ "offset7", false },
{ NULL },
};
static void param_set(struct controller_block *adc, int param, va_list val)
{
switch (param) {
case 0:
adc->private->gain0 = va_arg(val, double);
break;
}
}
struct controller_block * block_am335x_adc_create(char *name)
{
struct controller_block *adc;
if (!(adc = controller_block_alloc("am355x_adc", name, sizeof(struct controller_block_private))))
return NULL;
if (controller_block_outterm_list_init(adc, outterms))
goto err_block;
adc->calculate = adc_calculate;
if (controller_block_param_list_init(adc, params))
goto err_block;
adc->param_set = param_set;
controller_block_add(adc);
return adc;
err_block:
controller_block_free(adc);
return NULL;
}
BLOCK_TARGETS := $(LIBDIR)/libam335x.la
BLOCK_SRCS := \
$(DIR)/block_am335x_adc.c
BLOCK_OBJS := $(BLOCK_SRCS:.c=.lo)
$(BLOCK_OBJS): CFLAGS += -O3 -g -Wall
$(LIBDIR)/libam335x.la_LDFLAGS +=
$(LIBDIR)/libam335x.la: $(BLOCK_OBJS)
$(LIB_LINK)
TARGETS += $(BLOCK_TARGETS)
CLEAN += $(BLOCK_TARGETS) $(BLOCK_OBJS)
SRCS += $(BLOCK_SRCS)
BLOCK_TARGETS += $(LIBDIR)/libblock.la
BLOCK_TARGETS := $(LIBDIR)/libblock.la
$(eval $(call SUBDIR,il2c))
BLOCK_SRCS = \
BLOCK_SRCS := \
$(DIR)/block_add.c \
$(DIR)/block_and2.il \
$(DIR)/block_bridge_pwm.c \
......@@ -47,7 +47,6 @@ BLOCK_SRCS = \
$(DIR)/block_value_bool.c \
$(DIR)/block_value_uint32.c
OS= $(shell uname -s)
ifneq ($(OS), FreeBSD)
BLOCK_SRCS+= \
$(DIR)/block_joystick.c
......@@ -57,7 +56,7 @@ BLOCK_OBJSC := $(BLOCK_SRCS:.c=.lo)
BLOCK_OBJS := $(BLOCK_OBJSC:.il=.il2c.lo)
$(BLOCK_OBJS): CFLAGS += -O0 -g -Wall
$(BLOCK_OBJS): CFLAGS += -O3 -Wall
$(LIBDIR)/libblock.la_LDFLAGS += -lm
$(LIBDIR)/libblock.la: $(BLOCK_OBJS)
$(LIB_LINK)
......
......@@ -9,26 +9,26 @@ $(eval $(call SUBDIR,dt_azimuth))
$(eval $(call SUBDIR,dt_elevation))
$(eval $(call SUBDIR,test))
ifneq (,$(findstring arm,$(HW)))
$(eval $(call SUBDIR,am335x))
endif
DT_CTRL_TARGETS += $(DIR)/dt_ctrl
DT_CTRL_SRCS := $(DIR)/dt_ctrl.c
DT_CTRL_OBJS := $(DT_CTRL_SRCS:.c=.o)
BLOCKS := `$(DIR)/controller/block_list.sh $(DIR)/lib/*.a`
BLOCKS := $(shell $(DIR)/controller/block_list.sh $(DIR)/lib/*.a)
BLOCKDEP := $(shell $(DIR)/controller/block_dep.sh $(DIR)/lib/*.a)
$(DIR)/dt_ctrl: \
libcontroller.la \
libblock.la \
libethercat.la \
liblog.la \
libshell.la \
libdt_azimuth.la \
libdt_elevation.la
$(BLOCKDEP)
$(DIR)/dt_ctrl: CFLAGS += -Wall -O3
$(DIR)/dt_ctrl: LDFLAGS += \
-Wl,-E \
-lcontroller \
-lblock \
-lethercat \
-llog \
-lshell \
......
#!/bin/sh
for lib in $@; do
SYMBOLS=`nm $lib |grep "block_.*_create" |cut -d' ' -f3`
if [ "${SYMBOLS}none" != "none" ]; then
echo -n "$lib "
fi
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment