⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 etpuc_common.h

📁 mpc55**系列芯片的例程 包括SCI,SPI,TIMER,FIT,EDMA等几乎所有功能的实现
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef __ETPUC_COMMON_H
#define __ETPUC_COMMON_H

/********************************************************************************

 FILE NAME: etpuc_common.h

 COPYRIGHT (c) ASH WARE, Byte Craft Limited, Freescale 2002-2004.
 All Rights Reserved.

 VERSION:  1.0

 This file is maintained as part of the support for the eTPU_C
 development tools by Byte Craft Limited.

 This code may be adapted for any purpose when used with the eTPU_C
 Code Development System.  No warranty is implied or given as to their
 usability for any purpose.

 Portions of this file are governed by the following copyrights and
 terms:

 (c) Freescale 2002-2004 FREESCALE, INC. All Rights Reserved.
 *  You are hereby granted a copyright license to use, modify, and
 *  distribute the SOFTWARE so long as this entire notice is
 *  retained without alteration in any modified and/or redistributed
 *  versions, and that such modified versions are clearly identified
 *  as such. No licenses are granted by implication, estoppel or
 *  otherwise under any patents or trademarks of Freescale, Inc. This
 *  software is provided on an "AS IS" basis and without warranty.
 *
 *  To the maximum extent permitted by applicable law, FREESCALE
 *  DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING
 *  IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
 *  PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH REGARD TO THE
 *  SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) AND ANY
 *  ACCOMPANYING WRITTEN MATERIALS.
 *
 *  To the maximum extent permitted by applicable law, IN NO EVENT
 *  SHALL FREESCALE BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING
 *  WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS
 *  INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
 *  LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
 *
 *  Freescale assumes no responsibility for the maintenance and support
 *  of this software

 (c) Copyright 2002-2004 Byte Craft Limited
 421 King St.N., Waterloo, ON, Canada, N2J 4E4
 VOICE: 1 (519) 888 6911
 email: support@bytecraft.com

 (c) Copyright 2002-2004 ASH WARE

================================================================================

DESCRIPTION: This file defines the application-friendly macros,
functions for common tasks like channel set up and register control
field access.

================================================================================

SOURCES:

etpuc_common.h is based on the following header files commonly used by
the eTPU development community:

AshWareETpu.h - developed by Andy Klumpp from ASH WARE
Mike.h - developed by Mike Pauwels from Freescale
etpu_common.h - developped by Ming Li from Freescale

Jeff Loeliger from Freescale and Walter Banks from Byte Craft
also made significant contibutions.

================================================================================
 UPDATE HISTORY
 REV      AUTHOR        DATE                DESCRIPTION OF CHANGE
 ---      -------      --------    ---------------------
 0.0      Ming Li      10/30/03    Initial creation
 0.1      Ming Li      11/12/03    Updated to incorporate comments from eTPU
                                   development community.
 0.2      Walter Banks 15 Dec 03   Made changes to be reflect definitions in
                                   eTPUc.h
                                   Corrected IsTransALatched()
                                             IsTransBLatched()
                                   Added missing definitions
                                             set_pin_per_opacA
                                             set_pin_per_opacB
                                             force_pin_high
                                             force_pin_low
                                   Corrected opac1 to opacA
                                             opac2 to opacB

 0.3      Walter Banks  5 Jan 04   Corrected opacB = pin_action; to
                                       opacA = pin_action;

 0.4     J. Loeliger    21/Jan/04  Cleared up reorganized and added more:
                                   -Moved TRUE & FALSE to top and added
                                      conditional
                                   -Moved entry conditions up and added macros
                                      for all conditions
                                   -Merged with AshWareETpu.h
                                      -Removed commet with of PDCM names.
                                   -Grouped latches and flags together.
                                     -added new set and clear for latches and
                                        flags
                                   -Merged output pin value to 1 set rather
                                      than 2
                                   -Added long channel mode names.
                                   -Added SetupMatch_AB for better
                                      optimization
                                   -Added match only conditions for output
                                      functions.
                                   -Added new ActionUnintA/B macros
                                   -Added new Pin macro
                                   -And more.
 0.5     J. Loeliger     12/Feb/04 -Changed DetectTrans to OnTrans.
 0.6     J. Loeliger     30/Mar/04 -Added SetupMatchB and fixed some old
                                     references to 1 & 2 -> A & B
 0.7     J. Loeliger     16/Apr/04 -Changed Disable match (MRLE) to =0
 0.8     J. Loeliger     27/Apr/04 -Fixed Disable/Enable match in thread,
                                      they were swapped.
 0.9     J. Loeliger     10/May/04 -Added support for OBE with new
         M. Brejl                   EnableOutputBuffer()/DisableOutputBuffer()
                                    Removed all // comments. Changed Motorola
                                    to Freescale.
                                    Fixed spelling mistake in GetCurentChanNum

 0.4     Karen McMurray  19 May 04  Changed all ertA to erta
                                                ertB to ertb.

 1.0     Kirk Zurell     11 Aug 04  Integrated etpuc_common.h from J. Loeliger
                                    and etpuc_common.h from Byte Craft Limited.
                                    Removed tabs & made comments more sustainable.
                                    Conditionalized some definitions to be more
                                    economical on symbols.

                                    Divider lines have 80 asterices.

*/



