datagram.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  *  $Id: datagram.h 490 2006-08-02 12:25:25Z fp $
00004  *
00005  *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
00006  *
00007  *  This file is part of the IgH EtherCAT Master.
00008  *
00009  *  The IgH EtherCAT Master is free software; you can redistribute it
00010  *  and/or modify it under the terms of the GNU General Public License
00011  *  as published by the Free Software Foundation; either version 2 of the
00012  *  License, or (at your option) any later version.
00013  *
00014  *  The IgH EtherCAT Master is distributed in the hope that it will be
00015  *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with the IgH EtherCAT Master; if not, write to the Free Software
00021  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022  *
00023  *  The right to use EtherCAT Technology is granted and comes free of
00024  *  charge under condition of compatibility of product made by
00025  *  Licensee. People intending to distribute/sell products based on the
00026  *  code, have to sign an agreement to guarantee that products using
00027  *  software based on IgH EtherCAT master stay compatible with the actual
00028  *  EtherCAT specification (which are released themselves as an open
00029  *  standard) as the (only) precondition to have the right to use EtherCAT
00030  *  Technology, IP and trade marks.
00031  *
00032  *****************************************************************************/
00033 
00039 /*****************************************************************************/
00040 
00041 #ifndef _EC_DATAGRAM_H_
00042 #define _EC_DATAGRAM_H_
00043 
00044 #include <linux/list.h>
00045 #include <linux/time.h>
00046 #include <linux/timex.h>
00047 
00048 #include "globals.h"
00049 
00050 /*****************************************************************************/
00051 
00056 typedef enum
00057 {
00058     EC_CMD_NONE = 0x00, 
00059     EC_CMD_APRD = 0x01, 
00060     EC_CMD_APWR = 0x02, 
00061     EC_CMD_NPRD = 0x04, 
00062     EC_CMD_NPWR = 0x05, 
00063     EC_CMD_BRD  = 0x07, 
00064     EC_CMD_BWR  = 0x08, 
00065     EC_CMD_LRW  = 0x0C  
00066 }
00067 ec_datagram_type_t;
00068 
00073 typedef enum
00074 {
00075     EC_CMD_INIT, 
00076     EC_CMD_QUEUED, 
00077     EC_CMD_SENT, 
00078     EC_CMD_RECEIVED, 
00079     EC_CMD_TIMEOUT, 
00080     EC_CMD_ERROR 
00081 }
00082 ec_datagram_state_t;
00083 
00084 /*****************************************************************************/
00085 
00090 typedef union
00091 {
00092     struct
00093     {
00094         uint16_t slave; 
00095         uint16_t mem; 
00096     }
00097     physical; 
00099     uint32_t logical; 
00100 }
00101 ec_address_t;
00102 
00103 /*****************************************************************************/
00104 
00109 typedef struct
00110 {
00111     struct list_head list; 
00112     struct list_head queue; 
00113     ec_datagram_type_t type; 
00114     ec_address_t address; 
00115     uint8_t *data; 
00116     size_t mem_size; 
00117     size_t data_size; 
00118     uint8_t index; 
00119     uint16_t working_counter; 
00120     ec_datagram_state_t state; 
00121     cycles_t t_sent; 
00122 }
00123 ec_datagram_t;
00124 
00125 /*****************************************************************************/
00126 
00127 void ec_datagram_init(ec_datagram_t *);
00128 void ec_datagram_clear(ec_datagram_t *);
00129 int ec_datagram_prealloc(ec_datagram_t *, size_t);
00130 
00131 int ec_datagram_nprd(ec_datagram_t *, uint16_t, uint16_t, size_t);
00132 int ec_datagram_npwr(ec_datagram_t *, uint16_t, uint16_t, size_t);
00133 int ec_datagram_aprd(ec_datagram_t *, uint16_t, uint16_t, size_t);
00134 int ec_datagram_apwr(ec_datagram_t *, uint16_t, uint16_t, size_t);
00135 int ec_datagram_brd(ec_datagram_t *, uint16_t, size_t);
00136 int ec_datagram_bwr(ec_datagram_t *, uint16_t, size_t);
00137 int ec_datagram_lrw(ec_datagram_t *, uint32_t, size_t);
00138 
00139 /*****************************************************************************/
00140 
00141 #endif

Generated on Wed Aug 2 18:41:43 2006 for IgH EtherCAT master by  doxygen 1.4.6