📄 etpuc_common.h
字号:
/* return current channel number */
#define GetCurrentChanNum() (chan)
/* branch condition */
#define LinkServiceRequest channel.LSR
#define IsLinkReqActive() (channel.LSR==1)
#define IsSampledLink() (channel.LSR==1)
#define IsLatchedLink() (channel.LSR==1)
/********************************************************************************/
/* Entry Conditions Definition */
/* Usage: use these in the if()/else if()/else structure in an
ETPU_function */
#define HostServiceRequest hsr
#define IsHostServiceRequestEvent(num) (hsr==num)
#define MatchA_TransB (m1==1)
#define matchA_transB (m1==1)
#define IsMatchAOrTransitionBEvent() (m1==1)
#define MatchB_TransA (m2==1)
#define matchB_transA (m2==1)
#define IsMatchBOrTransitionAEvent() (m2==1)
#define linkRequest (lsr==1)
#define IsLinkServiceRequestEvent() (lsr==1)
/* For output-only functions */
#define MatchA (m1==1)
#define MatchB (m2==1)
/********************************************************************************/
/* Predefined Channel Modes (PDCM) */
#define SetChannelMode(mode) (channel.PDCM = mode)
#define channel_setup channel.PDCM
/* Usage: channel_setup = PDCM_constant
PDCM_constants are taken from etpuc.h:
em_b_st Either Match, Blocking, Single Transition
em_b_dt Either Match, Blocking, Double Transition
em_nb_st Either Match, NonBlocking, Single Transition
em_nb_dt Either Match, NonBlocking, Double Transition
m2_st Match2, Single, Transition
m2_dt Match2, Double, Transition
bm_st Both Match, Single Transition
bm_dt Both Match, Double Transition
m2_o_st Match2, Ordered Single Blocking Transition
m2_o_dt Match2, Ordered Double Transition
sm_st_e Single Match, Single Transition Enhanced
sm_st Single Match, Single Transition
sm_dt Single Match, Double Transition
*/
/* SYNONYMS */
#define EitherMatchBlockingSingleTransition() channel.PDCM = em_b_st
#define EitherMatchBlockingDoubleTransition() channel.PDCM = em_b_dt
#define EitherMatchNonBlockingSingleTransition() channel.PDCM = em_nb_st
#define EitherMatchNonBlockingDoubleTransition() channel.PDCM = em_nb_dt
#define Match2SingleTransition() channel.PDCM = m2_st
#define Match2DoubleTransition() channel.PDCM = m2_dt
#define BothMatchSingleTransition() channel.PDCM = bm_st
#define BothMatchDoubleTransition() channel.PDCM = bm_dt
#define Match2OrderedSingleBlockingTransition() channel.PDCM = m2_o_st
#define Match2OrderedDoubleTransition() channel.PDCM = m2_o_dt
#define SingleMatchSingleTransitionEnhanced() channel.PDCM = sm_st_e
#define SingleMatchSingleTransition() channel.PDCM = sm_st
#define SingleMatchDoubleTransition() channel.PDCM = sm_dt
#define ClearAllLatches() \
(lsr = 0);(mrlA = 0);(mrlB = 0);(tdl = 0);
/********************************************************************************/
/* Complex Macros */
/* These macros should provide the most optimized way of doing things.
They should be in the best order for optimizing. The compiler might
be able to identify this code for optimization. */
#define SetupMatchA(reference) \
erta = reference; \
EnableMatchA(); \
ClearMatchALatch();
#define SetupMatchB(reference) \
ertb = reference; \
EnableMatchB(); \
ClearMatchBLatch();
/* These are ONLY useful for init. and if you know which TCR you want
to use. Latches are cleared at the end so it can be combined with
other latches. */
#define ConfigMatch_AB() \
WriteErtAToMatchAAndEnable(); \
WriteErtBToMatchBAndEnable(); \
EnableMatchA(); \
EnableMatchB(); \
EnableEventHandling();\
ClearMatchALatch();\
ClearMatchBLatch();
#define SetupMatch_A(reference, timebase_comparator, pin_action) \
erta = reference; \
act_unitA = timebase_comparator; \
opacA = pin_action; \
EnableMatchA(); \
ClearMatchALatch();\
EnableEventHandling();
#define SetupMatch_B(reference, timebase_comparator, pin_action) \
ertb = reference; \
act_unitB = timebase_comparator; \
opacB = pin_action; \
EnableMatchB(); \
ClearMatchBLatch();\
EnableEventHandling();
#define SetupCaptureTrans_A(timebase, pin_trans) \
act_unitA = timebase;\
ipacA = pin_trans;\
ClearTransLatch();\
EnableEventHandling();
#define SetupCaptureTrans_B(timebase, pin_trans) \
act_unitB = timebase;\
ipacB = pin_trans;\
ClearTransLatch();\
EnableEventHandling();
/********************************************************************************/
/* Action Units */
/* Usage: ActionUnitA( MatchTCR1 | MatchTCR2,
CaptureTCR1 | CaptureTCR2,
GreaterEqual | EqualOnly ); */
#define ActionUnitA( match, capture, compare) (act_unitA=match##capture##compare)
#define ActionUnitB( match, capture, compare) (act_unitB=match##capture##compare)
#define MatchTCR1 Mtcr1_
#define MatchTCR2 Mtcr2_
#define CaptureTCR1 Ctcr1_
#define CaptureTCR2 Ctcr2_
#define GreaterEqual ge
#define EqualOnly eq
/* SYNONYMS */
/* Action Unit A, Time Bases for match and capture */
#define TimeBaseAMatchTcr1CaptureTcr1GreaterEqual() channel.TBSA = Mtcr1_Ctcr1_ge
#define TimeBaseAMatchTcr2CaptureTcr1GreaterEqual() channel.TBSA = Mtcr2_Ctcr1_ge
#define TimeBaseAMatchTcr1CaptureTcr2GreaterEqual() channel.TBSA = Mtcr1_Ctcr2_ge
#define TimeBaseAMatchTcr2CaptureTcr2GreaterEqual() channel.TBSA = Mtcr2_Ctcr2_ge
#define TimeBaseAMatchTcr1CaptureTcr1ExactlyEqual() channel.TBSA = Mtcr1_Ctcr1_eq
#define TimeBaseAMatchTcr2CaptureTcr1ExactlyEqual() channel.TBSA = Mtcr2_Ctcr1_eq
#define TimeBaseAMatchTcr1CaptureTcr2ExactlyEqual() channel.TBSA = Mtcr1_Ctcr2_eq
#define TimeBaseAMatchTcr2CaptureTcr2ExactlyEqual() channel.TBSA = Mtcr2_Ctcr2_eq
/* Action Unit B, Time Bases for match and capture */
#define TimeBaseBMatchTcr1CaptureTcr1GreaterEqual() channel.TBSB = Mtcr1_Ctcr1_ge
#define TimeBaseBMatchTcr2CaptureTcr1GreaterEqual() channel.TBSB = Mtcr2_Ctcr1_ge
#define TimeBaseBMatchTcr1CaptureTcr2GreaterEqual() channel.TBSB = Mtcr1_Ctcr2_ge
#define TimeBaseBMatchTcr2CaptureTcr2GreaterEqual() channel.TBSB = Mtcr2_Ctcr2_ge
#define TimeBaseBMatchTcr1CaptureTcr1ExactlyEqual() channel.TBSB = Mtcr1_Ctcr1_eq
#define TimeBaseBMatchTcr2CaptureTcr1ExactlyEqual() channel.TBSB = Mtcr2_Ctcr1_eq
#define TimeBaseBMatchTcr1CaptureTcr2ExactlyEqual() channel.TBSB = Mtcr1_Ctcr2_eq
#define TimeBaseBMatchTcr2CaptureTcr2ExactlyEqual() channel.TBSB = Mtcr2_Ctcr2_eq
/********************************************************************************/
/* Pin output buffer */
#define EnableOutputBuffer() (channel.TBSA = enable_output_buffer)
#define DisableOutputBuffer() (channel.TBSA = disable_output_buffer)
/********************************************************************************/
/* Pin control */
/* Pin() definitions */
#define SetHigh pin_high
#define SetLow pin_low
#define PerPacA pin_opacA
#define PerPacB pin_opacB
/* Set Output Pin
Usage: Pin( SetHigh | SetLow | PerPacA | PerPacB ); */
#define Pin( state ) (channel.PIN=state)
/* Immediate output pin */
#define set_pin_per_opacA pin_opacA
#define set_pin_per_opacB pin_opacB
#define force_pin_high pin_high
#define force_pin_low pin_low
#define SetPinHigh() (channel.PIN=force_pin_high)
#define SetPinLow() (channel.PIN=force_pin_low)
#define SetPinPerPacA() (channel.PIN=set_pin_per_opacA)
#define SetPinPerPacB() (channel.PIN=set_pin_per_opacB)
/* Reading the pin states: branch conditions */
#define SampledInputPin channel.PSS
#define IsLatchedInputPin() (channel.PSS==1)
#define IsInputPinHigh() (channel.PSS==1)
#define CurrentInputPin channel.PSTI
#define IsCurrentInputPin() (channel.PSTI==1)
#define CurrentOutputPin channel.PSTO
#define IsCurrentOutputPin() (channel.PSTO==1)
/* SYNONYMS */
#define IsSampledInputPinHigh() (channel.PSS==1)
#define IsLatchedInputPinHigh() (channel.PSS==1)
#define IsCurrentInputPinHigh() (channel.PSTI==1)
#define IsCurrentOutputPinHigh() (channel.PSTO==1)
/********************************************************************************/
/* Output Pin Action */
#define NoChange match_no_change
#define PinHigh match_high
#define PinLow match_low
#define PinToggle match_toggle
/* Usage: OnMatchA( NoChange | PinHigh | PinLow | PinToggle ); */
#define OnMatchA(action) (opacA = action)
#define OnMatchB(action) (opacB = action)
/* SYNONYMS */
/* Action Unit A, Output Pin Actions */
#define OnMatchAPinNoChange() channel.OPACA = match_no_change
#define OnMatchAPinHigh() channel.OPACA = match_high
#define OnMatchAPinLow() channel.OPACA = match_low
#define OnMatchAPinToggle() channel.OPACA = match_toggle
#define OnInputActionAPinLow() channel.OPACA = transition_low
#define OnInputActionAPinHigh() channel.OPACA = transition_high
#define OnInputActionAPinToggle() channel.OPACA = transition_toggle
/* Action Unit B, Output Pin Actions */
#define OnMatchBPinNoChange() channel.OPACB = match_no_change
#define OnMatchBPinHigh() channel.OPACB = match_high
#define OnMatchBPinLow() channel.OPACB = match_low
#define OnMatchBPinToggle() channel.OPACB = match_toggle
#define OnInputActionBPinLow() channel.OPACB = transition_low
#define OnInputActionBPinHigh() channel.OPACB = transition_high
#define OnInputActionBPinToggle() channel.OPACB = transition_toggle
/********************************************************************************/
/* Input Pin Action */
#define NoDetect no_detect
#define LowHigh low_high
#define HighLow high_low
#define AnyTrans any_trans
/* Usage: DetectTransA( no_detect | low_high | high_low | any_trans | ...); */
#define OnTransA(action) (ipacA = action)
#define OnTransB(action) (ipacB = action)
/* SYNONYMS */
/* Action Unit A, Input Pin Edge Detection */
#define DetectADisable() channel.IPACA = no_detect
#define DetectARisingEdge() channel.IPACA = low_high
#define DetectAFallingEdge() channel.IPACA = high_low
#define DetectAAnyEdge() channel.IPACA = any_trans
#define DetectALowOnMatchA() channel.IPACA = detect_input_0_on_match
#define DetectAHighOnMatchA() channel.IPACA = detect_input_1_on_match
/* Action Unit B, Input Pin Edge Detection */
#define DetectBDisable() channel.IPACB = no_detect
#define DetectBRisingEdge() channel.IPACB = low_high
#define DetectBFallingEdge() channel.IPACB = high_low
#define DetectBAnyEdge() channel.IPACB = any_trans
#define DetectBLowOnMatchA() channel.IPACB = detect_input_0_on_match
#define DetectBHighOnMatchA() channel.IPACB = detect_input_1_on_match
/********************************************************************************/
/* Intrinsics synonyms */
/* Matches in Threads */
#define DisableMatchesInThread() match_disable()
#define EnableMatchesInThread() match_enable()
#endif /* __ETPUC_COMMON_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -