include/pdo.h
author etisserant
Thu, 12 Apr 2007 16:14:07 +0200
changeset 152 5e14844e5756
parent 71 95cd3376cc9f
child 201 2966cd34162a
permissions -rw-r--r--
Now, setNodeId does change TPDO and RPDO CobId without testing previous CobId in order to avoid confusion. Standard does not says when 'default value' should be applied. See DS301 - Object 1400h - 15FFh: Receive PDO Communication Parameter page 108.
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
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
#ifndef __pdo_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
#define __pdo_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
#include <applicfg.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
#include <def.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
/* The process_var structure
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
 Used to store the PDO before the transmission or the reception.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
typedef struct struct_s_process_var {
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    33
  UNS8 count; /* Size of data. Ex : for a PDO of 6 bytes of data, count = 6 */
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    34
  /* WARNING s_process_var.data is subject to ENDIANISATION 
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    35
   * (with respect to CANOPEN_BIG_ENDIAN)
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    36
   */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
  UNS8 data[PDO_MAX_LEN];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
}s_process_var;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
#include "data.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    42
/** The PDO structure */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    43
typedef struct struct_s_PDO {
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    44
  UNS32 cobId;	  /* COB-ID */
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    45
  UNS8           len;	  /* Number of data transmitted (in data[]) */
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    46
  UNS8           data[8]; /* Contain the data */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    47
}s_PDO;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
/** Transmit a PDO data frame on the bus bus_id
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
 * pdo is a structure which contains the pdo to transmit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
 * return canSend(bus_id,&m) or 0xFF if error
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
 * request can take the value  REQUEST or NOT_A_REQUEST
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
UNS8 sendPDO (CO_Data* d, s_PDO pdo, UNS8 request);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
/** Prepare a PDO frame transmission, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
 * whose different parameters are stored in process_var table,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
 * to the slave.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
 * call the function sendPDO
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    62
 * return the result of the function sendPDO or 0xFF if error
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    64
UNS8 PDOmGR (CO_Data* d, UNS32 cobId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    65
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    66
/** Prepare the PDO defined at index to be sent by  PDOmGR
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    67
 * Copy all the data to transmit in process_var
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    68
 * *pwCobId : returns the value of the cobid. (subindex 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    69
 * Return 0 or 0xFF if error.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
UNS8 buildPDO (CO_Data* d, UNS16 index);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
/** Transmit a PDO request frame on the bus bus_id
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
 * to the slave.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
 * Returns 0xFF if error, other in success.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
UNS8 sendPDOrequest (CO_Data* d, UNS32 cobId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
/** Compute a PDO frame reception
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
 * return 0xFF if error, else return 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
UNS8 proceedPDO (CO_Data* d, Message *m);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    86
/* used by the application to send a variable by PDO.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    87
 * Check in which PDO the variable is mapped, and send the PDO. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    88
 * of course, the others variables mapped in the PDO are also sent !
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
 * ( ie when a specific event occured)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
 * variable is a pointer to the variable which has to be sent. Must be
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
 * defined in the object dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
 * return 0xFF if error, else return 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
UNS8 sendPDOevent (CO_Data* d, void * variable);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
#endif