include/pdo.h
author Edouard Tisserant
Sat, 21 Jan 2012 18:49:54 +0100
changeset 676 11e95dd60ffc
parent 670 e37511baf56b
permissions -rwxr-xr-x
Merged some canfestival-3-ica Fixes.
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
See COPYING file for copyrights details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    12
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    16
Lesser General Public License for more details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    17
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    21
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    22
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    23
/** @defgroup pdo Process Data Object (PDO)
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    24
 *  PDO is a communication object defined by the DPO communication parameter and PDA mapping parameter objects.
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    25
 *  It is an uncomfirmed communication service without protocol overhead.
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    26
 *  @ingroup comobj
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    27
 */
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    28
 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
#ifndef __pdo_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
#define __pdo_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
#include <applicfg.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
#include <def.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    35
#include "can.h"
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    36
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    37
typedef struct struct_s_PDO_status s_PDO_status;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
#include "data.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
670
e37511baf56b New feature : event timers allowed for RxPDOs (subidx 5 in RxPDO com paramaters)
Mongo
parents: 649
diff changeset
    41
/* Handler for RxPDO event timers : empty function that user can overload */
e37511baf56b New feature : event timers allowed for RxPDOs (subidx 5 in RxPDO com paramaters)
Mongo
parents: 649
diff changeset
    42
void _RxPDO_EventTimers_Handler(CO_Data *d, UNS32 pdoNum);
e37511baf56b New feature : event timers allowed for RxPDOs (subidx 5 in RxPDO com paramaters)
Mongo
parents: 649
diff changeset
    43
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    44
/* Status of the TPDO : */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    45
#define PDO_INHIBITED 0x01
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
    46
#define PDO_RTR_SYNC_READY 0x01
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    47
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
/** The PDO structure */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    49
struct struct_s_PDO_status {
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    50
  UNS8 transmit_type_parameter;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    51
  TIMER_HANDLE event_timer;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    52
  TIMER_HANDLE inhibit_timer;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    53
  Message last_message;
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    54
};
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
366
47763dd15e00 Fixed Peter Christen remarks as regards typo
etisserant
parents: 236
diff changeset
    56
#define s_PDO_status_Initializer {0, TIMER_NONE, TIMER_NONE, Message_Initializer}
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    57
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    58
/** definitions of the different types of PDOs' transmission
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    59
 * 
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    60
 * SYNCHRO(n) means that the PDO will be transmited every n SYNC signal.
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
 */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    62
#define TRANS_EVERY_N_SYNC(n) (n) /*n = 1 to 240 */
426
8011552b1319 Preliminary support for TRANS_SYNC_ACYCLIC (0) transmit type.
etisserant
parents: 366
diff changeset
    63
#define TRANS_SYNC_ACYCLIC    0    /* Trans after reception of n SYNC. n = 1 to 240 */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    64
#define TRANS_SYNC_MIN        1    /* Trans after reception of n SYNC. n = 1 to 240 */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    65
#define TRANS_SYNC_MAX        240  /* Trans after reception of n SYNC. n = 1 to 240 */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    66
#define TRANS_RTR_SYNC        252  /* Transmission on request */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    67
#define TRANS_RTR             253  /* Transmission on request */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    68
#define TRANS_EVENT_SPECIFIC  254  /* Transmission on event */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    69
#define TRANS_EVENT_PROFILE   255  /* Transmission on event */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
529
c171e11707c5 Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 528
diff changeset
    71
/** 
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    72
 * @brief Copy all the data to transmit in process_var
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    73
 * Prepare the PDO defined at index to be sent
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
 * *pwCobId : returns the value of the cobid. (subindex 1)
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    75
 * @param *d Pointer on a CAN object data structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    76
 * @param numPdo The PDO number
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    77
 * @param *pdo Pointer on a CAN message structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    78
 * @return 0 or 0xFF if error.
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
 */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
    80
UNS8 buildPDO(CO_Data* d, UNS8 numPdo, Message *pdo);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    82
/** 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    83
 * @ingroup pdo
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    84
 * @brief Transmit a PDO request frame on the network to the slave.
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    85
 * @param *d Pointer on a CAN object data structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    86
 * @param RPDOIndex Index of the receive PDO
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    87
 * @return
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    88
 *       - CanFestival file descriptor is returned upon success.
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    89
 *       - 0xFF is returned if RPDO Index is not found.
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    90
 
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    91
 * @return 0xFF if error, other in success.
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
 */
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 235
diff changeset
    93
UNS8 sendPDOrequest( CO_Data* d, UNS16 RPDOIndex );
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    95
/**
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    96
 * @brief Compute a PDO frame reception
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
 * bus_id is hardware dependant
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    98
 * @param *d Pointer on a CAN object data structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
    99
 * @param *m Pointer on a CAN message structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   100
 * @return 0xFF if error, else return 0
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   102
UNS8 proceedPDO (CO_Data* d, Message *m);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
529
c171e11707c5 Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 528
diff changeset
   104
/** 
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   105
 * @brief Used by the application to signal changes in process data
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   106
 * that could be mapped to some TPDO.
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   107
 * This do not necessarily imply PDO emission.
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   108
 * Function iterates on all TPDO and look TPDO transmit 
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   109
 * type and content change before sending it.    
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   110
 * @param *d Pointer on a CAN object data structure
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   111
 */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   112
UNS8 sendPDOevent (CO_Data* d);
649
3beb784bacee CHANGED: - function sendOnePDOevent (CO_Data* d, UNS32 pdoNum) into sendOnePDOevent (CO_Data* d, UNS8 pdoNum)
Christian Taedcke
parents: 611
diff changeset
   113
UNS8 sendOnePDOevent (CO_Data* d, UNS8 pdoNum);
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   114
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   115
/** 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   116
 * @ingroup pdo
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   117
 * @brief Function iterates on all TPDO and look TPDO transmit 
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   118
 * type and content change before sending it.
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   119
 * @param *d Pointer on a CAN object data structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   120
 * @param isSyncEvent
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   121
 */
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   122
UNS8 _sendPDOevent(CO_Data* d, UNS8 isSyncEvent);
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   123
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   124
/** 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   125
 * @brief Initialize PDO feature 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   126
 * @param *d Pointer on a CAN object data structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   127
 */
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   128
void PDOInit(CO_Data* d);
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   129
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   130
/** 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   131
 * @brief Stop PDO feature 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   132
 * @param *d Pointer on a CAN object data structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   133
 */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   134
void PDOStop(CO_Data* d);
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   135
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   136
/** 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   137
 * @ingroup pdo
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   138
 * @brief Set timer for PDO event
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   139
 * @param *d Pointer on a CAN object data structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   140
 * @param pdoNum The PDO number
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   141
 */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   142
void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum);
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   143
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   144
/** 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   145
 * @ingroup pdo
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   146
 * @brief Inhibit timer for PDO event
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   147
 * @param *d Pointer on a CAN object data structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   148
 * @param pdoNum The PDO number
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 426
diff changeset
   149
 */
235
f812bf6b7237 Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents: 201
diff changeset
   150
void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
201
2966cd34162a Boolean variable mapped in PDO
greg
parents: 71
diff changeset
   152
/* copy bit per bit in little endian */
2966cd34162a Boolean variable mapped in PDO
greg
parents: 71
diff changeset
   153
void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
#endif