/home/hillier_g/checkout/most4linux/libnetservices/src/linux/par_cp.c

00001 /*
00002  *  Copyright(c) Siemens AG, Muenchen, Germany, 2005, 2006, 2007
00003  *                           Bernhard Walle <bernhard.walle@gmx.de>
00004  *                           Gernot Hillier <gernot.hillier@siemens.com>
00005  *                           All rights reserved.
00006  *
00007  * ----------------------------------------------------------------------------
00008  * The contents of this file are subject to the Mozilla Public License
00009  * Version 1.1 (the "License"); you may not use this file except in
00010  * compliance with the License. You may obtain a copy of the License at
00011  * http://www.mozilla.org/MPL/
00012  * 
00013  * Software distributed under the License is distributed on an "AS IS"
00014  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
00015  * License for the specific language governing rights and limitations
00016  * under the License.
00017  *
00018  * The Original Code is Siemens code.
00019  * 
00020  * The Initial Developer of the Original Code is Siemens AG.
00021  * Portions created by the Initial Developer are Copyright (C) 2005-06
00022  * the Initial Developer. All Rights Reserved.
00023  * ----------------------------------------------------------------------------
00024  */
00025 #include <errno.h>
00026 #include <sys/ioctl.h>
00027 
00028 #include "adjust.h"
00029 #include "mostns1.h"
00030 #include "mostnetsdll.h"
00031 #include "par_cp.h"
00032 #include "global.h"
00033 #include "most-netservice.h"
00034 
00035 /* -------------------------------------------------------------------------- */
00036 void ParWrite(tMostMap map, byte value)
00037 {
00038     struct single_transfer_arg  arg;
00039     int                         ret;
00040 
00041     CHECK_FILEDESCRIPTOR_RET();
00042     
00043     arg.address = map;
00044     arg.value   = value;
00045 
00046     ret = ioctl(g_control_fd, MOST_NETS_WRITEREG, &arg);
00047     if (ret < 0) {
00048         PERR_DEBUG("Writing a register value failed");
00049     }
00050 
00051     PRINT_TRACE("Writing register 0x%x, value 0x%x", map, value);
00052 }
00053 
00054 /* -------------------------------------------------------------------------- */
00055 byte ParRead(tMostMap map)
00056 {
00057     struct single_transfer_arg  arg;
00058     int                         ret;
00059 
00060     CHECK_FILEDESCRIPTOR_RET_VAL(-1);
00061 
00062     arg.address = map;
00063 
00064     ret = ioctl(g_control_fd, MOST_NETS_READREG, &arg);
00065     if (ret < 0) {
00066         PERR_DEBUG("Reading a register value failed");
00067     }
00068 
00069     PRINT_TRACE("Reading register 0x%x, value 0x%x", map, arg.value);
00070     
00071     return arg.value;
00072 }
00073 
00074 
00075 /* -------------------------------------------------------------------------- */
00076 void ParWriteBlock(tMostMap map, byte num, byte *data)
00077 {
00078     struct block_transfer_arg   arg;
00079     int                         ret;
00080 
00081     CHECK_FILEDESCRIPTOR_RET();
00082 
00083     arg.address = map;
00084     arg.count   = num;
00085     arg.data    = data;
00086 
00087     ret = ioctl(g_control_fd, MOST_NETS_WRITEREG_BLOCK, &arg);
00088     if (ret < 0) {
00089         PERR_DEBUG("Writing a block of register value failed");
00090     }
00091 
00092     PRINT_TRACE("Writing block of registers 0x%x, number = %d", map, num);
00093 }
00094 
00095 /* -------------------------------------------------------------------------- */
00096 void ParReadBlock(tMostMap map, byte num, byte *data)
00097 {
00098     struct block_transfer_arg   arg;
00099     int                         ret;
00100 
00101     CHECK_FILEDESCRIPTOR_RET();
00102 
00103     arg.address = map;
00104     arg.count   = num;
00105     arg.data    = data;
00106 
00107     ret = ioctl(g_control_fd, MOST_NETS_READREG_BLOCK, &arg);
00108     if (ret < 0) {
00109         PERR_DEBUG("Reading a block of register value failed");
00110     }
00111 
00112     PRINT_TRACE("Reading block of registers 0x%x, number = %d", map, num);
00113 }
00114 
00115 /* -------------------------------------------------------------------------- */
00116 void Most_Reset(void)
00117 {
00118     int ret;
00119 
00120     PRINT_TRACE();
00121     
00122     printf("-- Reset --\n");
00123 
00124     CHECK_FILEDESCRIPTOR_RET();
00125     
00126     ret = ioctl(g_control_fd, MOST_NETS_RESET);
00127     if (ret < 0) {
00128         PERR_DEBUG("MOST_NETS_RESET failed");
00129     }
00130 }
00131 
00132 /* vim: set ts=4 et sw=4: */

Generated on Fri Mar 9 14:48:59 2007 for MOST Adaption Layer for Netservices Library by  doxygen 1.5.0