Commit 9bace7cb authored by claes's avatar claes

IO PiFace Digital for Raspberry Pi added

parent b507ffc0
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
/*
Dummy for piface
*/
#include <stdint.h>
int pfio_init(void) { return 1;}
int pfio_deinit(void) {return 1;}
uint8_t pfio_digital_read(uint8_t pin_number) {return 0;}
void pfio_digital_write(uint8_t pin_number, uint8_t value) {}
uint8_t pfio_read_input(void) {return 0;}
uint8_t pfio_read_output(void) {return 0;}
void pfio_write_output(uint8_t value) {}
uint8_t pfio_get_pin_bit_mask(uint8_t pin_number) {return 0;}
uint8_t pfio_get_pin_number(uint8_t bit_mask) {return 0;}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2014 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 2 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* rt_io_m_piface_digital.c -- I/O methods for class PiFace_Digital. */
#include "pwr.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "co_time.h"
#include "rt_io_base.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "rt_io_card_write.h"
#include "rt_io_msg.h"
#if defined PWRE_CONF_LIBPIFACE && PWRE_CONF_PIFACE
#include <libpiface-1.0/pfio.h>
typedef struct {
pwr_tStatus sts;
} io_sLocal_PiFace;
static pwr_tStatus IoCardInit( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocal_PiFace *local;
pwr_sClass_PiFace_Digital *op = (pwr_sClass_PiFace_Digital *)cp->op;
local = (io_sLocal_PiFace *) calloc( 1, sizeof(io_sLocal_PiFace));
cp->Local = local;
local->sts = pfio_init();
if ( local->sts != 0) {
op->Status = IO__INITFAIL;
return op->Status;
}
errh_Info( "Init of PiFace Digital '%s'", cp->Name);
op->Status = IO__SUCCESS;
return IO__SUCCESS;
}
static pwr_tStatus IoCardClose( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocal_PiFace *local = (io_sLocal_PiFace *)cp->Local;
if ( local->sts == 0)
pfio_deinit();
if ( cp->Local)
free( cp->Local);
return IO__SUCCESS;
}
static pwr_tStatus IoCardRead( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocal_PiFace *local = (io_sLocal_PiFace *)cp->Local;
uint8_t value;
uint8_t m;
int i;
if ( local->sts != 0)
return 0;
// Handle Di
value = pfio_read_input();
m = 1;
for ( i = 0; i < 8; i++) {
if ( cp->chanlist[i].sop)
*(pwr_tBoolean *)cp->chanlist[i].vbp = ((value & m) != 0);
m = m << 1;
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardWrite( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocal_PiFace *local = (io_sLocal_PiFace *)cp->Local;
uint8_t value;
uint8_t m;
int i;
if ( local->sts != 0)
return 0;
// Handle Do
m = 1;
for ( i = 0; i < 8; i++) {
if ( cp->chanlist[i+8].sop) {
if ( *(pwr_tBoolean *)cp->chanlist[i+8].vbp)
value |= m;
}
m = m << 1;
}
pfio_write_output(value);
return IO__SUCCESS;
}
#else
static pwr_tStatus IoCardInit( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return IO__RELEASEBUILD;}
static pwr_tStatus IoCardClose( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return IO__RELEASEBUILD;}
static pwr_tStatus IoCardRead( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return IO__RELEASEBUILD;}
static pwr_tStatus IoCardWrite( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return IO__RELEASEBUILD;}
#endif
/* Every method should be registred here. */
pwr_dExport pwr_BindIoMethods(PiFace_Digital) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
......@@ -32,4 +32,5 @@ Epl_MN
Epl_Module
Epl_CNServer
Epl_CNServerModule
PiFace_Digital
#endif
\ No newline at end of file
This diff is collapsed.
......@@ -167,6 +167,8 @@ pwre_config_check_lib()
conf_libpnak=$conf_libpnak" -l${lib%.*}"
elif test $4 == "libusb"; then
conf_lib=$conf_lib" -lusb-1.0"
elif test $4 == "libpiface"; then
conf_lib=$conf_lib" -lpiface-1.0"
elif test $4 == "powerlink"; then
conf_libpowerlink=$conf_libpowerlink" -L$lib_path -l${lib%.*}"
elif test $4 == "powerlinkcn"; then
......@@ -456,8 +458,12 @@ else
pwre_config_check_lib libusb LIBUSB lib libusb 1 "/usr/lib/libusb-1.0.so:/usr/lib/$hwpl-linux-$gnu/libusb-1.0.so"
pwre_config_check_lib powerlink POWERLINK lib powerlink 1 "$epl/build/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a"
pwre_config_check_lib powerlinkcn POWERLINKCN lib powerlinkcn 1 "$epl/buildcn/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a"
pwre_config_check_lib libpcap LIBPCAP lib libpcap 1 "/usr/lib/libpcap.so:/usr/lib/$hwpl-linux-$gnu/libpcap.so"
pwre_config_check_lib libpcap LIBPCAP lib libpcap 1 "/usr/lib/libpcap.so:/usr/lib/$hwpl-linux-$gnu/libpcap.so"
pwre_config_check_lib librsvg LIBRSVG lib librsvg 1 "/usr/lib/librsvg-2.so:/usr/lib/$hwpl-linux-$gnu/librsvg-2.so"
if [ $pwre_hw == "hw_arm" ]; then
pwre_config_check_lib libpiface LIBPIFACE lib libpiface 1 "/usr/local/lib/libpiface-1.0.a"
pwre_config_check_include piface PIFACE 1 "/usr/local/include/libpiface-1.0/pfio.h"
fi
pwre_config_check_include mq MQ 0 "/usr/local/dmq/include/p_entry.h"
pwre_config_check_include wmq WMQ 1 "/opt/mqm/inc/cmqc.h"
......
......@@ -184,7 +184,7 @@ CompileRtNode()
ld_opt_tmp="`cat $pwrp_exe/$FileName.opt`"
ld_opt="`eval echo $ld_opt_tmp`"
else
ld_opt="`eval echo $pwrobj/rt_io_user.o -lpwr_rt -lpwr_usbio_dummy -lpwr_usb_dummy -lpwr_pnak_dummy -lpwr_cifx_dummy`"
ld_opt="`eval echo $pwrobj/rt_io_user.o -lpwr_rt -lpwr_usbio_dummy -lpwr_usb_dummy -lpwr_pnak_dummy -lpwr_cifx_dummy -lpwr_piface_dummy`"
fi
if $ldxx $link_debug -L/lib/thread -L$pwrp_lib -L$pwrp_cmn/arm_linux/lib -L$pwrlib \
......
Markdown is supported
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