/********************************************************************************/

/* This file depends upon definitions from etpuc.h */

#ifndef __ETPUC_H
#include <etpuc.h>
#endif /* __ETPUC_H */


/********************************************************************************/

/* Constant definitions */

#ifndef TRUE
#define TRUE        1
#endif

#ifndef FALSE
#define FALSE       0
#endif


/********************************************************************************/

/* State Resolution Flags, and other latches */

/* Clear() definitions */
#define LSRLatch      lsr
#define LatchedMatchA mrlA
#define LatchedMatchB mrlB
#define TransLatch    tdl

/* Macros */

/* Set flag0 or flag1
   Usage: Set(flag0 | flag1);*/

#define Set(cond)     (cond = 1)

/* Clear a flag
   Usage: Clear(flag0 | flag1 | LSRLatch | lsr | MatchALatch | mrlA |
                 MatchBLatch | mrlB | TransLatch | tdl);         */

#define Clear(cond)   (cond = 0)

/* SYNONYMS */
/* Flag 0 & flag 1 */
#define ClrFlag0()  (channel.FLAG0 = 0)
#define SetFlag0()  (channel.FLAG0 = 1)
#define ClrFlag1()  (channel.FLAG1 = 0)
#define SetFlag1()  (channel.FLAG1 = 1)


#define FunctionMode0          channel.FM0
#define IsFunctionMode0()     (channel.FM0==1)
#define IsSampledFuncMode0()  (channel.FM0==1)
#define IsLatchedFuncMode0()  (channel.FM0==1)

#define FunctionMode1          channel.FM1
#define IsFunctionMode1()     (channel.FM1==1)
#define IsSampledFuncMode1()  (channel.FM1==1)
#define IsLatchedFuncMode1()  (channel.FM1==1)


/********************************************************************************/

/* Writing the match registers and enabling/disabling the Match
   Recognition Latch Enable */

#define EnableMatchA()                 (channel.ERWA = 0)
#define EnableMatchB()                 (channel.ERWB = 0)
#define DisableMatch()                 (channel.MRLE = 0)

/* SYNONYMS */
#define WriteErtAToMatchAAndEnable()   channel.ERWA = 0
#define WriteErtBToMatchBAndEnable()   channel.ERWB = 0
#define DisableMatchDetection();       channel.MRLE = 0


/* Read capture register */
#define GetCapRegA()  (erta)
#define GetCapRegB()  (ertb)

/* Clear Latch */
#define ClearLSRLatch()       (channel.LSR  = 0)

#define ClearMatchALatch()    (channel.MRLA = 0)
#define ClearMatchBLatch()    (channel.MRLB = 0)

#define ClearTransLatch()     (channel.TDL = 0)

/* SYNONYMS */
#define ClearLinkServiceRequestEvent() (lsr  = 0)

#define ClearMatchAEvent()    (channel.MRLA = 0)
#define ClearMatchBEvent()    (channel.MRLB = 0)

#define ClearTransitionEvents() (channel.TDL = 0)



/* Test latch conditions */

#define TransitionALatch           channel.TDLA
#define IsTransALatched()         (channel.TDLA==1)

#define TransitionBLatch           channel.TDLB
#define IsTransBLatched()         (channel.TDLB==1)

#define MatchALatch            channel.MRLA
#define IsMatchALatched()     (channel.MRLA==1)

#define MatchBLatch            channel.MRLB
#define IsMatchBLatched()     (channel.MRLB==1)

/* SYNONYMS */
#define IsLatchedTransitionA()    (channel.TDLA==1)
#define IsLatchedTransitionB()    (channel.TDLB==1)
#define IsLatchedMatchA()         (channel.MRLA==1)
#define IsLatchedMatchB()         (channel.MRLB==1)



/********************************************************************************/

/* Enabling/Disabling Event Handling */

#define EnableEventHandling()                   (channel.MTD = 0)
#define DisableEventHandling()                  (channel.MTD = 1)

/* SYNONYMS */
#define EnableMatchAndTransitionEventHandling()  channel.MTD = 0
#define DisableMatchAndTransitionEventHandling() channel.MTD = 1


/********************************************************************************/

/* Semaphore Operations */

#define IsSemaphoreLocked()   (channel.SMPR == 1)
#define LockSemaphore(num)    (channel.SMPR = num)
#define FreeSemaphore()       (channel.SMPR = -1)


/********************************************************************************/

/* Exceptions */

/* Channel control macros */
#define SetChannelInterrupt()       (channel.CIRC = 0)
#define SetChannelInterruptRequest()(channel.CIRC = 0)

#define SetDataTransferInterrupt()        (channel.CIRC = 1)
#define SetDataTransferInterruptRequest() (channel.CIRC = 1)

#define SetGlobalException()  (channel.CIRC = 2)

/* Channel control */

/* Generate the link service request to channel[ChNum] */
#define LinkToChannel(ChNum)            (link = ChNum)
#define LinkTo(num)                 link = num;
#define LinkToEngine1Chan(num)      link = (num | (1<<6))
#define LinkToEngine2Chan(num)      link = (num | (2<<6))
#define LinkToOtherEngineChan(num)  link = (num | (3<<6))

/* switch to specified channel from current channel */
#define SwitchToChannel(ChNum)      (chan = ChNum)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -