include/lss.h
author etisserant
Fri, 01 Feb 2008 18:01:36 +0100
changeset 377 bea5a1576cbd
parent 361 2220813498f2
child 381 854c43cdc24a
permissions -rw-r--r--
Enhanced cleanup of TCP CAN client/server
343
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
     1
/*
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
     3
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
     4
Copyright (C): Jorge Berzosa
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
     5
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
     6
See COPYING file for copyrights details.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
     7
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    12
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    16
Lesser General Public License for more details.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    17
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    21
*/
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    22
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    23
#ifndef __LSS_h__
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    24
#define __LSS_h__
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    25
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    26
#define SLSS_ADRESS	0x7E4
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    27
#define MLSS_ADRESS	0x7E5
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    28
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    29
#define LSS_MSG_TIMER 0
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    30
#define LSS_SWITCH_DELAY_TIMER 1
361
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
    31
#define LSS_FS_TIMER 2
343
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    32
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    33
#define SDELAY_OFF		0
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    34
#define SDELAY_FIRST 	1
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    35
#define SDELAY_SECOND 	2
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    36
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    37
#define LSS_WAITING_MODE 0
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    38
#define LSS_CONFIGURATION_MODE 1
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    39
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    40
/* Switch mode services */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    41
#define LSS_SM_GLOBAL 				 4
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    42
#define LSS_SM_SELECTIVE_VENDOR 	64
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    43
#define LSS_SM_SELECTIVE_PRODUCT 	65
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    44
#define LSS_SM_SELECTIVE_REVISION 	66
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    45
#define LSS_SM_SELECTIVE_SERIAL 	67
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    46
#define LSS_SM_SELECTIVE_RESP 		68
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    47
/* Configuration services */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    48
#define LSS_CONF_NODE_ID 			17
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    49
#define LSS_CONF_BIT_TIMING 		19
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    50
#define LSS_CONF_ACT_BIT_TIMING 	21
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    51
#define LSS_CONF_STORE 				23
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    52
/* Inquire services */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    53
#define LSS_INQ_VENDOR_ID 		90
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    54
#define LSS_INQ_PRODUCT_CODE 	91
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    55
#define LSS_INQ_REV_NUMBER 		92
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    56
#define LSS_INQ_SERIAL_NUMBER 	93
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    57
#define LSS_INQ_NODE_ID 		94
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    58
/* Identification services */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    59
#define LSS_IDENT_REMOTE_VENDOR 		70
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    60
#define LSS_IDENT_REMOTE_PRODUCT 		71
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    61
#define LSS_IDENT_REMOTE_REV_LOW 		72
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    62
#define LSS_IDENT_REMOTE_REV_HIGH 		73
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    63
#define LSS_IDENT_REMOTE_SERIAL_LOW 	74
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    64
#define LSS_IDENT_REMOTE_SERIAL_HIGH 	75
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    65
#define LSS_IDENT_REMOTE_NON_CONF 		76
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    66
#define LSS_IDENT_SLAVE 				79
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    67
#define LSS_IDENT_NON_CONF_SLAVE 		80
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    68
#define LSS_IDENT_FASTSCAN				81
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    69
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    70
/*FastScan State Machine*/
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    71
#define LSS_FS_RESET	0
361
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
    72
#define LSS_FS_PROCESSING 1
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
    73
#define LSS_FS_CONFIRMATION 2
343
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    74
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    75
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    76
typedef void (*LSSCallback_t)(CO_Data* d, UNS8 command); 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    77
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    78
typedef void (*lss_StoreConfiguration_t)(UNS8*,UNS8*);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    79
//void _lss_StoreConfiguration(UNS8 *error, UNS8 *spec_error);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    80
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    81
typedef void (*lss_ChangeBaudRate_t)(char*);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    82
//void _lss_ChangeBaudRate(char *BaudRate);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    83
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    84
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    85
struct struct_lss_transfer;
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    86
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    87
//#include "timer.h"
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    88
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    89
/* The Transfer structure
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    90
* Used to store the different fields of the internal state of the LSS  
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    91
*/
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    92
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    93
struct struct_lss_transfer {
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    94
  UNS8          state;      /* state of the transmission : Takes the values LSS_... */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    95
  UNS8 			command;     /* the LSS command of the transmision */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    96
  UNS8			mode;       /* LSS mode */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    97
  
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    98
  UNS32 		dat1;		/* the data from the last msg received */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
    99
  UNS8			dat2; 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   100
  
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   101
  e_nodeState currentState; /* the state of the node before switching to LSSTimingDelay*/
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   102
  UNS8 nodeID;              /* the new nodeid stored to update the nodeid when switching to LSS operational*/
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   103
  UNS8 addr_sel_match;    	/* the matching mask for the LSS Switch Mode Selective service */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   104
  UNS8 addr_ident_match;    /* the matching mask for the LSS Identify Remote Slaves service*/
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   105
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   106
  char *baudRate;           /* the new baudrate stored to update the node baudrate when a Activate Bit 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   107
  							 * Timing Parameters is received*/
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   108
  UNS16 switchDelay;		/* the period of the two delay */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   109
  UNS8  switchDelayState;   /* the state machine for the switchDelay */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   110
361
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
   111
  TIMER_HANDLE timers[3];      /* Time counters to implement a timeout in milliseconds.
343
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   112
                              * LSS_MSG_TIMER (index 0) is automatically incremented whenever 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   113
                              * the lss state is in LSS_TRANS_IN_PROGRESS, and reseted to 0 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   114
                              * when the response LSS have been received.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   115
                              * LSS_SWITCH_DELAY_TIMER (index 1) is automatically incremented whenever 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   116
                              * the lss switchDelayState is in SDELAY_FIRST or SDELAY_SECOND, and reseted to 0 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   117
                              * when the two periods have been expired.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   118
                              */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   119
  LSSCallback_t Callback;   /* The user callback func to be called at LSS transaction end */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   120
  
361
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
   121
  UNS8 LSSanswer;			/* stores if a message has been received during a timer period */
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
   122
  
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
   123
  UNS32 IDNumber;			/* in the master, the LSS address parameter which it currently tries to identify.
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
   124
  							 * in the slave, the LSS address parameter which is being checked (LSS-ID[sub]). */
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
   125
  UNS8 BitChecked;			/* bits of the current IDNumber that are currently checked */
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
   126
  UNS8 LSSSub;				/* which part of the LSS-ID is currently checked in IDNumber */
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
   127
  UNS8 LSSNext;				/* which LSSSub value will be used in the next request */
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
   128
  UNS8 LSSPos;				/* in the slave, which part of the LSS-ID is currently processed*/
2220813498f2 Added FastScan support to the LSS services.
groke6
parents: 343
diff changeset
   129
  UNS8 FastScan_SM;			/* the state machine for the FastScan protocol */
343
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   130
};
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   131
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   132
#ifdef CO_ENABLE_LSS
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   133
typedef struct struct_lss_transfer lss_transfer_t;
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   134
#else
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   135
typedef UNS8 lss_transfer_t;
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   136
#endif
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   137
  
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   138
  
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   139
void startLSS(CO_Data* d);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   140
void stopLSS(CO_Data* d);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   141
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   142
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   143
/** transmit a LSS message 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   144
 * Checks if the msg can be transmited (i.e. we are not in LssTimingDelay state)
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   145
 * command is the LSS command specifier
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   146
 * dat1 and dat2 are pointers to optional data (depend on command)
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   147
 * return sendLSSMessage(d,command,dat1,dat2)
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   148
 */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   149
