Commit 3680771b authored by claes's avatar claes

Fixed I/O-routines with new driver

parent cb9390dd
/******************************************************************************
/*
* Proview $Id: Papi.c,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*******************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
......
/*
* Proview $Id: buildnr.papi.h,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define BUILD_NUMBER 52
#define BUILD_NUMBER_STR "52"
......
/*
* Proview $Id: busparam.c,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************
* *
* SOFTING AG *
......
/*
* Proview $Id: ccrl.c,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************
* *
* SOFTING AG *
......
/*
* Proview $Id: dpgdl.c,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************
* *
* SOFTING AG *
......
/*
* Proview $Id: dpsgdl.c,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************
* *
* SOFTING AG *
......
/*
* Proview $Id: fdlgdl.c,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************
* *
* SOFTING AG *
......
/*
* Proview $Id: fm7gdl.c,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************
* *
* SOFTING AG *
......
/*
* Proview $Id: fmbgdl.c,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************
* *
* SOFTING AG *
......
/*
* Proview $Id: fmsgdl.c,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************
* *
* SOFTING AG *
......
/*
* Proview $Id: keywords.h,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: papiaux.c,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************
* *
* SOFTING AG *
......
/*
* Proview $Id: pb_conf.h,v 1.4 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_dp.h,v 1.4 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_dps.h,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_err.h,v 1.4 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_fdl.h,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_fm7.h,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_fmb.h,v 1.4 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_fms.h,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_hw.h,v 1.2 2006-02-01 08:35:51 claes Exp $
* Proview $Id: pb_hw.h,v 1.3 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Proview $Id: pb_hw.h,v 1.3 2007-01-17 12:40:30 claes Exp $
* Copyright (C) SOFTING GmbH 1995-1999.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......
/*
* Proview $Id: pb_if.h,v 1.4 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_ioctl.h,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_ntdrv.h,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_tools.h,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pb_type.h,v 1.4 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
/*
* Proview $Id: pbus.h,v 1.1 2006-01-16 10:55:42 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __PBDRVR__
#define __PBDRVR__
#define INIT_MODE 0x00
#define CONFIG_MODE 0x05
#define COMM_MODE 0x08
#define H_READY_MASK 0x874B2D1E
#define C_READY_MASK 0x78B4D2E1
#define IDLE 0x00
#define BUSY 0x01
#define D_DATA_IDLE 0x00
#define D_DATA_APPLY 0xF0
#define D_DATA_BUSY 0x0F
// Macros for defining ioctl commands
#define PB_IOCTL_MAGIC 'c'
#define PB_IOCTL_READCMIDESC _IO(PB_IOCTL_MAGIC, 1)
#define PB_IOCTL_READLOCALREG _IO(PB_IOCTL_MAGIC, 2)
#define PB_IOCTL_WRITECMIDESC _IO(PB_IOCTL_MAGIC, 3)
#define PB_IOCTL_HWRESET _IO(PB_IOCTL_MAGIC, 4)
#define PB_IOCTL_CMI_INIT _IO(PB_IOCTL_MAGIC, 5)
#define PB_IOCTL_READDATADESC _IO(PB_IOCTL_MAGIC, 6)
#define PB_IOCTL_CMI_WRITE _IO(PB_IOCTL_MAGIC, 7)
#define PB_IOCTL_READ_SDB _IO(PB_IOCTL_MAGIC, 8)
#define PB_IOCTL_READ_DB _IO(PB_IOCTL_MAGIC, 9)
#define PB_IOCTL_CMI_READ _IO(PB_IOCTL_MAGIC, 10)
#define PB_IOCTL_READ_IRQ_VALUES _IO(PB_IOCTL_MAGIC, 11)
#define PB_IOCTL_READ_FIRST_SLAVE _IO(PB_IOCTL_MAGIC, 12)
#define PB_IOCTL_WRITE_FIRST_SLAVE _IO(PB_IOCTL_MAGIC, 13)
#define PB_IOCTL_READVERSION _IO(PB_IOCTL_MAGIC, 14)
#define PB_IOCTL_READSERIAL _IO(PB_IOCTL_MAGIC, 15)
#define PB_IOCTL_SET_STALLTIME _IO(PB_IOCTL_MAGIC, 16)
#define ERROR_DESCR_LENGTH 32
typedef struct {
unsigned int h_ready_mask;
unsigned int h_base_address;
unsigned char h_id;
unsigned char h_int_enable;
unsigned char h_address_swap_mode;
unsigned char h_state;
unsigned int h_param_addr;
unsigned int h_data_addr;
unsigned short h_param_size;
unsigned short h_data_size;
unsigned char h_sema;
unsigned char h_ret_val;
unsigned char h_head;
unsigned char h_tail;
unsigned int h_data_descr_addr;
unsigned int c_ready_mask;
unsigned int c_base_address;
unsigned char c_id;
unsigned char c_int_enable;
unsigned char c_address_swap_mode;
unsigned char c_state;
unsigned int c_param_addr;
unsigned int c_data_addr;
unsigned short c_param_size;
unsigned short c_data_size;
unsigned char c_sema;
unsigned char c_ret_val;
unsigned char c_head;
unsigned char c_tail;
unsigned int c_data_descr_addr;
}T_CMI_DESCRIPTOR;
typedef struct {
unsigned int reg[21];
} T_LOCALREG;
typedef struct {
unsigned char d_id;
unsigned char dummy;
unsigned char d_sema_c;
unsigned char d_sema_h;
unsigned short d_data_size;
unsigned int d_data_addr;
} T_DATA_DESCR;
typedef struct {
T_PROFI_SERVICE_DESCR *sdb_ptr;
USIGN8 *data_ptr;
USIGN16 *data_len_ptr;
USIGN16 *retval_ptr;
} cmi_request_access_struct;
typedef struct {
USIGN8 data_id; // Id of data structure
USIGN16 offset; // Offset in data area
USIGN8 *data_ptr; // Pointer to data to write/to be read
USIGN16 *retval_ptr; // Pointer to return value
} cmi_data_access_struct;
#endif
/*
* Proview $Id: rt_io_m_pb_ai.c,v 1.4 2006-09-05 11:14:34 claes Exp $
* Proview $Id: rt_io_m_pb_ai.c,v 1.5 2007-01-17 12:40:30 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -30,8 +30,12 @@
#include <sys/file.h>
#include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h"
......
/*
* Proview $Id: rt_io_m_pb_profiboard.c,v 1.5 2007-01-12 13:28:31 claes Exp $
* Proview $Id: rt_io_m_pb_profiboard.c,v 1.6 2007-01-17 12:40:30 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -55,23 +55,10 @@
#define DP_MAX_SERVICE_RETRY 10
#define PROFI_RCV_CON_IND() retry_counter = DP_MAX_SERVICE_RETRY; \
do { \
result = profi_rcv_con_ind (hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len); \
} while ((result == NO_CON_IND_RECEIVED) && (retry_counter-- > 0)); \
\
if (result == E_IF_FATAL_ERROR) return (PB_FALSE); \
static int count;
USIGN8 con_ind_buffer [256];
USIGN16 con_ind_buffer_len = 256;
T_PROFI_SERVICE_DESCR con_ind_sdb;
INT16 result; /* !!! local result variable !!! */
USIGN16 retry_counter;
static pwr_tStatus IoAgentInit (
io_tCtx ctx,
io_sAgent *ap
......@@ -90,6 +77,29 @@ static pwr_tStatus IoAgentClose (
);
/*----------------------------------------------------------------------------*\
Sends request to Profiboard for setting FMB parameters
\*----------------------------------------------------------------------------*/
static short try_profi_rcv_con_ind(T_PROFI_DEVICE_HANDLE *hDevice,
T_PROFI_SERVICE_DESCR *con_ind_sdb,
USIGN8 *con_ind_buffer,
USIGN16 *con_ind_buffer_len,
INT16 *result)
{
int retry_counter;
struct timespec rqtp = {0, 10000000}; // 10 ms
retry_counter = DP_MAX_SERVICE_RETRY;
do {
nanosleep(&rqtp, NULL);
*result = profi_rcv_con_ind (hDevice, con_ind_sdb, con_ind_buffer, con_ind_buffer_len);
} while ((*result == NO_CON_IND_RECEIVED) && (retry_counter-- > 0));
if (*result == E_IF_FATAL_ERROR) return (PB_FALSE);
return (PB_TRUE);
}
/*----------------------------------------------------------------------------*\
Sends request to Profiboard for setting FMB parameters
\*----------------------------------------------------------------------------*/
......@@ -103,7 +113,6 @@ static short fmb_set_configuration(T_PROFI_DEVICE_HANDLE *hDevice,
USIGN16 con_ind_buffer_len = 256;
T_PROFI_SERVICE_DESCR con_ind_sdb;
INT16 result; /* !!! local result variable !!! */
USIGN16 retry_counter;
sdb.comm_ref = 0;
sdb.layer = FMB;
......@@ -129,7 +138,7 @@ static short fmb_set_configuration(T_PROFI_DEVICE_HANDLE *hDevice,
profi_snd_req_res(hDevice, &sdb, &data, PB_FALSE);
PROFI_RCV_CON_IND (); /*Macro to fetch one confirmation or indication*/
try_profi_rcv_con_ind(hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
if ((con_ind_sdb.service == FMB_SET_CONFIGURATION) &&
(con_ind_sdb.primitive == CON ) &&
......@@ -154,7 +163,6 @@ static short dp_init_master(T_PROFI_DEVICE_HANDLE *hDevice)
USIGN16 con_ind_buffer_len = 256;
T_PROFI_SERVICE_DESCR con_ind_sdb;
INT16 result; /* !!! local result variable !!! */
USIGN16 retry_counter;
sdb.comm_ref = 0;
sdb.layer = DP;
......@@ -173,8 +181,8 @@ static short dp_init_master(T_PROFI_DEVICE_HANDLE *hDevice)
profi_snd_req_res(hDevice, &sdb, &data, PB_FALSE);
PROFI_RCV_CON_IND (); /*Macro to fetch one confirmation or indication*/
try_profi_rcv_con_ind(hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
if ((con_ind_sdb.service == DP_INIT_MASTER) &&
(con_ind_sdb.primitive == CON ) &&
(con_ind_sdb.result == POS )) {
......@@ -202,7 +210,6 @@ static short dp_download_bus(T_PROFI_DEVICE_HANDLE *hDevice,
USIGN16 con_ind_buffer_len = 256;
T_PROFI_SERVICE_DESCR con_ind_sdb;
INT16 result; /* !!! local result variable !!! */
USIGN16 retry_counter;
sdb.comm_ref = 0;
sdb.layer = DP;
......@@ -264,7 +271,7 @@ static short dp_download_bus(T_PROFI_DEVICE_HANDLE *hDevice,
profi_snd_req_res(hDevice, &sdb, &data, PB_FALSE);
PROFI_RCV_CON_IND (); /*Macro to fetch one confirmation or indication*/
try_profi_rcv_con_ind(hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
if ((con_ind_sdb.service == DP_DOWNLOAD_LOC) &&
(con_ind_sdb.primitive == CON ) &&
......@@ -305,7 +312,7 @@ static short dp_act_param_loc(T_PROFI_DEVICE_HANDLE *hDevice,
}
/*----------------------------------------------------------------------------*\
Sends request for selecting operation mode to the Profiboard
Sends request for getting slave diagnostics
\*----------------------------------------------------------------------------*/
static pwr_tBoolean dp_get_slave_diag(T_PROFI_DEVICE_HANDLE *hDevice)
{
......@@ -326,7 +333,7 @@ static pwr_tBoolean dp_get_slave_diag(T_PROFI_DEVICE_HANDLE *hDevice)
}
/*----------------------------------------------------------------------------*\
Sends request for selecting operation mode to the Profiboard
Get slave diagnostics
\*----------------------------------------------------------------------------*/
static void dp_get_slave_diag_con(T_DP_GET_SLAVE_DIAG_CON * get_slave_diag_con_ptr)
{
......@@ -379,13 +386,9 @@ static pwr_tStatus dp_download_slave (
USIGN16 con_ind_buffer_len = 256;
T_PROFI_SERVICE_DESCR con_ind_sdb;
INT16 result; /* !!! local result variable !!! */
USIGN16 retry_counter;
op->Status = PB__NOTINIT;
// Try to initialize slave, make three attempts before we give up
download_data_size = sizeof(prm_head) + sizeof(prm_data) +
op->PrmUserDataLen + op->ConfigDataLen +
sizeof(aat_data) + sizeof(user_data);
......@@ -446,7 +449,7 @@ static pwr_tStatus dp_download_slave (
profi_snd_req_res(hDevice, &sdb, &slave_data, PB_FALSE);
PROFI_RCV_CON_IND (); /*Macro to fetch one confirmation or indication*/
try_profi_rcv_con_ind(hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
if ((con_ind_sdb.service == DP_DOWNLOAD_LOC) &&
(con_ind_sdb.primitive == CON ) &&
......@@ -479,7 +482,6 @@ static pwr_tStatus dp_io_offsets (
USIGN16 con_ind_buffer_len = 256;
T_PROFI_SERVICE_DESCR con_ind_sdb;
INT16 result; /* !!! local result variable !!! */
USIGN16 retry_counter;
sdb.comm_ref = 0;
sdb.layer = DP;
......@@ -495,7 +497,7 @@ static pwr_tStatus dp_io_offsets (
if (result != E_OK) return (result);
PROFI_RCV_CON_IND ();
try_profi_rcv_con_ind(hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
get_slave_param_con_ptr = (T_DP_GET_SLAVE_PARAM_CON FAR*) con_ind_buffer;
......@@ -536,18 +538,13 @@ static pwr_tStatus IoAgentInit (
pwr_sClass_Pb_DP_Slave *sop;
char name[196];
USIGN8 con_ind_buffer [256];
USIGN16 con_ind_buffer_len = 256;
T_PROFI_SERVICE_DESCR con_ind_sdb;
count=0;
/* Allocate area for local data structure */
ap->Local = calloc(1, sizeof(io_sAgentLocal));
if (!ap->Local) {
errh_Info( "ERROR config Profibus DP Master %s - %s", ap->Name, "calloc");
errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name, "calloc");
return IO__ERRINIDEVICE;
}
......@@ -564,7 +561,7 @@ static pwr_tStatus IoAgentInit (
{
/* Can't open driver */
op->Status = PB__INITFAIL;
errh_Info( "ERROR config Profibus DP Master %s - %s", ap->Name, "open device");
errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name, "open device");
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
......@@ -600,7 +597,7 @@ static pwr_tStatus IoAgentInit (
sts = fmb_set_configuration(hDevice, op);
if (!sts) {
op->Status = PB__INITFAIL;
errh_Info( "ERROR config Profibus DP Master %s - %s", ap->Name, "fmb set configuration");
errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name, "fmb set configuration");
return IO__ERRINIDEVICE;
}
......@@ -609,16 +606,16 @@ static pwr_tStatus IoAgentInit (
sts = dp_init_master(hDevice);
if (!sts) {
op->Status = PB__INITFAIL;
errh_Info( "ERROR config Profibus DP Master %s - %s", ap->Name, "dp init master");
errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name, "dp init master");
return IO__ERRINIDEVICE;
}
/* Download DP bus parameters */
sts = dp_download_bus(hDevice, op);
if (sts != PB_OK) {
if (!sts) {
op->Status = PB__INITFAIL;
errh_Info( "ERROR config Profibus DP Master %s - %s", ap->Name, "dp download bus");
errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name, "dp download bus");
return IO__ERRINIDEVICE;
}
......@@ -638,35 +635,13 @@ static pwr_tStatus IoAgentInit (
status = dp_download_slave(hDevice, sop);
if (!status) {
errh_Info( "ERROR Init Profibus DP slave %s", name);
errh_Error( "ERROR Init Profibus DP slave %s", name);
}
op->NumberSlaves++;
status = gdh_GetNextSibling(slave_objid, &slave_objid);
}
/* Move to STOP mode, this will fix the DPRAM layout */
sts = dp_act_param_loc(hDevice, DP_OP_MODE_STOP);
if (sts != E_OK) {
op->Status = PB__INITFAIL;
errh_Info( "ERROR config Profibus DP Master %s - %s", ap->Name, "act param loc to STOPPED");
return IO__ERRINIDEVICE;
}
PROFI_RCV_CON_IND ();
if ( (con_ind_sdb.service == DP_ACT_PARAM_LOC ) &&
(con_ind_sdb.primitive == CON ) &&
(con_ind_sdb.result == POS ) ) {
op->Status = PB__STOPPED;
} else {
op->Status = PB__INITFAIL;
errh_Info( "ERROR config Profibus DP Master %s - %s", ap->Name, "act param loc to STOPPED");
return IO__ERRINIDEVICE;
}
/* Calculate offsets of inputs and outputs for a slave */
status = gdh_GetChild(ap->Objid, &slave_objid);
......@@ -680,62 +655,29 @@ static pwr_tStatus IoAgentInit (
status = gdh_GetNextSibling(slave_objid, &slave_objid);
}
/* Move to CLEAR and OPERATE mode */
sts = dp_act_param_loc(hDevice, DP_OP_MODE_CLEAR);
if (sts == E_OK) {
PROFI_RCV_CON_IND ();
if ( (con_ind_sdb.service == DP_ACT_PARAM_LOC ) &&
(con_ind_sdb.primitive == CON ) &&
(con_ind_sdb.result == POS ) ) {
op->Status = PB__CLEARED;
} else {
op->Status = PB__INITFAIL;
errh_Info( "ERROR config Profibus DP Master %s - %s", ap->Name, "act param loc to CLEARED");
return IO__ERRINIDEVICE;
}
/* Move to STOP mode, this will fix the DPRAM layout */
sts = dp_act_param_loc(hDevice, DP_OP_MODE_OPERATE);
if (sts == E_OK) {
if ( (con_ind_sdb.service == DP_ACT_PARAM_LOC ) &&
(con_ind_sdb.primitive == CON ) &&
(con_ind_sdb.result == POS ) ) {
op->Status = PB__NORMAL;
errh_Info( "Profibus DP Master %s to state OPERATE", ap->Name);
} else {
op->Status = PB__INITFAIL;
errh_Info( "ERROR config Profibus DP Master %s - %s", ap->Name, "act param loc to OPERATE");
return IO__ERRINIDEVICE;
}
} else {
op->Status = PB__INITFAIL;
errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name, "act param loc to OPERATE");
return IO__ERRINIDEVICE;
}
}
else {
sts = dp_act_param_loc(hDevice, DP_OP_MODE_STOP);
if (sts != E_OK) {
op->Status = PB__INITFAIL;
errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name, "act param loc to CLEAR");
errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name, "act param loc to STOPPED");
return IO__ERRINIDEVICE;
}
ok = TRUE;
/* for (i=0; i<4; i++) {
if (ok) {
sts = profi_rcv_con_ind (local, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len);
if (sts != PB_DEVICE_ERROR) {
errh_Info("Init problems, Reconfig - %d", i);
ok = FALSE;
}
rqtp.tv_sec = 0;
rqtp.tv_nsec = 200000000;
nanosleep(&rqtp, &rmtp); */
} /* End - While !ok */
} /* End - Initialization only if not restart */
else {
/* Move to STOP mode, this will fix the DPRAM layout */
sts = dp_act_param_loc(hDevice, DP_OP_MODE_STOP);
if (sts != E_OK) {
op->Status = PB__INITFAIL;
errh_Error( "ERROR config Profibus DP Master %s - %s", ap->Name, "act param loc to STOPPED");
return IO__ERRINIDEVICE;
}
}
}
else
op->Status = PB__DISABLED;
......@@ -784,6 +726,7 @@ static pwr_tStatus IoAgentRead (
case PB__NORMAL:
case PB__STOPPED:
case PB__CLEARED:
case PB__NOTINIT:
sts = profi_rcv_con_ind ( hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len);
if (sts == CON_IND_RECEIVED) {
......@@ -796,15 +739,16 @@ static pwr_tStatus IoAgentRead (
if (op->Status == PB__NOTINIT) {
op->Status = PB__STOPPED;
errh_Info( "Profibus DP Master %s to state STOPPED", ap->Name);
dp_act_param_loc(hDevice, DP_OP_MODE_CLEAR);
}
else if (op->Status == PB__STOPPED) {
op->Status = PB__CLEARED;
errh_Info( "Profibus DP Master %s to state CLEARED", ap->Name);
dp_act_param_loc(hDevice, DP_OP_MODE_OPERATE);
}
else if (op->Status == PB__CLEARED) {
errh_Info( "Profibus DP Master %s to state OPERATE", ap->Name);
op->Status = PB__NORMAL;
}
......@@ -836,7 +780,7 @@ static pwr_tStatus IoAgentRead (
} /* if POS */
else {
op->Status = PB__NOTINIT;
errh_Info( "Profibus DP Master %s - %d neg con rec", ap->Name, count );
errh_Error( "Profibus DP Master %s - %d neg con rec", ap->Name, count );
} /* else POS */
} /* if CON */
else if (con_ind_sdb.primitive == IND) {
......@@ -928,7 +872,7 @@ static pwr_tStatus IoAgentRead (
} /* if POS */
else {
op->Status = PB__NOTINIT;
errh_Info( "Profibus DP Master %s - %d neg ind rec", ap->Name, count );
errh_Error( "Profibus DP Master %s - %d neg ind rec", ap->Name, count );
} /* else POS */
} /* if IND */
} else if (sts != NO_CON_IND_RECEIVED) {
......@@ -939,7 +883,7 @@ static pwr_tStatus IoAgentRead (
default:
op->Status = PB__NOTINIT;
errh_Info( "Reconfig of Profibus DP Master %s - %d", ap->Name, count );
errh_Error( "Reconfig of Profibus DP Master %s - %d", ap->Name, count );
IoAgentClose(ctx, ap);
IoAgentInit(ctx, ap);
break;
......@@ -980,7 +924,6 @@ static pwr_tStatus IoAgentClose (
USIGN16 con_ind_buffer_len = 256;
T_PROFI_SERVICE_DESCR con_ind_sdb;
INT16 result; /* !!! local result variable !!! */
USIGN16 retry_counter;
local = (io_sAgentLocal *) ap->Local;
hDevice = (T_PROFI_DEVICE_HANDLE *) ap->Local;
......@@ -993,7 +936,7 @@ static pwr_tStatus IoAgentClose (
profi_snd_req_res(hDevice, &sdb, &sdb, PB_FALSE);
PROFI_RCV_CON_IND (); /*Macro to fetch one confirmation or indication*/
try_profi_rcv_con_ind(hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len, &result);
if ((con_ind_sdb.service == DP_EXIT_MASTER) &&
(con_ind_sdb.primitive == CON ) &&
......
/*
* Proview $Id: version.h,v 1.2 2007-01-17 12:40:30 claes Exp $
*
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/* */
/* SOFTING AG */
......
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