iLLD_TC27xD  1.0
IfxIom_Iom.c
Go to the documentation of this file.
1 /**
2  * \file IfxIom_Iom.c
3  * \brief IOM IOM details
4  *
5  * \version iLLD_1_0_0_11_0
6  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
7  *
8  *
9  * IMPORTANT NOTICE
10  *
11  *
12  * Infineon Technologies AG (Infineon) is supplying this file for use
13  * exclusively with Infineon's microcontroller products. This file can be freely
14  * distributed within development tools that are supporting such microcontroller
15  * products.
16  *
17  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
18  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
20  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
21  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
22  *
23  *
24  */
25 
26 /******************************************************************************/
27 /*----------------------------------Includes----------------------------------*/
28 /******************************************************************************/
29 
30 #include "IfxIom_Iom.h"
31 
32 /******************************************************************************/
33 /*-------------------------Function Implementations---------------------------*/
34 /******************************************************************************/
35 
37 {
38  Ifx_IOM *iomSFR = iom->iom;
39  uint8 channelId = (IfxIom_FpcChannelId)fpcConfig->channelId;
40 
41  if (fpcConfig->edgeType == IfxIom_EdgeClearType_rising) /* to clear rising edge */
42  {
43  Ifx_IOM_FPCESR tempFPCESR;
44  tempFPCESR.U = (1 << (channelId + 16U));
45  iomSFR->FPCESR.U = tempFPCESR.U;
46  }
47  else if (fpcConfig->edgeType == IfxIom_EdgeClearType_falling) /* to clear falling edge */
48  {
49  Ifx_IOM_FPCESR tempFPCESR;
50  tempFPCESR.U = (1 << channelId);
51  iomSFR->FPCESR.U = tempFPCESR.U;
52  }
53  else if (fpcConfig->edgeType == IfxIom_EdgeClearType_risingFalling) /* to clear both edges */
54  {
55  Ifx_IOM_FPCESR tempFPCESR;
56  tempFPCESR.U = (1 << channelId);
57  tempFPCESR.U |= (1 << (channelId + 16U));
58  iomSFR->FPCESR.U = tempFPCESR.U;
59  }
60  else
61  {
62  /* do nothing */
63  }
64 }
65 
66 
68 {
69  IfxIom_resetModule(iom->iom);
70 }
71 
72 
74 {
75  boolean status = TRUE;
76 
77  Ifx_IOM *iomSFR = iom->iom;
78  uint8 lamId = (IfxIom_LamId)lamConfig->lamId;
79  {
80  Ifx_IOM_LAMCFG tempLAMCFG;
81  tempLAMCFG.U = 0;
82  tempLAMCFG.B.IVR = lamConfig->referenceSignalInverted;
83  tempLAMCFG.B.IVM = lamConfig->monitorSignalInverted;
84  tempLAMCFG.B.MOS = lamConfig->lamMonitorSource;
85  tempLAMCFG.B.RMS = lamConfig->lamMode;
86  tempLAMCFG.B.EWS = lamConfig->eventSource;
87  tempLAMCFG.B.EDS = lamConfig->eventActiveEdgeSelection;
88  tempLAMCFG.B.IVW = lamConfig->eventWindowInverted;
89  tempLAMCFG.B.MCS = lamConfig->lamMonitorInputChannel;
90  tempLAMCFG.B.RCS = lamConfig->lamReferenceInputChannel;
91  iomSFR->LAMCFG[lamId].U = tempLAMCFG.U;
92  }
93 
94  {
95  Ifx_IOM_LAMEWS tempLAMEWS;
96  tempLAMEWS.U = 0;
97  tempLAMEWS.B.THR = lamConfig->eventWindowThreshold;
98  iomSFR->LAMEWS[lamId].U = tempLAMEWS.U;
99  }
100  return status;
101 }
102 
103 
105 {
106  lamConfig->lamId = IfxIom_LamId_0;
110  lamConfig->eventWindowThreshold = 15;
111  lamConfig->monitorSignalInverted = TRUE;
112  lamConfig->referenceSignalInverted = TRUE;
115  lamConfig->eventWindowInverted = TRUE;
117 }
118 
119 
121 {
122  boolean status = TRUE;
123  Ifx_IOM *iomSFR = iom->iom;
124  {
125  Ifx_IOM_ECMCCFG tempECMCCFG;
126  tempECMCCFG.U = 0;
127  tempECMCCFG.B.SELC0 = ecmConfig->eventCounter[0].input;
128  tempECMCCFG.B.THRC0 = ecmConfig->eventCounter[0].threshold;
129  tempECMCCFG.B.SELC1 = ecmConfig->eventCounter[1].input;
130  tempECMCCFG.B.THCR1 = ecmConfig->eventCounter[1].threshold;
131  tempECMCCFG.B.SELC2 = ecmConfig->eventCounter[2].input;
132  tempECMCCFG.B.THCR2 = ecmConfig->eventCounter[2].threshold;
133  tempECMCCFG.B.SELC3 = ecmConfig->eventCounter[3].input;
134  tempECMCCFG.B.THCR3 = ecmConfig->eventCounter[3].threshold;
135  iomSFR->ECMCCFG.U = tempECMCCFG.U;
136  }
137 
138  {
139  iomSFR->ECMSELR.U = ecmConfig->globalEventSelection.U;
140  }
141  return status;
142 }
143 
144 
146 {
147  uint8 counterId;
148  ecmConfig->globalEventSelection.U = 0;
149 
150  for (counterId = 0; counterId <= 3; counterId++)
151  {
152  ecmConfig->eventCounter[counterId].input = IfxIom_EventCounterChannel_0;
154  }
155 }
156 
157 
159 {
160  boolean status = TRUE;
161 
162  Ifx_IOM *iomSFR = iom->iom;
163  uint8 exorInput;
164 
165  {
166  uint8 channelId = (IfxIom_FpcChannelId)fpcConfig->channelId;
167  Ifx_IOM_FPCCTR tempFPCCTR;
168  tempFPCCTR.U = 0;
169  tempFPCCTR.B.CMP = fpcConfig->comparatorThreshold;
170  tempFPCCTR.B.MOD = fpcConfig->filterMode;
171  tempFPCCTR.B.ISM = fpcConfig->monitorSignal;
172  tempFPCCTR.B.RTG = fpcConfig->timerReset;
173  tempFPCCTR.B.ISR = fpcConfig->referenceSignal;
174  iomSFR->FPCCTR[channelId].U = tempFPCCTR.U;
175  }
176 
177  {
178  Ifx_IOM_GTMEXR tempGTMEXR;
179  tempGTMEXR.U = 0;
180 
181  for (exorInput = 0; exorInput <= 7; exorInput++)
182  {
183  if (fpcConfig->exorInputEnable[exorInput])
184  {
185  tempGTMEXR.U |= (1 << exorInput);
186  }
187  else
188  {
189  tempGTMEXR.U &= ~(1 << exorInput);
190  }
191  }
192 
193  iomSFR->GTMEXR.U = tempGTMEXR.U;
194  }
195  return status;
196 }
197 
198 
200 {
201  uint8 exorInput;
202  fpcConfig->channelId = IfxIom_FpcChannelId_0;
206  fpcConfig->comparatorThreshold = 15;
207  fpcConfig->timerReset = TRUE;
209 
210  for (exorInput = 0; exorInput <= 7; exorInput++)
211  {
212  fpcConfig->exorInputEnable[exorInput] = FALSE;
213  }
214 }
215 
216 
218 {
219  boolean status = TRUE;
220 
221  Ifx_IOM *iomSFR = iom->iom;
222  {
223  Ifx_IOM_CLC tempCLC;
224  tempCLC.U = 0;
225  tempCLC.B.EDIS = 0;
226  tempCLC.B.RMC = 1;
229  iomSFR->CLC.U = tempCLC.U;
230  IfxIom_enableModule(iomSFR);
231  IfxScuWdt_setCpuEndinit(passwd);
232  }
233 
234  return status;
235 }
236 
237 
238 void IfxIom_Iom_initModuleConfig(IfxIom_Iom *iom, Ifx_IOM *module)
239 {
240  iom->iom = module;
241 }