1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
8 Description: include file for Epl Configuration Manager Module
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
23 3. Neither the name of SYSTEC electronic GmbH nor the names of its
24 contributors may be used to endorse or promote products derived
25 from this software without prior written permission. For written
26 permission, please contact info@systec-electronic.com.
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 POSSIBILITY OF SUCH DAMAGE.
43 If a provision of this License is or becomes illegal, invalid or
44 unenforceable in any jurisdiction, that shall not affect:
45 1. the validity or enforceability in that jurisdiction of any other
46 provision of this License; or
47 2. the validity or enforceability in other jurisdictions of that or
48 any other provision of this License.
50 -------------------------------------------------------------------------
52 $RCSfile: EplCfgMau.h,v $
56 $Revision: 1.4 $ $Date: 2008/10/17 15:32:32 $
63 -------------------------------------------------------------------------
67 2006/07/14 k.t.: start of the implementation
68 -> based on CANopen CfgMa-Modul (CANopen version 5.34)
70 ****************************************************************************/
75 #include "../EplInc.h"
77 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFGMA)) != 0)
80 #include "EplSdoComu.h"
82 //define max number of timeouts for configuration of 1 device
83 #define EPL_CFGMA_MAX_TIMEOUT 3
85 //callbackfunction, called if configuration is finished
86 typedef void (* tfpEplCfgMaCb)(unsigned int uiNodeId_p,
87 tEplKernel Errorstate_p);
89 //State for configuartion manager Statemachine
92 kEplCfgMaIdle = 0x0000, // Configurationsprocess
94 kEplCfgMaWaitForSdocEvent = 0x0001, // wait until the last
96 kEplCfgMaSkipMappingSub0 = 0x0002, // write Sub0 of mapping
99 kEplCfgMaFinished = 0x0004 // configuartion is finished
103 kEplCfgMaDcfTypSystecSeg = 0x00,
104 kEplCfgMaDcfTypConDcf = 0x01,
105 kEplCfgMaDcfTypDcf = 0x02, // not supported
106 kEplCfgMaDcfTypXdc = 0x03 // not supported
110 kEplCfgMaCommon = 0, // all other index
111 kEplCfgMaPdoComm = 1, // communication index
112 kEplCfgMaPdoMapp = 2, // mapping index
113 kEplCfgMaPdoCommAfterMapp = 3, // write PDO Cob-Id after mapping subindex 0(set PDO valid)
115 } tEplCfgMaIndexType;
117 //bitcoded answer about the last sdo transfer saved in m_SdocState
118 // also used to singal start of the State Maschine
120 kEplCfgMaSdocBusy = 0x00, // SDOC activ
121 kEplCfgMaSdocReady = 0x01, // SDOC finished
122 kEplCfgMaSdocTimeout = 0x02, // SDOC Timeout
123 kEplCfgMaSdocAbortReceived = 0x04, // SDOC Abort, see Abortcode
124 kEplCfgMaSdocStart = 0x08 // start State Mschine
127 //internal structure (instancetable for modul configuration manager)
129 tEplCfgState m_CfgState; // state of the configuration state maschine
130 tEplSdoComConHdl m_SdoComConHdl; // handle for sdo connection
131 u32 m_dwLastAbortCode;
132 unsigned int m_uiLastIndex; // last index of configuration, to compair with actual index
133 u8 *m_pbConcise; // Ptr to concise DCF
134 u8 *m_pbActualIndex; // Ptr to actual index in the DCF segment
135 tfpEplCfgMaCb m_pfnCfgMaCb; // Ptr to CfgMa Callback, is call if configuration finished
136 tEplKernel m_EplKernelError; // errorcode
137 u32 m_dwNumValueCopy; // numeric values are copied in this variable
138 unsigned int m_uiPdoNodeId; // buffer for PDO node id
139 u8 m_bNrOfMappedObject; // number of mapped objects
140 unsigned int m_uiNodeId; // Epl node addresse
141 tEplSdocState m_SdocState; // bitcoded state of the SDO transfer
142 unsigned int m_uiLastSubIndex; // last subindex of configuration
143 BOOL m_fOneTranferOk; // atleased one transfer was successful
144 u8 m_bEventFlag; // for Eventsignaling to the State Maschine
145 u32 m_dwCntObjectInDcf; // number of Objects in DCF
146 tEplCfgMaIndexType m_SkipCfg; // TRUE if a adsitional Configurationprocess
147 // have to insert e.g. PDO-mapping
148 u16 m_wTimeOutCnt; // Timeout Counter, break configuration is
149 // m_wTimeOutCnt == CFGMA_MAX_TIMEOUT
153 //---------------------------------------------------------------------------
154 // Function: EplCfgMaInit()
156 // Description: Function creates first instance of Configuration Manager
160 // Returns: tEplKernel = error code
161 //---------------------------------------------------------------------------
162 tEplKernel EplCfgMaInit(void);
164 //---------------------------------------------------------------------------
165 // Function: EplCfgMaAddInstance()
167 // Description: Function creates additional instance of Configuration Manager
171 // Returns: tEplKernel = error code
172 //---------------------------------------------------------------------------
173 tEplKernel EplCfgMaAddInstance(void);
175 //---------------------------------------------------------------------------
176 // Function: EplCfgMaDelInstance()
178 // Description: Function delete instance of Configuration Manager
182 // Returns: tEplKernel = error code
183 //---------------------------------------------------------------------------
184 tEplKernel plCfgMaDelInstance(void);
186 //---------------------------------------------------------------------------
187 // Function: EplCfgMaStartConfig()
189 // Description: Function starts the configuration process
190 // initialization the statemachine for CfgMa- process
192 // Parameters: uiNodeId_p = NodeId of the node to configure
193 // pbConcise_p = pointer to DCF
194 // fpCfgMaCb_p = pointer to callback function (should not be NULL)
195 // SizeOfConcise_p = size of DCF in u8 -> for future use
196 // DcfType_p = type of the DCF
198 // Returns: tCopKernel = error code
199 //---------------------------------------------------------------------------
200 tEplKernel EplCfgMaStartConfig(unsigned int uiNodeId_p,
202 tfpEplCfgMaCb fpCfgMaCb_p,
203 tEplObdSize SizeOfConcise_p,
204 tEplCfgMaDcfTyp DcfType_p);
206 //---------------------------------------------------------------------------
207 // Function: CfgMaStartConfigurationNode()
209 // Description: Function started the configuration process
210 // with the DCF from according OD-entry Subindex == bNodeId_p
212 // Parameters: uiNodeId_p = NodeId of the node to configure
213 // fpCfgMaCb_p = pointer to callback function (should not be NULL)
214 // DcfType_p = type of the DCF
216 // Returns: tCopKernel = error code
217 //---------------------------------------------------------------------------
218 tEplKernel EplCfgMaStartConfigNode(unsigned int uiNodeId_p,
219 tfpEplCfgMaCb fpCfgMaCb_p,
220 tEplCfgMaDcfTyp DcfType_p);
222 //---------------------------------------------------------------------------
223 // Function: EplCfgMaStartConfigNodeDcf()
225 // Description: Function starts the configuration process
226 // and links the configuration data to the OD
228 // Parameters: uiNodeId_p = NodeId of the node to configure
229 // pbConcise_p = pointer to DCF
230 // fpCfgMaCb_p = pointer to callback function (should not be NULL)
231 // SizeOfConcise_p = size of DCF in u8 -> for future use
232 // DcfType_p = type of the DCF
234 // Returns: tCopKernel = error code
235 //---------------------------------------------------------------------------
236 tEplKernel EplCfgMaStartConfigNodeDcf(unsigned int uiNodeId_p,
238 tfpEplCfgMaCb fpCfgMaCb_p,
239 tEplObdSize SizeOfConcise_p,
240 tEplCfgMaDcfTyp DcfType_p);
242 //---------------------------------------------------------------------------
243 // Function: EplCfgMaLinkDcf()
245 // Description: Function links the configuration data to the OD
247 // Parameters: uiNodeId_p = NodeId of the node to configure
248 // pbConcise_p = pointer to DCF
249 // SizeOfConcise_p = size of DCF in u8 -> for future use
250 // DcfType_p = type of the DCF
252 // Returns: tCopKernel = error code
253 //---------------------------------------------------------------------------
254 tEplKernel EplCfgMaLinkDcf(unsigned int uiNodeId_p,
256 tEplObdSize SizeOfConcise_p,
257 tEplCfgMaDcfTyp DcfType_p);
259 //---------------------------------------------------------------------------
260 // Function: EplCfgMaCheckDcf()
262 // Description: Function check if there is allready a configuration file linked
263 // to the OD (type is given by DcfType_p)
265 // Parameters: uiNodeId_p = NodeId
266 // DcfType_p = type of the DCF
268 // Returns: tCopKernel = error code
269 //---------------------------------------------------------------------------
270 tEplKernel EplCfgMaCheckDcf(unsigned int uiNodeId_p, tEplCfgMaDcfTyp DcfType_p);
272 #endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFGMA)) != 0)
274 #endif // _EPLCFGMA_H_