PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
mft_icu.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3 *
4 * This software is owned and published by:
5 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6 *
7 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9 *
10 * This software contains source code for use with Spansion
11 * components. This software is licensed by Spansion to be adapted only
12 * for use in systems utilizing Spansion components. Spansion shall not be
13 * responsible for misuse or illegal use of this software for devices not
14 * supported herein. Spansion is providing this software "AS IS" and will
15 * not be responsible for issues arising from incorrect user implementation
16 * of the software.
17 *
18 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23 * WARRANTY OF NONINFRINGEMENT.
24 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30 * SAVINGS OR PROFITS,
31 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34 * FROM, THE SOFTWARE.
35 *
36 * This software may be replicated in part or whole for the licensed use,
37 * with the restriction that this Disclaimer and Copyright notice must be
38 * included with each copy of this software, whether used in part or whole,
39 * at all times.
40 */
41 /******************************************************************************/
55 /******************************************************************************/
56 /* Include files */
57 /******************************************************************************/
58 #include "mft_icu.h"
59 
60 #if (defined(PDL_PERIPHERAL_MFT_ICU_ACTIVE))
61 
67 
68 /******************************************************************************/
69 /* Local pre-processor symbols/macros ('#define') */
70 /******************************************************************************/
71 
72 /******************************************************************************/
73 /* Global variable definitions (declared in header file with 'extern') */
74 /******************************************************************************/
76 {
77 #if (PDL_PERIPHERAL_ENABLE_MFT0_ICU == PDL_ON)
78  {
79  &MFT0_ICU, // pstcInstance
80  NULL // stcInternData (not initialized yet)
81  },
82 #endif
83 #if (PDL_PERIPHERAL_ENABLE_MFT1_ICU == PDL_ON)
84  {
85  &MFT1_ICU, // pstcInstance
86  NULL // stcInternData (not initialized yet)
87  },
88 #endif
89 #if (PDL_PERIPHERAL_ENABLE_MFT2_ICU == PDL_ON)
90  {
91  &MFT2_ICU, // pstcInstance
92  NULL // stcInternData (not initialized yet)
93  },
94 #endif
95 };
96 
97 /******************************************************************************/
98 /* Local type definitions ('typedef') */
99 /******************************************************************************/
100 
101 /******************************************************************************/
102 /* Local function prototypes ('static') */
103 /******************************************************************************/
104 #if (PDL_INTERRUPT_ENABLE_MFT0_ICU == PDL_ON) || \
105  (PDL_INTERRUPT_ENABLE_MFT1_ICU == PDL_ON) || \
106  (PDL_INTERRUPT_ENABLE_MFT2_ICU == PDL_ON)
108 static en_result_t MftIcu_InitIrq( volatile stc_mftn_icu_t* pstcMftIcu );
109 static en_result_t MftIcu_DeInitIrq( volatile stc_mftn_icu_t* pstcMftIcu );
110 #endif
111 /******************************************************************************/
112 /* Local variable definitions ('static') */
113 /******************************************************************************/
114 
115 /******************************************************************************/
116 /* Function implementation - global ('extern') and local ('static') */
117 /******************************************************************************/
118 
119 #if (PDL_INTERRUPT_ENABLE_MFT0_ICU == PDL_ON) || \
120  (PDL_INTERRUPT_ENABLE_MFT1_ICU == PDL_ON) || \
121  (PDL_INTERRUPT_ENABLE_MFT2_ICU == PDL_ON)
122 
132 {
133  uint32_t u32Instance;
134 
135  for (u32Instance = 0u; u32Instance < MFT_ICU_INSTANCE_COUNT; u32Instance++)
136  {
137  if (pstcMftIcu == m_astcMftIcuInstanceDataLut[u32Instance].pstcInstance)
138  {
139  return &m_astcMftIcuInstanceDataLut[u32Instance].stcInternData;
140  }
141  }
142 
143  return NULL;
144 }
145 
155 void Mft_Icu_IrqHandler( volatile stc_mftn_icu_t* pstcMftIcu,
156  stc_mft_icu_intern_data_t* pstcMftIcuInternData)
157 {
158  // ICU interrupt 0
159  if(TRUE == pstcMftIcu->ICSA10_f.ICP0)
160  {
161  pstcMftIcu->ICSA10_f.ICP0 = 0u;
162  if (pstcMftIcuInternData->pfnIcu0Callback != NULL)
163  {
164  pstcMftIcuInternData->pfnIcu0Callback();
165  }
166  }
167  // ICU interrupt 1
168  if(TRUE == pstcMftIcu->ICSA10_f.ICP1)
169  {
170  pstcMftIcu->ICSA10_f.ICP1 = 0u;
171  if (pstcMftIcuInternData->pfnIcu1Callback != NULL)
172  {
173  pstcMftIcuInternData->pfnIcu1Callback();
174  }
175  }
176  // ICU interrupt 2
177  if(TRUE == pstcMftIcu->ICSA32_f.ICP0)
178  {
179  pstcMftIcu->ICSA32_f.ICP0 = 0u;
180  if (pstcMftIcuInternData->pfnIcu2Callback != NULL)
181  {
182  pstcMftIcuInternData->pfnIcu2Callback();
183  }
184  }
185  // ICU interrupt 3
186  if(TRUE == pstcMftIcu->ICSA32_f.ICP1)
187  {
188  pstcMftIcu->ICSA32_f.ICP1 = 0u;
189  if (pstcMftIcuInternData->pfnIcu3Callback != NULL)
190  {
191  pstcMftIcuInternData->pfnIcu3Callback();
192  }
193  }
194 }
195 
206 static en_result_t MftIcu_InitIrq( volatile stc_mftn_icu_t* pstcMftIcu )
207 {
208 #if (PDL_INTERRUPT_ENABLE_MFT0_ICU == PDL_ON)
209  if (pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT0_ICU))
210  {
211  NVIC_ClearPendingIRQ(ICU0_IRQn);
212  NVIC_EnableIRQ(ICU0_IRQn);
213  NVIC_SetPriority(ICU0_IRQn, PDL_IRQ_LEVEL_MFT0_ICU);
214  }
215 #endif
216 #if (PDL_INTERRUPT_ENABLE_MFT1_ICU == PDL_ON)
217  if (pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT1_ICU))
218  {
219  NVIC_ClearPendingIRQ(ICU1_IRQn);
220  NVIC_EnableIRQ(ICU1_IRQn);
221  NVIC_SetPriority(ICU1_IRQn, PDL_IRQ_LEVEL_MFT1_ICU);
222  }
223 #endif
224 #if (PDL_INTERRUPT_ENABLE_MFT2_ICU == PDL_ON)
225  if (pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT2_ICU))
226  {
227  NVIC_ClearPendingIRQ(ICU2_IRQn);
228  NVIC_EnableIRQ(ICU2_IRQn);
229  NVIC_SetPriority(ICU2_IRQn, PDL_IRQ_LEVEL_MFT2_ICU);
230  }
231 #endif
232  return Ok;
233 }
234 
244 static en_result_t MftIcu_DeInitIrq( volatile stc_mftn_icu_t* pstcMftIcu )
245 {
246  if((pstcMftIcu->ICSA10_f.ICE0 == 0u) &&
247  (pstcMftIcu->ICSA10_f.ICE1 == 0u) &&
248  (pstcMftIcu->ICSA32_f.ICE0 == 0u) &&
249  (pstcMftIcu->ICSA32_f.ICE1 == 0u) )
250  {
251  #if (PDL_INTERRUPT_ENABLE_MFT0_ICU == PDL_ON)
252  if (pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT0_ICU))
253  {
254  NVIC_ClearPendingIRQ(ICU0_IRQn);
255  NVIC_DisableIRQ(ICU0_IRQn);
256  NVIC_SetPriority(ICU0_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
257  }
258  #endif
259  #if (PDL_INTERRUPT_ENABLE_MFT1_ICU == PDL_ON)
260  if (pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT1_ICU))
261  {
262  NVIC_ClearPendingIRQ(ICU1_IRQn);
263  NVIC_DisableIRQ(ICU1_IRQn);
264  NVIC_SetPriority(ICU1_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
265  }
266  #endif
267  #if (PDL_INTERRUPT_ENABLE_MFT2_ICU == PDL_ON)
268  if (pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT2_ICU))
269  {
270  NVIC_ClearPendingIRQ(ICU2_IRQn);
271  NVIC_DisableIRQ(ICU2_IRQn);
272  NVIC_SetPriority(ICU2_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
273  }
274  #endif
275  }
276  return Ok;
277 }
278 
279 #endif
280 
298 en_result_t Mft_Icu_SelFrt( volatile stc_mftn_icu_t* pstcMftIcu, uint8_t u8Ch, en_mft_icu_frt_t enFrt)
299 {
300  stc_mft_icu_icfs10_field_t* stcICFS10 = { 0u };
301  stc_mft_icu_icfs32_field_t* stcICFS32 = { 0u };
302 
303  // Check for NULL pointer and channel parameter
304  boolean_t bAvoidSideEffects = ((NULL == pstcMftIcu) ? 1u : 0u);
305  bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
306  if (TRUE == bAvoidSideEffects)
307  {
308  return ErrorInvalidParameter ;
309  }
310 
311  // Get actual address of register list of current channel
312  stcICFS10 = (stc_mft_icu_icfs10_field_t*)(&(pstcMftIcu->ICFS10));
313  stcICFS32 = (stc_mft_icu_icfs32_field_t*)(&(pstcMftIcu->ICFS32));
314 
315  // FRT channel select: FRTx -> ICUx
316  if(enFrt > IcuFrtToExt1)
317  {
318  return ErrorInvalidParameter;
319  }
320  // configure the Frt channel to connect to Icu
321  switch(u8Ch)
322  {
323  // ICU channel 0
324  case MFT_ICU_CH0:
325  stcICFS10->FSI00 = (((uint8_t)enFrt >> 0u) & 0x01u);
326  stcICFS10->FSI01 = (((uint8_t)enFrt >> 1u) & 0x01u);
327  stcICFS10->FSI02 = (((uint8_t)enFrt >> 2u) & 0x01u);
328  stcICFS10->FSI03 = (((uint8_t)enFrt >> 3u) & 0x01u);
329  break;
330  // ICU channel 1
331  case MFT_ICU_CH1:
332  stcICFS10->FSI10 = (((uint8_t)enFrt >> 0u) & 0x01u);
333  stcICFS10->FSI11 = (((uint8_t)enFrt >> 1u) & 0x01u);
334  stcICFS10->FSI12 = (((uint8_t)enFrt >> 2u) & 0x01u);
335  stcICFS10->FSI13 = (((uint8_t)enFrt >> 3u) & 0x01u);
336  break;
337  // ICU channel 2
338  case MFT_ICU_CH2:
339  stcICFS32->FSI00 = (((uint8_t)enFrt >> 0u) & 0x01u);
340  stcICFS32->FSI01 = (((uint8_t)enFrt >> 1u) & 0x01u);
341  stcICFS32->FSI02 = (((uint8_t)enFrt >> 2u) & 0x01u);
342  stcICFS32->FSI03 = (((uint8_t)enFrt >> 3u) & 0x01u);
343  break;
344  // ICU channel 3
345  case MFT_ICU_CH3:
346  stcICFS32->FSI10 = (((uint8_t)enFrt >> 0u) & 0x01u);
347  stcICFS32->FSI11 = (((uint8_t)enFrt >> 1u) & 0x01u);
348  stcICFS32->FSI12 = (((uint8_t)enFrt >> 2u) & 0x01u);
349  stcICFS32->FSI13 = (((uint8_t)enFrt >> 3u) & 0x01u);
350  break;
351  default:
352  return ErrorInvalidParameter;
353  }
354 
355  return Ok;
356 }
357 
375 en_result_t Mft_Icu_ConfigDetectMode( volatile stc_mftn_icu_t* pstcMftIcu, uint8_t u8Ch,
376  en_mft_icu_mode_t enMode)
377 {
378  // Check for NULL pointer and channel parameter
379  boolean_t bAvoidSideEffects = ((NULL == pstcMftIcu) ? 1u : 0u);
380  bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
381  if (bAvoidSideEffects)
382  {
383  return ErrorInvalidParameter ;
384  }
385 
386  // Check configuration of Mft Icu mode
387  if(enMode > IcuBothDetect)
388  {
389  return ErrorInvalidParameter;
390  }
391  // Configure Icu detection mode
392  switch (u8Ch)
393  {
394  // ICU channel 0
395  case MFT_ICU_CH0:
396  pstcMftIcu->ICSA10_f.EG00 = (((uint8_t)enMode >> 0u) & 0x01u);
397  pstcMftIcu->ICSA10_f.EG01 = (((uint8_t)enMode >> 1u) & 0x01u);
398  break;
399  // ICU channel 1
400  case MFT_ICU_CH1:
401  pstcMftIcu->ICSA10_f.EG10 = (((uint8_t)enMode >> 0u) & 0x01u);
402  pstcMftIcu->ICSA10_f.EG11 = (((uint8_t)enMode >> 1u) & 0x01u);
403  break;
404  // ICU channel 2
405  case MFT_ICU_CH2:
406  pstcMftIcu->ICSA32_f.EG00 = (((uint8_t)enMode >> 0u) & 0x01u);
407  pstcMftIcu->ICSA32_f.EG01 = (((uint8_t)enMode >> 1u) & 0x01u);
408  break;
409  // ICU channel 3
410  case MFT_ICU_CH3:
411  pstcMftIcu->ICSA32_f.EG10 = (((uint8_t)enMode >> 0u) & 0x01u);
412  pstcMftIcu->ICSA32_f.EG11 = (((uint8_t)enMode >> 1u) & 0x01u);
413  break;
414  // ICU channel number error
415  default:
416  return ErrorInvalidParameter;
417  }
418  return Ok;
419 }
420 
421 #if (PDL_INTERRUPT_ENABLE_MFT0_ICU == PDL_ON) || \
422  (PDL_INTERRUPT_ENABLE_MFT1_ICU == PDL_ON) || \
423  (PDL_INTERRUPT_ENABLE_MFT2_ICU == PDL_ON)
424 
438 en_result_t Mft_Icu_EnableInt( volatile stc_mftn_icu_t*pstcMftIcu, uint8_t u8Ch,
439  func_ptr_t pfnCallback)
440 {
441  // Pointer to internal data
442  stc_mft_icu_intern_data_t* pstcMftIcuInternData ;
443  volatile stc_mftn_icu_t* pstcOrgMftIcu = pstcMftIcu;
444 
445  // Check for NULL pointer and channel parameter
446  boolean_t bAvoidSideEffects = ((NULL == pstcMftIcu) ? 1u : 0u);
447  bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
448  if (bAvoidSideEffects)
449  {
450  return ErrorInvalidParameter ;
451  }
452 
453  // Get pointer to internal data structure
454  pstcMftIcuInternData = MftIcuGetInternDataPtr( pstcOrgMftIcu );
455 
456  switch (u8Ch)
457  {
458  // ICU channel 0
459  case MFT_ICU_CH0:
460  pstcMftIcuInternData->pfnIcu0Callback = pfnCallback;
461  pstcMftIcu->ICSA10_f.ICE0 = 1u;
462  break;
463  // ICU channel 1
464  case MFT_ICU_CH1:
465  pstcMftIcuInternData->pfnIcu1Callback = pfnCallback;
466  pstcMftIcu->ICSA10_f.ICE1 = 1u;
467  break;
468  // ICU channel 2
469  case MFT_ICU_CH2:
470  pstcMftIcuInternData->pfnIcu2Callback = pfnCallback;
471  pstcMftIcu->ICSA32_f.ICE0 = 1u;
472  break;
473  // ICU channel 3
474  case MFT_ICU_CH3:
475  pstcMftIcuInternData->pfnIcu3Callback = pfnCallback;
476  pstcMftIcu->ICSA32_f.ICE1 = 1u;
477  break;
478  // ICU channel number error
479  default:
480  return ErrorInvalidParameter;
481  }
482 
483  // initialize interrupt
484  MftIcu_InitIrq(pstcOrgMftIcu);
485  return Ok;
486 }
487 
501 en_result_t Mft_Icu_DisableInt( volatile stc_mftn_icu_t*pstcMftIcu, uint8_t u8Ch)
502 {
503  // Pointer to internal data
504  stc_mft_icu_intern_data_t* pstcMftIcuInternData ;
505  volatile stc_mftn_icu_t* pstcOrgMftIcu = pstcMftIcu;
506 
507  // Check for NULL pointer and channel parameter
508  boolean_t bAvoidSideEffects = ((NULL == pstcMftIcu) ? 1u : 0u);
509  bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
510  if (bAvoidSideEffects)
511  {
512  return ErrorInvalidParameter ;
513  }
514 
515  // Get pointer to internal data structure
516  pstcMftIcuInternData = MftIcuGetInternDataPtr( pstcOrgMftIcu );
517  // Dis-register callback function and disable interrupt operation
518  switch (u8Ch)
519  {
520  // ICU channel 0
521  case MFT_ICU_CH0:
522  pstcMftIcuInternData->pfnIcu0Callback = NULL;
523  pstcMftIcu->ICSA10_f.ICE0 = 0u;
524  break;
525  // ICU channel 1
526  case MFT_ICU_CH1:
527  pstcMftIcuInternData->pfnIcu1Callback = NULL;
528  pstcMftIcu->ICSA10_f.ICE1 = 0u;
529  break;
530  // ICU channel 2
531  case MFT_ICU_CH2:
532  pstcMftIcuInternData->pfnIcu2Callback = NULL;
533  pstcMftIcu->ICSA32_f.ICE0 = 0u;
534  break;
535  // ICU channel 3
536  case MFT_ICU_CH3:
537  pstcMftIcuInternData->pfnIcu3Callback = NULL;
538  pstcMftIcu->ICSA32_f.ICE1 = 0u;
539  break;
540  // ICU channel number error
541  default:
542  return ErrorInvalidParameter;
543  }
544 
545  MftIcu_DeInitIrq(pstcOrgMftIcu);
546  return Ok;
547 }
548 
549 #endif
550 
564 en_int_flag_t Mft_Icu_GetIntFlag(volatile stc_mftn_icu_t *pstcMftIcu, uint8_t u8Ch)
565 {
566  en_int_flag_t enIntFlagBuf;
567 
568  // Read interrupt flag
569  switch (u8Ch)
570  {
571  // ICU channel 0
572  case MFT_ICU_CH0:
573  enIntFlagBuf = (en_int_flag_t)(pstcMftIcu->ICSA10_f.ICP0);
574  break;
575  // ICU channel 1
576  case MFT_ICU_CH1:
577  enIntFlagBuf = (en_int_flag_t)(pstcMftIcu->ICSA10_f.ICP1);
578  break;
579  // ICU channel 2
580  case MFT_ICU_CH2:
581  enIntFlagBuf = (en_int_flag_t)(pstcMftIcu->ICSA32_f.ICP0);
582  break;
583  // ICU channel 3
584  case MFT_ICU_CH3:
585  enIntFlagBuf = (en_int_flag_t)(pstcMftIcu->ICSA32_f.ICP1);
586  break;
587  // ICU channel number error
588  default:
589  break;
590  }
591  // return interrupt flag
592  return (en_int_flag_t)enIntFlagBuf;
593 }
607 en_result_t Mft_Icu_ClrIntFlag( volatile stc_mftn_icu_t *pstcMftIcu, uint8_t u8Ch)
608 {
609  // Check for NULL pointer and channel parameter
610  boolean_t bAvoidSideEffects = ((NULL == pstcMftIcu) ? 1u : 0u);
611  bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
612  if (bAvoidSideEffects)
613  {
614  return ErrorInvalidParameter ;
615  }
616 
617  // Clear interrupt flag
618  switch (u8Ch)
619  {
620  // ICU channel 0
621  case MFT_ICU_CH0:
622  pstcMftIcu->ICSA10_f.ICP0 = 0u;
623  break;
624  // ICU channel 1
625  case MFT_ICU_CH1:
626  pstcMftIcu->ICSA10_f.ICP1 = 0u;
627  break;
628  // ICU channel 2
629  case MFT_ICU_CH2:
630  pstcMftIcu->ICSA32_f.ICP0 = 0u;
631  break;
632  // ICU channel 3
633  case MFT_ICU_CH3:
634  pstcMftIcu->ICSA32_f.ICP1 = 0u;
635  break;
636  // ICU channel number error
637  default:
638  return ErrorInvalidParameter;
639  }
640 
641  return Ok;
642 }
654 en_mft_icu_edge_t Mft_Icu_GetLastEdge( volatile stc_mftn_icu_t *pstcMftIcu, uint8_t u8Ch)
655 {
656  en_mft_icu_edge_t enEdgeTypeBuf;
657 
658  // Read last Edge type
659  switch (u8Ch)
660  {
661  // ICU channel 0
662  case MFT_ICU_CH0:
663  enEdgeTypeBuf = (en_mft_icu_edge_t)(pstcMftIcu->ICSB10_f.IEI0);
664  break;
665  // ICU channel 1
666  case MFT_ICU_CH1:
667  enEdgeTypeBuf = (en_mft_icu_edge_t)(pstcMftIcu->ICSB10_f.IEI1);
668  break;
669  // ICU channel 2
670  case MFT_ICU_CH2:
671  enEdgeTypeBuf = (en_mft_icu_edge_t)(pstcMftIcu->ICSB32_f.IEI0);
672  break;
673  // ICU channel 3
674  case MFT_ICU_CH3:
675  enEdgeTypeBuf = (en_mft_icu_edge_t)(pstcMftIcu->ICSB32_f.IEI1);
676  break;
677  // ICU channel number error
678  default:
679  break;
680  }
681  // return last edge type
682  return (en_mft_icu_edge_t)enEdgeTypeBuf;
683 }
695 uint16_t Mft_Icu_GetCaptureData(volatile stc_mftn_icu_t *pstcMftIcu, uint8_t u8Ch)
696 {
697  uint16_t u16CaptureVal;
698  // Check for NULL pointer and channel parameter
699  boolean_t bAvoidSideEffects = ((NULL == pstcMftIcu) ? 1u : 0u);
700  bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
701  if (bAvoidSideEffects)
702  {
703  return ErrorInvalidParameter ;
704  }
705  // Read captured value
706  switch (u8Ch)
707  {
708  // ICU channel 0
709  case MFT_ICU_CH0:
710  u16CaptureVal = (uint16_t)(pstcMftIcu->ICCP0);
711  break;
712  // ICU channel 1
713  case MFT_ICU_CH1:
714  u16CaptureVal = (uint16_t)(pstcMftIcu->ICCP1);
715  break;
716  // ICU channel 2
717  case MFT_ICU_CH2:
718  u16CaptureVal = (uint16_t)(pstcMftIcu->ICCP2);
719  break;
720  // ICU channel 3
721  case MFT_ICU_CH3:
722  u16CaptureVal = (uint16_t)(pstcMftIcu->ICCP3);
723  break;
724  // ICU channel number error
725  default:
726  return ErrorInvalidParameter;
727  }
728 
729  return (uint16_t)u16CaptureVal;
730 }
731 
733 
734 #endif // #if (defined(PDL_PERIPHERAL_MFT_ICU_ACTIVE))
735 
736 /******************************************************************************/
737 /* EOF (not truncated) */
738 /******************************************************************************/