Kinetis SDK v.1.2 Demo Applications User's Guide  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
freemaster_private.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Freescale Semiconductor Inc.
4 * (c) Copyright 2004-2010 Freescale Semiconductor
5 * ALL RIGHTS RESERVED.
6 *
7 ****************************************************************************/
19 #ifndef __FREEMASTER_PRIVATE_H
20 #define __FREEMASTER_PRIVATE_H
21 
22 #ifndef __FREEMASTER_H
23 #error Please include the freemaster.h master header file before the freemaster_private.h
24 #endif
25 
26 //#include "freemaster.h"
27 #include "freemaster_cfg.h"
28 
29 #if FMSTR_USE_MQX_IO
30  /* include MQX headers */
31  #include <mqx.h>
32  #include <bsp.h>
33 #endif
34 
35 
36 /******************************************************************************
37 * Platform-dependent types, macros and functions
38 ******************************************************************************/
39 
40 #undef FMSTR_PLATFORM
41 
42 /* platform macro FMSTR_PLATFORM_xxxxxxx should be defined */
43 /* as "non-zero" in the "freemaster.h" file */
44 
45 #if defined(FMSTR_PLATFORM_56F8xx)
46  #if FMSTR_PLATFORM_56F8xx
47  #include "freemaster_56F8xx.h"
48  #define FMSTR_PLATFORM 56F8xx
49  #else
50  #undef FMSTR_PLATFORM_56F8xx
51  #endif
52 #endif
53 
54 #if defined(FMSTR_PLATFORM_56F8xxx)
55  #if FMSTR_PLATFORM_56F8xxx
56  #include "freemaster_56F8xxx.h"
57  #define FMSTR_PLATFORM 56F8xxx
58  #else
59  #undef FMSTR_PLATFORM_56F8xxx
60  #endif
61 #endif
62 
63 #if defined(FMSTR_PLATFORM_HC12)
64  #if FMSTR_PLATFORM_HC12
65  #include "freemaster_HC12.h"
66  #define FMSTR_PLATFORM HC12
67  #else
68  #undef FMSTR_PLATFORM_HC12
69  #endif
70 #endif
71 
72 #if defined(FMSTR_PLATFORM_HC08)
73  #if FMSTR_PLATFORM_HC08
74  #include "freemaster_HC08.h"
75  #define FMSTR_PLATFORM HC08
76  #else
77  #undef FMSTR_PLATFORM_HC08
78  #endif
79 #endif
80 
81 #if defined(FMSTR_PLATFORM_MPC55xx)
82  #if FMSTR_PLATFORM_MPC55xx
83  #include "freemaster_MPC55xx.h"
84  #define FMSTR_PLATFORM MPC55xx
85  #else
86  #undef FMSTR_PLATFORM_MPC55xx
87  #endif
88 #endif
89 
90 #if defined(FMSTR_PLATFORM_MPC5xx)
91  #if FMSTR_PLATFORM_MPC5xx
92  #include "freemaster_MPC5xx.h"
93  #define FMSTR_PLATFORM MPC5xx
94  #else
95  #undef FMSTR_PLATFORM_MPC5xx
96  #endif
97 #endif
98 
99 #if defined(FMSTR_PLATFORM_MCF51xx)
100  #if FMSTR_PLATFORM_MCF51xx
101  #include "freemaster_MCF51xx.h"
102  #define FMSTR_PLATFORM MCF51xx
103  #else
104  #undef FMSTR_PLATFORM_MCF51xx
105  #endif
106 #endif
107 
108 #if defined(FMSTR_PLATFORM_MCF52xx)
109  #if FMSTR_PLATFORM_MCF52xx
110  #include "freemaster_MCF52xx.h"
111  #define FMSTR_PLATFORM MCF52xx
112  #else
113  #undef FMSTR_PLATFORM_MCF52xx
114  #endif
115 #endif
116 
117 #if defined(FMSTR_PLATFORM_MPC56xx)
118  #if FMSTR_PLATFORM_MPC56xx
119  #include "freemaster_MPC56xx.h"
120  #define FMSTR_PLATFORM MPC56xx
121  #else
122  #undef FMSTR_PLATFORM_MPC56xx
123  #endif
124 #endif
125 
126 #if defined(FMSTR_PLATFORM_MQX)
127  #if FMSTR_PLATFORM_MQX
128  #include "freemaster_MQX.h"
129  #define FMSTR_PLATFORM MQX
130  #else
131  #undef FMSTR_PLATFORM_MQX
132  #endif
133 #endif
134 
135 #if defined(FMSTR_PLATFORM_KXX)
136  #if FMSTR_PLATFORM_KXX
137  #include "freemaster_Kxx.h"
138  #define FMSTR_PLATFORM KXX
139  #else
140  #undef FMSTR_PLATFORM_KXX
141  #endif
142 #endif
143 
144 #ifndef FMSTR_PLATFORM
145 #error Unknown FreeMASTER driver platform
146 #endif
147 
148 /******************************************************************************
149 * NULL needed
150 ******************************************************************************/
151 
152 #ifndef NULL
153 #define NULL ((void *) 0)
154 #endif
155 
156 /******************************************************************************
157 * Boolean values
158 ******************************************************************************/
159 
160 #ifndef FMSTR_TRUE
161 #define FMSTR_TRUE (1U)
162 #endif
163 
164 #ifndef FMSTR_FALSE
165 #define FMSTR_FALSE (0U)
166 #endif
167 
168 /******************************************************************************
169 * CAN-related constants
170 ******************************************************************************/
171 
172 #ifdef FMSTR_CAN_EXTID
173 #if FMSTR_CAN_EXTID != 0x80000000U
174 #error FMSTR_CAN_EXTID must be defined as 0x80000000
175 #undef FMSTR_CAN_EXTID
176 #endif
177 #endif
178 
179 #ifndef FMSTR_CAN_EXTID
180 #define FMSTR_CAN_EXTID 0x80000000U
181 #endif
182 
183 /******************************************************************************
184 * inline functions
185 ******************************************************************************/
186 
187 /* we do not assume the inline is always supported by compiler
188  rather each platform header defines its FMSTR_INLINE */
189 #ifndef FMSTR_INLINE
190 #define FMSTR_INLINE static
191 #endif
192 
193 /* building macro-based inline code */
194 #define FMSTR_MACROCODE_BEGIN() do{
195 #define FMSTR_MACROCODE_END() }while(0)
196 
197 /******************************************************************************
198 * Global non-API functions (used internally in FreeMASTER driver)
199 ******************************************************************************/
200 
201 void FMSTR_InitSerial(void);
203 void FMSTR_SendResponse(FMSTR_BPTR pMessageIO, FMSTR_SIZE8 nLength);
204 void FMSTR_ProcessSCI(void);
205 void FMSTR_ProcessJTAG(void);
206 
209 
216 
217 void FMSTR_InitAppCmds(void);
221 
222 void FMSTR_InitScope(void);
225 
226 void FMSTR_InitRec(void);
234 
235 void FMSTR_InitTsa(void);
240 
241 void FMSTR_InitSfio(void);
244 
245 void FMSTR_InitPipes(void);
247 
248 void FMSTR_InitCan(void);
249 void FMSTR_SetCanCmdID(FMSTR_U32 canID);
250 void FMSTR_SetCanRespID(FMSTR_U32 canID);
251 FMSTR_BOOL FMSTR_TxCan(void);
252 FMSTR_BOOL FMSTR_RxCan(void);
253 void FMSTR_ProcessCanRx(void);
254 void FMSTR_ProcessCanTx(void);
255 
256 /****************************************************************************************
257 * Potentialy unused variable declaration
258 *****************************************************************************************/
259 
260 #ifdef _lint
261 #define FMSTR_UNUSED(sym) /*lint -esym(715,sym) -esym(818,sym) -esym(529,sym) -e{960} */
262 #else
263 #define FMSTR_UNUSED(sym) ((sym),0)
264 #endif
265 
266 /******************************************************************************
267 * Configuration check
268 ******************************************************************************/
269 
270 /* polling mode as default when nothing selected */
271 #if !defined(FMSTR_POLL_DRIVEN) && !defined(FMSTR_LONG_INTR) && !defined(FMSTR_SHORT_INTR)
272  #define FMSTR_LONG_INTR 0
273  #define FMSTR_SHORT_INTR 0
274  #define FMSTR_POLL_DRIVEN 1
275 #endif
276 
277 /* otherwise, "undefined" means false for all three options */
278 #ifndef FMSTR_POLL_DRIVEN
279 #define FMSTR_POLL_DRIVEN 0
280 #endif
281 #ifndef FMSTR_LONG_INTR
282 #define FMSTR_LONG_INTR 0
283 #endif
284 #ifndef FMSTR_SHORT_INTR
285 #define FMSTR_SHORT_INTR 0
286 #endif
287 
288 #if (FMSTR_LONG_INTR && (FMSTR_SHORT_INTR || FMSTR_POLL_DRIVEN)) || \
289  (FMSTR_SHORT_INTR && (FMSTR_LONG_INTR || FMSTR_POLL_DRIVEN)) || \
290  (FMSTR_POLL_DRIVEN && (FMSTR_LONG_INTR || FMSTR_SHORT_INTR)) || \
291  !(FMSTR_POLL_DRIVEN || FMSTR_LONG_INTR || FMSTR_SHORT_INTR)
292  /* mismatch in interrupt modes, only one can be selected */
293  #error You have to enable exctly one of FMSTR_LONG_INTR or FMSTR_SHORT_INTR or FMSTR_POLL_DRIVEN
294 #endif
295 
296 #if FMSTR_SHORT_INTR
297  /* default short-interrupt FIFO size */
298  #ifndef FMSTR_COMM_RQUEUE_SIZE
299  #define FMSTR_COMM_RQUEUE_SIZE 32
300  #endif
301 
302  #if !FMSTR_COMM_RQUEUE_SIZE
303  #undef FMSTR_COMM_RQUEUE_SIZE
304  #define FMSTR_COMM_RQUEUE_SIZE 32
305  #endif
306 
307  #if FMSTR_COMM_RQUEUE_SIZE < 1
308  #error Error in FMSTR_COMM_RQUEUE_SIZE value.
309  #endif
310 #endif
311 
312 /* select JTAG, SCI or CAN interface */
313 /* one of these is typically already enabled in freemaster_cfg.h */
314 #ifndef FMSTR_USE_JTAG
315 #define FMSTR_USE_JTAG 0
316 #endif
317 
318 #ifndef FMSTR_USE_MSCAN
319  #define FMSTR_USE_MSCAN 0
320 #endif
321 
322 #ifndef FMSTR_USE_FLEXCAN
323  #define FMSTR_USE_FLEXCAN 0
324 #endif
325 
326 #ifndef FMSTR_USE_CAN
327  #if ((FMSTR_USE_MSCAN) || (FMSTR_USE_FLEXCAN))
328  #define FMSTR_USE_CAN 1
329  #else
330  #define FMSTR_USE_CAN 0
331  #endif
332 #endif
333 
334 #ifndef FMSTR_USE_MQX_IO
335  #define FMSTR_USE_MQX_IO 0
336 #endif
337 
338 /* SCI used by default if BASE address is provided */
339 #ifndef FMSTR_USE_SCI
340  #if defined(FMSTR_SCI_BASE) && !FMSTR_USE_JTAG && !FMSTR_USE_CAN && !FMSTR_USE_MQX_IO
341  #define FMSTR_USE_SCI 1
342  #else
343  #define FMSTR_USE_SCI 0
344  #endif
345 #endif
346 
347 /* only one communication link may be selected */
348 #if ((((FMSTR_USE_SCI)?1:0) + ((FMSTR_USE_JTAG)?1:0) + ((FMSTR_USE_CAN)?1:0)) > 1)
349 #error More than one communication interface selected for FreeMASTER driver
350 #endif
351 
352 /* SCI does not have a transmission double buffer (kind of queue) */
353 /* (if not specified differently in platform-dependent header file) */
354 #if FMSTR_USE_SCI
355  #ifndef FMSTR_SCI_BASE
356  #error FMSTR_SCI_BASE must be defined when using SCI interface
357  #endif
358 
359  #ifndef FMSTR_SCI_HAS_TXQUEUE
360  #define FMSTR_SCI_HAS_TXQUEUE 0
361  #endif
362 
363  #ifndef FMSTR_SCI_TE_RE
364  #define FMSTR_SCI_TE_RE() do {FMSTR_SCI_TE(); FMSTR_SCI_RE();} while(0)
365  #endif
366 
367 #endif
368 
369 /* CAN is MSCAN or FLEXCAN */
370 #if FMSTR_USE_CAN
371 
372  /* if CANHW is not specified in freemaster.h, the platform is not yet tested with CAN */
373  #if (!defined(FMSTR_CANHW_MSCAN)) && FMSTR_USE_MSCAN
374  #warning MSCAN support not yet fully tested on this platform
375  #endif
376 
377  /* if CANHW is not specified in freemaster.h, the platform is not yet tested with CAN */
378  #if (!defined(FMSTR_CANHW_FLEXCAN)) && FMSTR_USE_FLEXCAN
379  #warning FlexCAN support not yet fully tested on this platform
380  #endif
381 
382 
383  #ifndef FMSTR_CAN_BASE
384  #error FMSTR_CAN_BASE must be defined when is using CAN interface
385  #endif
386 
387  /* can't be both*/
388  #if (FMSTR_USE_MSCAN) && (FMSTR_USE_FLEXCAN)
389  #error Can not configure FreeMASTER to use both MSCAN and FlexCAN
390  #endif
391 
392  /* should be at least one */
393  #if !(FMSTR_USE_MSCAN) && !(FMSTR_USE_FLEXCAN)
394  #error Please select if MSCAN or FlexCAN will be used
395  #endif
396 
397  /* flexcan needs to know the transmit and receive MB number */
398  #if FMSTR_USE_FLEXCAN
399  /* Flexcan TX message buffer must be defined */
400  #ifndef FMSTR_FLEXCAN_TXMB
401  //#error FlexCAN transmit buffer needs to be specified (use FMSTR_FLEXCAN_TXMB)
402  #warning FlexCAN Message Buffer 0 is used for transmit messages
403  #define FMSTR_FLEXCAN_TXMB 0
404  #endif
405  /* Flexcan RX message buffer must be defined */
406  #ifndef FMSTR_FLEXCAN_RXMB
407  //#error FlexCAN receive buffer needs to be specified (use FMSTR_FLEXCAN_RXMB)
408  #warning FlexCAN Message Buffer 1 is used for receive messages
409  #define FMSTR_FLEXCAN_RXMB 1
410  #endif
411 
412  #if FMSTR_FLEXCAN_TXMB == FMSTR_FLEXCAN_RXMB
413  #warning FCAN RX and FCAN TX are using same Message Buffer. FreeMASTER CAN driver doesnt support this configuration. Please change number of Message Buffer in FMSTR_FLEXCAN_TXMB or FMSTR_FLEXCAN_RXMB macros.
414  #endif
415  #endif
416 
417 
418  /* incoming (command) CAN message ID */
419  #ifndef FMSTR_CAN_CMDID
420  #define FMSTR_CAN_CMDID 0x7aa
421  #endif
422 
423  /* command ID can be changed in runtime (before FMSTR_Init) */
424  #ifndef FMSTR_CAN_CMDID_DYNAMIC
425  #define FMSTR_CAN_CMDID_DYNAMIC 0 /* disabled by default */
426  #endif
427 
428  /* response CAN message ID, may be the same as command ID */
429  #ifndef FMSTR_CAN_RESPID
430  #define FMSTR_CAN_RESPID 0x7aa
431  #endif
432 
433  /* response ID can be changed in runtime (before FMSTR_Init) */
434  #ifndef FMSTR_CAN_RESPID_DYNAMIC
435  #define FMSTR_CAN_RESPID_DYNAMIC 0 /* disabled by default */
436  #endif
437 
438 #endif
439 
440 /* MQX communication interface warnings and errors */
441 #if FMSTR_USE_MQX_IO
442 
443  /* define FreeMASTER IO Channel */
444  #ifndef FMSTR_MQX_IO_CHANNEL
445  #warning MQX IO Channel is not defined by FMSTR_MQX_IO_CHANNEL macro, FreeMASTER use "ttya:" IO Channel
446  #define FMSTR_MQX_IO_CHANNEL "ttya:"
447  #endif
448 
449  /* configure the FreeMASTER communication channel to non blocking mode */
450  #ifndef FMSTR_MQX_IO_BLOCKING
451  #warning FMSTR_MQX_IO_BLOCKING macro is not defined, the MQX IO Channel will be open in non blocking mode
452  #define FMSTR_MQX_IO_BLOCKING 0
453  #endif
454 
455  /* MQX open port paramters */
456  #if FMSTR_MQX_IO_BLOCKING
457  #define FMSTR_MQX_IO_PARAMETER 0
458  #else
459  #define FMSTR_MQX_IO_PARAMETER IO_SERIAL_NON_BLOCKING
460  #endif
461 
462  /* MQX doesn't supports Long interrupt and Short interrupt */
463  #if FMSTR_LONG_INTR
464  #warning MQX target driver doesn't supports the Long Interrupt routines
465  #elif FMSTR_SHORT_INTR
466  #warning MQX target driver doesn't supports the normal Short Interrupt routines, please open your MQX communication interface in Interrupt mode
467  #endif
468 
469 
470 #endif
471 
472 #if FMSTR_PLATFORM_MQX
473  #if FMSTR_USE_SCI
474  #error MQX target driver doesn't supports the SCI module as communication interface
475  #elif FMSTR_USE_CAN
476  #error MQX target driver doesn't supports the CAN module as communication interface
477  #elif FMSTR_USE_JTAG
478  #error MQX target driver doesn't supports the JTAG module as communication interface
479  #endif
480 #endif
481 
482 /* read memory commands are ENABLED by default */
483 #ifndef FMSTR_USE_READMEM
484 #define FMSTR_USE_READMEM 1
485 #endif
486 #ifndef FMSTR_USE_WRITEMEM
487 #define FMSTR_USE_WRITEMEM 1
488 #endif
489 #ifndef FMSTR_USE_WRITEMEMMASK
490 #define FMSTR_USE_WRITEMEMMASK 1
491 #endif
492 
493 /* read variable commands are DISABLED by default */
494 #ifndef FMSTR_USE_READVAR
495 #define FMSTR_USE_READVAR 0
496 #endif
497 #ifndef FMSTR_USE_WRITEVAR
498 #define FMSTR_USE_WRITEVAR 0
499 #endif
500 #ifndef FMSTR_USE_WRITEVARMASK
501 #define FMSTR_USE_WRITEVARMASK 0
502 #endif
503 
504 /* default scope settings */
505 #ifndef FMSTR_USE_SCOPE
506 #define FMSTR_USE_SCOPE 0
507 #endif
508 
509 #ifndef FMSTR_MAX_SCOPE_VARS
510 #define FMSTR_MAX_SCOPE_VARS 8
511 #endif
512 
513 /* check scope settings */
514 #if FMSTR_USE_SCOPE
515  #if FMSTR_MAX_SCOPE_VARS > 8 || FMSTR_MAX_SCOPE_VARS < 2
516  #error Error in FMSTR_MAX_SCOPE_VARS value. Use a value in range 2..8
517  #endif
518 #endif
519 
520 /* default recorder settings */
521 #ifndef FMSTR_USE_RECORDER
522 #define FMSTR_USE_RECORDER 0
523 #endif
524 
525 #ifndef FMSTR_MAX_REC_VARS
526 #define FMSTR_MAX_REC_VARS 8
527 #endif
528 
529 #ifndef FMSTR_REC_FARBUFF
530 #define FMSTR_REC_FARBUFF 0
531 #endif
532 
533 #ifndef FMSTR_REC_OWNBUFF
534 #define FMSTR_REC_OWNBUFF 0
535 #endif
536 
537 #ifndef FMSTR_USE_FASTREC
538 #define FMSTR_USE_FASTREC 0
539 #endif
540 
541 /* Enable code size optimalization */
542 #ifndef FMSTR_LIGHT_VERSION
543 #define FMSTR_LIGHT_VERSION 0
544 #endif
545 
546 /* Always report sigle error code from recorder routines */
547 #ifndef FMSTR_REC_COMMON_ERR_CODES
548 #define FMSTR_REC_COMMON_ERR_CODES FMSTR_LIGHT_VERSION
549 #endif
550 
551 /* Remove code for single wire communication */
552 #ifndef FMSTR_SCI_TWOWIRE_ONLY
553 #define FMSTR_SCI_TWOWIRE_ONLY FMSTR_LIGHT_VERSION
554 #endif
555 
556 /* Number of recorder post-trigger samples is by default controlled by PC */
557 #ifndef FMSTR_REC_STATIC_POSTTRIG
558 #define FMSTR_REC_STATIC_POSTTRIG 0
559 #endif
560 
561 /* Recorder divisor is by default controlled by PC */
562 #ifndef FMSTR_REC_STATIC_DIVISOR
563 #define FMSTR_REC_STATIC_DIVISOR 0
564 #endif
565 
566 /* check recorder settings */
567 #if FMSTR_USE_RECORDER || FMSTR_USE_FASTREC
568  #if FMSTR_MAX_REC_VARS > 8 || FMSTR_MAX_REC_VARS < 2
569  #error Error in FMSTR_MAX_REC_VARS value. Use a value in range 2..8
570  #endif
571 
572  /* 0 means recorder time base is "unknown" */
573  #ifndef FMSTR_REC_TIMEBASE
574  #define FMSTR_REC_TIMEBASE 0
575  #endif
576 
577  /* default recorder buffer size is 256 */
578  #ifndef FMSTR_REC_BUFF_SIZE
579  #define FMSTR_REC_BUFF_SIZE 256
580  #endif
581 
582  #if !FMSTR_USE_READMEM
583  #error Recorder needs the FMSTR_USE_READMEM feature
584  #endif
585 #endif
586 
587 /* fast recorder requires its own allocation of recorder buffer */
588 #if FMSTR_USE_FASTREC
589  #if FMSTR_REC_OWNBUFF
590  #error Fast recorder requires its own buffer allocation
591  #endif
592 #endif
593 
594 /* default app.cmds settings */
595 #ifndef FMSTR_USE_APPCMD
596 #define FMSTR_USE_APPCMD 0
597 #endif
598 
599 #ifndef FMSTR_APPCMD_BUFF_SIZE
600 #define FMSTR_APPCMD_BUFF_SIZE 16
601 #endif
602 
603 #ifndef FMSTR_MAX_APPCMD_CALLS
604 #define FMSTR_MAX_APPCMD_CALLS 0
605 #endif
606 
607 /* TSA configuration check */
608 #ifndef FMSTR_USE_TSA
609 #define FMSTR_USE_TSA 0
610 #endif
611 
612 #ifndef FMSTR_USE_TSA_SAFETY
613 #define FMSTR_USE_TSA_SAFETY 0
614 #endif
615 
616 #if FMSTR_USE_TSA
617  #if !FMSTR_USE_READMEM
618  #error TSA needs the FMSTR_USE_READMEM feature
619  #endif
620 #endif
621 
622 /* SFIO not used by default */
623 #ifndef FMSTR_USE_SFIO
624 #define FMSTR_USE_SFIO 0
625 #endif
626 
627 /* check SFIO settings */
628 #if FMSTR_USE_SFIO
629 
630  /* The SFIO configuration files (sfio.h and optionally also the sfio_cfg.h) exist
631  in project to define SFIO parameters. */
632  #include "sfio.h"
633 
634  #ifndef SFIO_MAX_INPUT_DATA_LENGTH
635  #error SFIO_MAX_INPUT_DATA_LENGTH was not defined in sfio_cfg.h
636  #endif
637  #ifndef SFIO_MAX_OUTPUT_DATA_LENGTH
638  #error SFIO_MAX_OUTPUT_DATA_LENGTH was not defined in sfio_cfg.h
639  #endif
640 
641 #endif
642 
643 /* use transport "pipe" functionality */
644 #ifndef FMSTR_USE_PIPES
645 #define FMSTR_USE_PIPES 0
646 #endif
647 
648 /* "pipe" putstring formatting (enabled by default) */
649 #ifndef FMSTR_USE_PIPE_PRINTF
650 #define FMSTR_USE_PIPE_PRINTF 1
651 #endif
652 
653 /* "pipe" variable-argument printf (enabled by default) */
654 #ifndef FMSTR_USE_PIPE_PRINTF_VARG
655 #define FMSTR_USE_PIPE_PRINTF_VARG FMSTR_USE_PIPE_PRINTF
656 #endif
657 
658 #if FMSTR_USE_PIPES
659 
660  #ifdef FMSTR_PIPES_EXPERIMENTAL
661  #warning The "pipes" feature is now in experimental code phase. Not yet tested on this platform.
662  #endif
663 
664  /* one pipe by default */
665  #ifndef FMSTR_MAX_PIPES_COUNT
666  #define FMSTR_MAX_PIPES_COUNT 1
667  #endif
668 
669  /* must enable printf for vararg printf */
670  #if !(FMSTR_USE_PIPE_PRINTF) && (FMSTR_USE_PIPE_PRINTF_VARG)
671  #error You must enable pipe printf for vararg printf (see FMSTR_USE_PIPE_PRINTF)
672  #endif
673 
674  /* pipe printf buffer */
675  #ifndef FMSTR_PIPES_PRINTF_BUFF_SIZE
676  #define FMSTR_PIPES_PRINTF_BUFF_SIZE 48
677  #endif
678 
679  /* at least one */
680  #if FMSTR_MAX_PIPES_COUNT < 1
681  #warning No sense to allocate zero-count pipes. Disabling pipes.
682  #undef FMSTR_USE_PIPES
683  #define FMSTR_USE_PIPES 0
684  #endif
685 
686  /* printf buffer should accept one integer printed */
687  #if FMSTR_PIPES_PRINTF_BUFF_SIZE < 8
688  #error Pipe printf buffer should be at least 8 (see FMSTR_PIPES_PRINTF_BUFF_SIZE)
689  #endif
690  #if FMSTR_PIPES_PRINTF_BUFF_SIZE > 255
691  #error Pipe printf buffer should not exceed 255 (see FMSTR_PIPES_PRINTF_BUFF_SIZE)
692  #endif
693 
694 #endif
695 
696 /* what kind of board information structure will be sent? */
697 #ifndef FMSTR_USE_BRIEFINFO
698  #if FMSTR_USE_RECORDER
699  /* recorder requires full info */
700  #define FMSTR_USE_BRIEFINFO 0
701  #else
702  /* otherwise no brief info is enough */
703  #define FMSTR_USE_BRIEFINFO 1
704  #endif
705 #endif
706 
707 /* check what kind of board info is sent */
708 #if FMSTR_USE_BRIEFINFO
709  #if FMSTR_USE_RECORDER
710  #warning The full information structure must be used when recorder is to be used
711  #undef FMSTR_USE_BRIEFINFO
712  #define FMSTR_USE_BRIEFINFO 1
713  #endif
714 #endif
715 
716 /* automatic buffer size by default */
717 #ifndef FMSTR_COMM_BUFFER_SIZE
718 #define FMSTR_COMM_BUFFER_SIZE 0
719 #endif
720 
721 /* check minimal buffer size required for all enabled features */
722 #if FMSTR_COMM_BUFFER_SIZE
723 
724  /* basic commands (getinfobrief, write/read memory etc.) */
725  #if FMSTR_USE_BRIEFINFO && FMSTR_COMM_BUFFER_SIZE < 11
726  #error FMSTR_COMM_BUFFER_SIZE set too small for basic FreeMASTER commands (11 bytes)
727  #endif
728 
729  /* full info required */
730  #if !(FMSTR_USE_BRIEFINFO) && FMSTR_COMM_BUFFER_SIZE < 35
731  #error FMSTR_COMM_BUFFER_SIZE set too small for GETINFO command (size 35)
732  #endif
733 
734  /* application commands */
735  #if FMSTR_USE_APPCMD && FMSTR_COMM_BUFFER_SIZE < ((FMSTR_APPCMD_BUFF_SIZE)+1)
736  #error FMSTR_COMM_BUFFER_SIZE set too small for SENDAPPCMD command (size FMSTR_APPCMD_BUFF_SIZE+1)
737  #endif
738 
739  /* configuring scope (EX) */
740  #if FMSTR_USE_SCOPE && FMSTR_COMM_BUFFER_SIZE < ((FMSTR_MAX_SCOPE_VARS)*5+1)
741  #error FMSTR_COMM_BUFFER_SIZE set too small for SETUPSCOPEEX command (size FMSTR_MAX_SCOPE_VARS*5+1)
742  #endif
743 
744  /* configuring recorder (EX) */
745  #if FMSTR_USE_RECORDER && FMSTR_COMM_BUFFER_SIZE < ((FMSTR_MAX_REC_VARS)*5+18)
746  #error FMSTR_COMM_BUFFER_SIZE set too small for SETUPRECEX command (size FMSTR_MAX_REC_VARS*5+18)
747  #endif
748 
749  /* SFIO encapsulation */
750  #if FMSTR_USE_SFIO
751  #if (FMSTR_COMM_BUFFER_SIZE < ((SFIO_MAX_INPUT_DATA_LENGTH)+1)) || \
752  (FMSTR_COMM_BUFFER_SIZE < ((SFIO_MAX_OUTPUT_DATA_LENGTH)+1))
753  #error FMSTR_COMM_BUFFER_SIZE set too small for SFIO encapsulation (see SFIO_MAX_xxx_DATA_LENGTH)
754  #endif
755  #endif
756 
757 /* automatic: determine required buffer size based on features enabled */
758 #else
759  /* smallest for basic commands (getinfobrief, write/read memory etc.) */
760  #undef FMSTR_COMM_BUFFER_SIZE
761  #define FMSTR_COMM_BUFFER_SIZE 11
762 
763  /* full info required */
764  #if !(FMSTR_USE_BRIEFINFO) && FMSTR_COMM_BUFFER_SIZE < 35
765  #undef FMSTR_COMM_BUFFER_SIZE
766  #define FMSTR_COMM_BUFFER_SIZE 35
767  #endif
768 
769  /* using application commands (must accomodate maximal app.cmd data length) */
770  #if FMSTR_USE_APPCMD && FMSTR_COMM_BUFFER_SIZE < ((FMSTR_APPCMD_BUFF_SIZE)+1)
771  #undef FMSTR_COMM_BUFFER_SIZE
772  #define FMSTR_COMM_BUFFER_SIZE ((FMSTR_APPCMD_BUFF_SIZE)+1)
773  #endif
774 
775  /* configuring scope (EX) */
776  #if FMSTR_USE_SCOPE && FMSTR_COMM_BUFFER_SIZE < ((FMSTR_MAX_SCOPE_VARS)*5+1)
777  #undef FMSTR_COMM_BUFFER_SIZE
778  #define FMSTR_COMM_BUFFER_SIZE ((FMSTR_MAX_SCOPE_VARS)*5+1)
779  #endif
780 
781  /* configuring recorder (EX) */
782  #if FMSTR_USE_RECORDER && FMSTR_COMM_BUFFER_SIZE < ((FMSTR_MAX_REC_VARS)*5+18)
783  #undef FMSTR_COMM_BUFFER_SIZE
784  #define FMSTR_COMM_BUFFER_SIZE ((FMSTR_MAX_REC_VARS)*5+18)
785  #endif
786 
787  /* SFIO encapsulation (in buffer) */
788  #if FMSTR_USE_SFIO
789  #if FMSTR_COMM_BUFFER_SIZE < ((SFIO_MAX_INPUT_DATA_LENGTH)+1)
790  #undef FMSTR_COMM_BUFFER_SIZE
791  #define FMSTR_COMM_BUFFER_SIZE ((SFIO_MAX_INPUT_DATA_LENGTH)+1)
792  #endif
793  #endif
794 
795  /* SFIO encapsulation (out buffer) */
796  #if FMSTR_USE_SFIO
797  #if FMSTR_COMM_BUFFER_SIZE < ((SFIO_MAX_OUTPUT_DATA_LENGTH)+1)
798  #undef FMSTR_COMM_BUFFER_SIZE
799  #define FMSTR_COMM_BUFFER_SIZE ((SFIO_MAX_OUTPUT_DATA_LENGTH)+1)
800  #endif
801  #endif
802 
803 #endif
804 
805 #endif /* __FREEMASTER_PRIVATE_H */
806 
void FMSTR_SendResponse(FMSTR_BPTR pMessageIO, FMSTR_SIZE8 nLength)
FMSTR_BPTR FMSTR_GetStringLen(FMSTR_BPTR pMessageIO)
FMSTR_BPTR FMSTR_WriteVar(FMSTR_BPTR pMessageIO, FMSTR_SIZE8 nSize)
Handling WRITEVAR command.
Definition: freemaster_protocol.c:577
void FMSTR_InitCan(void)
void FMSTR_ProcessSCI(void)
FMSTR_BOOL FMSTR_IsInRecBuffer(FMSTR_ADDR nAddr, FMSTR_SIZE8 nSize)
void FMSTR_ProcessCanRx(void)
void FMSTR_InitTsa(void)
FMSTR_BPTR FMSTR_ReadMem(FMSTR_BPTR pMessageIO)
Handling READMEM and READMEM_EX commands.
Definition: freemaster_protocol.c:467
unsigned char FMSTR_BOOL
Definition: freemaster.h:40
unsigned short FMSTR_SIZE
Definition: freemaster.h:39
FMSTR_BOOL FMSTR_CheckTsaSpace(FMSTR_ADDR nAddr, FMSTR_SIZE8 nSize, FMSTR_BOOL bWriteAccess)
FMSTR_BPTR FMSTR_SfioFrame(FMSTR_BPTR pMessageIO)
void FMSTR_InitScope(void)
FMSTR_BPTR FMSTR_ReadVar(FMSTR_BPTR pMessageIO, FMSTR_SIZE8 nSize)
Handling READVAR and READVAR_EX commands (for all sizes 1,2,4)
Definition: freemaster_protocol.c:507
FMSTR_BPTR FMSTR_SfioGetResp(FMSTR_BPTR pMessageIO)
FMSTR_BPTR FMSTR_GetTsaInfo(FMSTR_BPTR pMessageIO)
FMSTR_BOOL FMSTR_RxCan(void)
void FMSTR_InitRec(void)
FreeMASTER Driver hardware dependent stuff.
FMSTR_BPTR FMSTR_GetAppCmdRespData(FMSTR_BPTR pMessageIO)
FMSTR_BPTR FMSTR_GetBoardInfo(FMSTR_BPTR pMessageIO)
Handling GETINFO or GETINFO_BRIEF.
Definition: freemaster_protocol.c:394
unsigned char FMSTR_SIZE8
Definition: freemaster_Kxx.h:80
void FMSTR_InitSerial(void)
FMSTR_BPTR FMSTR_WriteMem(FMSTR_BPTR pMessageIO)
Handling WRITEMEM and WRITEMEM_EX commands.
Definition: freemaster_protocol.c:539
FMSTR_BPTR FMSTR_GetRecBuff(FMSTR_BPTR pMessageIO)
FMSTR_BPTR FMSTR_StartRec(FMSTR_BPTR pMessageIO)
FMSTR_BPTR FMSTR_StopRec(FMSTR_BPTR pMessageIO)
FMSTR_BOOL FMSTR_TxCan(void)
unsigned long FMSTR_U32
Definition: freemaster_Kxx.h:69
FMSTR_U16 FMSTR_StrLen(FMSTR_ADDR nAddr)
Private inline implementation of &quot;strlen&quot; used by TSA and Pipes.
Definition: freemaster_protocol.c:693
FMSTR_SIZE FMSTR_GetRecBuffSize(void)
FMSTR_BPTR FMSTR_ReadScope(FMSTR_BPTR pMessageIO)
void FMSTR_ProcessJTAG(void)
FMSTR_BOOL FMSTR_InitMQX(void)
FMSTR_BPTR FMSTR_PipeFrame(FMSTR_BPTR pMessageIO)
FMSTR_BPTR FMSTR_WriteMemMask(FMSTR_BPTR pMessageIO)
Handling WRITEMEMMASK and WRITEMEMMASK_EX commands.
Definition: freemaster_protocol.c:614
FMSTR_BPTR FMSTR_SetUpScope(FMSTR_BPTR pMessageIO)
unsigned char * FMSTR_BPTR
Definition: freemaster_Kxx.h:84
FMSTR_BPTR FMSTR_GetAppCmdStatus(FMSTR_BPTR pMessageIO)
unsigned char * FMSTR_ADDR
Definition: freemaster.h:38
FMSTR_BPTR FMSTR_GetRecStatus(FMSTR_BPTR pMessageIO)
FMSTR_BPTR FMSTR_SetUpRec(FMSTR_BPTR pMessageIO)
void FMSTR_InitAppCmds(void)
unsigned short FMSTR_U16
Definition: freemaster_Kxx.h:68
FMSTR_BPTR FMSTR_WriteVarMask(FMSTR_BPTR pMessageIO, FMSTR_SIZE8 nSize)
Handling WRITEVARMASK command.
Definition: freemaster_protocol.c:661
void FMSTR_InitPipes(void)
void FMSTR_ProcessCanTx(void)
void FMSTR_SetCanCmdID(FMSTR_U32 canID)
FMSTR_BPTR FMSTR_StoreAppCmd(FMSTR_BPTR pMessageIO)
void FMSTR_InitSfio(void)
void FMSTR_SetCanRespID(FMSTR_U32 canID)
FMSTR_BOOL FMSTR_ProtocolDecoder(FMSTR_BPTR pMessageIO)
Decodes the FreeMASTER protocol and calls appropriate handlers.
Definition: freemaster_protocol.c:98