include/pdo.h
author frdupin
Tue, 12 Dec 2006 17:32:05 +0100
changeset 52 1dc256e8e49a
parent 0 4472ee7c6c3e
child 71 95cd3376cc9f
permissions -rw-r--r--
Je n'ai pas termin?
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 {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
  UNS8 count; // Size of data. Ex : for a PDO of 6 bytes of data, count = 6
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
  // WARNING s_process_var.data is subject to ENDIANISATION 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
  // (with respect to CANOPEN_BIG_ENDIAN)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
  UNS8 data[PDO_MAX_LEN];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
}s_process_var;
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
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
/** The PDO structure */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    42
typedef struct struct_s_PDO {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    43
  UNS32 cobId;	  // COB-ID
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    44
  UNS8           len;	  // Number of data transmitted (in data[])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    45
  UNS8           data[8]; // Contain the data
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
}s_PDO;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    47
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
/** Transmit a PDO data frame on the bus bus_id
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
 * pdo is a structure which contains the pdo to transmit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
 * return canSend(bus_id,&m) or 0xFF if error
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
 * request can take the value  REQUEST or NOT_A_REQUEST
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
UNS8 sendPDO (CO_Data* d, s_PDO pdo, UNS8 request);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
/** Prepare a PDO frame transmission, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
 * whose different parameters are stored in process_var table,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
 * to the slave.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
 * call the function sendPDO
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
 * return the result of the function sendPDO or 0xFF if error
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    62
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
UNS8 PDOmGR (CO_Data* d, UNS32 cobId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    64
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    65
/** Prepare the PDO defined at index to be sent by  PDOmGR
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    66
 * Copy all the data to transmit in process_var
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    67
 * *pwCobId : returns the value of the cobid. (subindex 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    68
 * Return 0 or 0xFF if error.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    69
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
UNS8 buildPDO (CO_Data* d, UNS16 index);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
/** Transmit a PDO request frame on the bus bus_id
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
 * to the slave.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
 * Returns 0xFF if error, other in success.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
UNS8 sendPDOrequest (CO_Data* d, UNS32 cobId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
/** Compute a PDO frame reception
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
 * return 0xFF if error, else return 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
UNS8 proceedPDO (CO_Data* d, Message *m);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
/* used by the application to send a variable by PDO.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    86
 * Check in which PDO the variable is mapped, and send the PDO. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    87
 * of course, the others variables mapped in the PDO are also sent !
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    88
 * ( ie when a specific event occured)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
 * variable is a pointer to the variable which has to be sent. Must be
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
 * defined in the object dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
 * return 0xFF if error, else return 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
UNS8 sendPDOevent (CO_Data* d, void * variable);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
#endif