UNS8 sendLSS (CO_Data* d, UNS8 command,void *dat1, void *dat2);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   150
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   151
/** transmit a LSS message on CAN bus
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   152
 * comamnd is the LSS command specifier
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   153
 * bus_id is MLSS_ADRESS or SLSS_ADRESS depending in d->iam_a_slave. 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   154
 * dat1 and dat2 are pointers to optional data (depend on command).
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   155
 * return canSend(bus_id,&m)
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   156
 */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   157
 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   158
UNS8 sendLSSMessage(CO_Data* d, UNS8 command,  void *dat1, void *dat2);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   159
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   160
/** This function is called when the node is receiving a Master LSS message (cob-id = 0x7E5).
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   161
 *  - Check if there is a callback which will take care of the response. If not return 0 but does nothing.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   162
 *  - Stops the timer so the alarm wont raise an error.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   163
 *  - return 0 if OK
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   164
 */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   165
UNS8 proceedLSS_Master (CO_Data* d, Message* m );
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   166
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   167
/** This function is called when the node is receiving a Slave LSS message (cob-id = 0x7E4).
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   168
 *  - Call the callback function or send the response message depending on the LSS comand within m.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   169
 *  - return 0 if OK
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   170
 */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   171
UNS8 proceedLSS_Slave (CO_Data* d, Message* m );
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   172
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   173
/** Used by the Master application to send a LSS command, WITHOUT response, to the slave. 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   174
 * command: the LSS command. LSS_...
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   175
 * dat1 and dat2: pointers to optional data (depend on command).
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   176
 * return sendLSS(d,command,dat1,dat2)
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   177
 */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   178
UNS8 configNetworkNode(CO_Data* d, UNS8 command, void *dat1, void* dat2);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   179
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   180
/** Used by the Master application to send a LSS command, WITH response, to the slave. 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   181
 * The function Callback, which must be defined in the user code, is called at the
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   182
 * end of the exchange (on succes or abort) and can be NULL.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   183
 * The LSS_MSG_TIMER timer is started to control the timeout
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   184
 * return sendLSS(d,command,dat1,dat2)
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   185
 */
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   186
UNS8 configNetworkNodeCallBack (CO_Data* d, UNS8 command, void *dat1, void* dat2, LSSCallback_t Callback);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   187
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   188
/** Use this function after a configNetworkNode or configNetworkNodeCallBack to get the result.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   189
  Returns : LSS_RESET				// Transmission not started. Init state.
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   190
			LSS_FINISHED			// data are available                           
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   191
			LSS_ABORTED_INTERNAL	// Aborted but not because of an abort message. 
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   192
			LSS_TRANS_IN_PROGRESS	// Data not yet available
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   193
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   194
  * command: the LSS command (unused).
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   195
  * example:
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   196
  * UNS32 dat1;
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   197
  * UNS8 dat2;
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   198
  res=configNetworkNodeCallBack(&_Data,LSS_INQ_NODE_ID,0,0,NULL); // inquire the nodeID
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   199
  while (getConfigResultNetworkNode (&_Data, LSS_INQ_NODE_ID, &dat1, &dat2) != LSS_TRANS_IN_PROGRESS);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   200
*/
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   201
UNS8 getConfigResultNetworkNode (CO_Data* d, UNS8 command, UNS32* dat1, UNS8* dat2);
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   202
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents:
diff changeset
   203
#endif