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_elc_common.h
22  * Description  : ELC LLD API
23  **********************************************************************************************************************/
24 
25 
26 /*******************************************************************************************************************//**
27  * @addtogroup ELC
28  * @{
29  **********************************************************************************************************************/
30 
31 #ifndef HW_ELC_COMMON_H
32 #define HW_ELC_COMMON_H
33 
34 /**********************************************************************************************************************
35  * Includes
36  **********************************************************************************************************************/
37 #include "bsp_api.h"
38 
39 
40 /* Common macro for SSP header files. There is also a corresponding SSP_FOOTER macro at the end of this file. */
41 SSP_HEADER
42 
43 
44 /***********************************************************************************************************************
45  * Macro definitions
46  **********************************************************************************************************************/
47 
48 /***********************************************************************************************************************
49  * Typedef definitions
50  **********************************************************************************************************************/
51 #define ELC_ELSEGRN_STEP1 (0U)     /* WI = 0, WE = 0, SEG = 0 */
52 #define ELC_ELSEGRN_STEP2 (0x40U)  /* WI = 0, WE = 1, SEG = 0 */
53 #define ELC_ELSEGRN_STEP3 (0x41U)  /* WI = 0, WE = 1, SEG = 1 */
54 
55 /***********************************************************************************************************************
56  * Private function prototypes
57  **********************************************************************************************************************/
58 
59 /***********************************************************************************************************************
60  * Private global variables
61  **********************************************************************************************************************/
62 
63 /***********************************************************************************************************************
64  * Private Functions
65  **********************************************************************************************************************/
66 
67 /*******************************************************************************************************************//**
68  * Generate a software event 0
69  **********************************************************************************************************************/
HW_ELC_SoftwareEvent0Generate(R_ELC_Type * p_elc_reg)70 __STATIC_INLINE void HW_ELC_SoftwareEvent0Generate (R_ELC_Type * p_elc_reg)
71 {
72     /* Step 1. enable the ELSEGR0 register for writing */
73     p_elc_reg->ELSEGRnRC0[0].ELSEGRn = ELC_ELSEGRN_STEP1;
74 
75     /* Step 2. Enable the SEG bit for writing */
76     p_elc_reg->ELSEGRnRC0[0].ELSEGRn = ELC_ELSEGRN_STEP2;
77 
78     /* Step 3. Set the SEG bit which causes the software event generation */
79     p_elc_reg->ELSEGRnRC0[0].ELSEGRn = ELC_ELSEGRN_STEP3;
80 }
81 
82 /*******************************************************************************************************************//**
83  * Generate a software event 1
84  **********************************************************************************************************************/
HW_ELC_SoftwareEvent1Generate(R_ELC_Type * p_elc_reg)85 __STATIC_INLINE void HW_ELC_SoftwareEvent1Generate (R_ELC_Type * p_elc_reg)
86 {
87     /* Step 1. enable the ELSEGR0 register for writing */
88     p_elc_reg->ELSEGRnRC0[1].ELSEGRn = ELC_ELSEGRN_STEP1;
89 
90     /* Step 2. Enable the SEG bit for writing */
91     p_elc_reg->ELSEGRnRC0[1].ELSEGRn = ELC_ELSEGRN_STEP2;
92 
93     /* Step 3. Set the SEG bit which causes the software event generation */
94     p_elc_reg->ELSEGRnRC0[1].ELSEGRn = ELC_ELSEGRN_STEP3;
95 }
96 
97 /*******************************************************************************************************************//**
98  * Enable the ELC block
99  **********************************************************************************************************************/
HW_ELC_Enable(R_ELC_Type * p_elc_reg)100 __STATIC_INLINE void HW_ELC_Enable (R_ELC_Type * p_elc_reg)
101 {
102     p_elc_reg->ELCR_b.ELCON = 1U;
103 }
104 
105 /*******************************************************************************************************************//**
106  * Disable the ELC block
107  **********************************************************************************************************************/
HW_ELC_Disable(R_ELC_Type * p_elc_reg)108 __STATIC_INLINE void HW_ELC_Disable (R_ELC_Type * p_elc_reg)
109 {
110     p_elc_reg->ELCR_b.ELCON = 0U;
111 }
112 
113 /*******************************************************************************************************************//**
114  * Make a link between a signal and a peripheral
115  **********************************************************************************************************************/
HW_ELC_LinkSet(R_ELC_Type * p_elc_reg,uint32_t peripheral,uint16_t signal)116 __STATIC_INLINE void HW_ELC_LinkSet (R_ELC_Type * p_elc_reg, uint32_t peripheral, uint16_t signal)
117 {
118     p_elc_reg->ELSRnRC0[peripheral].ELSRn = signal;
119 }
120 
121 /*******************************************************************************************************************//**
122  * Break a link between a signal and a peripheral
123  **********************************************************************************************************************/
HW_ELC_LinkBreak(R_ELC_Type * p_elc_reg,uint32_t peripheral)124 __STATIC_INLINE void HW_ELC_LinkBreak (R_ELC_Type * p_elc_reg, uint32_t peripheral)
125 {
126     p_elc_reg->ELSRnRC0[peripheral].ELSRn = 0U;
127 }
128 
129 
130 
131 /* Common macro for SSP header files. There is also a corresponding SSP_HEADER macro at the top of this file. */
132 SSP_FOOTER
133 
134 
135 #endif /* HW_ELC_COMMON_H */
136