├── LICENSE
├── README.md
├── XcpBasic.c
├── XcpBasic.h
├── XcpCfg.c
├── XcpCfg.h
├── XcpSxIMaster.cpp
├── XcpSxIMaster.h
└── demo.ino
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Arduino-Xcp
2 | this library is going to implement a lightweight ASAM XCP protocol for real time measurement and calibration. A GUI client will also be developed.
3 |
4 | many projects use serial commands and prints to control or measure data in arduino devices, that's not cool at all.
5 |
--------------------------------------------------------------------------------
/XcpBasic.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*****************************************************************************
4 | | Project Name: XCP Protocol Layer
5 | | File Name: XcpBasic.h
6 | |
7 | | Description: Header of XCP Protocol Layer
8 | | XCP V1.0 slave device driver
9 | | Basic Version
10 | |
11 | |-----------------------------------------------------------------------------
12 | | D E M O
13 | |-----------------------------------------------------------------------------
14 | |
15 | | Please note, that the demo and example programs
16 | | only show special aspects of the software.
17 | | With regard to the fact that these programs are meant
18 | | for demonstration purposes only,
19 | | Vector Informatik's liability shall be expressly excluded in cases
20 | | of ordinary negligence, to the extent admissible by law or statute.
21 | |
22 | |-----------------------------------------------------------------------------
23 | | C O P Y R I G H T
24 | |-----------------------------------------------------------------------------
25 | | Copyright (c) 2017 by Vector Informatik GmbH. All rights reserved.
26 | |
27 | | This software is copyright protected and
28 | | proporietary to Vector Informatik GmbH.
29 | | Vector Informatik GmbH grants to you only
30 | | those rights as set out in the license conditions.
31 | | All other rights remain with Vector Informatik GmbH.
32 | |
33 | | Diese Software ist urheberrechtlich geschuetzt.
34 | | Vector Informatik GmbH raeumt Ihnen an dieser Software nur
35 | | die in den Lizenzbedingungen ausdruecklich genannten Rechte ein.
36 | | Alle anderen Rechte verbleiben bei Vector Informatik GmbH.
37 | |
38 | |-----------------------------------------------------------------------------
39 | | A U T H O R I D E N T I T Y
40 | |-----------------------------------------------------------------------------
41 | | Initials Name Company
42 | | -------- --------------------- -------------------------------------
43 | | Ds Sven Deckardt Vector Informatik GmbH
44 | | Eta Edgar Tongoona Vector Informatik GmbH
45 | | Hr Andreas Herkommer Vector Informatik GmbH
46 | | Svh Sven Hesselmann Vector Informatik GmbH
47 | | Tri Frank Triem Vector Informatik GmbH
48 | | Za Rainer Zaiser Vector Informatik GmbH
49 | | Ore Oliver Reineke Vector Informatik GmbH
50 | | Bwr Brandon Root Vector CANtech
51 | |-----------------------------------------------------------------------------
52 | | R E V I S I O N H I S T O R Y
53 | |-----------------------------------------------------------------------------
54 | | Date Version Author Description
55 | | ---------- ------- ------ -----------------------------------------------
56 | | 2000-24-09 10 Ds - New header description
57 | | 2003-24-04 10 Ds - Swap GET_SECTOR_INFO Mode and Number
58 | | 2003-24-04 10 Ds - Swap SET_SEGMENT_MODE Mode and Number
59 | | 2003-25-04 10 Ds - Swap GET_SEGMENT_INFO Mode and Number
60 | | 2003-28-04 10 Ds - GET_SEGMENT_MODE reserved position 1
61 | | 2003-28-04 10 Ds - GET_PAGE_INFO reserved position 1
62 | | 2003-10-30 1.0.03 Ds - Rename xcp20.h to xcpProf.h
63 | | 2003-11-20 1.01.00 Tri Updated to PSC standard.
64 | | MISRA rules applied.
65 | | Minor changes.
66 | | 2004-02-11 1.01.01 Ds,Tri Updated and adaption for CANape
67 | | ESCAN00007511: Warning when compiling XCP.H
68 | | ESCAN00007517: Compiler error when using a packet length of 253 bytes or greater
69 | | ESCAN00007518: Seed & Key: reading of the unlock key not performed correctly
70 | | ESCAN00007532: Division by zero in calculation of the queue size
71 | | ESCAN00007533: Memory overflow check during memory allocation might not be detected.
72 | | 2004-06-16 1.02.00 Tri ESCAN00008482: Add user defined function to service GET_ID
73 | | 2005-01-03 1.03.00 Tri,Za ESCAN00008009: Rename module versions according to PD_PSC_Development
74 | | ESCAN00009121: Add copyright note
75 | | ESCAN00009125: Remove defines for revision 18
76 | | ESCAN00009127: Remove XCP_ENABLE_SEND_BUFFER
77 | | ESCAN00009130: Add support for data stimulation (STIM)
78 | | ESCAN00007824: Warning due to unreferenced label 'negative_response1'
79 | | ESCAN00008012: Remove include definitions of the standard libraries within XCP Professional
80 | | ESCAN00008015: Avoid usage of the test mode within XCP Professional
81 | | ESCAN00008018: XCP module version in response of CC_GET_COMM_MODE_INFO corrected
82 | | ESCAN00008004: Compiler error when block upload is enabled and block download is disabled
83 | | ESCAN00008005: Resource bit for CAL/PAG always set in response upon CC_CONNECT
84 | | ESCAN00009141: Compiler warnings while compilation with Tasking Compiler
85 | | ESCAN00007823: Warning about unreferenced variable 'prescaler'
86 | | ESCAN00008003: Compiler error when block download is disabled and Programming enabled
87 | | ESCAN00008060: Issue in negative response of command BUILD_CHECKSUM
88 | | ESCAN00008013: Checksum calculation wrong
89 | | ESCAN00008072: Compiler warning in range check of defines
90 | | ESCAN00007971: Implement and support 'session configuration id'
91 | | ESCAN00008006: Page switching always enabled when programming is enabled.
92 | | ESCAN00008010: Remove extern declaration for xcp struct
93 | | ESCAN00009154: Update Seed & Key
94 | | ESCAN00010703: PROGRAM size = 0 is valid
95 | | ESCAN00008017: Rework of Flash Programming by Flash Kernel
96 | | ESCAN00009200: Positive Response upon command PROGRAM_START not correct
97 | | ESCAN00010705: Rework command PROGRAM_RESET
98 | | ESCAN00010706: Return the status of event channels
99 | | ESCAN00010707: Consistency check in case of no DAQ released
100 | | ESCAN00008008: Apply PSC naming convention for types and structures
101 | | ESCAN00009173: Consistency check for generator DLL and component
102 | | ESCAN00008007: Rename the post-organified filenames to xcpProf.h and xcpProf.c
103 | | ESCAN00009172: Atmega only: Compiler error due to pointer conversion from RAM to Flash
104 | | ESCAN00007209: Apply naming convention to callback functions
105 | | ESCAN00009144: Minor changes
106 | | 2005-02-01 1.04.00 Tri ESCAN00010989: Update comment for version scan
107 | | ESCAN00010848: Move timestamp unit of response to GET_DAQ_EVENT_INFO in low nibble
108 | | 2005-02-17 1.05.00 Tri ESCAN00011210: Support GENy Fwk 1.3 DLL Versions
109 | | 2005-02-28 1.06.00 Tri ESCAN00010961: Include XCP Transport Layer on CAN
110 | | 2005-05-10 1.07.00 Tri ESCAN00011446: Tasking Compiler only: Compiler Warnings
111 | | ESCAN00012314: Compatibility with CANape 5.5.x regarding timestamp unit
112 | | ESCAN00012356: Support data paging on Star12X / Metrowerks
113 | | ESCAN00012617: Add service to retrieve XCP state
114 | | 2006-01-03 1.08.00 Tri ESCAN00013899: Data acquisition not possible during cold start
115 | | ESCAN00009196: PROGRAM_FORMAT is not implemented as specified
116 | | ESCAN00009199: Negative Response to command PROGRAM_PREPARE is not correct
117 | | ESCAN00009202: Programming Info not implemented correctly
118 | | ESCAN00014313: Warning because of undefined 'kXcpStimOdtCount'
119 | | ESCAN00013634: Remove kXcpPacketHeaderSize
120 | | ESCAN00014710: Rework Calibration Data Page Freeze
121 | | ESCAN00014712: Rework Segment Info and Page Info
122 | | ESCAN00014775: Delayed EEPROM read access not possible
123 | | 2006-03-09 1.09.00 Tri ESCAN00013637: Support command TRANSPORT_LAYER_CMD
124 | | ESCAN00015283: Start of a single DAQ list is not possible
125 | | ESCAN00015607: Support XCP on FlexRay Transport Layer
126 | | 2006-05-05 1.10.00 Tri ESCAN00016158: Add demo disclaimer to XCP Basic
127 | | ESCAN00016098: Calculation of CRC16 CCITT is not correct
128 | | 2006-05-30 1.11.00 Tri ESCAN00016225: Support Cp_XcpOnLin
129 | | 2006-07-18 1.12.00 Tri ESCAN00016955: Support AUTOSAR CRC module
130 | | ESCAN00016958: Delayed EEPROM read access not possible
131 | | 2006-10-26 1.13.00 Tri ESCAN00017516: Support Cp_XcpOnCanAsr
132 | | ESCAN00017504: Replace P_MEM_ROM by MEMORY_FAR resp. V_MEMRAM2_FAR
133 | | ESCAN00017804: Multiple definitions of XCP_DISABLE_TESTMODE
134 | | ESCAN00017878: Overwriting of memory during data acquisition allocation
135 | | 2007-01-30 1.14.00 Tri ESCAN00018808: Support data paging on Star12X / Cosmic
136 | | 2007-04-03 1.15.00 Eta ESCAN00018153: Overwriting of memory during data stimulation
137 | | Svh ESCAN00020126: Commands SHORT_DOWNLOAD and MODIFY_BITS must be supported
138 | | ESCAN00012618: Support command MODIFY_BITS
139 | | ESCAN00020127: It has to be possible to en-/disable XCP globally
140 | | ESCAN00019094: Extend implementation for runtime deactivation of XCP (professional)
141 | | ESCAN00020128: Add AUTOSAR based API
142 | | ESCAN00018154: Support overwriting of XcpSendDto() in header
143 | | ESCAN00015859: Support memory read protection
144 | | 2007-05-25 1.16.00 Svh ESCAN00020906: Compiler error due to incorrect pointer assignment
145 | | 2007-07-09 1.16.01 Hr Support AUTOSAR Memory Mapping
146 | | 2007-12-07 1.16.02 Hr ISS046 - Only CTOs are flushed by the Protocol Layer
147 | | 2007-09-14 1.17.00 Svh ESCAN00022293: Support for SET_SEGMENT_MODE and GET_SEGMENT_MODE added
148 | | 2007-12-17 1.18.00 Svh ESCAN00023759: Compile error for MCS12x
149 | | 2008-03-17 1.19.00 Svh ESCAN00021035: XcpSendCallBack() always returns 1
150 | | ESCAN00024265: STIM with time stamp is not supported
151 | | ESCAN00024863: Missing error code in CC_TRANSPORT_LAYER_CMD
152 | | ESCAN00025020: Possible stack issues with big MAX_DTO values in case Send Queue is not used
153 | | ESCAN00023570: Do not set default answer is last CRM is still pending
154 | | 2008-04-10 1.20.00 Svh ESCAN00025979: tXcpDto wrong structure ordering causing erroneous one-time Stim trigger
155 | | 2008-04-30 1.21.00 Eta ESCAN00026424: compiler error when using Cosmic with option -pck
156 | | Svh ESCAN00026491: Data inconsistency of ODTs in case of Overrun + FlexRay
157 | | 2008-04-30 1.21.01 Svh ESCAN00026541: compiler error due to unknown symbol
158 | | 2008-06-04 1.21.02 Svh ESCAN00027343: Redefinition of ApplXcpSendFlush
159 | | 2008-07-21 1.22.00 Hr ESCAN00022545: Memory Read Protection always returns Ok to CANape
160 | | ESCAN00020637: Support different Info Time Unit for DTO handling
161 | | ESCAN00017954: Support MIN_ST_PGM
162 | | ESCAN00017951: Add open interface for command processing
163 | | ESCAN00028579: CC_PROGRAM_START should support an application callback
164 | | Svh ESCAN00028720: Support ADDRESS_GRANULARITY WORD
165 | | 2008-09-10 1.23.00 Svh ESCAN00029890: Incorrect checksum calculation
166 | | ESCAN00029896: Command pending for several call backs added
167 | | ESCAN00029897: XcpStimEventStatus() returns 1 also if no STIM data is available
168 | | ESCAN00029905: Configuration of parameter MIN_ST in response of GET_COMM_MODE_INFO command added
169 | | 2008-10-01 1.23.01 Hr ESCAN00030382: Compiler error due to missing ;
170 | | 2008-10-10 1.23.02 Bwr ESCAN00030037: Support for more than 255 ODT entries
171 | | 2008-12-01 1.24.00 Hr ESCAN00031342: Version information of implementation inconsistent to release version information
172 | | ESCAN00031726: Add support for XcpOnTcpIpAsr
173 | | ESCAN00031948: Event gets lost, if a Response is still pending
174 | | ESCAN00031949: Add error check for ODT_SIZE_WORD with no DAQ_HDR_ODT_DAQ
175 | | Bwr ESCAN00030566: SET_REQUEST with incorrect mode is ignored
176 | | ESCAN00030601: Support for more than 255 ODTs
177 | | 2009-02-05 1.24.01 Hr ESCAN00032861: CC_SET_DAQ_PTR fails due to Diab Data Compiler bug
178 | | 2009-02-27 1.24.02 Hr ESCAN00031794: Compiler warning: large type was implicitly cast to small type
179 | | ESCAN00033655: Canbedded compile error due to uint8
180 | | 2009-05-13 1.25.00 Hr ESCAN00033909: New features implemented: Prog Write Protection, Timestamps, Calibration activation
181 | | 2009-10-08 1.25.01 Hr ESCAN00038283: After second measurement start with INCA no timestamps are generated anymore.
182 | | ESCAN00039240: Compile error by uint8
183 | | ESCAN00039241: Variables not in NOINIT sections
184 | | 2009-11-26 Hr ESCAN00039350: TMS320 Compile error: struct has no field "EightByteField"
185 | | 2010-03-24 1.26.00 Hr ESCAN00041784: new API for better calibration support
186 | | ESCAN00041784: Queue size calculation incorrect under certain conditions
187 | | 2010-05-25 1.26.01 Hr ESCAN00042660: Send queue variables to small
188 | | ESCAN00043113: Compiler error: identifier uint16 not declared
189 | | 2010-07-08 1.26.02 Hr ESCAN00043335: Queue size calculation incorrect on 32Bit Platforms
190 | | 2010-10-12 1.26.03 Hr ESCAN00045791: Send Queue limited to 255 Entries by typecasts
191 | | 2011-02-11 1.27.00 Hr ESCAN00047153: 'XCP on LIN' and 'XCP on CAN' can not be used in the same configuration.
192 | | ESCAN00048613: CC_PROGRAM_CLEAR does not make use of programming write protection
193 | | ESCAN00049091: Optimization to prevent a goto in the code
194 | | ESCAN00049090: Software might hang in endless software loop
195 | | 2011-06-06 1.27.01 Hr ESCAN00051222: Customer can't compile XCP when disabling the DAQ feature
196 | | 2011-07-19 1.27.02 Ore ESCAN00052011: Reading memory of the ECU via XCP is not possible. XCP Connect aborts with error condition PAGE_MODE_NOT_VALID (=0x27)
197 | | 2011-08-29 1.27.03 Hr ESCAN00052721: Compiler Error because MEMORY_ROM definition
198 | | ESCAN00053956: Check DAQ lists for validity before they are started
199 | | 2011-11-25 1.27.04 Hr ESCAN00054318: Issue of memory read/write protection in DAQ measurement
200 | | 2012-02-20 1.27.05 Hr ESCAN00055216: DAQ Lists can be extended after START_STOP_SYNCH
201 | | 2012-05-31 1.27.06 Hr ESCAN00058916: Trap if WRITE_DAQ is used before a DAQ list is created.
202 | | 2012-08-13 1.28.00 Hr ESCAN00038632: Support for address doubling in CANape for DSP micros
203 | | 2013-06-17 1.28.01 Hr ESCAN00068052: Provide an API to detect XCP state and usage
204 | | 2013-09-17 1.28.02 Hr ESCAN00069598: The PROGRAM_MAX command uses a wrong length
205 | | ESCAN00067667: Compiler warning: warning #177-D: label "negative_response1" was declared but never referenced
206 | | 2013-12-09 1.29.00 Hr ESCAN00072412: Provide an API to detect XCP state and usage
207 | | ESCAN00072503: Support custom CRC Cbk
208 | | ESCAN00072505: Support Generic GET_ID
209 | | 2015-03-26 1.30.00 Hr ESCAN00082098: Time Check for DAQ lists
210 | | 2016-01-12 1.30.01 Hr ESCAN00087368: Unexpected byte order used on word-addressed platforms (e.g. TMS320)
211 | | 2016-06-24 1.30.02 Hr ESCAN00090639: Compiler error: "truncating assignment"
212 | | ESCAN00090685: Max PID not checked against 0x7C if Overload Indication is active
213 | | ESCAN00090687: Prescaler does not disable single DAQ list per event optimization
214 | | ESCAN00090699: MPU detects illegal access to variable dto
215 | | 2016-11-18 1.30.03 Hr ESCAN00091645: Wrong memory size calculation during memory allocation
216 | | ESCAN00092933: XcpMemCpy does not fully utilize XCP_ENABLE_MEM_ACCESS_BY_APPL
217 | | ESCAN00092934: Max PID not checked against 0x7B if Overload Indication is active
218 | | 2017-09-01 1.30.04 Hr ESCAN00095506: TMS320 wrong Endianess used during memory access.
219 | | ESCAN00096039: Compiler error: out of bounds array access optimized away
220 | | ESCAN00096161: Compiler warning: Unused variable qs
221 | | ESCAN00096627: Improve plausibility check of DAQ allocation
222 | |***************************************************************************/
223 |
224 | #if !defined ( __XCP_H_ )
225 | #define __XCP_H_
226 |
227 |
228 | /***************************************************************************/
229 | /* Include */
230 | /***************************************************************************/
231 |
232 | /* Includes for XcpProf.c/XcpBasic.c */
233 | #include "XcpCfg.h"
234 |
235 | #ifdef __cplusplus
236 | extern "C" {
237 | #endif
238 |
239 | /* Include the Transport Layer for LIN if available. */
240 |
241 | /* Include the Transport Layer for FlexRay if available. */
242 |
243 | /* PRQA S 0857 EOF */ /* MD_MSR_1.1_857 */
244 | /* PRQA S 0828 EOF */ /* MD_MSR_1.1_828 */
245 | /* PRQA S 3453 EOF */ /* MD_MSR_19.7 */
246 | /* PRQA S 3458 EOF */ /* MD_MSR_19.4 */
247 |
248 | /***************************************************************************/
249 | /* Version */
250 | /***************************************************************************/
251 |
252 | /* BCD coded version number of XCP module */
253 | /* ##V_CFG_MANAGEMENT ##CQProject : Cp_Xcp CQComponent : Implementation */
254 | #define CP_XCP_VERSION 0x0130u
255 | #define CP_XCP_RELEASE_VERSION 0x04u
256 |
257 | /* Version of the XCP Protocol Layer Specification V1.0 */
258 | #if ! defined ( XCP_VERSION )
259 | #define XCP_VERSION 0x0100
260 | #endif
261 |
262 | #define XCP_VENDOR_ID 30u
263 | #define XCP_MODULE_ID 26u
264 |
265 |
266 | /****************************************************************************/
267 | /* Definitions */
268 | /****************************************************************************/
269 |
270 | /* Definition of endianess. */
271 | #if defined ( XCP_CPUTYPE_BIGENDIAN ) || defined ( XCP_CPUTYPE_LITTLEENDIAN )
272 | #else
273 | #if defined ( C_CPUTYPE_BIGENDIAN )
274 | #define XCP_CPUTYPE_BIGENDIAN
275 | #endif
276 | #if defined ( C_CPUTYPE_LITTLEENDIAN )
277 | #define XCP_CPUTYPE_LITTLEENDIAN
278 | #endif
279 | #if defined ( CPU_BYTE_ORDER )
280 | #if ( CPU_BYTE_ORDER == HIGH_BYTE_FIRST )
281 | #define XCP_CPUTYPE_BIGENDIAN
282 | #endif
283 | #if ( CPU_BYTE_ORDER == LOW_BYTE_FIRST )
284 | #define XCP_CPUTYPE_LITTLEENDIAN
285 | #endif
286 | #endif
287 | #endif
288 |
289 |
290 | /***************************************************************************/
291 | /* Commands */
292 | /***************************************************************************/
293 |
294 |
295 | /*-------------------------------------------------------------------------*/
296 | /* Standard Commands */
297 |
298 | #define CC_CONNECT 0xFF
299 | #define CC_DISCONNECT 0xFE
300 | #define CC_GET_STATUS 0xFD
301 | #define CC_SYNC 0xFC
302 |
303 | #define CC_GET_COMM_MODE_INFO 0xFB
304 | #define CC_GET_ID 0xFA
305 | #define CC_SET_REQUEST 0xF9
306 | #define CC_GET_SEED 0xF8
307 | #define CC_UNLOCK 0xF7
308 | #define CC_SET_MTA 0xF6
309 | #define CC_UPLOAD 0xF5
310 | #define CC_SHORT_UPLOAD 0xF4
311 | #define CC_BUILD_CHECKSUM 0xF3
312 |
313 | #define CC_TRANSPORT_LAYER_CMD 0xF2
314 | #define CC_USER_CMD 0xF1
315 |
316 |
317 | /*-------------------------------------------------------------------------*/
318 | /* Calibration Commands*/
319 |
320 | #define CC_DOWNLOAD 0xF0
321 |
322 | #define CC_DOWNLOAD_NEXT 0xEF
323 | #define CC_DOWNLOAD_MAX 0xEE
324 | #define CC_SHORT_DOWNLOAD 0xED
325 | #define CC_MODIFY_BITS 0xEC
326 |
327 |
328 | /*-------------------------------------------------------------------------*/
329 | /* Page switching Commands (PAG) */
330 |
331 | #define CC_SET_CAL_PAGE 0xEB
332 | #define CC_GET_CAL_PAGE 0xEA
333 |
334 | #define CC_GET_PAG_PROCESSOR_INFO 0xE9
335 | #define CC_GET_SEGMENT_INFO 0xE8
336 | #define CC_GET_PAGE_INFO 0xE7
337 | #define CC_SET_SEGMENT_MODE 0xE6
338 | #define CC_GET_SEGMENT_MODE 0xE5
339 | #define CC_COPY_CAL_PAGE 0xE4
340 |
341 |
342 | /*-------------------------------------------------------------------------*/
343 | /* DATA Acquisition and Stimulation Commands (DAQ/STIM) */
344 |
345 | #define CC_CLEAR_DAQ_LIST 0xE3
346 | #define CC_SET_DAQ_PTR 0xE2
347 | #define CC_WRITE_DAQ 0xE1
348 | #define CC_SET_DAQ_LIST_MODE 0xE0
349 | #define CC_GET_DAQ_LIST_MODE 0xDF
350 | #define CC_START_STOP_DAQ_LIST 0xDE
351 | #define CC_START_STOP_SYNCH 0xDD
352 |
353 | #define CC_GET_DAQ_CLOCK 0xDC
354 | #define CC_READ_DAQ 0xDB
355 | #define CC_GET_DAQ_PROCESSOR_INFO 0xDA
356 | #define CC_GET_DAQ_RESOLUTION_INFO 0xD9
357 | #define CC_GET_DAQ_LIST_INFO 0xD8
358 | #define CC_GET_DAQ_EVENT_INFO 0xD7
359 |
360 | #define CC_FREE_DAQ 0xD6
361 | #define CC_ALLOC_DAQ 0xD5
362 | #define CC_ALLOC_ODT 0xD4
363 | #define CC_ALLOC_ODT_ENTRY 0xD3
364 |
365 |
366 | /*-------------------------------------------------------------------------*/
367 | /* Non volatile memory Programming Commands PGM */
368 |
369 | #define CC_PROGRAM_START 0xD2
370 | #define CC_PROGRAM_CLEAR 0xD1
371 | #define CC_PROGRAM 0xD0
372 | #define CC_PROGRAM_RESET 0xCF
373 |
374 | #define CC_GET_PGM_PROCESSOR_INFO 0xCE
375 | #define CC_GET_SECTOR_INFO 0xCD
376 | #define CC_PROGRAM_PREPARE 0xCC
377 | #define CC_PROGRAM_FORMAT 0xCB
378 | #define CC_PROGRAM_NEXT 0xCA
379 | #define CC_PROGRAM_MAX 0xC9
380 | #define CC_PROGRAM_VERIFY 0xC8
381 |
382 |
383 | /*-------------------------------------------------------------------------*/
384 | /* Customer specific commands */
385 |
386 | #define CC_WRITE_DAQ_MULTIPLE 0x81
387 |
388 |
389 | /*-------------------------------------------------------------------------*/
390 | /* Packet Identifiers Slave -> Master */
391 | #define PID_RES 0xFF /* response packet */
392 | #define PID_ERR 0xFE /* error packet */
393 | #define PID_EV 0xFD /* event packet */
394 | #define PID_SERV 0xFC /* service request packet */
395 |
396 |
397 | /*-------------------------------------------------------------------------*/
398 | /* Command Return Codes */
399 |
400 | #define CRC_CMD_SYNCH 0x00
401 |
402 | #define CRC_CMD_BUSY 0x10
403 | #define CRC_DAQ_ACTIVE 0x11
404 | #define CRC_PRM_ACTIVE 0x12
405 |
406 | #define CRC_CMD_UNKNOWN 0x20
407 | #define CRC_CMD_SYNTAX 0x21
408 | #define CRC_OUT_OF_RANGE 0x22
409 | #define CRC_WRITE_PROTECTED 0x23
410 | #define CRC_ACCESS_DENIED 0x24
411 | #define CRC_ACCESS_LOCKED 0x25
412 | #define CRC_PAGE_NOT_VALID 0x26
413 | #define CRC_PAGE_MODE_NOT_VALID 0x27
414 | #define CRC_SEGMENT_NOT_VALID 0x28
415 | #define CRC_SEQUENCE 0x29
416 | #define CRC_DAQ_CONDIF 0x2A
417 |
418 | #define CRC_MEMORY_OVERFLOW 0x30
419 | #define CRC_GENERIC 0x31
420 | #define CRC_VERIFY 0x32
421 |
422 |
423 | /*-------------------------------------------------------------------------*/
424 | /* Event Codes */
425 |
426 | #define EVC_RESUME_MODE 0x00
427 | #define EVC_CLEAR_DAQ 0x01
428 | #define EVC_STORE_DAQ 0x02
429 | #define EVC_STORE_CAL 0x03
430 | #define EVC_CMD_PENDING 0x05
431 | #define EVC_DAQ_OVERLOAD 0x06
432 | #define EVC_SESSION_TERMINATED 0x07
433 | #define EVC_USER 0xFE
434 | #define EVC_TRANSPORT 0xFF
435 |
436 |
437 | /*-------------------------------------------------------------------------*/
438 | /* Service Request Codes */
439 |
440 | #define SERV_RESET 0x00 /* Slave requesting to be reset */
441 | #define SERV_TEXT 0x01 /* Plain ASCII text null terminated */
442 |
443 |
444 |
445 | /***************************************************************************/
446 | /* Definitions */
447 | /***************************************************************************/
448 |
449 | /*-------------------------------------------------------------------------*/
450 | /* ResourceMask (CONNECT) */
451 |
452 | #define RM_CAL_PAG 0x01
453 | #define RM_DAQ 0x04
454 | #define RM_STIM 0x08
455 | #define RM_PGM 0x10
456 |
457 |
458 | /*-------------------------------------------------------------------------*/
459 | /* CommModeBasic (CONNECT) */
460 |
461 | #define PI_MOTOROLA 0x01
462 |
463 | #define CMB_BYTE_ORDER (0x01u<<0)
464 | #define CMB_ADDRESS_GRANULARITY (0x03u<<1)
465 | #define CMB_SLAVE_BLOCK_MODE (0x01u<<6)
466 | #define CMB_OPTIONAL (0x01u<<7)
467 |
468 | #define CMB_ADDRESS_GRANULARITY_BYTE (0<<1)
469 | #define CMB_ADDRESS_GRANULARITY_WORD (1<<1)
470 | #define CMB_ADDRESS_GRANULARITY_DWORD (2<<1)
471 | #define CMB_ADDRESS_GRANULARITY_QWORD (3<<1)
472 |
473 |
474 | /*-------------------------------------------------------------------------*/
475 | /* Protocol Info (GET_COMM_MODE_INFO - COMM_OPTIONAL) */
476 |
477 | #define CMO_MASTER_BLOCK_MODE 0x01
478 | #define CMO_INTERLEAVED_MODE 0x02
479 |
480 |
481 | /*-------------------------------------------------------------------------*/
482 | /* Session Status (GET_STATUS and SET_REQUEST) */
483 |
484 | #define SS_STORE_CAL_REQ 0x0001u
485 | #define SS_BLOCK_UPLOAD 0x0002u /* Internal */
486 | #define SS_STORE_DAQ_REQ 0x0004u
487 | #define SS_CLEAR_DAQ_REQ 0x0008u
488 | #define SS_ERROR 0x0010u /* Internal */
489 | #define SS_CONNECTED 0x0020u /* Internal */
490 | #define SS_DAQ 0x0040u
491 | #define SS_RESUME 0x0080u
492 | #define SS_POLLING 0x0100u /* Internal */
493 |
494 |
495 | /*-------------------------------------------------------------------------*/
496 | /* Identifier Type (GET_ID) */
497 |
498 | #define IDT_ASCII 0
499 | #define IDT_ASAM_NAME 1
500 | #define IDT_ASAM_PATH 2
501 | #define IDT_ASAM_URL 3
502 | #define IDT_ASAM_UPLOAD 4
503 | #define IDT_VECTOR_MAPNAMES 0xDB
504 |
505 | /*-------------------------------------------------------------------------*/
506 | /* Checksum Types (BUILD_CHECKSUM) */
507 |
508 | #define XCP_CHECKSUM_TYPE_ADD11 0x01 /* Add BYTE into a BYTE checksum, ignore overflows */
509 | #define XCP_CHECKSUM_TYPE_ADD12 0x02 /* Add BYTE into a WORD checksum, ignore overflows */
510 | #define XCP_CHECKSUM_TYPE_ADD14 0x03 /* Add BYTE into a DWORD checksum, ignore overflows */
511 | #define XCP_CHECKSUM_TYPE_ADD22 0x04 /* Add WORD into a WORD checksum, ignore overflows, blocksize must be modulo 2 */
512 | #define XCP_CHECKSUM_TYPE_ADD24 0x05 /* Add WORD into a DWORD checksum, ignore overflows, blocksize must be modulo 2 */
513 | #define XCP_CHECKSUM_TYPE_ADD44 0x06 /* Add DWORD into DWORD, ignore overflows, blocksize must be modulo 4 */
514 | #define XCP_CHECKSUM_TYPE_CRC16 0x07 /* See CRC error detection algorithms */
515 | #define XCP_CHECKSUM_TYPE_CRC16CCITT 0x08 /* See CRC error detection algorithms */
516 | #define XCP_CHECKSUM_TYPE_CRC32 0x09 /* See CRC error detection algorithms */
517 | #define XCP_CHECKSUM_TYPE_DLL 0xFF /* User defined, ASAM MCD 2MC DLL Interface */
518 |
519 |
520 | /*-------------------------------------------------------------------------*/
521 | /* Page Mode (SET_CAL_PAGE) */
522 |
523 | #define CAL_ECU 0x01
524 | #define CAL_XCP 0x02
525 | #define CAL_ALL 0x80 /* not supported */
526 |
527 |
528 | /*-------------------------------------------------------------------------*/
529 | /* PAG_PROPERTIES (GET_PAG_PROCESSOR_INFO) */
530 |
531 | #define PAG_PROPERTY_FREEZE 0x01
532 |
533 |
534 | /*-------------------------------------------------------------------------*/
535 | /* PAGE_PROPERTIES (GET_PAGE_INFO)*/
536 |
537 | #define ECU_ACCESS_TYPE 0x03
538 | #define XCP_READ_ACCESS_TYPE 0x0C
539 | #define XCP_WRITE_ACCESS_TYPE 0x30
540 |
541 | /* ECU_ACCESS_TYPE */
542 | #define ECU_ACCESS_NONE (0<<0)
543 | #define ECU_ACCESS_WITHOUT (1<<0)
544 | #define ECU_ACCESS_WITH (2<<0)
545 | #define ECU_ACCESS_DONT_CARE (3<<0)
546 |
547 | /* XCP_READ_ACCESS_TYPE */
548 | #define XCP_READ_ACCESS_NONE (0<<2)
549 | #define XCP_READ_ACCESS_WITHOUT (1<<2)
550 | #define XCP_READ_ACCESS_WITH (2<<2)
551 | #define XCP_READ_ACCESS_DONT_CARE (3<<2)
552 |
553 | /* XCP_WRITE_ACCESS_TYPE */
554 | #define XCP_WRITE_ACCESS_NONE (0<<4)
555 | #define XCP_WRITE_ACCESS_WITHOUT (1<<4)
556 | #define XCP_WRITE_ACCESS_WITH (2<<4)
557 | #define XCP_WRITE_ACCESS_DONT_CARE (3<<4)
558 |
559 |
560 | /*-------------------------------------------------------------------------*/
561 | /* SEGMENT_MODE (GET_SEGMENT_MODE, SET_SEGMENT_MODE) */
562 |
563 | #define SEGMENT_FLAG_FREEZE 0x01 /* */
564 |
565 |
566 | /*-------------------------------------------------------------------------*/
567 | /* DAQ_LIST_MODE (GET_DAQ_LIST_MODE, SET_DAQ_LIST_MODE) */
568 |
569 | #define DAQ_FLAG_SELECTED 0x01u /* */
570 | #define DAQ_FLAG_DIRECTION 0x02u /* Data Stimulation Mode */
571 |
572 | #define DAQ_FLAG_TIMESTAMP 0x10u /* Timestamps */
573 | #define DAQ_FLAG_NO_PID 0x20u /* No PID */
574 | #define DAQ_FLAG_RUNNING 0x40u /* Is started */
575 | #define DAQ_FLAG_RESUME 0x80u /* Resume Mode */
576 |
577 | #define DAQ_FLAG_RESERVED 0x08u
578 | #define DAQ_FLAG_OVERRUN 0x08u /* Overun (Internal Use) */
579 |
580 |
581 | /*-------------------------------------------------------------------------*/
582 | /* GET_DAQ_PROCESSOR_INFO */
583 |
584 | /* DAQ_PROPERTIES */
585 | #define DAQ_PROPERTY_CONFIG_TYPE 0x01
586 | #define DAQ_PROPERTY_PRESCALER 0x02
587 | #define DAQ_PROPERTY_RESUME 0x04
588 | #define DAQ_PROPERTY_BIT_STIM 0x08
589 | #define DAQ_PROPERTY_TIMESTAMP 0x10
590 | #define DAQ_PROPERTY_NO_PID 0x20
591 | #define DAQ_PROPERTY_OVERLOAD_INDICATION 0xC0
592 |
593 | /* DAQ Overload Indication Type */
594 | #define DAQ_OVERLOAD_INDICATION_NONE (0<<6)
595 | #define DAQ_OVERLOAD_INDICATION_PID (1<<6)
596 | #define DAQ_OVERLOAD_INDICATION_EVENT (2<<6)
597 |
598 | /* DAQ_KEY_BYTE */
599 | #define DAQ_OPT_TYPE 0x0F
600 | #define DAQ_EXT_TYPE 0x30
601 | #define DAQ_HDR_TYPE 0xC0
602 |
603 | /* DAQ Optimisation Type */
604 | #define DAQ_OPT_DEFAULT (0<<0)
605 | #define DAQ_OPT_ODT_16 (1<<0)
606 | #define DAQ_OPT_ODT_32 (2<<0)
607 | #define DAQ_OPT_ODT_64 (3<<0)
608 | #define DAQ_OPT_ALIGNMENT (4<<0)
609 | #define DAQ_OPT_MAX_ENTRY_SIZE (5<<0)
610 |
611 | /* DAQ Address Extension Scope */
612 | #define DAQ_EXT_FREE (0<<4)
613 | #define DAQ_EXT_ODT (1<<4)
614 | #define DAQ_EXT_DAQ (3<<4)
615 |
616 | /* DAQ Identification Field Type */
617 | #define DAQ_HDR_PID (0<<6)
618 | #define DAQ_HDR_ODT_DAQB (1<<6)
619 | #define DAQ_HDR_ODT_DAQW (2<<6)
620 | #define DAQ_HDR_ODT_FIL_DAQW (3<<6)
621 |
622 |
623 | /*-------------------------------------------------------------------------*/
624 | /* GET_DAQ_RESOLUTION_INFO */
625 |
626 | /* TIMESTAMP_MODE */
627 | #define DAQ_TIMESTAMP_SIZE 0x07
628 | #define DAQ_TIMESTAMP_FIXED 0x08
629 | #define DAQ_TIMESTAMP_UNIT 0xF0
630 |
631 | /* DAQ Timestamp Size */
632 | #define DAQ_TIMESTAMP_OFF (0<<0)
633 | #define DAQ_TIMESTAMP_BYTE (1<<0)
634 | #define DAQ_TIMESTAMP_WORD (2<<0)
635 | #define DAQ_TIMESTAMP_DWORD (4<<0)
636 |
637 | /* DAQ Timestamp Unit */
638 | #define DAQ_TIMESTAMP_UNIT_1NS (0<<4)
639 | #define DAQ_TIMESTAMP_UNIT_10NS (1<<4)
640 | #define DAQ_TIMESTAMP_UNIT_100NS (2<<4)
641 | #define DAQ_TIMESTAMP_UNIT_1US (3<<4)
642 | #define DAQ_TIMESTAMP_UNIT_10US (4<<4)
643 | #define DAQ_TIMESTAMP_UNIT_100US (5<<4)
644 | #define DAQ_TIMESTAMP_UNIT_1MS (6<<4)
645 | #define DAQ_TIMESTAMP_UNIT_10MS (7<<4)
646 | #define DAQ_TIMESTAMP_UNIT_100MS (8<<4)
647 | #define DAQ_TIMESTAMP_UNIT_1S (9<<4)
648 |
649 |
650 | /*-------------------------------------------------------------------------*/
651 | /* DAQ_LIST_PROPERTIES (GET_DAQ_LIST_INFO) */
652 |
653 | #define DAQ_LIST_PREDEFINED 0x01
654 | #define DAQ_LIST_FIXED_EVENT 0x02
655 | #define DAQ_LIST_DIR_DAQ 0x04
656 | #define DAQ_LIST_DIR_STIM 0x08
657 |
658 |
659 | /*-------------------------------------------------------------------------*/
660 | /* EVENT_PROPERTY (GET_DAQ_EVENT_INFO) */
661 |
662 | #define DAQ_EVENT_DIRECTION_DAQ 0x04
663 | #define DAQ_EVENT_DIRECTION_STIM 0x08
664 | #define DAQ_EVENT_DIRECTION_DAQ_STIM 0x0C
665 |
666 |
667 | /*-------------------------------------------------------------------------*/
668 | /* Comm mode programming parameter (PROGRAM_START) */
669 |
670 | #define PI_PGM_BLOCK_DOWNLOAD 0x01
671 | #define PI_PGM_BLOCK_UPLOAD 0x40
672 |
673 |
674 | /*-------------------------------------------------------------------------*/
675 | /* PGM_PROPERTIES (GET_PGM_PROCESSOR_INFO) */
676 |
677 | #define PGM_ACCESS_TYPE 0x03
678 | #define PGM_COMPRESSION_TYPE 0x0C
679 | #define PGM_ENCRYPTION_TYPE 0x30
680 | #define PGM_NON_SEQ_TYPE 0xC0
681 |
682 | /* PGM Access Mode */
683 | #define PGM_ACCESS_ABSOLUTE (1<<0)
684 | #define PGM_ACCESS_FUNCTIONAL (2<<0)
685 | #define PGM_ACCESS_FREE (3<<0)
686 |
687 | /* PGM Compression type */
688 | #define PGM_COMPRESSION_NONE (0<<2)
689 | #define PGM_COMPRESSION_SUPPORTED (1<<2)
690 | #define PGM_COMPRESSION_REQUIRED (3<<2)
691 |
692 | /* PGM Encryption type */
693 | #define PGM_ENCRYPTION_NONE (0<<4)
694 | #define PGM_ENCRYPTION_SUPPORTED (1<<4)
695 | #define PGM_ENCRYPTION_REQUIRED (3<<4)
696 |
697 | /* PGM non sequential programming type */
698 | #define PGM_NON_SEQ_NONE (0<<6)
699 | #define PGM_NON_SEQ_SUPPORTED (1<<6)
700 | #define PGM_NON_SEQ_REQUIRED (3<<6)
701 |
702 | /* Compatibility defines */
703 |
704 | #if defined ( XCP_TRANSPORT_LAYER_TYPE_CAN )
705 | #define kXcpMaxCTO kCanXcpMaxCTO
706 | #define kXcpMaxDTO kCanXcpMaxDTO
707 | #endif
708 |
709 |
710 | /***************************************************************************/
711 | /* XCP Commands and Responces, Type Definition */
712 | /***************************************************************************/
713 |
714 | /* Protocol command structure definition */
715 | #define CRO_CMD CRO_BYTE(0)
716 | #define CRM_CMD CRM_BYTE(0)
717 | #define CRM_ERR CRM_BYTE(1)
718 | /* CONNECT */
719 |
720 | #define CRO_CONNECT_LEN 2
721 | #define CRO_CONNECT_MODE CRO_BYTE(1)
722 | #define CRM_CONNECT_LEN 8
723 | #define CRM_CONNECT_RESOURCE CRM_BYTE(1)
724 | #define CRM_CONNECT_COMM_BASIC CRM_BYTE(2)
725 | #define CRM_CONNECT_MAX_CTO_SIZE CRM_BYTE(3)
726 | #define CRM_CONNECT_MAX_DTO_SIZE CRM_WORD(2)
727 | #define CRM_CONNECT_MAX_DTO_SIZE_WRITE(size) CRM_WORD_WRITE(2, size)
728 | #define CRM_CONNECT_PROTOCOL_VERSION CRM_BYTE(6)
729 | #define CRM_CONNECT_TRANSPORT_VERSION CRM_BYTE(7)
730 |
731 |
732 | /* DISCONNECT */
733 |
734 | #define CRO_DISCONNECT_LEN 1
735 | #define CRM_DISCONNECT_LEN 1
736 |
737 |
738 | /* GET_STATUS */
739 |
740 | #define CRO_GET_STATUS_LEN 1
741 |
742 | #define CRM_GET_STATUS_LEN 6
743 | #define CRM_GET_STATUS_STATUS CRM_BYTE(1)
744 | #define CRM_GET_STATUS_PROTECTION CRM_BYTE(2)
745 | #define CRM_GET_STATUS_CONFIG_ID CRM_WORD(2)
746 | #define CRM_GET_STATUS_CONFIG_ID_WRITE(id) CRM_WORD_WRITE(2, id)
747 |
748 |
749 | /* SYNCH */
750 |
751 | #define CRO_SYNCH_LEN 1
752 |
753 | #define CRM_SYNCH_LEN 2
754 | #define CRM_SYNCH_RESULT CRM_BYTE(1)
755 |
756 |
757 | /* GET_COMM_MODE_INFO */
758 |
759 | #define CRO_GET_COMM_MODE_INFO_LEN 1
760 |
761 | #define CRM_GET_COMM_MODE_INFO_LEN 8
762 | #define CRM_GET_COMM_MODE_INFO_COMM_OPTIONAL CRM_BYTE(2)
763 | #define CRM_GET_COMM_MODE_INFO_MAX_BS CRM_BYTE(4)
764 | #define CRM_GET_COMM_MODE_INFO_MIN_ST CRM_BYTE(5)
765 | #define CRM_GET_COMM_MODE_INFO_QUEUE_SIZE CRM_BYTE(6)
766 | #define CRM_GET_COMM_MODE_INFO_DRIVER_VERSION CRM_BYTE(7)
767 |
768 |
769 | /* GET_ID */
770 |
771 | #define CRO_GET_ID_LEN 2
772 | #define CRO_GET_ID_TYPE CRO_BYTE(1)
773 |
774 | #define CRM_GET_ID_LEN 8
775 | #define CRM_GET_ID_MODE CRM_BYTE(1)
776 | #define CRM_GET_ID_LENGTH CRM_DWORD(1)
777 | #define CRM_GET_ID_LENGTH_WRITE(len) CRM_DWORD_WRITE(1, len)
778 | #define CRM_GET_ID_DATA (&CRM_BYTE(8))
779 |
780 | /* SET_REQUEST */
781 |
782 | #define CRO_SET_REQUEST_LEN 4
783 | #define CRO_SET_REQUEST_MODE CRO_BYTE(1)
784 | #define CRO_SET_REQUEST_CONFIG_ID CRO_WORD(1)
785 |
786 | #define CRM_SET_REQUEST_LEN 1
787 |
788 |
789 | /* GET_SEED */
790 |
791 | #define CRO_GET_SEED_LEN 3
792 | #define CRO_GET_SEED_MODE CRO_BYTE(1)
793 | #define CRO_GET_SEED_RESOURCE CRO_BYTE(2)
794 |
795 | #define CRM_GET_SEED_LEN (CRM_GET_SEED_LENGTH+2u)
796 | #define CRM_GET_SEED_LENGTH CRM_BYTE(1)
797 | #define CRM_GET_SEED_DATA (&CRM_BYTE(2))
798 |
799 |
800 | /* UNLOCK */
801 |
802 | #define CRO_UNLOCK_LEN 8
803 | #define CRO_UNLOCK_LENGTH CRO_BYTE(1)
804 | #define CRO_UNLOCK_KEY (&CRO_BYTE(2))
805 |
806 | #define CRM_UNLOCK_LEN 2
807 | #define CRM_UNLOCK_PROTECTION CRM_BYTE(1)
808 |
809 |
810 | /* SET_MTA */
811 |
812 | #define CRO_SET_MTA_LEN 8
813 | #define CRO_SET_MTA_EXT CRO_BYTE(3)
814 | #define CRO_SET_MTA_ADDR CRO_DWORD(1)
815 |
816 | #define CRM_SET_MTA_LEN 1
817 |
818 |
819 | /* UPLOAD */
820 |
821 | #define CRM_UPLOAD_MAX_SIZE ((vuint8)(kXcpMaxCTO-1))
822 | #define CRO_UPLOAD_LEN 2
823 | #define CRO_UPLOAD_SIZE CRO_BYTE(1)
824 |
825 | #define CRM_UPLOAD_LEN 1 /* +CRO_UPLOAD_SIZE */
826 | #define CRM_UPLOAD_DATA (&CRM_BYTE(1))
827 |
828 |
829 | /* SHORT_UPLOAD */
830 |
831 | #define CRO_SHORT_UPLOAD_LEN 8
832 | #define CRO_SHORT_UPLOAD_SIZE CRO_BYTE(1)
833 | #define CRO_SHORT_UPLOAD_EXT CRO_BYTE(3)
834 | #define CRO_SHORT_UPLOAD_ADDR CRO_DWORD(1)
835 |
836 | #define CRM_SHORT_UPLOAD_MAX_SIZE ((vuint8)(kXcpMaxCTO-1))
837 |
838 | #define CRM_SHORT_UPLOAD_LEN 1 /* +CRO_SHORT_UPLOAD_SIZE */
839 | #define CRM_SHORT_UPLOAD_DATA (&CRM_BYTE(1))
840 |
841 |
842 | /* BUILD_CHECKSUM */
843 |
844 | #define CRO_BUILD_CHECKSUM_LEN 8
845 | #define CRO_BUILD_CHECKSUM_SIZE CRO_DWORD(1)
846 |
847 | #define CRM_BUILD_CHECKSUM_LEN 8
848 | #define CRM_BUILD_CHECKSUM_TYPE CRM_BYTE(1)
849 | #define CRM_BUILD_CHECKSUM_RESULT CRM_DWORD(1)
850 | #define CRM_BUILD_CHECKSUM_RESULT_WRITE(result) CRM_DWORD_WRITE(1, result)
851 |
852 |
853 | /* DOWNLOAD */
854 |
855 | #define CRO_DOWNLOAD_MAX_SIZE ((vuint8)(kXcpMaxCTO-2))
856 |
857 | #define CRO_DOWNLOAD_LEN 2 /* + CRO_DOWNLOAD_SIZE */
858 | #define CRO_DOWNLOAD_SIZE CRO_BYTE(1)
859 | #define CRO_DOWNLOAD_DATA (&CRO_BYTE(2))
860 |
861 | #define CRM_DOWNLOAD_LEN 1
862 |
863 |
864 | /* DOWNLOAD_NEXT */
865 |
866 | #define CRO_DOWNLOAD_NEXT_MAX_SIZE ((vuint8)(kXcpMaxCTO-2))
867 |
868 | #define CRO_DOWNLOAD_NEXT_LEN 2 /* + size */
869 | #define CRO_DOWNLOAD_NEXT_SIZE CRO_BYTE(1)
870 | #define CRO_DOWNLOAD_NEXT_DATA (&CRO_BYTE(2))
871 |
872 | #define CRM_DOWNLOAD_NEXT_LEN 1
873 |
874 |
875 | /* DOWNLOAD_MAX */
876 |
877 | #define CRO_DOWNLOAD_MAX_MAX_SIZE ((vuint8)(kXcpMaxCTO-1))
878 | #define CRO_DOWNLOAD_MAX_DATA (&CRO_BYTE(1))
879 |
880 | #define CRM_DOWNLOAD_MAX_LEN 1
881 |
882 |
883 | /* SHORT_DOWNLOAD */
884 |
885 | #define CRO_SHORT_DOWNLOAD_LEN 8
886 | #define CRO_SHORT_DOWNLOAD_SIZE CRO_BYTE(1)
887 | #define CRO_SHORT_DOWNLOAD_EXT CRO_BYTE(3)
888 | #define CRO_SHORT_DOWNLOAD_ADDR CRO_DWORD(1)
889 | #define CRO_SHORT_DOWNLOAD_DATA (&CRO_BYTE(8))
890 |
891 | #define CRM_SHORT_DOWNLOAD_MAX_SIZE ((vuint8)(kXcpMaxCTO-8))
892 | #define CRM_SHORT_DOWNLOAD_LEN 1 /* +CRO_SHORT_UPLOAD_SIZE */
893 |
894 |
895 | /* MODIFY_BITS */
896 |
897 | #define CRO_MODIFY_BITS_LEN 6
898 | #define CRO_MODIFY_BITS_SHIFT CRO_BYTE(1)
899 | #define CRO_MODIFY_BITS_AND CRO_WORD(1)
900 | #define CRO_MODIFY_BITS_XOR CRO_WORD(2)
901 |
902 | #define CRM_MODIFY_BITS_LEN 1
903 |
904 |
905 | /* SET_CAL_PAGE */
906 |
907 | #define CRO_SET_CAL_PAGE_LEN 4
908 | #define CRO_SET_CAL_PAGE_MODE CRO_BYTE(1)
909 | #define CRO_SET_CAL_PAGE_SEGMENT CRO_BYTE(2)
910 | #define CRO_SET_CAL_PAGE_PAGE CRO_BYTE(3)
911 |
912 | #define CRM_SET_CAL_PAGE_LEN 1
913 |
914 |
915 | /* GET_CAL_PAGE */
916 |
917 | #define CRO_GET_CAL_PAGE_LEN 3
918 | #define CRO_GET_CAL_PAGE_MODE CRO_BYTE(1)
919 | #define CRO_GET_CAL_PAGE_SEGMENT CRO_BYTE(2)
920 |
921 | #define CRM_GET_CAL_PAGE_LEN 4
922 | #define CRM_GET_CAL_PAGE_PAGE CRM_BYTE(3)
923 |
924 |
925 | /* GET_PAG_PROCESSOR_INFO */
926 |
927 | #define CRO_GET_PAG_PROCESSOR_INFO_LEN 1
928 |
929 | #define CRM_GET_PAG_PROCESSOR_INFO_LEN 3
930 | #define CRM_GET_PAG_PROCESSOR_INFO_MAX_SEGMENT CRM_BYTE(1)
931 | #define CRM_GET_PAG_PROCESSOR_INFO_PROPERTIES CRM_BYTE(2)
932 |
933 |
934 | /* GET_SEGMENT_INFO */
935 |
936 | #define CRO_GET_SEGMENT_INFO_LEN 5
937 | #define CRO_GET_SEGMENT_INFO_MODE CRO_BYTE(1)
938 | #define CRO_GET_SEGMENT_INFO_NUMBER CRO_BYTE(2)
939 | #define CRO_GET_SEGMENT_INFO_MAPPING_INDEX CRO_BYTE(3)
940 | #define CRO_GET_SEGMENT_INFO_MAPPING CRO_BYTE(4)
941 |
942 | #define CRM_GET_SEGMENT_INFO_LEN 8
943 | #define CRM_GET_SEGMENT_INFO_MAX_PAGES CRM_BYTE(1)
944 | #define CRM_GET_SEGMENT_INFO_ADDRESS_EXTENSION CRM_BYTE(2)
945 | #define CRM_GET_SEGMENT_INFO_MAX_MAPPING CRM_BYTE(3)
946 | #define CRM_GET_SEGMENT_INFO_COMPRESSION CRM_BYTE(4)
947 | #define CRM_GET_SEGMENT_INFO_ENCRYPTION CRM_BYTE(5)
948 | #define CRM_GET_SEGMENT_INFO_MAPPING_INFO CRM_DWORD(1)
949 |
950 |
951 | /* GET_PAGE_INFO */
952 |
953 | #define CRO_GET_PAGE_INFO_LEN 4
954 | #define CRO_GET_PAGE_INFO_SEGMENT_NUMBER CRO_BYTE(2)
955 | #define CRO_GET_PAGE_INFO_PAGE_NUMBER CRO_BYTE(3)
956 |
957 | #define CRM_GET_PAGE_INFO_LEN 3
958 | #define CRM_GET_PAGE_INFO_PROPERTIES CRM_BYTE(1)
959 | #define CRM_GET_PAGE_INFO_INIT_SEGMENT CRM_BYTE(2)
960 |
961 |
962 | /* SET_SEGMENT_MODE */
963 |
964 | #define CRO_SET_SEGMENT_MODE_LEN 3
965 | #define CRO_SET_SEGMENT_MODE_MODE CRO_BYTE(1)
966 | #define CRO_SET_SEGMENT_MODE_SEGMENT CRO_BYTE(2)
967 |
968 | #define CRM_SET_SEGMENT_MODE_LEN 1
969 |
970 |
971 | /* GET_SEGMENT_MODE */
972 |
973 | #define CRO_GET_SEGMENT_MODE_LEN 3
974 | #define CRO_GET_SEGMENT_MODE_SEGMENT CRO_BYTE(2)
975 |
976 | #define CRM_GET_SEGMENT_MODE_LEN 3
977 | #define CRM_GET_SEGMENT_MODE_MODE CRM_BYTE(2)
978 |
979 |
980 | /* COPY_CAL_PAGE */
981 |
982 | #define CRO_COPY_CAL_PAGE_LEN 5
983 | #define CRO_COPY_CAL_PAGE_SRC_SEGMENT CRO_BYTE(1)
984 | #define CRO_COPY_CAL_PAGE_SRC_PAGE CRO_BYTE(2)
985 | #define CRO_COPY_CAL_PAGE_DEST_SEGMENT CRO_BYTE(3)
986 | #define CRO_COPY_CAL_PAGE_DEST_PAGE CRO_BYTE(4)
987 |
988 | #define CRM_COPY_CAL_PAGE_LEN 1
989 |
990 |
991 | /* CLEAR_DAQ_LIST */
992 |
993 | #define CRO_CLEAR_DAQ_LIST_LEN 4
994 | #define CRO_CLEAR_DAQ_LIST_DAQ CRO_WORD(1)
995 |
996 | #define CRM_CLEAR_DAQ_LIST_LEN 1
997 |
998 |
999 | /* SET_DAQ_PTR */
1000 |
1001 | #define CRO_SET_DAQ_PTR_LEN 6
1002 | #define CRO_SET_DAQ_PTR_DAQ CRO_WORD(1)
1003 | #define CRO_SET_DAQ_PTR_ODT CRO_BYTE(4)
1004 | #define CRO_SET_DAQ_PTR_IDX CRO_BYTE(5)
1005 |
1006 | #define CRM_SET_DAQ_PTR_LEN 1
1007 |
1008 |
1009 | /* WRITE_DAQ */
1010 |
1011 | #define CRO_WRITE_DAQ_LEN 8
1012 | #define CRO_WRITE_DAQ_BITOFFSET CRO_BYTE(1)
1013 | #define CRO_WRITE_DAQ_SIZE CRO_BYTE(2)
1014 | #define CRO_WRITE_DAQ_EXT CRO_BYTE(3)
1015 | #define CRO_WRITE_DAQ_ADDR CRO_DWORD(1)
1016 |
1017 | #define CRM_WRITE_DAQ_LEN 1
1018 |
1019 |
1020 | /* WRITE_DAQ_MULTIPLE */
1021 | #define CRO_WRITE_DAQ_MULTIPLE_LEN 8
1022 | #define CRO_WRITE_DAQ_MULTIPLE_COMMAND CRO_BYTE(1)
1023 | #define CRO_WRITE_DAQ_MULTIPLE_NODAQ CRO_BYTE(2)
1024 | #define CRO_WRITE_DAQ_MULTIPLE_BITOFFSET(i) CRO_BYTE(8 + (8*(i)))
1025 | #define CRO_WRITE_DAQ_MULTIPLE_SIZE(i) CRO_BYTE(9 + (8*(i)))
1026 | #define CRO_WRITE_DAQ_MULTIPLE_EXT(i) CRO_BYTE(10 + (8*(i)))
1027 | #define CRO_WRITE_DAQ_MULTIPLE_ADDR(i) CRO_DWORD(1 + (2*(i)))
1028 |
1029 | #define CRM_WRITE_DAQ_MULTIPLE_LEN 1
1030 |
1031 |
1032 | /* SET_DAQ_LIST_MODE */
1033 |
1034 | #define CRO_SET_DAQ_LIST_MODE_LEN 8
1035 | #define CRO_SET_DAQ_LIST_MODE_MODE CRO_BYTE(1)
1036 | #define CRO_SET_DAQ_LIST_MODE_DAQ CRO_WORD(1)
1037 | #define CRO_SET_DAQ_LIST_MODE_EVENTCHANNEL CRO_WORD(2)
1038 | #define CRO_SET_DAQ_LIST_MODE_PRESCALER CRO_BYTE(6)
1039 | #define CRO_SET_DAQ_LIST_MODE_PRIORITY CRO_BYTE(7)
1040 |
1041 | #define CRM_SET_DAQ_LIST_MODE_LEN 6
1042 |
1043 |
1044 | /* GET_DAQ_LIST_MODE */
1045 |
1046 | #define CRO_GET_DAQ_LIST_MODE_LEN 4
1047 | #define CRO_GET_DAQ_LIST_MODE_DAQ CRO_WORD(1)
1048 |
1049 | #define CRM_GET_DAQ_LIST_MODE_LEN 8
1050 | #define CRM_GET_DAQ_LIST_MODE_MODE CRM_BYTE(1)
1051 | #define CRM_GET_DAQ_LIST_MODE_EVENTCHANNEL CRM_WORD(2)
1052 | #define CRM_GET_DAQ_LIST_MODE_EVENTCHANNEL_WRITE(ch) CRM_WORD_WRITE(2, ch)
1053 | #define CRM_GET_DAQ_LIST_MODE_PRESCALER CRM_BYTE(6)
1054 | #define CRM_GET_DAQ_LIST_MODE_PRIORITY CRM_BYTE(7)
1055 |
1056 |
1057 | /* START_STOP_DAQ_LIST */
1058 |
1059 | #define CRO_START_STOP_LEN 4
1060 | #define CRO_START_STOP_MODE CRO_BYTE(1)
1061 | #define CRO_START_STOP_DAQ CRO_WORD(1)
1062 |
1063 | #define CRM_START_STOP_LEN 2
1064 | #define CRM_START_STOP_FIRST_PID CRM_BYTE(1)
1065 |
1066 |
1067 | /* START_STOP_SYNCH */
1068 |
1069 | #define CRO_START_STOP_SYNC_LEN 2
1070 | #define CRO_START_STOP_SYNC_MODE CRO_BYTE(1)
1071 |
1072 | #define CRM_START_STOP_SYNC_LEN 1
1073 |
1074 |
1075 | /* GET_DAQ_CLOCK */
1076 |
1077 | #define CRO_GET_DAQ_CLOCK_LEN 1
1078 |
1079 | #define CRM_GET_DAQ_CLOCK_LEN 8
1080 | #define CRM_GET_DAQ_CLOCK_TIME CRM_DWORD(1)
1081 | #define CRM_GET_DAQ_CLOCK_TIME_WRITE(time) CRM_DWORD_WRITE(1, time)
1082 |
1083 |
1084 | /* READ_DAQ */
1085 |
1086 | #define CRO_READ_DAQ_LEN 1
1087 |
1088 | #define CRM_READ_DAQ_LEN 8
1089 | #define CRM_READ_DAQ_BITOFFSET CRM_BYTE(1)
1090 | #define CRM_READ_DAQ_SIZE CRM_BYTE(2)
1091 | #define CRM_READ_DAQ_EXT CRM_BYTE(3)
1092 | #define CRM_READ_DAQ_ADDR CRM_DWORD(1)
1093 |
1094 |
1095 | /* GET_DAQ_PROCESSOR_INFO */
1096 |
1097 | #define CRO_GET_DAQ_PROCESSOR_INFO_LEN 1
1098 |
1099 | #define CRM_GET_DAQ_PROCESSOR_INFO_LEN 8
1100 | #define CRM_GET_DAQ_PROCESSOR_INFO_PROPERTIES CRM_BYTE(1)
1101 | #define CRM_GET_DAQ_PROCESSOR_INFO_MAX_DAQ CRM_WORD(1)
1102 | #define CRM_GET_DAQ_PROCESSOR_INFO_MAX_DAQ_WRITE(ndaq) CRM_WORD_WRITE(1, ndaq)
1103 | #define CRM_GET_DAQ_PROCESSOR_INFO_MAX_EVENT CRM_WORD(2)
1104 | #define CRM_GET_DAQ_PROCESSOR_INFO_MAX_EVENT_WRITE(evt) CRM_WORD_WRITE(2, evt)
1105 | #define CRM_GET_DAQ_PROCESSOR_INFO_MIN_DAQ CRM_BYTE(6)
1106 | #define CRM_GET_DAQ_PROCESSOR_INFO_DAQ_KEY_BYTE CRM_BYTE(7)
1107 |
1108 |
1109 | /* GET_DAQ_RESOLUTION_INFO */
1110 |
1111 | #define CRO_GET_DAQ_RESOLUTION_INFO_LEN 1
1112 |
1113 | #define CRM_GET_DAQ_RESOLUTION_INFO_LEN 8
1114 | #define CRM_GET_DAQ_RESOLUTION_INFO_GRANULARITY_DAQ CRM_BYTE(1)
1115 | #define CRM_GET_DAQ_RESOLUTION_INFO_MAX_SIZE_DAQ CRM_BYTE(2)
1116 | #define CRM_GET_DAQ_RESOLUTION_INFO_GRANULARITY_STIM CRM_BYTE(3)
1117 | #define CRM_GET_DAQ_RESOLUTION_INFO_MAX_SIZE_STIM CRM_BYTE(4)
1118 | #define CRM_GET_DAQ_RESOLUTION_INFO_TIMESTAMP_MODE CRM_BYTE(5)
1119 | #define CRM_GET_DAQ_RESOLUTION_INFO_TIMESTAMP_TICKS CRM_WORD(3)
1120 | #define CRM_GET_DAQ_RESOLUTION_INFO_TIMESTAMP_TICKS_WRITE(ticks) CRM_WORD_WRITE(3, ticks)
1121 |
1122 |
1123 | /* GET_DAQ_LIST_INFO */
1124 |
1125 | #define CRO_GET_DAQ_LIST_INFO_LEN 4
1126 | #define CRO_GET_DAQ_LIST_INFO_DAQ CRO_WORD(1)
1127 |
1128 | #define CRM_GET_DAQ_LIST_INFO_LEN 6
1129 | #define CRM_GET_DAQ_LIST_INFO_PROPERTIES CRM_BYTE(1)
1130 | #define CRM_GET_DAQ_LIST_INFO_MAX_ODT CRM_BYTE(2)
1131 | #define CRM_GET_DAQ_LIST_INFO_MAX_ODT_ENTRY CRM_BYTE(3)
1132 | #define CRM_GET_DAQ_LIST_INFO_FIXED_EVENT CRM_WORD(2)
1133 |
1134 |
1135 | /* GET_DAQ_EVENT_INFO */
1136 |
1137 | #define CRO_GET_DAQ_EVENT_INFO_LEN 4
1138 | #define CRO_GET_DAQ_EVENT_INFO_EVENT CRO_WORD(1)
1139 |
1140 | #define CRM_GET_DAQ_EVENT_INFO_LEN 7
1141 | #define CRM_GET_DAQ_EVENT_INFO_PROPERTIES CRM_BYTE(1)
1142 | #define CRM_GET_DAQ_EVENT_INFO_MAX_DAQ_LIST CRM_BYTE(2)
1143 | #define CRM_GET_DAQ_EVENT_INFO_NAME_LENGTH CRM_BYTE(3)
1144 | #define CRM_GET_DAQ_EVENT_INFO_TIME_CYCLE CRM_BYTE(4)
1145 | #define CRM_GET_DAQ_EVENT_INFO_TIME_UNIT CRM_BYTE(5)
1146 | #define CRM_GET_DAQ_EVENT_INFO_PRIORITY CRM_BYTE(6)
1147 |
1148 |
1149 | /* FREE_DAQ */
1150 |
1151 | #define CRO_FREE_DAQ_LEN 1
1152 |
1153 | #define CRM_FREE_DAQ_LEN 1
1154 |
1155 |
1156 | /* ALLOC_DAQ */
1157 |
1158 | #define CRO_ALLOC_DAQ_LEN 4
1159 | #define CRO_ALLOC_DAQ_COUNT CRO_WORD(1)
1160 |
1161 | #define CRM_ALLOC_DAQ_LEN 1
1162 |
1163 |
1164 | /* ALLOC_ODT */
1165 |
1166 | #define _CRO_ALLOC_ODT_LEN 3
1167 | #define _CRO_ALLOC_ODT_DAQ CRO_WORD(1)
1168 | #define _CRO_ALLOC_ODT_COUNT CRO_BYTE(1)
1169 |
1170 | #define CRO_ALLOC_ODT_LEN 5
1171 | #define CRO_ALLOC_ODT_DAQ CRO_WORD(1)
1172 | #define CRO_ALLOC_ODT_COUNT CRO_BYTE(4)
1173 |
1174 | #define CRM_ALLOC_ODT_LEN 1
1175 |
1176 |
1177 | /* ALLOC_ODT_ENTRY */
1178 |
1179 | #define CRO_ALLOC_ODT_ENTRY_LEN 6
1180 | #define CRO_ALLOC_ODT_ENTRY_DAQ CRO_WORD(1)
1181 | #define CRO_ALLOC_ODT_ENTRY_ODT CRO_BYTE(4)
1182 | #define CRO_ALLOC_ODT_ENTRY_COUNT CRO_BYTE(5)
1183 |
1184 | #define CRM_ALLOC_ODT_ENTRY_LEN 1
1185 |
1186 |
1187 | /* PROGRAM_START */
1188 |
1189 | #define CRO_PROGRAM_START_LEN 1
1190 |
1191 | #define CRM_PROGRAM_START_LEN 7
1192 | #define CRM_PROGRAM_COMM_MODE_PGM CRM_BYTE(2)
1193 | #define CRM_PROGRAM_MAX_CTO_PGM CRM_BYTE(3)
1194 | #define CRM_PROGRAM_MAX_BS_PGM CRM_BYTE(4)
1195 | #define CRM_PROGRAM_MIN_ST_PGM CRM_BYTE(5)
1196 | #define CRM_PROGRAM_QUEUE_SIZE_PGM CRM_BYTE(6)
1197 |
1198 |
1199 | /* PROGRAM_CLEAR */
1200 |
1201 | #define CRO_PROGRAM_CLEAR_LEN 8
1202 | #define CRO_PROGRAM_CLEAR_MODE CRO_BYTE(1)
1203 | #define CRO_PROGRAM_CLEAR_SIZE CRO_DWORD(1)
1204 |
1205 | #define CRM_PROGRAM_CLEAR_LEN 1
1206 |
1207 |
1208 | /* PROGRAM */
1209 |
1210 | #define CRO_PROGRAM_MAX_SIZE ((vuint8)(kXcpMaxCTO-2))
1211 |
1212 | #define CRO_PROGRAM_LEN 2 /* + CRO_PROGRAM_SIZE */
1213 | #define CRO_PROGRAM_SIZE CRO_BYTE(1)
1214 | #define CRO_PROGRAM_DATA (&CRO_BYTE(2))
1215 |
1216 | #define CRM_PROGRAM_LEN 1
1217 |
1218 |
1219 | /* PROGRAM RESET */
1220 |
1221 | #define CRO_PROGRAM_RESET_LEN 1
1222 |
1223 | #define CRM_PROGRAM_RESET_LEN 1
1224 |
1225 |
1226 | /*GET_PGM_PROCESSOR_INFO*/
1227 |
1228 | #define CRO_GET_PGM_PROCESSOR_INFO_LEN 1
1229 |
1230 | #define CRM_GET_PGM_PROCESSOR_INFO_LEN 3
1231 | #define CRM_GET_PGM_PROCESSOR_INFO_PROPERTIES CRM_BYTE(1)
1232 | #define CRM_GET_PGM_PROCESSOR_INFO_MAX_SECTOR CRM_BYTE(2)
1233 |
1234 |
1235 | /* GET_SECTOR_INFO */
1236 |
1237 | #define CRO_PROGRAM_GET_SECTOR_INFO_LEN 3
1238 | #define CRO_PROGRAM_GET_SECTOR_INFO_MODE CRO_BYTE(1)
1239 | #define CRO_PROGRAM_GET_SECTOR_INFO_NUMBER CRO_BYTE(2)
1240 |
1241 | #define CRM_PROGRAM_GET_SECTOR_INFO_LEN 8
1242 | #define CRM_PROGRAM_GET_SECTOR_CLEAR_SEQ_NUM CRM_BYTE(1)
1243 | #define CRM_PROGRAM_GET_SECTOR_PGM_SEQ_NUM CRM_BYTE(2)
1244 | #define CRM_PROGRAM_GET_SECTOR_PGM_METHOD CRM_BYTE(3)
1245 | #define CRM_PROGRAM_GET_SECTOR_SECTOR_INFO CRM_DWORD(1)
1246 | #define CRM_PROGRAM_GET_SECTOR_SECTOR_INFO_WRITE(info) CRM_DWORD_WRITE(1, info)
1247 |
1248 |
1249 | /* PROGRAM_PREPARE */
1250 |
1251 | #define CRO_PROGRAM_PREPARE_LEN 4
1252 | #define CRO_PROGRAM_PREPARE_SIZE CRO_WORD(1)
1253 |
1254 | #define CRM_PROGRAM_PREPARE_LEN 1
1255 |
1256 |
1257 | /* PROGRAM_FORMAT */
1258 |
1259 | #define CRO_PROGRAM_FORMAT_LEN 5
1260 | #define CRO_PROGRAM_FORMAT_COMPRESSION_METHOD CRO_BYTE(1)
1261 | #define CRO_PROGRAM_FORMAT_ENCRYPTION_METHOD CRO_BYTE(2)
1262 | #define CRO_PROGRAM_FORMAT_PROGRAMMING_METHOD CRO_BYTE(3)
1263 | #define CRO_PROGRAM_FORMAT_ACCESS_METHOD CRO_BYTE(4)
1264 |
1265 | #define CRM_PROGRAM_FORMAT_LEN 1
1266 |
1267 |
1268 | /* PROGRAM_NEXT */
1269 |
1270 | #define CRO_PROGRAM_NEXT_MAX_SIZE ((vuint8)(kXcpMaxCTO-2))
1271 |
1272 | #define CRO_PROGRAM_NEXT_LEN 2 /* + size */
1273 | #define CRO_PROGRAM_NEXT_SIZE CRO_BYTE(1)
1274 | #define CRO_PROGRAM_NEXT_DATA (&CRO_BYTE(2))
1275 |
1276 | #define CRM_PROGRAM_NEXT_LEN 3
1277 | #define CRM_PROGRAM_NEXT_ERR_SEQUENCE CRM_BYTE(1)
1278 | #define CRM_PROGRAM_NEXT_SIZE_EXPECTED_DATA CRM_BYTE(2)
1279 |
1280 |
1281 | /* PROGRAM_MAX */
1282 |
1283 | #define CRO_PROGRAM_MAX_MAX_SIZE ((vuint8)(kXcpMaxCTO-1))
1284 | #define CRO_PROGRAM_MAX_DATA (&CRO_BYTE(1))
1285 |
1286 | #define CRM_PROGRAM_MAX_LEN 1
1287 |
1288 |
1289 | /* PROGRAM_VERIFY */
1290 |
1291 | #define CRO_PROGRAM_VERIFY_LEN 8
1292 | #define CRO_PROGRAM_VERIFY_MODE CRO_BYTE(1)
1293 | #define CRO_PROGRAM_VERIFY_TYPE CRO_WORD(1)
1294 | #define CRO_PROGRAM_VERIFY_VALUE CRO_DWORD(1)
1295 |
1296 | #define CRM_PROGRAM_VERIFY_LEN 1
1297 |
1298 |
1299 | /* GET_SLAVE_ID */
1300 |
1301 | #define CRO_GET_SLAVE_ID_LEN 6
1302 | #define CRO_GET_SLAVE_ID_SUB_CODE CRO_BYTE(1)
1303 | #define CRO_GET_SLAVE_ID_X CRO_BYTE(2)
1304 | #define CRO_GET_SLAVE_ID_C CRO_BYTE(3)
1305 | #define CRO_GET_SLAVE_ID_P CRO_BYTE(4)
1306 | #define CRO_GET_SLAVE_ID_MODE CRO_BYTE(5)
1307 |
1308 | #define CRM_GET_SLAVE_ID_LEN 8
1309 | #define CRM_GET_SLAVE_ID_X CRM_BYTE(1)
1310 | #define CRM_GET_SLAVE_ID_C CRM_BYTE(2)
1311 | #define CRM_GET_SLAVE_ID_P CRM_BYTE(3)
1312 | #define CRM_GET_SLAVE_ID_CAN_ID_CMD_STIM CRM_DWORD(1)
1313 |
1314 |
1315 | /* GET_DAQ_ID */
1316 |
1317 | #define CRO_GET_DAQ_ID_LEN 3
1318 | #define CRO_GET_DAQ_ID_SUB_CODE CRO_BYTE(1)
1319 | #define CRO_GET_DAQ_ID_DAQ CRO_WORD(1)
1320 |
1321 | #define CRM_GET_DAQ_ID_LEN 8
1322 | #define CRM_GET_DAQ_ID_FIXED CRM_BYTE(1)
1323 | #define CRM_GET_DAQ_ID_ID CRM_DWORD(1)
1324 |
1325 |
1326 | /* SET_DAQ_ID */
1327 |
1328 | #define CRO_SET_DAQ_ID_LEN 8
1329 | #define CRO_SET_DAQ_ID_SUB_CODE CRO_BYTE(1)
1330 | #define CRO_SET_DAQ_ID_DAQ CRO_WORD(1)
1331 | #define CRO_SET_DAQ_ID_ID CRO_DWORD(1)
1332 |
1333 | #define CRM_SET_DAQ_ID_LEN 1
1334 |
1335 | /* SET_SLAVE_PORT */
1336 |
1337 | #define CRO_SET_SLAVE_PORT_LEN 4
1338 | #define CRO_SET_SLAVE_PORT_SUB_CODE CRO_BYTE(1)
1339 | #define CRO_SET_SLAVE_PORT_PORT CRO_WORD(1)
1340 |
1341 | #define CRM_SET_SLAVE_PORT 1
1342 |
1343 | #if defined ( XCP_ENABLE_GET_CONNECTION_STATE ) || defined ( XCP_ENABLE_GET_SESSION_STATUS_API )
1344 | #define XCP_DISCONNECTED 0u
1345 | #define XCP_CONNECTED 1u
1346 | #endif
1347 |
1348 |
1349 | /****************************************************************************/
1350 | /* Implementation */
1351 | /****************************************************************************/
1352 |
1353 |
1354 | #if defined ( XCP_ENABLE_SEND_EVENT ) || defined ( XCP_ENABLE_SERV_TEXT )
1355 | #define EV_BYTE(x) (xcp.Ev.b[x])
1356 | #endif
1357 |
1358 | #define CRO_BYTE(x) (pCmd->b[x])
1359 | #define CRM_BYTE(x) (xcp.Crm.b[x])
1360 |
1361 | #if defined ( XCP_ENABLE_USE_BYTE_ACCESS )
1362 | #if defined ( XCP_CPUTYPE_LITTLEENDIAN )
1363 | #define CRO_WORD(x) (((vuint16)pCmd->b[((x)*2)+1] << 8) | ((vuint8)pCmd->b[((x)*2)+0]))
1364 | #define CRO_DWORD(x) (((vuint32)pCmd->b[((x)*4)+3] << 24) | ((vuint32)pCmd->b[((x)*4)+2] << 16)| ((vuint16)pCmd->b[((x)*4)+1] << 8)| ((vuint8)pCmd->b[((x)*4)+0]))
1365 |
1366 | #define CRM_WORD(x) (((vuint16)xcp.Crm.b[((x)*2)+1] << 8) | ((vuint8)xcp.Crm.b[((x)*2)+0]))
1367 | #define CRM_WORD_WRITE(x, d) {xcp.Crm.b[((x)*2)+0] = ((vuint8)(d) & 0xFF); xcp.Crm.b[((x)*2)+1] = ((vuint8)((vuint16)(d) >> 8) & 0xFF);}
1368 | #define CRM_DWORD(x) (((vuint32)xcp.Crm.b[((x)*4)+3] << 24) | ((vuint32)xcp.Crm.b[((x)*4)+2] << 16) | ((vuint16)xcp.Crm.b[((x)*4)+1] << 8) | ((vuint8)xcp.Crm.b[((x)*4)+0]) )
1369 | #define CRM_DWORD_WRITE(x, d) {xcp.Crm.b[((x)*4)+0] = ((vuint8)((vuint32)(d) >> 0) & 0xFF); \
1370 | xcp.Crm.b[((x)*4)+1] = ((vuint8)((vuint32)(d) >> 8) & 0xFF); \
1371 | xcp.Crm.b[((x)*4)+2] = ((vuint8)((vuint32)(d) >> 16) & 0xFF); \
1372 | xcp.Crm.b[((x)*4)+3] = ((vuint8)((vuint32)(d) >> 24) & 0xFF);}
1373 | #else
1374 | #define CRO_WORD(x) (((vuint16)pCmd->b[((x)*2)+0] << 8) | ((vuint8)pCmd->b[((x)*2)+1]))
1375 | #define CRO_DWORD(x) (((vuint32)pCmd->b[((x)*4)+0] << 24) | ((vuint32)pCmd->b[((x)*4)+1] << 16)| ((vuint16)pCmd->b[((x)*4)+2] << 8)| ((vuint8)pCmd->b[((x)*4)+3]))
1376 |
1377 | #define CRM_WORD(x) (((vuint16)xcp.Crm.b[((x)*2)+0] << 8) | ((vuint8)xcp.Crm.b[((x)*2)+1]))
1378 | #define CRM_WORD_WRITE(x, d) {xcp.Crm.b[((x)*2)+1] = ((vuint8)(d) & 0xFF); xcp.Crm.b[((x)*2)+0] = ((vuint8)((vuint16)(d) >> 8) & 0xFF);}
1379 | #define CRM_DWORD(x) (((vuint32)xcp.Crm.b[((x)*4)+0] << 24) | ((vuint32)xcp.Crm.b[((x)*4)+1] << 16) | ((vuint16)xcp.Crm.b[((x)*4)+2] << 8) | ((vuint8)xcp.Crm.b[((x)*4)+3]) )
1380 | #define CRM_DWORD_WRITE(x, d) {xcp.Crm.b[((x)*4)+3] = ((vuint8)((vuint32)(d) >> 0) & 0xFF); \
1381 | xcp.Crm.b[((x)*4)+2] = ((vuint8)((vuint32)(d) >> 8) & 0xFF); \
1382 | xcp.Crm.b[((x)*4)+1] = ((vuint8)((vuint32)(d) >> 16) & 0xFF); \
1383 | xcp.Crm.b[((x)*4)+0] = ((vuint8)((vuint32)(d) >> 24) & 0xFF);}
1384 | #endif
1385 | #else
1386 | #define CRO_WORD(x) (pCmd->w[x])
1387 | #define CRO_DWORD(x) (pCmd->dw[x])
1388 | #define CRM_WORD(x) (xcp.Crm.w[x])
1389 | #define CRM_WORD_WRITE(x, d) (xcp.Crm.w[x] = (d))
1390 | #define CRM_DWORD(x) (xcp.Crm.dw[x])
1391 | #define CRM_DWORD_WRITE(x, d) (xcp.Crm.dw[x] = (d))
1392 | #endif
1393 |
1394 |
1395 |
1396 |
1397 | /****************************************************************************/
1398 | /* Default data type definitions */
1399 | /****************************************************************************/
1400 |
1401 | /* Pointer to far memory */
1402 | #if defined ( XCP_MEMORY_FAR )
1403 | #else
1404 | #if defined ( MEMORY_FAR )
1405 | #define XCP_MEMORY_FAR MEMORY_FAR
1406 | #else
1407 | #if defined ( V_MEMRAM2_FAR )
1408 | #define XCP_MEMORY_FAR V_MEMRAM2_FAR
1409 | #else
1410 | #define XCP_MEMORY_FAR
1411 | #endif
1412 | #endif
1413 | #endif
1414 |
1415 | /* Far memory qualifier for functions. */
1416 | #if defined ( XCP_FAR )
1417 | #else
1418 | #if defined ( C_COMP_COSMIC_MCS12X_MSCAN12 )
1419 | /* Always use far access for ApplXcpWrite() and ApplXcpread(). */
1420 | #define XCP_FAR @far
1421 | #else
1422 | #define XCP_FAR
1423 | #endif
1424 | #endif
1425 |
1426 | /* RAM */
1427 | #if defined ( RAM )
1428 | #else
1429 | #define RAM
1430 | #endif
1431 |
1432 |
1433 | /*
1434 | DAQBYTEPTR and MTABYTEPTR may be defined different to BYTEPTR to save memory
1435 | Example:
1436 | #define BYTEPTR unsigned char *
1437 | #define MTABYTEPTR huge unsigned char *
1438 | #define DAQBYTEPTR unsigned char *
1439 | */
1440 | #if defined ( DAQBYTEPTR )
1441 | #else
1442 | #define DAQBYTEPTR vuint8 XCP_MEMORY_FAR *
1443 | #endif
1444 |
1445 | #if defined ( MTABYTEPTR )
1446 | #else
1447 | #define MTABYTEPTR vuint8 XCP_MEMORY_FAR *
1448 | #endif
1449 |
1450 | /* Pointer type used to point into the xcp structure */
1451 | #if defined ( BYTEPTR )
1452 | #else
1453 | #define BYTEPTR vuint8 *
1454 | #endif
1455 |
1456 | #if defined ( ROMBYTEPTR )
1457 | #else
1458 | #define ROMBYTEPTR vuint8 const *
1459 | #endif
1460 |
1461 |
1462 | /****************************************************************************/
1463 | /* Checks and default values */
1464 | /****************************************************************************/
1465 |
1466 | /* Turn off test instrumentation, if not used */
1467 | #if !defined(XCP_ASSERT)
1468 | #define XCP_ASSERT(x)
1469 | #endif
1470 | #if !defined(XCP_PRINT)
1471 | #define XCP_PRINT(x)
1472 | #endif
1473 | #if !defined(BEGIN_PROFILE)
1474 | #define BEGIN_PROFILE(i)
1475 | #endif
1476 | #if !defined(END_PROFILE)
1477 | #define END_PROFILE(i)
1478 | #endif
1479 |
1480 | /* Check limits of the XCP imnplementation
1481 | */
1482 | #if ( kXcpMaxCTO > 255 )
1483 | #error "kXcpMaxCTO must be < 256"
1484 | #endif
1485 | #if ( kXcpMaxCTO < 0x08 )
1486 | #error "kXcpMaxCTO must be > 0x07"
1487 | #endif
1488 | #if ( kXcpMaxDTO > 255 )
1489 | #error "kXcpMaxDTO must be < 256"
1490 | #endif
1491 | #if ( kXcpMaxDTO < 0x08 )
1492 | #error "kXcpMaxDTO must be > 0x07"
1493 | #endif
1494 |
1495 | #if defined ( XCP_ENABLE_DAQ )
1496 |
1497 | /* kXcpDaqMemSize must be defined
1498 | */
1499 | #if defined ( kXcpDaqMemSize )
1500 | #else
1501 | #error "Please define kXcpDaqMemSize"
1502 | #endif
1503 |
1504 | /* Use send queue as default
1505 | */
1506 | #if defined ( XCP_ENABLE_SEND_QUEUE ) || defined ( XCP_DISABLE_SEND_QUEUE )
1507 | #else
1508 | #define XCP_ENABLE_SEND_QUEUE
1509 | #endif
1510 |
1511 | /*
1512 | Max. size of an object referenced by an ODT entry
1513 | XCP_MAX_ODT_ENTRY_SIZE may be limited
1514 | */
1515 | #if defined ( XCP_MAX_ODT_ENTRY_SIZE )
1516 | #else
1517 | #if defined ( XCP_ENABLE_DAQ_HDR_ODT_DAQ )
1518 | #define XCP_MAX_ODT_ENTRY_SIZE (kXcpMaxDTO-2)
1519 | #else
1520 | #define XCP_MAX_ODT_ENTRY_SIZE (kXcpMaxDTO-1)
1521 | #endif
1522 | #endif
1523 |
1524 | #else /* XCP_ENABLE_DAQ */
1525 | #endif /* XCP_ENABLE_DAQ */
1526 |
1527 |
1528 |
1529 | /****************************************************************************/
1530 | /* XCP Packet Type Definition */
1531 | /****************************************************************************/
1532 |
1533 | typedef struct {
1534 | vuint8 b[kXcpMaxDTO];
1535 | vuint8 l;
1536 | } tXcpDto;
1537 |
1538 | typedef union { /* PRQA S 0750 */ /* MD_MSR_18.4 */
1539 | /* There might be a loss of up to 3 bytes. */
1540 | vuint8 b[ ((kXcpMaxCTO + 3) & 0xFFC) ];
1541 | vuint16 w[ ((kXcpMaxCTO + 3) & 0xFFC) / 2 ];
1542 | vuint32 dw[ ((kXcpMaxCTO + 3) & 0xFFC) / 4 ];
1543 | } tXcpCto;
1544 |
1545 | /****************************************************************************/
1546 | /* DAQ Lists, Type Definition */
1547 | /****************************************************************************/
1548 |
1549 | /* Note:
1550 | - Adressextensions are not used for DAQ
1551 | */
1552 |
1553 | #if defined ( XCP_ENABLE_DAQ )
1554 |
1555 | /* ODT */
1556 | /* Size must be even !!! */
1557 | typedef struct {
1558 |
1559 | vuint16 firstOdtEntry; /* Absolute */
1560 | vuint16 lastOdtEntry; /* Absolute */
1561 |
1562 |
1563 | } tXcpOdt;
1564 |
1565 | #if defined( XCP_ENABLE_ODT_SIZE_WORD )
1566 | typedef vuint16 tXcpOdtIdx;
1567 | typedef vuint16 tXcpOdtCnt;
1568 | #else
1569 | typedef vuint8 tXcpOdtIdx;
1570 | typedef vuint8 tXcpOdtCnt;
1571 | #endif
1572 |
1573 | /* DAQ list */
1574 | typedef struct {
1575 |
1576 | tXcpOdtIdx lastOdt; /* Absolute */
1577 | tXcpOdtIdx firstOdt; /* Absolute */
1578 |
1579 | vuint8 flags;
1580 |
1581 | #if defined ( kXcpMaxEvent ) && ! defined ( XCP_ENABLE_DAQ_PRESCALER )
1582 | /* Event-Daq association array used */
1583 | #else
1584 | vuint8 eventChannel;
1585 | #endif
1586 |
1587 | #if defined ( XCP_ENABLE_DAQ_PRESCALER )
1588 | vuint8 prescaler;
1589 | vuint8 cycle;
1590 | #endif
1591 |
1592 | } tXcpDaqList;
1593 |
1594 | #endif /* XCP_ENABLE_DAQ */
1595 |
1596 | /* Dynamic DAQ list structures */
1597 | typedef struct {
1598 |
1599 | vuint8 ActiveTl; /* Active Transport Layer */
1600 |
1601 | #if defined ( XCP_ENABLE_DAQ ) /* Data Acquisition */
1602 |
1603 | vuint8 DaqCount;
1604 | tXcpOdtCnt OdtCount; /* Absolute count */
1605 | vuint16 OdtEntryCount; /* Absolute count */
1606 |
1607 | /* Session configuration id for resume mode */
1608 |
1609 | /* Event-Daq association array */
1610 | #if defined ( kXcpMaxEvent ) && ! defined ( XCP_ENABLE_DAQ_PRESCALER )
1611 | vuint8 EventDaq[kXcpMaxEvent];
1612 | #endif
1613 |
1614 | union { /* PRQA S 0750 */ /* MD_MSR_18.4 */
1615 | vuint8 b[kXcpDaqMemSize];
1616 | tXcpDaqList DaqList[kXcpDaqMemSize/sizeof(tXcpDaqList)]; /* ESCAN00096039 */
1617 | } u;
1618 |
1619 | #endif /* XCP_ENABLE_DAQ */
1620 |
1621 | } tXcpDaq;
1622 |
1623 | typedef vuint16 SessionStatusType;
1624 |
1625 | #if defined ( XCP_ENABLE_DAQ ) /* Data Acquisition */
1626 |
1627 | #if defined ( XCP_ENABLE_DAQ_TIMESTAMP )
1628 | #if ( kXcpDaqTimestampSize == DAQ_TIMESTAMP_BYTE )
1629 | typedef vuint8 XcpDaqTimestampType;
1630 | #define XcpDaqTimestampSize 1
1631 | #elif ( kXcpDaqTimestampSize == DAQ_TIMESTAMP_WORD )
1632 | typedef vuint16 XcpDaqTimestampType;
1633 | #define XcpDaqTimestampSize 2
1634 | #elif ( kXcpDaqTimestampSize == DAQ_TIMESTAMP_DWORD )
1635 | typedef vuint32 XcpDaqTimestampType;
1636 | #define XcpDaqTimestampSize 4
1637 | #else
1638 | #error "kXcpDaqTimestampSize not defined. Please define a valid timestamp type!"
1639 | #endif
1640 | #endif
1641 |
1642 |
1643 | /* Shortcuts */
1644 |
1645 | /* j is absolute odt number */
1646 | #define DaqListOdtEntryCount(j) ((xcp.pOdt[j].lastOdtEntry-xcp.pOdt[j].firstOdtEntry)+1)
1647 | #define DaqListOdtLastEntry(j) (xcp.pOdt[j].lastOdtEntry)
1648 | #define DaqListOdtFirstEntry(j) (xcp.pOdt[j].firstOdtEntry)
1649 | #define DaqListOdtStimBuffer(j) (xcp.pOdt[j].pStimBuffer)
1650 |
1651 | /* n is absolute odtEntry number */
1652 | #define OdtEntrySize(n) (xcp.pOdtEntrySize[n])
1653 | #define OdtEntryAddr(n) (xcp.pOdtEntryAddr[n])
1654 |
1655 | /* i is daq number */
1656 | #define DaqListOdtCount(i) ((xcp.Daq.u.DaqList[i].lastOdt-xcp.Daq.u.DaqList[i].firstOdt)+1)
1657 | #define DaqListLastOdt(i) xcp.Daq.u.DaqList[i].lastOdt
1658 | #define DaqListFirstOdt(i) xcp.Daq.u.DaqList[i].firstOdt
1659 | #define DaqListFirstPid(i) xcp.Daq.u.DaqList[i].firstOdt
1660 | #define DaqListFlags(i) xcp.Daq.u.DaqList[i].flags
1661 | #define DaqListEventChannel(i) xcp.Daq.u.DaqList[i].eventChannel
1662 | #define DaqListPrescaler(i) xcp.Daq.u.DaqList[i].prescaler
1663 | #define DaqListCycle(i) xcp.Daq.u.DaqList[i].cycle
1664 |
1665 |
1666 | #endif /* XCP_ENABLE_DAQ */
1667 |
1668 |
1669 | /****************************************************************************/
1670 | /* Checksum, Type Definition */
1671 | /****************************************************************************/
1672 | #if defined ( XCP_ENABLE_CHECKSUM )
1673 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD11 ) || \
1674 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD12 ) || \
1675 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD14 ) || \
1676 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_CRC16 ) || \
1677 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_CRC16CCITT ) || \
1678 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_CRC32 )
1679 | #define tXcpChecksumAddSize 1
1680 | typedef vuint8 tXcpChecksumAddType; /* Data type (width) of the data to be added. */
1681 | #endif
1682 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD22 ) || \
1683 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD24 )
1684 | #define tXcpChecksumAddSize 2
1685 | typedef vuint16 tXcpChecksumAddType; /* Data type (width) of the data to be added. */
1686 | #endif
1687 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD44 )
1688 | #define tXcpChecksumAddSize 4
1689 | typedef vuint32 tXcpChecksumAddType; /* Data type (width) of the data to be added. */
1690 | #endif
1691 |
1692 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD11 )
1693 | #define tXcpChecksumSumSize 1
1694 | typedef vuint8 tXcpChecksumSumType; /* Data type (width) of the actual checksum. */
1695 | #endif
1696 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD12 ) || \
1697 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD22 ) || \
1698 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_CRC16 ) || \
1699 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_CRC16CCITT )
1700 | #define tXcpChecksumSumSize 2
1701 | typedef vuint16 tXcpChecksumSumType; /* Data type (width) of the actual checksum. */
1702 | #endif
1703 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD14 ) || \
1704 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD24 ) || \
1705 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD44 ) || \
1706 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_CRC32 )
1707 | #define tXcpChecksumSumSize 4
1708 | typedef vuint32 tXcpChecksumSumType; /* Data type (width) of the actual checksum. */
1709 | #endif
1710 | #endif
1711 |
1712 |
1713 | /****************************************************************************/
1714 | /* XCP Segment CAL parameters */
1715 | /* Sement info */
1716 | /****************************************************************************/
1717 |
1718 | #if defined ( XCP_ENABLE_PAGE_INFO )
1719 | typedef struct {
1720 | vuint8 SegmentInfoMaxPages;
1721 | vuint8 SegmentInfoInitSegment;
1722 | vuint8 SegmentInfoAddressExtension;
1723 | vuint8 SegmentInfoMaxMapping;
1724 | vuint8 SegmentInfoMode;
1725 | vuint8 SegmentPageProperties[kXcpMaxPages];
1726 | vuint8 SegmentPageAktiv[kXcpMaxPages]; /* 1=aktiv, 0=deaktiv. */
1727 | vuint8 SegmentPageMode[kXcpMaxPages]; /* 1=ECU, 2=XCP */
1728 | vuint32 SegmentInfoMapping;
1729 | } tXcpSegmentInfo;
1730 | #endif
1731 |
1732 |
1733 | /****************************************************************************/
1734 | /* XCP Driver Variables, Type Definition */
1735 | /****************************************************************************/
1736 |
1737 | /* Return values */
1738 | #define XCP_CMD_DENIED 0
1739 | #define XCP_CMD_OK 1
1740 | #define XCP_CMD_PENDING 2
1741 | #define XCP_CMD_SYNTAX 3
1742 | #define XCP_CMD_BUSY 4
1743 | #define XCP_CMD_UNKNOWN 5
1744 | #define XCP_CMD_OUT_OF_RANGE 6
1745 | #define XCP_MODE_NOT_VALID 7
1746 | #define XCP_CMD_ERROR 0xFF
1747 |
1748 | #define XCP_OK 0
1749 | #define XCP_NOT_OK 1
1750 |
1751 | /* Return values for XcpEvent() */
1752 | #define XCP_EVENT_NOP 0x00u /* Inactive (DAQ not running, Event not configured) */
1753 | #define XCP_EVENT_DAQ 0x01u /* DAQ active */
1754 | #define XCP_EVENT_DAQ_OVERRUN 0x02u /* DAQ queue overflow */
1755 | #define XCP_EVENT_DAQ_TIMEOUT 0x04u /* Timeout supervision violation */
1756 | #define XCP_EVENT_STIM 0x08u /* STIM active */
1757 | #define XCP_EVENT_STIM_OVERRUN 0x10u /* STIM data not available */
1758 |
1759 | /* Bitmasks for xcp.SendStatus */
1760 | #define XCP_CRM_REQUEST 0x01u
1761 | #define XCP_DTO_REQUEST 0x02u
1762 | #define XCP_EVT_REQUEST 0x04u
1763 | #define XCP_CRM_PENDING 0x10u
1764 | #define XCP_DTO_PENDING 0x20u
1765 | #define XCP_EVT_PENDING 0x40u
1766 | #define XCP_SEND_PENDING (XCP_DTO_PENDING|XCP_CRM_PENDING|XCP_EVT_PENDING)
1767 |
1768 | typedef struct {
1769 | /* Crm has to be the first object of this structure !! (refer to XcpInit()) */
1770 |
1771 | tXcpCto Crm; /* RES,ERR Message buffer */
1772 | vuint8 CrmLen; /* RES,ERR Message length */
1773 |
1774 | #if defined ( XCP_ENABLE_SEND_EVENT ) || defined ( XCP_ENABLE_SERV_TEXT )
1775 | tXcpCto Ev; /* EV,SERV Message buffer */
1776 | vuint8 EvLen; /* EV,SERV Message length */
1777 | #endif
1778 |
1779 | SessionStatusType SessionStatus;
1780 |
1781 | MTABYTEPTR Mta; /* Memory Transfer Address */
1782 |
1783 |
1784 | #if defined ( XCP_ENABLE_SEED_KEY )
1785 | vuint8 ProtectionStatus; /* Resource Protection Status */
1786 | #endif
1787 |
1788 | #if defined ( XCP_ENABLE_CHECKSUM ) && !defined ( XCP_ENABLE_CUSTOM_CRC )
1789 | vuint16 CheckSumSize; /* Counter for checksum calculation */
1790 | tXcpChecksumSumType CheckSum; /* Actual checksum */
1791 | #endif
1792 |
1793 | /*
1794 | Dynamic DAQ list structures
1795 | This structure should be stored in resume mode
1796 | */
1797 | tXcpDaq Daq;
1798 |
1799 |
1800 | #if defined ( XCP_ENABLE_DAQ ) /* Data Acquisition */
1801 |
1802 | tXcpOdt *pOdt;
1803 | DAQBYTEPTR *pOdtEntryAddr;
1804 | vuint8 *pOdtEntrySize;
1805 |
1806 | /* Transmit Queue */
1807 | #if defined ( XCP_ENABLE_SEND_QUEUE )
1808 | tXcpDto *pQueue;
1809 | vuint16 QueueSize;
1810 | vuint16 QueueLen;
1811 | vuint16 QueueRp;
1812 | #endif
1813 |
1814 | /* Transmit Status */
1815 | #if defined ( XCP_ENABLE_SEND_QUEUE)
1816 | volatile vuint8 SendStatus;
1817 | #endif
1818 |
1819 | /* Pointer for SET_DAQ_PTR */
1820 | vuint16 DaqListPtr;
1821 |
1822 |
1823 | #endif /* XCP_ENABLE_DAQ */
1824 |
1825 | } tXcpData;
1826 |
1827 |
1828 | /***************************************************************************/
1829 | /* External Declarations */
1830 | /***************************************************************************/
1831 |
1832 | extern RAM tXcpData xcp;
1833 | /*******************************************************************************
1834 | * External 8 Bit Constants
1835 | *******************************************************************************/
1836 |
1837 | V_MEMROM0 extern const vuint8 kXcpMainVersion;
1838 | V_MEMROM0 extern const vuint8 kXcpSubVersion;
1839 | V_MEMROM0 extern const vuint8 kXcpReleaseVersion;
1840 |
1841 |
1842 |
1843 | /****************************************************************************/
1844 | /* Prototypes */
1845 | /****************************************************************************/
1846 |
1847 |
1848 | /* Important external functions of xcp.c */
1849 | /*-----------------------------------------*/
1850 |
1851 |
1852 | /* Initialization and deinitialization functions for the XCP Protocol Layer. */
1853 | extern void XcpInit( void );
1854 | extern void XcpExit( void );
1855 |
1856 | /* Trigger a XCP data acquisition or stimulation event */
1857 | /* Returns an error status XCP_EVENT_xxxx */
1858 | extern vuint8 XcpEvent( vuint8 event );
1859 |
1860 | /* Check if a XCP stimulation event can perform or delete the buffers */
1861 | /* Returns 1 (TRUE) if new stimulation data is available */
1862 |
1863 | /* Call the XCP command processor. */
1864 | extern void XcpCommand( const vuint32* pCommand );
1865 |
1866 | /* Transmit Notification */
1867 | /* Confirmation of the transmit request by ApplXcpSend(). */
1868 | /* Returns 0 when the XCP driver is idle */
1869 | extern vuint8 XcpSendCallBack( void );
1870 |
1871 | /* Background Loop */
1872 | /* Return 1 (TRUE) if anything is still pending */
1873 | /* Used only if Checksum Calculation or EEPROM Programming is required */
1874 | extern vuint8 XcpBackground( void );
1875 |
1876 |
1877 | /*-----------------------------------------------------------------------------------*/
1878 | /* Functions or Macros that have to be provided externally to the XCP Protocol Layer */
1879 | /*-----------------------------------------------------------------------------------*/
1880 |
1881 |
1882 | #if defined ( XCP_TRANSPORT_LAYER_TYPE_CAN )
1883 | #define ApplXcpSend(len, msg) XcpCanSend(len, msg)
1884 | #if defined ( ApplXcpSendFlush )
1885 | #else
1886 | #define ApplXcpSendFlush()
1887 | #endif
1888 | #define ApplXcpInit() XcpCanInit()
1889 | #define ApplXcpBackground() XcpCanBackground()
1890 | #endif
1891 |
1892 |
1893 | /* Transmission Request for a XCP Packet */
1894 | #if defined ( ApplXcpSend )
1895 | #else
1896 | extern void ApplXcpSend( vuint8 len, const BYTEPTR msg );
1897 | #endif
1898 |
1899 | /* Flush the transmit buffer if there is one implemented in ApplXcpSend() */
1900 | #if defined ( ApplXcpSendFlush )
1901 | #else
1902 | extern void ApplXcpSendFlush( void );
1903 | #endif
1904 |
1905 | /* Generate a native pointer from XCP address extension and address */
1906 | #if defined ( ApplXcpGetPointer )
1907 | #else
1908 | extern MTABYTEPTR ApplXcpGetPointer( vuint8 addr_ext, vuint32 addr );
1909 | #endif
1910 |
1911 | #if defined ( XCP_ENABLE_MEM_ACCESS_BY_APPL )
1912 | extern vuint8 ApplXcpRead( vuint32 addr );
1913 | extern void XCP_FAR ApplXcpWrite( vuint32 addr, vuint8 data );
1914 | #endif
1915 |
1916 | #if defined ( XCP_ENABLE_CALIBRATION_MEM_ACCESS_BY_APPL ) || defined ( XCP_ENABLE_MEM_ACCESS_BY_APPL )
1917 | #if defined ( XCP_ENABLE_CHECKSUM )
1918 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD22 ) || \
1919 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD24 ) || \
1920 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD44 ) || \
1921 | defined ( XCP_ENABLE_CALIBRATION_MEM_ACCESS_BY_APPL )
1922 | extern tXcpChecksumAddType ApplXcpReadChecksumValue( vuint32 addr );
1923 | #endif
1924 | #endif
1925 | #endif
1926 |
1927 |
1928 | #if defined ( XCP_ENABLE_CALIBRATION_MEM_ACCESS_BY_APPL ) && !defined ( XCP_ENABLE_MEM_ACCESS_BY_APPL )
1929 | extern vuint8 ApplXcpCalibrationWrite(MTABYTEPTR addr, vuint8 size, const BYTEPTR data);
1930 | extern vuint8 ApplXcpCalibrationRead(MTABYTEPTR addr, vuint8 size, BYTEPTR data);
1931 | #endif
1932 |
1933 | /* Application specific initialization function (called by XcpInit() ). */
1934 | #if defined ( ApplXcpInit )
1935 | #else
1936 | extern void ApplXcpInit( void );
1937 | #endif
1938 |
1939 | /* Application specific background ground loop (called by XcpBackground() ). */
1940 | #if defined ( ApplXcpBackground )
1941 | #else
1942 | extern void ApplXcpBackground( void );
1943 | #endif
1944 |
1945 | /* Enable interrupts */
1946 | #if defined ( ApplXcpInterruptEnable )
1947 | #else
1948 | extern void ApplXcpInterruptEnable( void );
1949 | #endif
1950 |
1951 | /* Disable interrupts */
1952 | #if defined ( ApplXcpInterruptDisable )
1953 | #else
1954 | extern void ApplXcpInterruptDisable( void );
1955 | #endif
1956 |
1957 |
1958 | /* Some available utility functions */
1959 | /*----------------------------------*/
1960 |
1961 | /* Force a XCP disconnect */
1962 | extern void XcpDisconnect( void );
1963 |
1964 | /* Set size of transfer objects */
1965 | void XcpSetActiveTl( vuint8 MaxCto, vuint8 MaxDto, vuint8 ActiveTl );
1966 | vuint8 XcpGetActiveTl( void );
1967 |
1968 | /* Send a pending XCP response packet (RES). */
1969 | /* To be used after a XCP_CMD_PENDING from EEPROM or FLASH programming. */
1970 | extern void XcpSendCrm( void );
1971 |
1972 | /* Send a XCP event (EV) or service request (SERV) message */
1973 | #if defined ( XCP_ENABLE_SEND_EVENT )
1974 | extern void XcpSendEvent( vuint8 evc, const BYTEPTR c, vuint8 len);
1975 | #endif
1976 |
1977 | /* Send a text message */
1978 | /* Implement print and putchar into a XCP SERV/SERV_TEXT message */
1979 | #if defined ( XCP_ENABLE_SERV_TEXT )
1980 | #if defined ( XCP_ENABLE_SERV_TEXT_PUTCHAR )
1981 | extern void XcpPutchar( const vuint8 c );
1982 | #if defined ( XCP_ENABLE_SERV_TEXT_PRINT )
1983 | extern void XcpPrint( const vuint8 *str );
1984 | #if defined ( XCP_ENABLE_SERV_TEXT_PRINTF )
1985 | extern void XcpPrintf( const vuint8 *str, ... );
1986 | #endif
1987 | #endif
1988 | #endif
1989 | #endif
1990 |
1991 |
1992 | /* Functions that may have be provided externally depending on options */
1993 | /*---------------------------------------------------------------------*/
1994 |
1995 | /* Utility functions from xcp.c */
1996 | /*------------------------------*/
1997 |
1998 | /* Override option for the memory transfer function */
1999 | /* May be used for optimization */
2000 | /* #define XcpMemCpy, #define XcpMemSet to disable the implementation in xcp.c */
2001 | #if defined ( XcpMemCpy ) || defined ( C_COMP_COSMIC_MCS12X_MSCAN12 )
2002 | #else
2003 | extern void XcpMemCpy( DAQBYTEPTR dest, const DAQBYTEPTR src, vuint8 n );
2004 | #endif
2005 | #if defined ( XcpMemSet )
2006 | #else
2007 | extern void XcpMemSet( BYTEPTR p, vuint16 n, vuint8 b );
2008 | #endif
2009 |
2010 | /* Send a DTO */
2011 | /* Can be redefined to meet DMA requirements */
2012 | #if defined ( XCP_ENABLE_DAQ )
2013 | #if defined ( XcpSendDto )
2014 | /* XcpSendDto is redefined */
2015 | #else
2016 | extern void XcpSendDto( const tXcpDto *dto );
2017 | #endif
2018 | #endif
2019 |
2020 | /* Resolve a transmit stall condition in XcpPutchar() or XcpSendEvent() */
2021 | /* Returns true (!=0) if successfull */
2022 | #if defined ( XCP_ENABLE_SEND_EVENT ) || defined ( XCP_ENABLE_SERV_TEXT_PUTCHAR )
2023 | #if defined ( XCP_ENABLE_SEND_QUEUE )
2024 | #if defined ( ApplXcpSendStall )
2025 | #else
2026 | extern vuint8 ApplXcpSendStall( void );
2027 | #endif
2028 | #endif
2029 | #endif
2030 |
2031 | /* Check addresses for valid write access */
2032 | /* Returns 0 (false) if access denied */
2033 | /* Used only, if write protection of memory areas is required */
2034 |
2035 | /* Check addresses for valid read access */
2036 | /* Returns 0 (false) if access denied */
2037 | /* Used only, if read protection of memory areas is required */
2038 |
2039 | /* Check addresses for valid read/write access */
2040 | /* Returns 0 (false) if access denied */
2041 | /* Used only, if DAQ protection of memory areas is required */
2042 | #if defined ( XCP_ENABLE_DAQ )
2043 | #endif
2044 |
2045 | /* Calculate checksum for a memory range */
2046 | /* Returns 0 (false) if access denied */
2047 | /* Used only, if read protection of memory areas is required */
2048 | #if defined ( XCP_ENABLE_CHECKSUM ) && defined ( XCP_ENABLE_CUSTOM_CRC )
2049 | #if defined ( ApplXcpCalculateChecksum ) /* Not defined as macro */
2050 | #else
2051 | extern vuint8 ApplXcpCalculateChecksum( ROMBYTEPTR pMemArea, BYTEPTR pRes, vuint32 length );
2052 | #endif
2053 | #endif
2054 |
2055 | /* Check addresses for valid programming access */
2056 | /* Returns 0 (false) if access denied */
2057 | /* Used only, if programming protection of memory areas is required */
2058 |
2059 | /* DAQ resume */
2060 |
2061 | /* DAQ Timestamp */
2062 | #if defined ( XCP_ENABLE_DAQ_TIMESTAMP )
2063 | #if defined ( ApplXcpGetTimestamp )
2064 | /* ApplXcpGetTimestamp is redefined */
2065 | #else
2066 | extern XcpDaqTimestampType ApplXcpGetTimestamp( void );
2067 | #endif
2068 | #endif
2069 |
2070 |
2071 |
2072 | /* Flash Programming by Flash Kernel */
2073 |
2074 |
2075 | /* Flash Programming */
2076 |
2077 |
2078 | /* RAM/ROM Switching */
2079 | #if defined ( XCP_ENABLE_CALIBRATION_PAGE )
2080 |
2081 | extern vuint8 ApplXcpGetCalPage( vuint8 segment, vuint8 mode );
2082 | extern vuint8 ApplXcpSetCalPage( vuint8 segment, vuint8 page, vuint8 mode);
2083 |
2084 | /* extern void ApplXcpInitCalPage( void ); */
2085 | #if defined ( XCP_ENABLE_PAGE_COPY )
2086 | extern vuint8 ApplXcpCopyCalPage( vuint8 srcSeg, vuint8 srcPage, vuint8 destSeg, vuint8 destPage );
2087 | /* Returns:
2088 | XCP_CMD_OK
2089 | XCP_CMD_PENDING - call XcpSendCrm when done
2090 | XCP_CMD_ERROR
2091 | */
2092 | #endif
2093 | #endif
2094 | #if defined ( XCP_ENABLE_PAGE_FREEZE )
2095 | extern void ApplXcpSetFreezeMode( vuint8 segment, vuint8 mode );
2096 | extern vuint8 ApplXcpGetFreezeMode( vuint8 segment );
2097 | #endif
2098 |
2099 | /* Seed & Key */
2100 | #if defined ( XCP_ENABLE_SEED_KEY )
2101 |
2102 | extern vuint8 ApplXcpGetSeed( const vuint8 resource, vuint8 *seed );
2103 | extern vuint8 ApplXcpUnlock( const vuint8 *key, const vuint8 length );
2104 |
2105 | #endif
2106 |
2107 | /* User defined service of GET_ID */
2108 | #if defined ( XCP_ENABLE_GET_ID_GENERIC )
2109 | extern vuint32 ApplXcpGetIdData( MTABYTEPTR *pData, vuint8 id );
2110 | #endif
2111 |
2112 | /* EEPROM Programing */
2113 |
2114 |
2115 | /* User defined service */
2116 | #if defined ( XCP_ENABLE_USER_COMMAND )
2117 | /* Return values for ApplXcpUserService:
2118 | XCP_CMD_OK - Done
2119 | XCP_CMD_PENDING - Pending, call XcpSendCrm when done
2120 | XCP_CMD_SYNTAX - Error
2121 | */
2122 | extern vuint8 ApplXcpUserService( const BYTEPTR pCmd );
2123 | #endif
2124 |
2125 | /* Transport Layer service */
2126 |
2127 |
2128 | #if defined ( XCP_ENABLE_VERSION_INFO_API )
2129 | extern void XcpGetVersionInfo(Std_VersionInfoType *XcpVerInfoPtr);
2130 | #endif
2131 |
2132 | #if defined ( XCP_ENABLE_GET_CONNECTION_STATE ) || defined ( XCP_ENABLE_GET_SESSION_STATUS_API )
2133 | /* Get the connection state of the XCP Protocol Layer */
2134 | extern vuint8 XcpGetState( void );
2135 | #endif
2136 |
2137 | #if defined ( XCP_ENABLE_GET_SESSION_STATUS_API )
2138 | /* Get the session state of the XCP Protocol Layer */
2139 | extern SessionStatusType XcpGetSessionStatus( void );
2140 | #endif
2141 |
2142 |
2143 | #if defined ( XCP_ENABLE_GET_XCP_DATA_POINTER )
2144 | extern void XcpGetXcpDataPointer( RAM tXcpData ** pXcpData );
2145 | #endif
2146 |
2147 |
2148 |
2149 | #if defined ( XCP_ENABLE_TESTMODE )
2150 |
2151 | /****************************************************************************/
2152 | /* Test */
2153 | /****************************************************************************/
2154 |
2155 | extern vuint8 gDebugLevel;
2156 |
2157 | #if defined ( ApplXcpPrint )
2158 | /* ApplXcpPrint is a macro */
2159 | #else
2160 | extern void ApplXcpPrint( const vsint8 *str, ... );
2161 | #endif
2162 |
2163 | extern void XcpPrintDaqList( vuint8 daq );
2164 | #endif /* XCP_ENABLE_TESTMODE */
2165 |
2166 |
2167 |
2168 |
2169 | /*****************************************************************************/
2170 | /* Consistency and limit checks ( XCP Protocol Layer specific ) */
2171 | /*****************************************************************************/
2172 |
2173 | /* The test mode must not be used with XCP Professional. */
2174 |
2175 |
2176 |
2177 | /* Check consistency of DAQ switch */
2178 |
2179 | #if defined ( XCP_ENABLE_DAQ ) && defined ( XCP_DISABLE_DAQ )
2180 | #error "XCP consistency error: DAQ must be either enabled or disabled."
2181 | #endif
2182 | #if defined ( XCP_ENABLE_DAQ ) || defined ( XCP_DISABLE_DAQ )
2183 | #else
2184 | #error "XCP consistency error: DAQ must be enabled or disabled."
2185 | #endif
2186 |
2187 | /* Check consistency of send queue */
2188 |
2189 | #if defined ( XCP_ENABLE_SEND_QUEUE ) && defined ( XCP_DISABLE_SEND_QUEUE )
2190 | #error "XCP consistency error: Send queue must be either enabled or disabled."
2191 | #endif
2192 | #if defined ( XCP_ENABLE_SEND_QUEUE ) || defined ( XCP_DISABLE_SEND_QUEUE )
2193 | #else
2194 | #error "XCP consistency error: Send queue must be enabled or disabled."
2195 | #endif
2196 | #if defined ( XCP_ENABLE_SEND_QUEUE ) && defined ( XCP_DISABLE_DAQ )
2197 | #error "XCP consistency error: Send queue cannot be used without DAQ."
2198 | #endif
2199 |
2200 | /* Check consistency of communictaion mode info */
2201 |
2202 | #if defined ( XCP_ENABLE_COMM_MODE_INFO ) && defined ( XCP_DISABLE_COMM_MODE_INFO )
2203 | #error "XCP consistency error: Communictaion mode info must be either enabled or disabled."
2204 | #endif
2205 | #if defined ( XCP_ENABLE_COMM_MODE_INFO ) || defined ( XCP_DISABLE_COMM_MODE_INFO )
2206 | #else
2207 | #error "XCP consistency error: Communictaion mode info must be enabled or disabled."
2208 | #endif
2209 |
2210 | /* Check service request */
2211 |
2212 | #if defined ( XCP_ENABLE_SERV_TEXT ) && defined ( XCP_DISABLE_SERV_TEXT )
2213 | #error "XCP consistency error: Service request must be either enabled or disabled."
2214 | #endif
2215 | #if defined ( XCP_ENABLE_SERV_TEXT ) || defined ( XCP_DISABLE_SERV_TEXT )
2216 | #else
2217 | #error "XCP consistency error: Service request must be enabled or disabled."
2218 | #endif
2219 | #if defined ( XCP_ENABLE_SERV_TEXT ) && defined ( XCP_DISABLE_SERV_TEXT_PUTCHAR )
2220 | #error "XCP consistency error: Without XcpPutchar is no service request possible."
2221 | #endif
2222 |
2223 | /* Check service request XcpPutchar */
2224 |
2225 | #if defined ( XCP_ENABLE_SERV_TEXT_PUTCHAR ) && defined ( XCP_DISABLE_SERV_TEXT_PUTCHAR )
2226 | #error "XCP consistency error: XcpPutchar function must be either enabled or disabled."
2227 | #endif
2228 | #if defined ( XCP_ENABLE_SERV_TEXT_PUTCHAR ) || defined ( XCP_DISABLE_SERV_TEXT_PUTCHAR )
2229 | #else
2230 | #error "XCP consistency error: XcpPutchar function must be enabled or disabled."
2231 | #endif
2232 | #if defined ( XCP_DISABLE_SERV_TEXT ) && defined ( XCP_ENABLE_SERV_TEXT_PUTCHAR )
2233 | #error "XCP consistency error: XcpPutchar function can only be used with service requests."
2234 | #endif
2235 |
2236 | /* check service request XcpPutchar */
2237 |
2238 | #if defined ( XCP_ENABLE_SERV_TEXT_PRINT ) && defined ( XCP_DISABLE_SERV_TEXT_PRINT )
2239 | #error "XCP consistency error: XcpPrint function must be either enabled or disabled."
2240 | #endif
2241 | #if defined ( XCP_ENABLE_SERV_TEXT_PRINT ) || defined ( XCP_DISABLE_SERV_TEXT_PRINT )
2242 | #else
2243 | #error "XCP consistency error: XcpPrint function must be enabled or disabled."
2244 | #endif
2245 | #if defined ( XCP_ENABLE_SERV_TEXT ) && defined ( XCP_DISABLE_SERV_TEXT_PUTCHAR )
2246 | #error "XCP consistency error: XcpPrint requires XcpPutchar function."
2247 | #endif
2248 |
2249 | /* Check consistency of DAQ header ODT */
2250 | #if defined(XCP_ENABLE_DAQ)
2251 | #if defined ( XCP_ENABLE_DAQ_HDR_ODT_DAQ ) && defined ( XCP_DISABLE_DAQ_HDR_ODT_DAQ )
2252 | #error "XCP consistency error: DAQ_HDR_ODT_DAQ must be either enabled or disabled."
2253 | #endif
2254 | #if defined ( XCP_ENABLE_DAQ_HDR_ODT_DAQ ) || defined ( XCP_DISABLE_DAQ_HDR_ODT_DAQ )
2255 | #else
2256 | #error "XCP consistency error: DAQ_HDR_ODT_DAQ must be enabled or disabled."
2257 | #endif
2258 | #endif
2259 |
2260 | /* Check consistency of Page switching */
2261 |
2262 | #if defined ( XCP_ENABLE_CALIBRATION_PAGE ) && defined ( XCP_DISABLE_CALIBRATION_PAGE )
2263 | #error "XCP consistency error: Page switching must be either enabled or disabled."
2264 | #endif
2265 | #if defined ( XCP_ENABLE_CALIBRATION_PAGE ) || defined ( XCP_DISABLE_CALIBRATION_PAGE )
2266 | #else
2267 | #error "XCP consistency error: Page switching must be enabled or disabled."
2268 | #endif
2269 |
2270 | /* Check range of kXcpStationIdLength */
2271 |
2272 | #if defined ( kXcpStationIdLength )
2273 | #if ( kXcpStationIdLength > 0xFF )
2274 | #error "XCP error: kXcpStationIdLength must be < 256."
2275 | #endif
2276 | #endif
2277 |
2278 | /* Check range of kXcpStimOdtCount */
2279 |
2280 |
2281 | #if defined ( XCP_ENABLE_DAQ )
2282 |
2283 | /* Check range of kXcpDaqMemSize */
2284 |
2285 | #if defined ( kXcpDaqMemSize )
2286 | #if ( kXcpDaqMemSize > 0xFFFF )
2287 | #error "XCP error: kXcpDaqMemSize must be <= 0xFFFF."
2288 | #endif
2289 | #endif
2290 |
2291 | /* Check range of kXcpSendQueueMinSize. */
2292 |
2293 | #if defined ( kXcpSendQueueMinSize )
2294 | #if ( kXcpSendQueueMinSize > 0xFF )
2295 | #error "XCP error: kXcpSendQueueMinSize must be <= 0xFF."
2296 | #endif
2297 | #endif
2298 |
2299 | /* Check range of kXcpMaxEvent */
2300 | #if defined ( kXcpMaxEvent )
2301 | #if ( kXcpMaxEvent > 0xFF )
2302 | #error "XCP error: kXcpMaxEvent must be <= 0xFF."
2303 | #endif
2304 | #endif
2305 |
2306 | /* Check XCP_ENABLE_ODT_SIZE_WORD in combination with XCP_ENABLE_DAQ_HDR_ODT_DAQ */
2307 | #if defined ( XCP_ENABLE_ODT_SIZE_WORD )
2308 | #if defined ( XCP_ENABLE_DAQ_HDR_ODT_DAQ )
2309 | #else
2310 | #error "XCP error: If XCP_ENABLE_ODT_SIZE_WORD is enabled, XCP_ENABLE_DAQ_HDR_ODT_DAQ must be enabled as well."
2311 | #endif
2312 | #endif
2313 |
2314 | #endif /* defined ( XCP_ENABLE_DAQ ) */
2315 |
2316 | #if defined ( XCP_ENABLE_CHECKSUM )
2317 |
2318 | /* Check configuration of kXcpChecksumMethod */
2319 | #if defined ( kXcpChecksumMethod )
2320 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD11 ) || \
2321 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD12 ) || \
2322 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD14 ) || \
2323 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD22 ) || \
2324 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD24 ) || \
2325 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD44 ) || \
2326 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_CRC32 ) || \
2327 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_CRC16CCITT )
2328 | #else
2329 | #error "XCP error: Checksum calculation method not supported."
2330 | #endif
2331 | #endif
2332 |
2333 | /* Check configuration of kXcpChecksumBlockSize. */
2334 | #if defined ( kXcpChecksumBlockSize )
2335 | #if ( kXcpChecksumBlockSize > 0xFFFF )
2336 | #error "XCP error: Checksum block size is limited to a maximum of 0xFFFF."
2337 | #endif
2338 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD22 ) || \
2339 | ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD24 )
2340 | #if ((kXcpChecksumBlockSize % 2) != 0 )
2341 | #error "XCP error: The blocksize must be modulo 2."
2342 | #endif
2343 | #endif
2344 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_ADD44 )
2345 | #if ((kXcpChecksumBlockSize % 4) != 0 )
2346 | #error "XCP error: The blocksize must be modulo 4."
2347 | #endif
2348 | #endif
2349 | #endif
2350 |
2351 | #if ( kXcpChecksumMethod == XCP_CHECKSUM_TYPE_CRC32 )
2352 | #error "XCP error: Checksum calculation method not supported."
2353 | #endif
2354 |
2355 | #endif /* defined ( XCP_ENABLE_CHECKSUM ) */
2356 |
2357 | #if defined ( XCP_ENABLE_DAQ_TIMESTAMP )
2358 |
2359 | /* Check configuration of kXcpDaqTimestampUnit. */
2360 |
2361 | #if defined ( kXcpDaqTimestampUnit )
2362 | #if ( (kXcpDaqTimestampUnit >> 4) > 9 ) || ( (kXcpDaqTimestampUnit & 0x0F) > 0 )
2363 | #error "XCP error: the value of kXcpDaqTimestampUnit is not valid."
2364 | #endif
2365 | #endif
2366 |
2367 | /* Check configuration of kXcpDaqTimestampTicksPerUnit. */
2368 |
2369 | #if defined ( kXcpDaqTimestampTicksPerUnit )
2370 | #if ( (kXcpDaqTimestampTicksPerUnit > 0xFFFF) || (kXcpDaqTimestampTicksPerUnit == 0) )
2371 | #error "XCP error: illegal range of kXcpDaqTimestampTicksPerUnit: 0 < kXcpDaqTimestampTicksPerUnit <= 0xFFFF."
2372 | #endif
2373 | #endif
2374 |
2375 | /* Check for configuration of kXcpDaqTimestampSize */
2376 | #if defined ( kXcpDaqTimestampSize )
2377 | #if ( kXcpDaqTimestampSize != DAQ_TIMESTAMP_BYTE ) && ( kXcpDaqTimestampSize != DAQ_TIMESTAMP_WORD ) && ( kXcpDaqTimestampSize != DAQ_TIMESTAMP_DWORD )
2378 | #error "XCP error: Please define kXcpDaqTimestampSize to either DAQ_TIMESTAMP_BYTE, DAQ_TIMESTAMP_WORD or DAQ_TIMESTAMP_DWORD"
2379 | #endif
2380 | #endif
2381 |
2382 | #endif
2383 |
2384 | /* Check range of service request kXcpMaxSegment. */
2385 |
2386 | #if defined ( XCP_ENABLE_PAGE_INFO )
2387 | #if defined ( kXcpMaxSegment )
2388 | #if ( ( kXcpMaxSegment > 0xFF ) || ( kXcpMaxSegment == 0x00 ) )
2389 | #error "XCP error: kXcpMaxSegment must be <= 0xFF and > 0x00."
2390 | #endif
2391 | #endif
2392 | #endif
2393 |
2394 | /* Check range of service request kXcpProgramMaxSector. */
2395 |
2396 |
2397 | /* Check if option MODIFY_BITS is valid */
2398 |
2399 |
2400 | #ifdef __cplusplus
2401 | }
2402 | #endif
2403 |
2404 | #endif /* ! defined ( __XCP_H_ ) */
2405 |
2406 |
--------------------------------------------------------------------------------
/XcpCfg.c:
--------------------------------------------------------------------------------
1 | #include "XcpCfg.h"
2 |
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | /*
9 | Bit
10 | 7: CONSISTENCY_DAQ
11 | 6: CONSISTENCY_EVENT
12 | 5: x
13 | 4: x
14 | 3: STIM
15 | 2: DAQ
16 | 1: x
17 | 0: x
18 | */
19 | vuint8 kXcpEventDirection[kXcpMaxEvent] = {
20 | 0b00000100, 0b00000100
21 | };
22 |
23 | vuint8 kXcpEventNameLength[kXcpMaxEvent] = {
24 | 5, 6
25 | };
26 |
27 | vuint8* kXcpEventName[kXcpMaxEvent] = {
28 | "10ms", "100ms"
29 | };
30 |
31 | vuint8 kXcpEventCycle[kXcpMaxEvent] = {
32 | 10, 100 /* unit: ms */
33 | };
34 |
35 | /*
36 | 0 0 0 0 EVENT_CHANNEL _TIME_UNIT_1NS 1 NS = 1 nanosecond = 10-9 second
37 | 0 0 0 1 EVENT_CHANNEL _TIME_UNIT_10NS
38 | 0 0 1 0 EVENT_CHANNEL _TIME_UNIT_100NS
39 | 0 0 1 1 EVENT_CHANNEL _TIME_UNIT_1US 1 US = 1 microsecond = 10-6 second
40 | 0 1 0 0 EVENT_CHANNEL _TIME_UNIT_10US
41 | 0 1 0 1 EVENT_CHANNEL _TIME_UNIT_100US
42 | 0 1 1 0 EVENT_CHANNEL _TIME_UNIT_1MS 1 MS = 1 millisecond = 10-3 second
43 | 0 1 1 1 EVENT_CHANNEL _TIME_UNIT_10MS
44 | 1 0 0 0 EVENT_CHANNEL _TIME_UNIT_100MS
45 | 1 0 0 1 EVENT_CHANNEL _TIME_UNIT_1S 1 S = 1 second = 1 second
46 | 1 0 1 0 EVENT_CHANNEL _TIME_UNIT_1PS 1 PS = 1 picosecond = 10-12 second
47 | 1 0 1 1 EVENT_CHANNEL _TIME_UNIT_10PS
48 | 1 1 0 0 EVENT_CHANNEL _TIME_UNIT_100PS
49 | */
50 | vuint8 kXcpEventUnit[kXcpMaxEvent] = {
51 | 6<<4, 6<<4
52 | };
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
--------------------------------------------------------------------------------
/XcpCfg.h:
--------------------------------------------------------------------------------
1 | /*----------------------------------------------------------------------------
2 | | Project: XCP_Delivery
3 | |
4 | | Description: Implementation of the XCP Protocol Layer
5 | | XCP V1.0 slave device driver
6 | | Basic Version
7 | |
8 | |-----------------------------------------------------------------------------
9 | | Copyright (c) by Vector Informatik GmbH. All rights reserved.
10 | ----------------------------------------------------------------------------*/
11 |
12 | #if !defined(__XCP_CFG_H__)
13 | #define __XCP_CFG_H__
14 |
15 | #include "Arduino.h"
16 |
17 | /* define here configuration parameters for customizing XcpBasic driver */
18 |
19 | #ifdef __cplusplus
20 | extern "C" {
21 | #endif
22 |
23 | #define vuint8 unsigned char /* Unsigned 8-bit identifier */
24 | #define vuint16 unsigned short /* Unsigned 16-bit identifier */
25 | #define vuint32 unsigned long /* Unsigned 32-bit identifier */
26 |
27 | /* ROM memory qualifiers */
28 | #if !defined(MEMORY_ROM)
29 | #define MEMORY_ROM const
30 | #endif
31 | #if !defined(V_MEMROM0)
32 | #define V_MEMROM0
33 | #endif
34 | #if !defined(MEMORY_CONST)
35 | #define MEMORY_CONST
36 | #endif
37 |
38 |
39 | /* General settings */
40 |
41 | #define XCP_ENABLE_PARAMETER_CHECK
42 | #define XCP_ENABLE_CALIBRATION
43 | #define XCP_DISABLE_SEND_EVENT
44 | #define XCP_DISABLE_TESTMODE
45 | #define XCP_DISABLE_BOOTLOADER_DOWNLOAD
46 | #define XCP_DISABLE_WRITE_PROTECTION
47 | #define XCP_DISABLE_READ_PROTECTION
48 | #define XCP_DISABLE_CONTROL
49 | #define XCP_DISABLE_GET_XCP_DATA_POINTER
50 | #define XCP_DISABLE_OPENCMDIF
51 |
52 | #define XCP_CPUTYPE_LITTLEENDIAN
53 |
54 | /* EEPROM access */
55 | #define XCP_DISABLE_READ_EEPROM
56 | #define XCP_DISABLE_WRITE_EEPROM
57 |
58 | /* Service request message */
59 | #define XCP_DISABLE_SERV_TEXT
60 | #define XCP_DISABLE_SERV_TEXT_PUTCHAR
61 | #define XCP_DISABLE_SERV_TEXT_PRINTF
62 | #define XCP_DISABLE_SERV_TEXT_PRINT
63 |
64 | /* Standard commands */
65 | #define XCP_ENABLE_COMM_MODE_INFO
66 | #define XCP_DISABLE_SEED_KEY
67 | #define XCP_DISABLE_MODIFY_BITS
68 | #define XCP_DISABLE_SHORT_DOWNLOAD
69 | #define XCP_DISABLE_USER_COMMAND
70 | #define XCP_DISABLE_VECTOR_MAPNAMES
71 | #define XCP_DISABLE_TL_COMMAND
72 |
73 | /* Block transfer */
74 | #define XCP_DISABLE_BLOCK_UPLOAD
75 | #define XCP_DISABLE_BLOCK_DOWNLOAD
76 |
77 | /* Checksum */
78 | #define XCP_DISABLE_CHECKSUM
79 |
80 | /* Synchronous Data Acquisition (DAQ) */
81 | #define XCP_ENABLE_DAQ
82 | #define kXcpDaqMemSize 256
83 | #define XCP_DISABLE_STIM
84 | #define XCP_DISABLE_UNALIGNED_MEM_ACCESS
85 | #define XCP_ENABLE_SEND_QUEUE
86 | #define XCP_DISABLE_DAQ_PRESCALER
87 | #define XCP_ENABLE_DAQ_OVERRUN_INDICATION
88 | #define XCP_DISABLE_WRITE_DAQ_MULTIPLE
89 | #define XCP_DISABLE_DAQ_HDR_ODT_DAQ
90 | #define XCP_DISABLE_DAQ_RESUME
91 | #define XCP_ENABLE_DAQ_PROCESSOR_INFO
92 | #define XCP_ENABLE_DAQ_RESOLUTION_INFO
93 | #define XCP_SEND_QUEUE_SAMPLE_ODT
94 |
95 | /* Events */
96 | #define XCP_ENABLE_DAQ_EVENT_INFO
97 |
98 | /* DAQ Timestamp */
99 | #define XCP_DISABLE_DAQ_TIMESTAMP
100 | #define XCP_DISABLE_DAQ_TIMESTAMP_FIXED
101 |
102 | /* Page switching */
103 | #define XCP_DISABLE_CALIBRATION_PAGE
104 |
105 | /* Programming */
106 | #define XCP_DISABLE_PROGRAM
107 |
108 | #define CP_XCPDLL_VERSION 0x0213u
109 | #define CP_XCPDLL_RELEASE_VERSION 0x03u
110 |
111 | /* Transport Layer */
112 | #define kXcpNumberOfCanChannels 1
113 | #define XCP_DISABLE_MULTI_CHANNEL
114 | #define XCP_DISABLE_MULTI_CONNECTION_PROTECTION
115 | #define XCP_TRANSPORT_LAYER_VERSION 0x0100u
116 | #define XCP_DISABLE_VARIABLE_DLC
117 | #define kXcpSendQueueMinSize 1
118 | // #define XCP_ENABLE_COMM_MODE_INFO
119 | // #define XCP_DISABLE_USER_COMMAND
120 | // #define XCP_DISABLE_BLOCK_UPLOAD
121 | // #define XCP_DISABLE_SEND_EVENT
122 | // #define XCP_DISABLE_SERV_TEXT
123 | // #define XCP_DISABLE_SERV_TEXT_PRINT
124 | // #define XCP_DISABLE_SERV_TEXT_PUTCHAR
125 | // #define XCP_DISABLE_CALIBRATION_PAGE
126 |
127 | // #define XCP_ENABLE_DAQ
128 | // #define XCP_ENABLE_SEND_QUEUE
129 | // #define XCP_ENABLE_DAQ_PROCESSOR_INFO
130 | // #define XCP_ENABLE_DAQ_RESOLUTION_INFO
131 | // #define XCP_DISABLE_DAQ_PRESCALER
132 | // #define XCP_ENABLE_DAQ_OVERRUN_INDICATION
133 | // #define XCP_DISABLE_DAQ_RESUME
134 | // #define XCP_DISABLE_DAQ_HDR_ODT_DAQ
135 |
136 |
137 | #define ApplXcpInterruptDisable noInterrupts
138 | #define ApplXcpInterruptEnable interrupts
139 | #define ApplXcpSendFlush()
140 | #define ApplXcpBackground()
141 |
142 | /* XCP message length */
143 | #define kXcpMaxCTO 14 /* Maximum CTO Message Length */
144 | #define kXcpMaxDTO 14 /* Maximum DTO Message Length */
145 |
146 | #ifdef XCP_ENABLE_DAQ_EVENT_INFO
147 | #define kXcpMaxEvent 2
148 | extern vuint8 kXcpEventDirection[kXcpMaxEvent];
149 | extern vuint8 kXcpEventNameLength[kXcpMaxEvent];
150 | extern vuint8 kXcpEventCycle[kXcpMaxEvent];
151 | extern vuint8 kXcpEventUnit[kXcpMaxEvent];
152 | extern vuint8* kXcpEventName[kXcpMaxEvent];
153 | #endif
154 |
155 | #ifdef __cplusplus
156 | }
157 | #endif
158 |
159 | #endif /* __XCP_CFG_H__ */
160 |
--------------------------------------------------------------------------------
/XcpSxIMaster.cpp:
--------------------------------------------------------------------------------
1 | #include "XcpSxIMaster.h"
2 | #include "XcpBasic.h"
3 | #include "Arduino.h"
4 |
5 | #define SLIP_SYNC 0x9A
6 | #define SLIP_ESC 0x9B
7 | #define ESC_SYNC 1
8 | #define ESC_ESC 0
9 |
10 |
11 | XcpSxIMaster::XcpSxIMaster(unsigned long baudrate)
12 | {
13 | baudrate = baudrate;
14 | Serial.begin(baudrate);
15 | }
16 |
17 | void XcpSxIMaster::Init()
18 | {
19 | XcpInit();
20 | }
21 |
22 | void XcpSxIMaster::Event(unsigned char event)
23 | {
24 | XcpEvent(event);
25 | }
26 |
27 | void XcpSxIMaster::BackgroudTask()
28 | {
29 | static char bOld;
30 | static bool sync = false;
31 |
32 | while (Serial.available())
33 | {
34 | char b = Serial.read();
35 | // SlipMode
36 | // A new packet always starts with a SYNC
37 | if (!sync)
38 | {
39 | if (b < 0)
40 | continue;
41 | if (b != SLIP_SYNC)
42 | continue; // Skip this byte
43 | sync = 1;
44 | bufIdx = 0;
45 | bOld = 0;
46 | }
47 | else
48 | {
49 | if (b == SLIP_SYNC)
50 | {
51 | sync = 1;
52 | bufIdx = 0;
53 | bOld = 0;
54 | continue; // SYNC shall be replaced by ESC+ESC_SYNC
55 | }
56 | else if (bOld == SLIP_ESC)
57 | {
58 | bOld = 0;
59 | if (b == ESC_SYNC)
60 | {
61 | buf[bufIdx] = SLIP_SYNC;
62 | bufIdx++;
63 | }
64 | else if (b == ESC_ESC)
65 | {
66 | buf[bufIdx] = SLIP_ESC;
67 | bufIdx++;
68 | }
69 | else
70 | {
71 | // it's wrong, discard entire packet
72 | sync = 0;
73 | bufIdx = 0;
74 | }
75 | continue;
76 | }
77 | else if ((b == SLIP_ESC) && (bufIdx > 0) && (bufIdx <= buf[0] + 1))
78 | {
79 | // framing machanism only used in data field
80 | bOld = b;
81 | continue;
82 | }
83 | else
84 | {
85 | // Save this byte
86 | buf[bufIdx] = b;
87 | unsigned char len = buf[0]; // buf[0] always is the packet length
88 | bufIdx++;
89 |
90 | // Check if this is a valid packet
91 | if (len == 0)
92 | {
93 | sync = 0;
94 | bufIdx = 0;
95 | }
96 |
97 | // Check if the packet is complete
98 | if (bufIdx <= len + 1)
99 | {
100 | continue;
101 | }
102 |
103 | // Verify checksum
104 | unsigned char cs = len;
105 | for (unsigned char i = 0; i < len; i++)
106 | cs += buf[i + 1];
107 | if (cs != buf[bufIdx - 1])
108 | {
109 | // Checksum error
110 | sync = 0;
111 | bufIdx = 0;
112 | continue;
113 | }
114 |
115 | // Return the packet
116 | sync = 0;
117 | bufIdx = 0;
118 | XcpCommand((unsigned long *)&buf[1]);
119 | }
120 | }
121 | }
122 |
123 | XcpBackground();
124 | XcpSendCallBack();
125 | }
126 |
127 | extern "C"
128 | {
129 |
130 | unsigned char TransmitSlipByte(unsigned char b)
131 | {
132 | /* NOTE: If the transmit buffer is full then Serial.write() will block until there is enough space in the buffer.*/
133 | switch (b)
134 | {
135 | case SLIP_ESC:
136 | return Serial.write(SLIP_ESC) && Serial.write(0x00);
137 | case SLIP_SYNC:
138 | return Serial.write(SLIP_ESC) && Serial.write(0x01);
139 | default:
140 | return Serial.write(b);
141 | }
142 | }
143 |
144 | // Transmit a XCP packet
145 | // Called by the XCP driver
146 | void ApplXcpSend(unsigned char len, const unsigned char * pMsg)
147 | {
148 | unsigned char b, checksum, i, len1;
149 | const unsigned char * pData = pMsg;
150 | if (len==0||len>kXcpMaxDTO) return; // should not happen
151 | if (!Serial.write(SLIP_SYNC)) return; // Each packet begins with SYNC
152 |
153 | len1 = len;
154 | for (i = 0; i < len; i++)
155 | {
156 | b = *pData++;
157 | if (b == SLIP_SYNC || b == SLIP_ESC)
158 | {
159 | len1++;
160 | }
161 | }
162 |
163 | if (!Serial.write(len1)) return;
164 |
165 | checksum = len1;
166 | while (len--)
167 | {
168 | b = *pMsg++;
169 | switch (b)
170 | {
171 | case SLIP_SYNC:
172 | checksum += SLIP_ESC + ESC_SYNC;
173 | break;
174 | case SLIP_ESC:
175 | checksum += SLIP_ESC + ESC_ESC;
176 | break;
177 | default:
178 | checksum += b;
179 | break;
180 | }
181 | if (!TransmitSlipByte(b)) return;
182 | }
183 | if (!Serial.write(checksum)) return;
184 |
185 | return;
186 | }
187 |
188 | //------------------------------------------------------------------------------
189 | // Platform dependend functions
190 |
191 | // Convert a XCP address to a pointer
192 | unsigned char * ApplXcpGetPointer(unsigned char addr_ext, unsigned long addr)
193 | {
194 | addr_ext = addr_ext;
195 | return (unsigned char *)addr;
196 | }
197 |
198 | }
199 |
--------------------------------------------------------------------------------
/XcpSxIMaster.h:
--------------------------------------------------------------------------------
1 | #ifndef XCP_SXI_MASTER_H
2 | #define XCP_SXI_MASTER_H
3 |
4 | #include "XcpCfg.h"
5 |
6 | class XcpSxIMaster
7 | {
8 | private:
9 | /* data */
10 | unsigned long baudrate;
11 | unsigned char buf[kXcpMaxCTO+2]; // + Header + Checksum
12 | unsigned char bufIdx;
13 |
14 | public:
15 | XcpSxIMaster(unsigned long baudrate);
16 |
17 | void Init();
18 | void Event(unsigned char event);
19 | void BackgroudTask();
20 | };
21 |
22 | extern "C"
23 | {
24 |
25 | extern void ApplXcpSend(unsigned char len, const unsigned char * const pMsg);
26 | extern unsigned char * ApplXcpGetPointer(unsigned char addr_ext, unsigned long addr);
27 |
28 | }
29 |
30 |
31 | #endif
--------------------------------------------------------------------------------
/demo.ino:
--------------------------------------------------------------------------------
1 | #if CONFIG_FREERTOS_UNICORE
2 | #define ARDUINO_RUNNING_CORE 0
3 | #else
4 | #define ARDUINO_RUNNING_CORE 1
5 | #endif
6 |
7 | #ifndef LED_BUILTIN
8 | #define LED_BUILTIN 13
9 | #endif
10 |
11 | #include "XcpSxIMaster.h"
12 |
13 | #define XCP_EVENT_10MS 0
14 | #define XCP_EVENT_100MS 1
15 |
16 | XcpSxIMaster xcpMaster = XcpSxIMaster(115200);
17 | unsigned char amplifier = 10;
18 | double sig = 0.0;
19 |
20 | // define two tasks for Blink & AnalogRead
21 | void TaskBlink( void *pvParameters );
22 | void TaskAnalogReadA3( void *pvParameters );
23 |
24 | // the setup function runs once when you press reset or power the board
25 | void setup() {
26 |
27 | // Now set up two tasks to run independently.
28 | xTaskCreatePinnedToCore(
29 | TaskBlink
30 | , "TaskBlink" // A name just for humans
31 | , 1024 // This stack size can be checked & adjusted by reading the Stack Highwater
32 | , NULL
33 | , 2 // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
34 | , NULL
35 | , ARDUINO_RUNNING_CORE);
36 |
37 | // Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.
38 | }
39 |
40 | void loop()
41 | {
42 | xcpMaster.BackgroudTask();
43 | }
44 |
45 | /*--------------------------------------------------*/
46 | /*---------------------- Tasks ---------------------*/
47 | /*--------------------------------------------------*/
48 |
49 | void TaskBlink(void *pvParameters) // This is a task.
50 | {
51 | (void) pvParameters;
52 | static bool on = true;
53 | static unsigned char i = 0;
54 |
55 | /*
56 | Blink
57 | Turns on an LED on for one second, then off for one second, repeatedly.
58 |
59 | If you want to know what pin the on-board LED is connected to on your ESP32 model, check
60 | the Technical Specs of your board.
61 | */
62 |
63 | // initialize digital LED_BUILTIN on pin 13 as an output.
64 | pinMode(LED_BUILTIN, OUTPUT);
65 |
66 | TickType_t xLastWakeTime = xTaskGetTickCount();
67 | for (;;) // A Task shall never return or exit.
68 | {
69 | vTaskDelayUntil(&xLastWakeTime, 100/portTICK_PERIOD_MS);
70 | sig = amplifier * sin(i*2*3.14159/20);
71 | if (++i == 20)
72 | {
73 | i = 0;
74 | }
75 | xcpMaster.Event(XCP_EVENT_100MS);
76 | digitalWrite(LED_BUILTIN, on ? HIGH: LOW);
77 | on = !on;
78 | }
79 | }
80 |
81 |
--------------------------------------------------------------------------------