1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016-2019 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef FSL_TRGMUX_H_
10 #define FSL_TRGMUX_H_
11 
12 #include "fsl_common.h"
13 
14 /*! @addtogroup trgmux */
15 /*! @{ */
16 
17 /*******************************************************************************
18  * Definitions
19  ******************************************************************************/
20 
21 /*! @name Driver version */
22 /*! @{ */
23 /*! @brief TRGMUX driver version. */
24 #define FSL_TRGMUX_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
25 /*! @} */
26 
27 /*! @brief TRGMUX configure status. */
28 enum
29 {
30     kStatus_TRGMUX_Locked = MAKE_STATUS(kStatusGroup_TRGMUX, 0), /*!< Configure failed for register is locked */
31 };
32 
33 /*!
34  * @brief Defines the MUX select for peripheral trigger input.
35  */
36 typedef enum _trgmux_trigger_input
37 {
38     kTRGMUX_TriggerInput0 = TRGMUX_TRGCFG_SEL0_SHIFT, /*!< The MUX select for peripheral trigger input 0*/
39     kTRGMUX_TriggerInput1 = TRGMUX_TRGCFG_SEL1_SHIFT, /*!< The MUX select for peripheral trigger input 1*/
40     kTRGMUX_TriggerInput2 = TRGMUX_TRGCFG_SEL2_SHIFT, /*!< The MUX select for peripheral trigger input 2*/
41     kTRGMUX_TriggerInput3 = TRGMUX_TRGCFG_SEL3_SHIFT, /*!< The MUX select for peripheral trigger input 3*/
42 } trgmux_trigger_input_t;
43 
44 /*******************************************************************************
45  * API
46  ******************************************************************************/
47 
48 #if defined(__cplusplus)
49 extern "C" {
50 #endif /* __cplusplus*/
51 
52 /*!
53  *@name TRGMUX Functional Operation
54  *@{*/
55 
56 /*!
57  * @brief Sets the flag of the register which is used to mark writeable.
58  *
59  * The function sets the flag of the register which is used to mark
60  * writeable.
61  * Example:
62    @code
63    TRGMUX_LockRegister(TRGMUX0,kTRGMUX_Trgmux0Dmamux0);
64    @endcode
65  *
66  * @param base        TRGMUX peripheral base address.
67  * @param index       The index of the TRGMUX register, see the enum trgmux_device_t
68  *                    defined in \<SOC\>.h.
69  */
TRGMUX_LockRegister(TRGMUX_Type * base,uint32_t index)70 static inline void TRGMUX_LockRegister(TRGMUX_Type *base, uint32_t index)
71 {
72     base->TRGCFG[index] |= TRGMUX_TRGCFG_LK_MASK;
73 }
74 
75 /*!
76  * @brief Configures the trigger source of the appointed peripheral.
77  *
78  * The function configures the trigger source of the appointed peripheral.
79  * Example:
80    @code
81    TRGMUX_SetTriggerSource(TRGMUX0, kTRGMUX_Trgmux0Dmamux0, kTRGMUX_TriggerInput0, kTRGMUX_SourcePortPin);
82    @endcode
83  * @param base        TRGMUX peripheral base address.
84  * @param index       The index of the TRGMUX register, see the enum trgmux_device_t
85  *                    defined in \<SOC\>.h.
86  * @param input       The MUX select for peripheral trigger input
87  * @param trigger_src The trigger inputs for various peripherals. See the enum trgmux_source_t
88  *                    defined in \<SOC\>.h.
89  * @retval  kStatus_Success  Configured successfully.
90  * @retval  kStatus_TRGMUX_Locked   Configuration failed because the register is locked.
91  */
92 status_t TRGMUX_SetTriggerSource(TRGMUX_Type *base, uint32_t index, trgmux_trigger_input_t input, uint32_t trigger_src);
93 
94 /*! @} */
95 
96 #if defined(__cplusplus)
97 }
98 #endif /* __cplusplus*/
99 
100 /*! @}*/
101 
102 #endif /* FSL_TRGMUX_H_*/
103