PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
mft_ocu.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_ocu.h"
59 
60 #if (defined(PDL_PERIPHERAL_MFT_OCU_ACTIVE))
61 
67 
68 /******************************************************************************/
69 /* Local pre-processor symbols/macros ('#define') */
70 /******************************************************************************/
72 #define OCU_INSTANCE_COUNT (uint32_t)(sizeof(m_astcMftOcuInstanceDataLut) \
73  / sizeof(m_astcMftOcuInstanceDataLut[0]))
74 
75 /******************************************************************************/
76 /* Global variable definitions (declared in header file with 'extern') */
77 /******************************************************************************/
80 {
81 #if (PDL_PERIPHERAL_ENABLE_MFT0_OCU == PDL_ON)
82  {
83  &MFT0_OCU, // pstcInstance
84  NULL // stcInternData (not initialized yet)
85  },
86 #endif
87 #if (PDL_PERIPHERAL_ENABLE_MFT1_OCU == PDL_ON)
88  {
89  &MFT1_OCU, // pstcInstance
90  NULL // stcInternData (not initialized yet)
91  },
92 #endif
93 #if (PDL_PERIPHERAL_ENABLE_MFT2_OCU == PDL_ON)
94  {
95  &MFT2_OCU, // pstcInstance
96  NULL // stcInternData (not initialized yet)
97  },
98 #endif
99 };
100 
101 /******************************************************************************/
102 /* Local type definitions ('typedef') */
103 /******************************************************************************/
104 
105 /******************************************************************************/
106 /* Local function prototypes ('static') */
107 /******************************************************************************/
108 
109 /******************************************************************************/
110 /* Local variable definitions ('static') */
111 /******************************************************************************/
112 
113 /******************************************************************************/
114 /* Function implementation - global ('extern') and local ('static') */
115 /******************************************************************************/
127 {
128  uint32_t u32Instance;
129 
130  for (u32Instance = 0; u32Instance < OCU_INSTANCE_COUNT; u32Instance++)
131  {
132  if (pstcOcu == m_astcMftOcuInstanceDataLut[u32Instance].pstcInstance)
133  {
134  return &m_astcMftOcuInstanceDataLut[u32Instance].stcInternData;
135  }
136  }
137 
138  return NULL;
139 }
140 
141 #if (PDL_INTERRUPT_ENABLE_MFT0_OCU == PDL_ON) || \
142  (PDL_INTERRUPT_ENABLE_MFT1_OCU == PDL_ON) || \
143  (PDL_INTERRUPT_ENABLE_MFT2_OCU == PDL_ON)
144 
157 void Mft_Ocu_IrqHandler( volatile stc_mftn_ocu_t*pstcMft,
158  stc_mft_ocu_intern_data_t* pstcMftOcuInternData)
159 {
160  func_ptr_t funCallBack;
161  uint32_t* ptemp;
162  uint8_t Ch;
163 
164  //lookup the handler
165  for(Ch=0;Ch<MFT_OCU_MAXCH;Ch++)
166  {
167  if(PdlSet == Mft_Ocu_GetIntFlag(pstcMft,Ch))
168  {
169  //clear the interrupt flag
170  Mft_Ocu_ClrIntFlag(pstcMft,Ch);
171 
172  //pointer callback function address
173  ptemp = (uint32_t*)&(pstcMftOcuInternData->pfnOcu0Callback);
174  funCallBack = (func_ptr_t)(*(uint32_t*)((uint32_t)ptemp +
175  (sizeof(func_ptr_t) * Ch)));
176 
177  if(funCallBack != NULL)
178  {
179  funCallBack();
180  }
181  }
182  }
183 }
184 
195 static en_result_t Mft_Ocu_InitIrq( volatile stc_mftn_ocu_t* pstcMft )
196 {
197 
198 #if (PDL_INTERRUPT_ENABLE_MFT0_OCU == PDL_ON)
199  if (pstcMft == (stc_mftn_ocu_t*)(&MFT0_OCU))
200  {
201  NVIC_ClearPendingIRQ(OCU0_IRQn);
202  NVIC_EnableIRQ(OCU0_IRQn);
203  NVIC_SetPriority(OCU0_IRQn, PDL_IRQ_LEVEL_MFT0_OCU);
204  }
205 #endif
206 #if (PDL_INTERRUPT_ENABLE_MFT1_OCU == PDL_ON)
207  if (pstcMft == (stc_mftn_ocu_t*)(&MFT1_OCU))
208  {
209  NVIC_ClearPendingIRQ(OCU1_IRQn);
210  NVIC_EnableIRQ(OCU1_IRQn);
211  NVIC_SetPriority(OCU1_IRQn, PDL_IRQ_LEVEL_MFT1_OCU);
212  }
213 #endif
214 #if (PDL_INTERRUPT_ENABLE_MFT2_OCU == PDL_ON)
215  if (pstcMft == (stc_mftn_ocu_t*)(&MFT2_OCU))
216  {
217  NVIC_ClearPendingIRQ(OCU2_IRQn);
218  NVIC_EnableIRQ(OCU2_IRQn);
219  NVIC_SetPriority(OCU2_IRQn, PDL_IRQ_LEVEL_MFT2_OCU);
220  }
221 #endif
222  return Ok;
223 }
224 
234 static en_result_t Mft_Ocu_DeInitIrq( volatile stc_mftn_ocu_t* pstcMft )
235 {
236  if((pstcMft->OCSA10_f.IOE0 == 0) && (pstcMft->OCSA10_f.IOE1 == 0) &&
237  (pstcMft->OCSA32_f.IOE0 == 0) && (pstcMft->OCSA10_f.IOE1 == 0) &&
238  (pstcMft->OCSA54_f.IOE0 == 0) && (pstcMft->OCSA10_f.IOE1 == 0) )
239  {
240  #if (PDL_INTERRUPT_ENABLE_MFT0_OCU == PDL_ON)
241  if (pstcMft == (stc_mftn_ocu_t*)(&MFT0_OCU))
242  {
243  NVIC_ClearPendingIRQ(OCU0_IRQn);
244  NVIC_DisableIRQ(OCU0_IRQn);
245  NVIC_SetPriority(OCU0_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
246 
247  }
248  #endif
249  #if (PDL_INTERRUPT_ENABLE_MFT1_OCU == PDL_ON)
250  if (pstcMft == (stc_mftn_ocu_t*)(&MFT1_OCU))
251  {
252  NVIC_ClearPendingIRQ(OCU1_IRQn);
253  NVIC_DisableIRQ(OCU1_IRQn);
254  NVIC_SetPriority(OCU1_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
255  }
256  #endif
257  #if (PDL_INTERRUPT_ENABLE_MFT2_OCU == PDL_ON)
258  if (pstcMft == (stc_mftn_ocu_t*)(&MFT2_OCU))
259  {
260  NVIC_ClearPendingIRQ(OCU2_IRQn);
261  NVIC_DisableIRQ(OCU2_IRQn);
262  NVIC_SetPriority(OCU2_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
263  }
264  #endif
265  }
266  return Ok;
267 }
268 
269 #endif
270 
271 /******************************************************************************/
272 /* Local Functions */
273 /******************************************************************************/
274 
294  uint8_t u8Ch, stc_mft_ocu_config_t* pstcOcuConfig)
295 {
296  stc_mft_ocu_intern_data_t* pstcOcuInternData;
297  uint8_t* p32OCFS;
298  stc_mft_ocu_ocsb10_field_t* pstcOCSB;
299  uint8_t* p8OCSC;
300  stc_mft_ocu_ocsd10_field_t* pstcOCSD;
301 
302  // Check for NULL pointer and configuration parameter
303  if ( (pstcMft == NULL) ||
304  (u8Ch >= MFT_OCU_MAXCH) ||
305  (pstcOcuConfig->enFrtConnect > OcuFrtToExt) ||
306  (pstcOcuConfig->bFm4 > 1) ||
307  (pstcOcuConfig->bCmod > 1) ||
308  (pstcOcuConfig->enOccpBufMode > OccpBufTrsfByFrtZeroPeak ) ||
309  (pstcOcuConfig->enOcseBufMode > OcseBufTrsfByFrtZeroPeak ) )
310  {
311  return ErrorInvalidParameter ;
312  }
313  // Get pointer to internal data structure ...
314  pstcOcuInternData = MftGetInternDataPtr( pstcMft ) ;
315  // ... and check for NULL
316  if ( pstcOcuInternData != NULL )
317  {
318  pstcOcuInternData->pfnOcu0Callback = NULL;
319  pstcOcuInternData->pfnOcu1Callback = NULL;
320  pstcOcuInternData->pfnOcu2Callback = NULL;
321  pstcOcuInternData->pfnOcu3Callback = NULL;
322  pstcOcuInternData->pfnOcu4Callback = NULL;
323  pstcOcuInternData->pfnOcu5Callback = NULL;
324  }
325 
326  //Get pointer of current channel OCU register address
327  p32OCFS = (uint8_t*)((uint8_t*)pstcMft + 0x68UL + u8Ch/2);
328  pstcOCSB = (stc_mft_ocu_ocsb10_field_t*)((uint8_t*)pstcMft + 0x19UL + (u8Ch/2)*4);
329  p8OCSC = (uint8_t*)((uint8_t*)pstcMft + 0x25UL);
330  pstcOCSD = (stc_mft_ocu_ocsd10_field_t*)((uint8_t*)pstcMft + 0x1AUL + (u8Ch/2)*4);
331 
332  //set OCSB register, config ocu's operation
333  pstcOCSB->CMOD = pstcOcuConfig->bCmod;
334  pstcOCSB->FM4 = pstcOcuConfig->bFm4;
335 
336  //set OCSC register, when enable FM3 compatible mode
337  *p8OCSC = pstcOcuConfig->u8Mod;
338 
339  //set OCSD register and RT output level state
340  if(0 == (u8Ch % 2)) //channel 0, 2, 4
341  {
342  pstcOCSD->OCCP0BUFE = pstcOcuConfig->enOccpBufMode;
343  pstcOCSD->OCSE0BUFE = pstcOcuConfig->enOcseBufMode;
344 
345  *p32OCFS |= pstcOcuConfig->enFrtConnect;
346  pstcOCSB->OTD0 = pstcOcuConfig->enStatePin;
347  }
348  else//channel 1, 3, 5
349  {
350  pstcOCSD->OCCP1BUFE = pstcOcuConfig->enOccpBufMode;
351  pstcOCSD->OCSE1BUFE = pstcOcuConfig->enOcseBufMode;
352 
353  *p32OCFS |= (pstcOcuConfig->enFrtConnect << 4);
354  pstcOCSB->OTD1 = pstcOcuConfig->enStatePin;
355  }
356 
357  return Ok;
358 }
359 
378  uint8_t EvenCh,
379  stc_even_compare_config_t* pstcConfig)
380 {
381  uint16_t* p16OCSE0;
382 
383  // Check for NULL pointer
384  if ( (pstcMft == NULL)
385  || (EvenCh%2 != 0)
386  || (pstcConfig == NULL)
393  || (pstcConfig->enIopFlagWhenFrtZeroEvenMatch > IopFlagSet)
394  || (pstcConfig->enIopFlagWhenFrtUpCntEvenMatch > IopFlagSet)
395  || (pstcConfig->enIopFlagWhenFrtPeakEvenMatch > IopFlagSet)
396  || (pstcConfig->enIopFlagWhenFrtDownCntEvenMatch > IopFlagSet) )
397  {
398  return ErrorInvalidParameter ;
399  }
400 
401  p16OCSE0 = (uint16_t*)((uint8_t*)pstcMft + 0x28UL + EvenCh*4);
402 
403  *p16OCSE0 = (pstcConfig->enFrtZeroEvenMatchEvenChRtStatus << 10) |
404  (pstcConfig->enFrtZeroEvenNotMatchEvenChRtStatus << 14) |
405  (pstcConfig->enFrtUpCntEvenMatchEvenChRtStatus << 8) |
406  (pstcConfig->enFrtPeakEvenMatchEvenChRtStatus << 6) |
407  (pstcConfig->enFrtPeakEvenNotMatchEvenChStatus << 12) |
408  (pstcConfig->enFrtDownCntEvenMatchEvenChRtStatus << 4) |
409  (pstcConfig->enIopFlagWhenFrtZeroEvenMatch << 3) |
410  (pstcConfig->enIopFlagWhenFrtUpCntEvenMatch << 2) |
411  (pstcConfig->enIopFlagWhenFrtPeakEvenMatch << 1) |
412  (pstcConfig->enIopFlagWhenFrtDownCntEvenMatch << 0);
413  return Ok;
414 }
415 
434  uint8_t OddCh,
435  stc_odd_compare_config_t* pstcConfig)
436 {
437  uint32_t* p32OCSE1;
438 
439  // Check for NULL pointer
440  if ( (pstcMft == NULL)
441  || (OddCh%2 == 0)
456  || (pstcConfig->enIopFlagWhenFrtZeroOddMatch > IopFlagSet)
457  || (pstcConfig->enIopFlagWhenFrtUpCntOddMatch > IopFlagSet)
458  || (pstcConfig->enIopFlagWhenFrtPeakOddMatch > IopFlagSet)
459  || (pstcConfig->enIopFlagWhenFrtDownCntOddMatch > IopFlagSet) )
460  {
461  return ErrorInvalidParameter ;
462  }
463 
464  p32OCSE1 = (uint32_t*)((uint8_t*)pstcMft + 0x28UL + OddCh*4);
465 
466  *p32OCSE1 = (pstcConfig->enFrtZeroOddMatchEvenMatchOddChRtStatus << 26) |
467  (pstcConfig->enFrtZeroOddMatchEvenNotMatchOddChRtStatus << 10) |
468  (pstcConfig->enFrtZeroOddNotMatchEvenMatchOddChRtStatus << 30) |
469  (pstcConfig->enFrtZeroOddNotMatchEvenNotMatchOddChRtStatus << 14) |
470  (pstcConfig->enFrtUpCntOddMatchEvenMatchOddChRtStatus << 24) |
472  (pstcConfig->enFrtUpCntOddNotMatchEvenMatchOddChRtStatus << 18) |
473  (pstcConfig->enFrtPeakOddMatchEvenMatchOddChRtStatus << 22) |
474  (pstcConfig->enFrtPeakOddMatchEvenNotMatchOddChRtStatus << 6) |
475  (pstcConfig->enFrtPeakOddNotMatchEvenMatchOddChRtStatus << 28) |
476  (pstcConfig->enFrtPeakOddNotMatchEvenNotMatchOddChRtStatus << 12) |
477  (pstcConfig->enFrtDownOddMatchEvenMatchOddChRtStatus << 20) |
478  (pstcConfig->enFrtDownOddMatchEvenNotMatchOddChRtStatus << 4) |
479  (pstcConfig->enFrtDownOddNotMatchEvenMatchOddChRtStatus << 16) |
480  (pstcConfig->enIopFlagWhenFrtZeroOddMatch << 3) |
481  (pstcConfig->enIopFlagWhenFrtUpCntOddMatch << 2) |
482  (pstcConfig->enIopFlagWhenFrtPeakOddMatch << 1) |
483  (pstcConfig->enIopFlagWhenFrtDownCntOddMatch << 0);
484 
485  return Ok;
486 }
487 
504 en_result_t Mft_Ocu_EnableOperation(volatile stc_mftn_ocu_t*pstcMft, uint8_t u8Ch)
505 {
506  stc_mft_ocu_ocsa10_field_t* pstcOCSA;
507 
508  // Check for NULL pointer
509  if ( (pstcMft == NULL)
510  || (u8Ch >= MFT_OCU_MAXCH))
511  {
512  return ErrorInvalidParameter ;
513  }
514 
515  //Get pointer of current channel OCU register address
516  pstcOCSA = (stc_mft_ocu_ocsa10_field_t*)((uint8_t*)pstcMft + 0x18UL + (u8Ch/2)*4);
517 
518  //set register
519  if(0 == (u8Ch%2)) //channel 0,2,4
520  {
521  pstcOCSA->CST0 = 1;
522  }
523  else //channel 1,3,5
524  {
525  pstcOCSA->CST1 = 1;
526  }
527 
528  return Ok;
529 }
530 
547 en_result_t Mft_Ocu_DisableOperation(volatile stc_mftn_ocu_t*pstcMft, uint8_t u8Ch)
548 {
549  stc_mft_ocu_ocsa10_field_t* pstcOCSA;
550 
551  // Check for NULL pointer
552  if ( (pstcMft == NULL)
553  || (u8Ch >= MFT_OCU_MAXCH))
554  {
555  return ErrorInvalidParameter ;
556  }
557 
558  //Get pointer of current channel OCU register address
559  pstcOCSA = (stc_mft_ocu_ocsa10_field_t*)((uint8_t*)pstcMft + 0x18UL + (u8Ch/2)*4);
560 
561  //set register
562  if(0 == (u8Ch%2)) //channel 0,2,4
563  {
564  pstcOCSA->CST0 = 0;
565  }
566  else //channel 1,3,5
567  {
568  pstcOCSA->CST1 = 0;
569  }
570 
571  return Ok;
572 }
573 
574 #if (PDL_INTERRUPT_ENABLE_MFT0_OCU == PDL_ON) || \
575  (PDL_INTERRUPT_ENABLE_MFT1_OCU == PDL_ON) || \
576  (PDL_INTERRUPT_ENABLE_MFT2_OCU == PDL_ON)
577 
596  uint8_t u8Ch, func_ptr_t pfnCallback)
597 {
598  stc_mft_ocu_intern_data_t* pstcOcuInternData;
599  stc_mft_ocu_ocsa10_field_t* pstcOCSA;
600  func_ptr_t* fnCallback;
601  // Check for NULL pointer
602  if ( (pstcMft == NULL)
603  || (u8Ch >= MFT_OCU_MAXCH))
604  {
605  return ErrorInvalidParameter ;
606  }
607 
608  // Get pointer to internal data structure ...
609  pstcOcuInternData = MftGetInternDataPtr( pstcMft ) ;
610 
611  //Get pointer of current channel OCU register address
612  pstcOCSA = (stc_mft_ocu_ocsa10_field_t*)((uint8_t*)pstcMft + 0x18UL + (u8Ch/2)*4);
613 // pstcOcuInternData = pstcOcuInternData + (sizeof(func_ptr_t)) * u8Ch;
614 
615  //set register
616  if(0 == (u8Ch%2)) //channel 0,2,4
617  {
618  pstcOCSA->IOE0 = 1;
619  }
620  else //channel 1,3,5
621  {
622  pstcOCSA->IOE1 = 1;
623  }
624 
625  //set callback function
626  fnCallback = (func_ptr_t*)((uint8_t*)&(pstcOcuInternData->pfnOcu0Callback)
627  + (sizeof(func_ptr_t) * u8Ch));
628  *fnCallback = pfnCallback;
629 
630  Mft_Ocu_InitIrq(pstcMft);
631 
632  return Ok;
633 }
634 
651 en_result_t Mft_Ocu_DisableInt(volatile stc_mftn_ocu_t*pstcMft,uint8_t u8Ch)
652 {
653  stc_mft_ocu_intern_data_t* pstcOcuInternData;
654  stc_mft_ocu_ocsa10_field_t* pstcOCSA;
655 
656  // Check for NULL pointer
657  if ( (pstcMft == NULL)
658  || (u8Ch >= MFT_OCU_MAXCH))
659  {
660  return ErrorInvalidParameter ;
661  }
662 
663  // Get pointer to internal data structure ...
664  pstcOcuInternData = MftGetInternDataPtr( pstcMft ) ;
665 
666  //Get pointer of current channel OCU register address
667  pstcOCSA = (stc_mft_ocu_ocsa10_field_t*)((uint8_t*)pstcMft + 0x18UL + (u8Ch/2)*4);
668  pstcOcuInternData = pstcOcuInternData + (sizeof(pstcOcuInternData)) * u8Ch;
669 
670  //set register
671  if(0 == (u8Ch%2)) //channel 0,2,4
672  {
673  pstcOCSA->IOE0 = 0;
674  }
675  else //channel 1,3,5
676  {
677  pstcOCSA->IOE1 = 0;
678  }
679 
680  //set callback function
681  pstcOcuInternData = NULL;
682 
683  Mft_Ocu_DeInitIrq(pstcMft);
684 
685  return Ok;
686 }
687 
688 #endif
689 
704 en_int_flag_t Mft_Ocu_GetIntFlag(volatile stc_mftn_ocu_t*pstcMft, uint8_t u8Ch)
705 {
706  stc_mft_ocu_ocsa10_field_t* pstcOCSA;
707  en_int_flag_t retval;
708 
709  //Get pointer of current channel OCU register address
710  pstcOCSA = (stc_mft_ocu_ocsa10_field_t*)((uint8_t*)pstcMft + 0x18UL + (u8Ch/2)*4);
711 
712  //set return value
713  if(0 == (u8Ch%2)) //channel 0,2,4
714  {
715  retval = (en_int_flag_t)pstcOCSA->IOP0;
716  }
717  else //channel 1,3,5
718  {
719  retval = (en_int_flag_t)pstcOCSA->IOP1;
720  }
721 
722  return retval;
723 }
724 
741 en_result_t Mft_Ocu_ClrIntFlag(volatile stc_mftn_ocu_t*pstcMft, uint8_t u8Ch)
742 {
743  stc_mft_ocu_ocsa10_field_t* pstcOCSA;
744 
745  // Check for NULL pointer
746  if ( (pstcMft == NULL)
747  || (u8Ch >= MFT_OCU_MAXCH))
748  {
749  return ErrorInvalidParameter ;
750  }
751 
752  //Get pointer of current channel OCU register address
753  pstcOCSA = (stc_mft_ocu_ocsa10_field_t*)((uint8_t*)pstcMft + 0x18UL + (u8Ch/2)*4);
754 
755  //clear register
756  if(0 == (u8Ch%2)) //channel 0,2,4
757  {
758  pstcOCSA->IOP0 = 0;
759  }
760  else //channel 1,3,5
761  {
762  pstcOCSA->IOP1 = 0;
763  }
764 
765  return Ok;
766 }
767 
783 {
784  stc_mft_ocu_ocsb10_field_t* pstcOCSB;
785  en_ocu_rt_out_state_t enLevel;
786 
787  // Get the OCSB address
788  pstcOCSB = (stc_mft_ocu_ocsb10_field_t*)((uint8_t*)pstcMft + 0x19UL + (u8Ch/2)*4);
789  if((u8Ch%2) == 0)
790  {
791  enLevel = (en_ocu_rt_out_state_t)pstcOCSB->OTD0;
792  }
793  else
794  {
795  enLevel = (en_ocu_rt_out_state_t)pstcOCSB->OTD1;
796  }
797 
798  return enLevel;
799 }
800 
820  uint8_t u8Ch, uint16_t u16Occp)
821 {
822  uint16_t* p16OCCP;
823 
824  // Check for NULL pointer
825  if ( (pstcMft == NULL)
826  || (u8Ch >= MFT_OCU_MAXCH))
827  {
828  return ErrorInvalidParameter ;
829  }
830  //Get pointer of current channel OCU register address
831  p16OCCP = (uint16_t*)((uint8_t*)pstcMft + 0x02 + u8Ch*4);
832 
833  //set register
834  *p16OCCP = u16Occp;
835 
836  return Ok;
837 }
838 
852 uint16_t Mft_Ocu_ReadOccp(volatile stc_mftn_ocu_t*pstcMft, uint8_t u8Ch)
853 {
854  uint16_t* p16OCCP;
855 
856  // Check for NULL pointer
857  if ( (pstcMft == NULL)
858  || (u8Ch >= MFT_OCU_MAXCH))
859  {
860  return 0 ;
861  }
862  //Get pointer of current channel OCU register address
863  p16OCCP = (uint16_t*)((uint8_t*)pstcMft + 0x02 + u8Ch*4);
864 
865  return (uint16_t)((*p16OCCP) & 0xFFFF);
866 }
867 
869 
870 #endif // #if (defined(PDL_PERIPHERAL_$$X_ACTIVE))
871 /******************************************************************************/
872 /* EOF (not truncated) */
873 /******************************************************************************/