1 /***********************************************************************************************************************
2  * Copyright [2015-2017] Renesas Electronics Corporation and/or its licensors. All Rights Reserved.
3  *
4  * This file is part of Renesas SynergyTM Software Package (SSP)
5  *
6  * The contents of this file (the "contents") are proprietary and confidential to Renesas Electronics Corporation
7  * and/or its licensors ("Renesas") and subject to statutory and contractual protections.
8  *
9  * This file is subject to a Renesas SSP license agreement. Unless otherwise agreed in an SSP license agreement with
10  * Renesas: 1) you may not use, copy, modify, distribute, display, or perform the contents; 2) you may not use any name
11  * or mark of Renesas for advertising or publicity purposes or in connection with your use of the contents; 3) RENESAS
12  * MAKES NO WARRANTY OR REPRESENTATIONS ABOUT THE SUITABILITY OF THE CONTENTS FOR ANY PURPOSE; THE CONTENTS ARE PROVIDED
13  * "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14  * PARTICULAR PURPOSE, AND NON-INFRINGEMENT; AND 4) RENESAS SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, OR
15  * CONSEQUENTIAL DAMAGES, INCLUDING DAMAGES RESULTING FROM LOSS OF USE, DATA, OR PROJECTS, WHETHER IN AN ACTION OF
16  * CONTRACT OR TORT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE CONTENTS. Third-party contents
17  * included in this file may be subject to different terms.
18  **********************************************************************************************************************/
19 
20 /**********************************************************************************************************************
21  * File Name    : hw_dtc_common.h
22  * Description  : DTC register access functions.
23  **********************************************************************************************************************/
24 
25 #ifndef HW_DTC_COMMON_H
26 #define HW_DTC_COMMON_H
27 
28 /**********************************************************************************************************************
29  * Includes
30  **********************************************************************************************************************/
31 #include "bsp_api.h"
32 
33 /* Common macro for SSP header files. There is also a corresponding SSP_FOOTER macro at the end of this file. */
34 SSP_HEADER
35 
36 /***********************************************************************************************************************
37  * Macro definitions
38  **********************************************************************************************************************/
39 
40 /***********************************************************************************************************************
41  * Typedef definitions
42  **********************************************************************************************************************/
43 
44 /***********************************************************************************************************************
45  * Private function prototypes
46  **********************************************************************************************************************/
47 
48 /***********************************************************************************************************************
49  * Private global variables
50  **********************************************************************************************************************/
51 
52 /***********************************************************************************************************************
53  * Private Functions
54  **********************************************************************************************************************/
55 
56 /*******************************************************************************************************************//**
57  * Sets vector table base address
58  * @param  p_vectors    Vector table base address.
59  **********************************************************************************************************************/
HW_DTC_VectorTableAddressSet(R_DTC_Type * p_dtc_regs,void * p_vectors)60 __STATIC_INLINE void HW_DTC_VectorTableAddressSet (R_DTC_Type * p_dtc_regs, void * p_vectors)
61 {
62     p_dtc_regs->DTCVBR = (uint32_t) p_vectors;
63 }
64 
65 /*******************************************************************************************************************//**
66  * Sets vector table base address
67  * @returns Base address of vector table
68  **********************************************************************************************************************/
HW_DTC_VectorTableAddressGet(R_DTC_Type * p_dtc_regs)69 __STATIC_INLINE void * HW_DTC_VectorTableAddressGet (R_DTC_Type * p_dtc_regs)
70 {
71     return (void *) p_dtc_regs->DTCVBR;
72 }
73 
74 /*******************************************************************************************************************//**
75  * Sets read skip enable bit (allows vector table read step to be skipped if vector is same as last transfer)
76  * @param  read_skip    Whether to allow read skip
77  **********************************************************************************************************************/
HW_DTC_ReadSkipEnableSet(R_DTC_Type * p_dtc_regs,dtc_read_skip_t const read_skip)78 __STATIC_INLINE void HW_DTC_ReadSkipEnableSet (R_DTC_Type * p_dtc_regs, dtc_read_skip_t const read_skip)
79 {
80     p_dtc_regs->DTCCR_b.RRS = read_skip;
81 }
82 
83 /*******************************************************************************************************************//**
84  * Starts or stops the DTC (globally for all transfers).
85  * @param  on_off       Whether to start or stop the DTC
86  **********************************************************************************************************************/
HW_DTC_StartStop(R_DTC_Type * p_dtc_regs,dtc_startstop_t on_off)87 __STATIC_INLINE void HW_DTC_StartStop (R_DTC_Type * p_dtc_regs, dtc_startstop_t on_off)
88 {
89     p_dtc_regs->DTCST_b.DTCST = on_off;
90 }
91 
92 /*******************************************************************************************************************//**
93  * Enables DTC transfer in ICU
94  * @param  irq          Interrupt source used to activate transfer
95  **********************************************************************************************************************/
HW_ICU_DTCEnable(R_ICU_Type * p_icu_regs,IRQn_Type irq)96 __STATIC_INLINE void HW_ICU_DTCEnable (R_ICU_Type * p_icu_regs, IRQn_Type irq)
97 {
98 	p_icu_regs->IELSRn_b[irq].IR = 0U;
99     p_icu_regs->IELSRn_b[irq].DTCE = 1U;
100 }
101 
102 /*******************************************************************************************************************//**
103  * Disables DTC transfer in ICU
104  * @param  irq          Interrupt source used to deactivate transfer
105  **********************************************************************************************************************/
HW_ICU_DTCDisable(R_ICU_Type * p_icu_regs,IRQn_Type irq)106 __STATIC_INLINE void HW_ICU_DTCDisable (R_ICU_Type * p_icu_regs, IRQn_Type irq)
107 {
108 	p_icu_regs->IELSRn_b[irq].DTCE = 0U;
109 }
110 
111 /*******************************************************************************************************************//**
112  * Returns DTC status register.
113  * @returns DTC status register
114  **********************************************************************************************************************/
HW_DTC_StatusGet(R_DTC_Type * p_dtc_regs)115 __STATIC_INLINE uint16_t HW_DTC_StatusGet (R_DTC_Type * p_dtc_regs)
116 {
117     return p_dtc_regs->DTCSTS;
118 }
119 
HW_DTC_ICUEventGet(R_ICU_Type * p_icu_regs,IRQn_Type irq)120 __STATIC_INLINE elc_event_t HW_DTC_ICUEventGet (R_ICU_Type * p_icu_regs, IRQn_Type irq)
121 {
122     return (elc_event_t) p_icu_regs->IELSRn_b[irq].IELS;
123 }
124 
125 
126 /* Common macro for SSP header files. There is also a corresponding SSP_HEADER macro at the top of this file. */
127 SSP_FOOTER
128 
129 #endif /* HW_DTC_COMMON_H */
130