src/pdo.c
author etisserant
Mon, 06 Aug 2007 17:59:06 +0200
changeset 250 39e22f84ce6e
parent 236 905677ed00f3
child 252 b0dd37421d28
permissions -rw-r--r--
Attic problem. Removed old unused dirs.
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     2
  This file is part of CanFestival, a library implementing CanOpen
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     3
  Stack.
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     4
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     5
  Copyright (C): Edouard TISSERANT and Francis DUPIN
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     6
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     7
  See COPYING file for copyrights details.
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     8
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
     9
  This library is free software; you can redistribute it and/or
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    10
  modify it under the terms of the GNU Lesser General Public
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    11
  License as published by the Free Software Foundation; either
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    12
  version 2.1 of the License, or (at your option) any later version.
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    13
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    14
  This library is distributed in the hope that it will be useful,
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    15
  but WITHOUT ANY WARRANTY; without even the implied warranty of
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    16
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    17
  Lesser General Public License for more details.
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    18
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    19
  You should have received a copy of the GNU Lesser General Public
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    20
  License along with this library; if not, write to the Free Software
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    21
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    22
  USA
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
#include "pdo.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
#include "objacces.h"
149
fe50ada8020b Changes in the API:
etisserant
parents: 90
diff changeset
    26
#include "canfestival.h"
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    28
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    29
** @file   pdo.c
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    30
** @author Edouard TISSERANT and Francis DUPIN
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    31
** @date   Tue Jun  5 09:32:32 2007
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    32
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    33
** @brief
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    34
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    35
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    36
*/
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    37
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    38
/*!
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    39
**
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    40
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    41
** @param d
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    42
** @param TPDO_com TPDO communication parameters OD entry
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    43
** @param TPDO_map TPDO mapping parameters OD entry
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    44
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    45
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    46
**/
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    47
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    48
UNS8 buildPDO(CO_Data* d, UNS8 numPdo, Message *pdo)
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    49
{
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    50
	const indextable* TPDO_com = d->objdict + d->firstIndex->PDO_TRS + numPdo; 
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    51
	const indextable* TPDO_map = d->objdict + d->firstIndex->PDO_TRS_MAP + numPdo;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    52
	
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    53
	UNS8 prp_j = 0x00;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    54
	UNS8 offset = 0x00;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    55
	const UNS8* pMappingCount = (UNS8*) TPDO_map->pSubindex[0].pObject;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    56
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
    57
	pdo->cob_id.w = *(UNS32*)TPDO_com->pSubindex[1].pObject & 0x7FF;
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    58
	pdo->rtr = NOT_A_REQUEST;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    59
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    60
	MSG_WAR(0x3009, "  PDO CobId is : ", *(UNS32*)TPDO_com->pSubindex[1].pObject);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    61
	MSG_WAR(0x300D, "  Number of objects mapped : ",*pMappingCount );
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    62
	
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    63
	do{
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    64
		UNS8 dataType; /* Unused */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    65
		UNS8 tmp[]= {0,0,0,0,0,0,0,0}; /* temporary space to hold bits */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    66
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    67
		/* pointer fo the var which holds the mapping parameter of an mapping entry  */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    68
		UNS32* pMappingParameter = (UNS32*) TPDO_map->pSubindex[prp_j + 1].pObject;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    69
		UNS16 index = (UNS16)((*pMappingParameter) >> 16);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    70
		UNS8 Size = (UNS8)(*pMappingParameter); /* Size in bits */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    71
		UNS8 ByteSize = 1 + ((Size - 1) >> 3); /*1->8 => 1 ; 9->16 => 2, ... */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    72
		UNS8 subIndex = (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    73
		
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    74
		MSG_WAR(0x300F, "  got mapping parameter : ", *pMappingParameter);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    75
		MSG_WAR(0x3050, "    at index : ", TPDO_map->index);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    76
		MSG_WAR(0x3051, "    sub-index : ", prp_j + 1);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    77
		
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    78
		if( getODentry(d, index, subIndex, tmp, &ByteSize, &dataType, 0 ) != OD_SUCCESSFUL ){
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    79
			MSG_ERR(0x1013, " Couldn't find mapped variable at index-subindex-size : ", (UNS16)(*pMappingParameter));
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    80
			return 0xFF;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    81
		}
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    82
		/* copy bit per bit in little endian*/
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    83
		CopyBits(Size, ((UNS8*)tmp), 0 , 0, (UNS8*)&pdo->data[offset>>3], offset%8, 0);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    84
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    85
		offset += Size ;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    86
		prp_j++;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    87
	}while( prp_j < *pMappingCount );
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    88
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    89
	pdo->len = 1 + ((offset - 1) >> 3);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    90
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    91
	MSG_WAR(0x3015, "  End scan mapped variable", 0);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    92
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    93
	return 0;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
    94
}
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    95
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    96
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    97
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    98
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
    99
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   100
** @param cobId
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   101
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   102
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   103
**/
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   104
UNS8 sendPDOrequest( CO_Data* d, UNS16 RPDOIndex )
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   105
{
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   106
  UNS32 * pwCobId;
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   107
  UNS16 offset = d->firstIndex->PDO_RCV;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   108
  UNS16 lastIndex = d->lastIndex->PDO_RCV;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   109
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   110
  /* Sending the request only if the cobid have been found on the PDO
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   111
     receive */
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   112
  /* part dictionary */
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   113
  
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   114
  MSG_WAR(0x3930, "sendPDOrequest RPDO Index : ",RPDOIndex);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   115
  
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   116
  if (offset && RPDOIndex >= 0x1400){
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   117
    offset += RPDOIndex - 0x1400;  
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   118
    if (offset <= lastIndex) {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   119
      /* get the CobId*/
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   120
      pwCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   121
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   122
      MSG_WAR(0x3930, "sendPDOrequest cobId is : ",*pwCobId);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   123
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   124
      Message pdo = {*pwCobId, REQUEST, 0};
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   125
      return canSend(d->canHandle,&pdo);
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   126
    }
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   127
  }
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   128
  MSG_ERR(0x1931, "sendPDOrequest : RPDO Index not found : ", RPDOIndex);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   129
  return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   131
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   133
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   134
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   135
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   136
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   137
** @param m
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   138
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   139
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   140
**/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
UNS8 proceedPDO(CO_Data* d, Message *m)
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   142
{
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
  UNS8   numPdo;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   144
  UNS8   numMap;  /* Number of the mapped varable */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   145
  UNS8 i;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   146
  UNS8 *     pMappingCount = NULL;    /* count of mapped objects... */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   147
  /* pointer to the var which is mapped to a pdo... */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   148
  /*  void *     pMappedAppObject = NULL;   */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   149
  /* pointer fo the var which holds the mapping parameter of an
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   150
     mapping entry */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   151
  UNS32 *    pMappingParameter = NULL;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   152
  UNS8  *    pTransmissionType = NULL; /* pointer to the transmission
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   153
                                         type */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
  UNS32 *    pwCobId = NULL;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
  UNS8       Size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
  UNS8       dataType;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
  UNS8       offset;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
  UNS8       status;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
  UNS32      objDict;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
  UNS16      offsetObjdict;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
  UNS16      lastIndex;
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   162
  
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   163
  status = state2;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   164
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   165
  MSG_WAR(0x3935, "proceedPDO, cobID : ", ((*m).cob_id.w & 0x7ff));
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
  offset = 0x00;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   167
  numPdo = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
  numMap = 0;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   169
  if((*m).rtr == NOT_A_REQUEST ) { /* The PDO received is not a
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   170
                                     request. */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   171
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
    offsetObjdict = d->firstIndex->PDO_RCV;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   173
    lastIndex = d->lastIndex->PDO_RCV;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   174
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   175
    /* study of all the PDO stored in the dictionary */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
    if(offsetObjdict)
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   177
      while (offsetObjdict <= lastIndex) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   178
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   179
        switch( status ) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   180
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   181
        case state2:
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   182
          /* get CobId of the dictionary correspondant to the received
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   183
             PDO */
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   184
          pwCobId = (UNS32*) d->objdict[offsetObjdict].pSubindex[1].pObject;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   185
          /* check the CobId coherance */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   186
          /*pwCobId is the cobId read in the dictionary at the state 3
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   187
            */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   188
          if ( *pwCobId == (*m).cob_id.w ){
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   189
            /* The cobId is recognized */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   190
            status = state4;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   191
            MSG_WAR(0x3936, "cobId found at index ", 0x1400 + numPdo);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   192
            break;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   193
          }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   194
          else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   195
            /* cobId received does not match with those write in the
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   196
              dictionnary */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   197
            numPdo++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   198
            offsetObjdict++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   199
            status = state2;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   200
            break;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   201
          }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   202
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   203
            case state4:/* Get Mapped Objects Number */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   204
               /* The cobId of the message received has been found in the
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   205
                 dictionnary. */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   206
               offsetObjdict = d->firstIndex->PDO_RCV_MAP;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   207
             lastIndex = d->lastIndex->PDO_RCV_MAP;
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   208
             pMappingCount = (UNS8*) (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   209
             numMap = 0;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   210
             while (numMap < *pMappingCount) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   211
               UNS8 tmp[]= {0,0,0,0,0,0,0,0};
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   212
               UNS8 ByteSize;
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   213
               pMappingParameter = (UNS32*) (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   214
               if (pMappingParameter == NULL) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   215
                 MSG_ERR(0x1937, "Couldn't get mapping parameter : ", numMap + 1);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   216
                 return 0xFF;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   217
               }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   218
               /* Get the addresse of the mapped variable. */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   219
               /* detail of *pMappingParameter : */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   220
               /* The 16 hight bits contains the index, the medium 8 bits
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   221
                 contains the subindex, */
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   222
               /* and the lower 8 bits contains the size of the mapped
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   223
                 variable. */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   224
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   225
               Size = (UNS8)(*pMappingParameter);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   226
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   227
               /* copy bit per bit in little endian */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   228
               CopyBits(Size, (UNS8*)&m->data[offset>>3], offset%8, 0, ((UNS8*)tmp), 0, 0);
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   229
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   230
               ByteSize = 1 + ((Size - 1) >> 3); /*1->8 => 1 ; 9->16 =>
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   231
                                                   2, ... */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   232
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   233
               objDict = setODentry(d, (UNS16)((*pMappingParameter) >> 16),
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   234
                                    (UNS8)(((*pMappingParameter) >> 8 ) & 0xFF),
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   235
                                 tmp, &ByteSize, 0 );
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   236
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   237
               if(objDict != OD_SUCCESSFUL) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   238
                 MSG_ERR(0x1938, "error accessing to the mapped var : ", numMap + 1);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   239
                 MSG_WAR(0x2939, "         Mapped at index : ", (*pMappingParameter) >> 16);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   240
                 MSG_WAR(0x2940, "                subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   241
                 return 0xFF;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   242
               }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   243
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   244
               MSG_WAR(0x3942, "Variable updated with value received by PDO cobid : ", m->cob_id.w);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   245
               MSG_WAR(0x3943, "         Mapped at index : ", (*pMappingParameter) >> 16);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   246
               MSG_WAR(0x3944, "                subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   247
               /* MSG_WAR(0x3945, "                data : ",*((UNS32*)pMappedAppObject)); */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   248
               offset += Size;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   249
               numMap++;
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   250
               /*TODO :  check that offset is not not greater that message size (in bit) */
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   251
             } /* end loop while on mapped variables */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   252
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   253
             offset=0x00;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   254
             numMap = 0;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   255
             return 0;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   256
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   257
        }/* end switch status*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   258
      }/* end while*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   259
  }/* end if Donnees */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   260
  else if ((*m).rtr == REQUEST ){
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   261
    MSG_WAR(0x3946, "Receive a PDO request cobId : ", m->cob_id.w);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   262
    status = state1;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   263
    offsetObjdict = d->firstIndex->PDO_TRS;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   264
    lastIndex = d->lastIndex->PDO_TRS;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   265
    if(offsetObjdict) while( offsetObjdict  <= lastIndex ){
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   266
      /* study of all PDO stored in the objects dictionary */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   267
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   268
      switch( status ){
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   269
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   270
      case state1:/* check the CobId */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   271
        /* get CobId of the dictionary which match to the received PDO
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   272
         */
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   273
        pwCobId = (UNS32*) (d->objdict + offsetObjdict)->pSubindex[1].pObject;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   274
        if ( *pwCobId == (*m).cob_id.w ) {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   275
          status = state4;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   276
          break;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   277
        }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   278
        else {
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   279
          numPdo++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   280
          offsetObjdict++;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   281
        }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   282
        status = state1;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   283
        break;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   284
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   285
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   286
      case state4:/* check transmission type */
217
94c3f89bc3cc Fixed compile error because of missed type casting in certain compiler (http://www.iar.se/). Thanks to Raphael Studer
etisserant
parents: 215
diff changeset
   287
        pTransmissionType = (UNS8*) d->objdict[offsetObjdict].pSubindex[2].pObject;
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   288
        /* If PDO is to be sampled and send on RTR, do it*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   289
        if ( (*pTransmissionType == TRANS_RTR)) {
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   290
          status = state5;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   291
          break;
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   292
        /* RTR_SYNC mean data is prepared at SYNC, and transmitted on RTR */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   293
        }else if ((*pTransmissionType == TRANS_RTR_SYNC )) {
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   294
    	  if(d->PDO_status[numPdo].transmit_type_parameter & PDO_RTR_SYNC_READY){
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   295
            /*Data ready, just send*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   296
    	    canSend(d->canHandle,&d->PDO_status[numPdo].last_message);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   297
            return 0;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   298
    	  }else{
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   299
            /* if SYNC did never occur, force emission with current data */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   300
            /* DS301 do not tell what to do in such a case...*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   301
            MSG_ERR(0x1947, "Not ready RTR_SYNC TPDO send current data : ", m->cob_id.w);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   302
            status = state5;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   303
    	  }
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   304
          break;
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   305
        }else if(
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   306
             (*pTransmissionType == TRANS_EVENT_PROFILE) ||
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   307
             (*pTransmissionType == TRANS_EVENT_SPECIFIC) ) {
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   308
	  /* Zap all timers and inhibit flag */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   309
	  d->PDO_status[numPdo].event_timer = DelAlarm(d->PDO_status[numPdo].event_timer);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   310
	  d->PDO_status[numPdo].inhibit_timer = DelAlarm(d->PDO_status[numPdo].inhibit_timer);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   311
  	  d->PDO_status[numPdo].transmit_type_parameter &= ~PDO_INHIBITED;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   312
  	  /* Call  PDOEventTimerAlarm for this TPDO, this will trigger emission et reset timers */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   313
          PDOEventTimerAlarm(d, numPdo);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   314
          return 0;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   315
        }else {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   316
          /* The requested PDO is not to send on request. So, does
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   317
            nothing. */
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   318
          MSG_WAR(0x2947, "PDO is not to send on request : ", m->cob_id.w);
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   319
          return 0xFF;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   320
        }
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   321
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   322
      case state5:/* build and send requested PDO */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   323
      {
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   324
      	Message pdo;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   325
    	if( buildPDO(d, numPdo, &pdo))
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   326
    	{
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   327
          MSG_ERR(0x1948, " Couldn't build TPDO n°", numPdo);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   328
          return 0xFF;
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   329
    	}
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   330
    	canSend(d->canHandle,&pdo);
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   331
        return 0;
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   332
      }
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   333
      }/* end switch status */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   334
    }/* end while */
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   335
  }/* end if Requete */
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   336
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   337
  return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   338
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   339
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   340
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   341
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   342
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   343
** @param NbBits
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   344
** @param SrcByteIndex
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   345
** @param SrcBitIndex
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   346
** @param SrcBigEndian
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   347
** @param DestByteIndex
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   348
** @param DestBitIndex
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   349
** @param DestBigEndian
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   350
**/
201
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   351
void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian)
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   352
{
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   353
  /* This loop copy as many bits that it can each time, crossing*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   354
  /* successively bytes*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   355
  // boundaries from LSB to MSB.
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   356
  while(NbBits > 0)
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   357
    {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   358
      /* Bit missalignement between src and dest*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   359
      INTEGER8 Vect = DestBitIndex - SrcBitIndex;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   360
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   361
      /* We can now get src and align it to dest*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   362
      UNS8 Aligned = Vect>0 ? *SrcByteIndex << Vect : *SrcByteIndex >> -Vect;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   363
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   364
      /* Compute the nb of bit we will be able to copy*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   365
      UNS8 BoudaryLimit = (Vect>0 ? 8 - DestBitIndex :  8 - SrcBitIndex );
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   366
      UNS8 BitsToCopy = BoudaryLimit > NbBits ? NbBits : BoudaryLimit;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   367
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   368
      /* Create a mask that will serve in:*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   369
      UNS8 Mask = ((0xff << (DestBitIndex + BitsToCopy)) | (0xff >> (8 - DestBitIndex)));
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   370
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   371
      /* - Filtering src*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   372
      UNS8 Filtered = Aligned & ~Mask;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   373
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   374
      /* - and erase bits where we write, preserve where we don't*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   375
      *DestByteIndex &= Mask;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   376
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   377
      /* Then write.*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   378
      *DestByteIndex |= Filtered ;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   379
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   380
      /*Compute next time cursors for src*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   381
      if((SrcBitIndex += BitsToCopy)>7)/* cross boundary ?*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   382
        {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   383
          SrcBitIndex = 0;/* First bit*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   384
          SrcByteIndex += (SrcBigEndian ? -1 : 1);/* Next byte*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   385
        }
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   386
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   387
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   388
      /*Compute next time cursors for dest*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   389
      if((DestBitIndex += BitsToCopy)>7)
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   390
        {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   391
          DestBitIndex = 0;/* First bit*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   392
          DestByteIndex += (DestBigEndian ? -1 : 1);/* Next byte*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   393
        }
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   394
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   395
      /*And decrement counter.*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   396
      NbBits -= BitsToCopy;
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   397
    }
201
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   398
2966cd34162a Boolean variable mapped in PDO
greg
parents: 149
diff changeset
   399
}
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   400
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   401
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   402
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   403
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   404
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   405
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 204
diff changeset
   406
**/
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   407
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   408
UNS8 sendPDOevent( CO_Data* d)
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   409
{
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   410
  /* Calls _sendPDOevent specifying it is not a sync event */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   411
  return _sendPDOevent(d, 0);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   412
}
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   413
	
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   414
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   415
void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum)
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   416
{
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   417
	/* This is needed to avoid deletion of re-attribuated timer */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   418
	d->PDO_status[pdoNum].event_timer = TIMER_NONE;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   419
	/* force emission of PDO by artificially changing last emitted*/
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   420
	d->PDO_status[pdoNum].last_message.cob_id.w = 0;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   421
	_sendPDOevent( d, 0 ); /* not a Sync Event*/	
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   422
}
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   423
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   424
void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum)
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   425
{
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   426
	/* This is needed to avoid deletion of re-attribuated timer */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   427
	d->PDO_status[pdoNum].inhibit_timer = TIMER_NONE;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   428
	/* Remove inhibit flag */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   429
	d->PDO_status[pdoNum].transmit_type_parameter &= ~PDO_INHIBITED;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   430
	_sendPDOevent( d, 0 ); /* not a Sync Event*/
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   431
}
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   432
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   433
/*!
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   434
**
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   435
**
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   436
** @param d
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   437
** @param isSyncEvent
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   438
**
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   439
** @return
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   440
**/
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   441
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   442
UNS8 _sendPDOevent( CO_Data* d, UNS8 isSyncEvent )
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   443
{ 
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   444
  UNS8 	pdoNum = 0x00;       /* number of the actual processed pdo-nr. */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   445
  UNS8* pTransmissionType = NULL;  
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   446
  UNS8 status = state3;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   447
  UNS16 offsetObjdict = d->firstIndex->PDO_TRS;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   448
  UNS16 offsetObjdictMap = d->firstIndex->PDO_TRS_MAP;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   449
  UNS16 lastIndex = d->lastIndex->PDO_TRS;  
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   450
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   451
  /* study all PDO stored in the objects dictionary */	
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   452
  if(offsetObjdict){
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   453
   Message pdo = Message_Initializer;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   454
   while( offsetObjdict <= lastIndex) {  
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   455
    switch( status ) {
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   456
    case state3:
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   457
      if (/*d->objdict[offsetObjdict].bSubCount < 5 || not necessary with objdictedit (always 5)*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   458
          /* check if TPDO is not valid */ 
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   459
          *(UNS32*)d->objdict[offsetObjdict].pSubindex[0].pObject & 0x8000) {
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   460
	  MSG_WAR(0x3960, "Not a valid PDO ", 0x1800 + pdoNum);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   461
	  /*Go next TPDO*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   462
	  status = state11;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   463
	  break;
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   464
	}
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   465
      /* get the PDO transmission type */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   466
      pTransmissionType = (UNS8*) d->objdict[offsetObjdict].pSubindex[2].pObject;    
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   467
      MSG_WAR(0x3962, "Reading PDO at index : ", 0x1800 + pdoNum);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   468
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   469
      /* check if transmission type is SYNCRONOUS */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   470
      /* The message is transmited every n SYNC with n=TransmissionType */      
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   471
      if( isSyncEvent && 
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   472
      	  (*pTransmissionType >= TRANS_SYNC_MIN) &&
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   473
      	  (*pTransmissionType <= TRANS_SYNC_MAX) &&
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   474
          (++d->PDO_status[pdoNum].transmit_type_parameter == *pTransmissionType) ) {
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   475
        /*Reset count of SYNC*/	
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   476
	d->PDO_status[pdoNum].transmit_type_parameter = 0;
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   477
	MSG_WAR(0x3964, "  PDO is on SYNCHRO. Trans type : ", *pTransmissionType);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   478
	pdo = (Message)Message_Initializer;
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   479
        if(buildPDO(d, pdoNum, &pdo))
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   480
        {
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   481
            MSG_ERR(0x1906, " Couldn't build TPDO number : ", pdoNum);
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   482
	    status = state11;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   483
	    break;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   484
        }
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   485
	status = state5;
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   486
      /* If transmission RTR, with data sampled on SYNC */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   487
      }else if( isSyncEvent && 
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   488
      	  (*pTransmissionType == TRANS_RTR_SYNC)) {
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   489
          if(buildPDO(d, pdoNum, &d->PDO_status[pdoNum].last_message))
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   490
          {
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   491
             MSG_ERR(0x1966, " Couldn't build TPDO number : ", pdoNum);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   492
             d->PDO_status[pdoNum].transmit_type_parameter &= ~PDO_RTR_SYNC_READY; 
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   493
          }else{
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   494
             d->PDO_status[pdoNum].transmit_type_parameter |= PDO_RTR_SYNC_READY; 
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   495
          }
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   496
	  status = state11;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   497
	  break;
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   498
      /* If transmission on Event and not inhibited, check for changes */
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   499
      }else if((*pTransmissionType == TRANS_EVENT_PROFILE ||
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   500
               *pTransmissionType == TRANS_EVENT_SPECIFIC )&&
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   501
              !(d->PDO_status[pdoNum].transmit_type_parameter & PDO_INHIBITED)) {
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   502
	MSG_WAR(0x3968, "  PDO is on EVENT. Trans type : ", *pTransmissionType);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   503
	pdo = (Message)Message_Initializer;
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   504
        if(buildPDO(d, pdoNum, &pdo))
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   505
        {
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   506
            MSG_ERR(0x3907, " Couldn't build TPDO number : ", pdoNum);
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   507
	    status = state11;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   508
	    break;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   509
        }
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   510
        
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   511
	/*Compare new and old PDO*/
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   512
	if(d->PDO_status[pdoNum].last_message.cob_id.w == pdo.cob_id.w &&
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   513
	   d->PDO_status[pdoNum].last_message.len == pdo.len &&
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   514
	   *(UNS64*)(&d->PDO_status[pdoNum].last_message.data[0]) == *(UNS64*)(&pdo.data[0])){
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   515
	   	/* No changes -> go to next pdo*/
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   516
		status = state11;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   517
	}else{
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   518
		MSG_WAR(0x306A, "Changes TPDO number : ", pdoNum);
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   519
		/* Changes detected -> transmit message */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   520
		status = state5;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   521
		
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   522
		/* Start both event_timer and inhibit_timer*/
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   523
		DelAlarm(d->PDO_status[pdoNum].event_timer);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   524
		d->PDO_status[pdoNum].event_timer = SetAlarm(d, pdoNum, &PDOEventTimerAlarm, MS_TO_TIMEVAL(*(UNS16*)d->objdict[offsetObjdict].pSubindex[5].pObject), 0);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   525
		
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   526
		DelAlarm(d->PDO_status[pdoNum].inhibit_timer);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   527
		d->PDO_status[pdoNum].inhibit_timer = SetAlarm(d, pdoNum, &PDOInhibitTimerAlarm, US_TO_TIMEVAL(*(UNS16*)d->objdict[offsetObjdict].pSubindex[3].pObject * 100), 0);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   528
		
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   529
		/* and inhibit TPDO */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   530
		d->PDO_status[pdoNum].transmit_type_parameter |= PDO_INHIBITED;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   531
	}
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   532
      }else{
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   533
	MSG_WAR(0x306C, "  PDO is not on EVENT or synchro or not at this SYNC. Trans type : ", *pTransmissionType);
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   534
	status = state11;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   535
      }      
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   536
        break;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   537
    case state5: /*Send the pdo*/
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   538
	/*store_as_last_message*/
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   539
	d->PDO_status[pdoNum].last_message = pdo;	
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   540
	MSG_WAR(0x396D, "sendPDO cobId :", pdo.cob_id.w);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   541
	MSG_WAR(0x396E,  "     Nb octets  : ",  pdo.len);
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   542
    	
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   543
    	canSend(d->canHandle,&pdo);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   544
	status = state11;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   545
	break;     
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   546
    case state11: /*Go to next TPDO*/     
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   547
	pdoNum++;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   548
	offsetObjdict++;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   549
	offsetObjdictMap++;
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   550
	MSG_WAR(0x3970, "next pdo index : ", pdoNum);
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   551
	status = state3;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   552
	break;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   553
      
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   554
    default:
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   555
      MSG_ERR(0x1972,"Unknown state has been reached : %d",status);
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   556
      return 0xFF;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   557
    }/* end switch case */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   558
    
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   559
  }/* end while */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   560
  }
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   561
  return 0;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   562
}
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   563
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   564
/*!
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   565
**
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   566
**
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   567
** @param d
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   568
** @param OD_entry
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   569
** @param bSubindex 
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   570
** @return always 0
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   571
**/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   572
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   573
UNS32 TPDO_Communication_Parameter_Callback(CO_Data* d, const indextable * OD_entry, UNS8 bSubindex)
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   574
{
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   575
  /* If PDO are actives */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   576
  if(d->CurrentCommunicationState.csPDO) switch(bSubindex)
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   577
  {
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   578
  	case 2: /* Changed transmition type */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   579
  	case 3: /* Changed inhibit time */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   580
  	case 5: /* Changed event time */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   581
  	{
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   582
          UNS8 pTransmissionType = *(UNS8*) OD_entry->pSubindex[2].pObject;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   583
          const indextable* TPDO_com = d->objdict + d->firstIndex->PDO_TRS; 
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   584
          UNS8 numPdo = OD_entry - TPDO_com;       /* number of the actual processed pdo-nr. */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   585
        
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   586
          /* Zap all timers and inhibit flag */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   587
          d->PDO_status[numPdo].event_timer = DelAlarm(d->PDO_status[numPdo].event_timer);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   588
          d->PDO_status[numPdo].inhibit_timer = DelAlarm(d->PDO_status[numPdo].inhibit_timer);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   589
          d->PDO_status[numPdo].transmit_type_parameter = 0;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   590
          /* Call  PDOEventTimerAlarm for this TPDO, this will trigger emission et reset timers */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   591
          PDOEventTimerAlarm(d, numPdo);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   592
          return 0;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   593
  	}
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   594
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   595
  	default: /* other subindex are ignored*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   596
  	break;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   597
  }
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   598
  return 0;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   599
}
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   600
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   601
void PDOInit(CO_Data* d)
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   602
{
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   603
  /* For each TPDO mapping parameters */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   604
  UNS16	pdoIndex = 0x1800; /* OD index of TDPO */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   605
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   606
  UNS16 offsetObjdict = d->firstIndex->PDO_TRS;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   607
  UNS16 lastIndex = d->lastIndex->PDO_TRS;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   608
  if(offsetObjdict) while( offsetObjdict <= lastIndex) {
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   609
    /* Assign callbacks to sensible TPDO mapping subindexes */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   610
    UNS32 errorCode;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   611
    ODCallback_t *CallbackList;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   612
    /* Find callback list */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   613
    scanIndexOD (d, pdoIndex, &errorCode, &CallbackList);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   614
    if(errorCode == OD_SUCCESSFUL && CallbackList)
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   615
    {
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   616
      /*Assign callbacks to corresponding subindex*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   617
      /* Transmission type */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   618
      CallbackList[2] = &TPDO_Communication_Parameter_Callback;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   619
      /* Inhibit time */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   620
      CallbackList[3] = &TPDO_Communication_Parameter_Callback;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   621
      /* Event timer */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   622
      CallbackList[5] = &TPDO_Communication_Parameter_Callback;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   623
    }
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   624
    pdoIndex++;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   625
    offsetObjdict++;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   626
  }  
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   627
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   628
  /* Trigger a non-sync event */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   629
  _sendPDOevent( d, 0 );
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   630
}
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   631
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   632
void PDOStop(CO_Data* d)
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   633
{
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   634
  /* For each TPDO mapping parameters */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   635
  UNS8 	pdoNum = 0x00;       /* number of the actual processed pdo-nr. */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   636
  UNS16 offsetObjdict = d->firstIndex->PDO_TRS;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   637
  UNS16 lastIndex = d->lastIndex->PDO_TRS;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   638
  if(offsetObjdict) while( offsetObjdict <= lastIndex) {
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   639
  	/* Delete TPDO timers */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   640
	d->PDO_status[pdoNum].event_timer = DelAlarm(d->PDO_status[pdoNum].event_timer);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   641
	d->PDO_status[pdoNum].inhibit_timer = DelAlarm(d->PDO_status[pdoNum].inhibit_timer);
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
   642
	/* Reset transmit type parameter */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   643
	d->PDO_status[pdoNum].transmit_type_parameter = 0;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   644
	d->PDO_status[pdoNum].last_message.cob_id.w = 0;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   645
	pdoNum++;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   646
	offsetObjdict++;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   647
  }  
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 217
diff changeset
   648
}