PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
mfs.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 /******************************************************************************/
52 /******************************************************************************/
53 /* Include files */
54 /******************************************************************************/
55 #include "pdl.h"
56 
57 #if (defined(PDL_PERIPHERAL_MFS_ACTIVE))
58 
64 
65 /******************************************************************************/
66 /* Local pre-processor symbols/macros ('#define') */
67 /******************************************************************************/
68 /* for checking clock (SCM_CTL RCS bit) */
69 #define MFS_MASTER_CLK_HCR (0x00u)
70 #define MFS_MASTER_CLK_MAIN (0x01u)
71 #define MFS_MASTER_CLK_PLL (0x02u)
72 #define MFS_MASTER_CLK_LCR (0x04u)
73 #define MFS_MASTER_CLK_SUB (0x05u)
74 
75 /* for checking clock (BSC_PSR) */
76 #define MFS_BASE_CLK_DIV1 (0x00u)
77 #define MFS_BASE_CLK_DIV2 (0x01u)
78 #define MFS_BASE_CLK_DIV3 (0x02u)
79 #define MFS_BASE_CLK_DIV4 (0x03u)
80 #define MFS_BASE_CLK_DIV6 (0x04u)
81 #define MFS_BASE_CLK_DIV8 (0x05u)
82 #define MFS_BASE_CLK_DIV16 (0x06u)
83 
84 /* Number */
85 #define MFS_NUM_1 (0x01u)
86 #define MFS_NUM_2 (0x02u)
87 #define MFS_NUM_3 (0x03u)
88 #define MFS_NUM_4 (0x04u)
89 #define MFS_NUM_5 (0x05u)
90 #define MFS_NUM_6 (0x06u)
91 #define MFS_NUM_7 (0x07u)
92 #define MFS_NUM_8 (0x08u)
93 #define MFS_NUM_16 (0x10u)
94 
95 /* for BGR */
96 #define MFS_BGR_MASK (0x7FFFu)
97 
98 /* for PLL */
99 #define MFS_PLL_CTL1_MASK (0x0Fu)
100 #define MFS_PLL_CTL2_MASK (0x3Fu)
101 
102 /******************************************************************************/
103 /* Global variable definitions (declared in header file with 'extern') */
104 /******************************************************************************/
105 
108 {
109 #if (PDL_PERIPHERAL_ENABLE_MFS0 == PDL_ON)
110  {
111  &MFS0, /* pstcInstance */
112  {NULL} /* stcInternData (not initialized yet) */
113  },
114 #endif
115 #if (PDL_PERIPHERAL_ENABLE_MFS1 == PDL_ON)
116  {
117  &MFS1, /* pstcInstance */
118  {NULL} /* stcInternData (not initialized yet) */
119  },
120 #endif
121 #if (PDL_PERIPHERAL_ENABLE_MFS2 == PDL_ON)
122  {
123  &MFS2, /* pstcInstance */
124  {NULL} /* stcInternData (not initialized yet) */
125  },
126 #endif
127 #if (PDL_PERIPHERAL_ENABLE_MFS3 == PDL_ON)
128  {
129  &MFS3, /* pstcInstance */
130  {NULL} /* stcInternData (not initialized yet) */
131  },
132 #endif
133 #if (PDL_PERIPHERAL_ENABLE_MFS4 == PDL_ON)
134  {
135  &MFS4, /* pstcInstance */
136  {NULL} /* stcInternData (not initialized yet) */
137  },
138 #endif
139 #if (PDL_PERIPHERAL_ENABLE_MFS5 == PDL_ON)
140  {
141  &MFS5, /* pstcInstance */
142  {NULL} /* stcInternData (not initialized yet) */
143  },
144 #endif
145 #if (PDL_PERIPHERAL_ENABLE_MFS6 == PDL_ON)
146  {
147  &MFS6, /* pstcInstance */
148  {NULL} /* stcInternData (not initialized yet) */
149  },
150 #endif
151 #if (PDL_PERIPHERAL_ENABLE_MFS7 == PDL_ON)
152  {
153  &MFS7, /* pstcInstance */
154  {NULL} /* stcInternData (not initialized yet) */
155  },
156 #endif
157 #if (PDL_PERIPHERAL_ENABLE_MFS8 == PDL_ON)
158  {
159  &MFS8, /* pstcInstance */
160  {NULL} /* stcInternData (not initialized yet) */
161  },
162 #endif
163 #if (PDL_PERIPHERAL_ENABLE_MFS9 == PDL_ON)
164  {
165  &MFS9, /* pstcInstance */
166  {NULL} /* stcInternData (not initialized yet) */
167  },
168 #endif
169 #if (PDL_PERIPHERAL_ENABLE_MFS10 == PDL_ON)
170  {
171  &MFS10, /* pstcInstance */
172  {NULL} /* stcInternData (not initialized yet) */
173  },
174 #endif
175 #if (PDL_PERIPHERAL_ENABLE_MFS11 == PDL_ON)
176  {
177  &MFS11, /* pstcInstance */
178  {NULL} /* stcInternData (not initialized yet) */
179  },
180 #endif
181 #if (PDL_PERIPHERAL_ENABLE_MFS12 == PDL_ON)
182  {
183  &MFS12, /* pstcInstance */
184  {NULL} /* stcInternData (not initialized yet) */
185  },
186 #endif
187 #if (PDL_PERIPHERAL_ENABLE_MFS13 == PDL_ON)
188  {
189  &MFS13, /* pstcInstance */
190  {NULL} /* stcInternData (not initialized yet) */
191  },
192 #endif
193 #if (PDL_PERIPHERAL_ENABLE_MFS14 == PDL_ON)
194  {
195  &MFS14, /* pstcInstance */
196  {NULL} /* stcInternData (not initialized yet) */
197  },
198 #endif
199 #if (PDL_PERIPHERAL_ENABLE_MFS15 == PDL_ON)
200  {
201  &MFS15, /* pstcInstance */
202  {NULL} /* stcInternData (not initialized yet) */
203  },
204 #endif
205 };
206 
207 /******************************************************************************/
208 /* Local type definitions ('typedef') */
209 /******************************************************************************/
210 
211 /******************************************************************************/
212 /* Local function prototypes ('static') */
213 /******************************************************************************/
214 static stc_mfs_intern_data_t* MfsGetInternDataPtr(volatile stc_mfsn_t* pstcMfs);
215 
216 /******************************************************************************/
217 /* Local variable definitions ('static') */
218 /******************************************************************************/
219 
220 /******************************************************************************/
221 /* Function implementation - global ('extern') and local ('static') */
222 /******************************************************************************/
223 
234 {
235  stc_mfs_intern_data_t* pstcInternDataPtr = NULL;
236  uint32_t u32Instance;
237 
238  if (NULL != pstcMfs)
239  {
240  for (u32Instance = 0u; u32Instance < (uint32_t)MfsInstanceIndexMax; u32Instance++)
241  {
242  if (pstcMfs == m_astcMfsInstanceDataLut[u32Instance].pstcInstance)
243  {
244  pstcInternDataPtr = &m_astcMfsInstanceDataLut[u32Instance].stcInternData;
245  break;
246  }
247  }
248  }
249 
250  return (pstcInternDataPtr);
251 } /* MfsGetInternDataPtr */
252 
264 {
265 #if (PDL_PERIPHERAL_ENABLE_MFS0 == PDL_ON)
266  if (pstcMfs == &MFS0)
267  {
268  /* MFS0 transmit interrupt settings */
269  NVIC_ClearPendingIRQ(MFS0_TX_IRQn);
270  NVIC_EnableIRQ(MFS0_TX_IRQn);
271  NVIC_SetPriority(MFS0_TX_IRQn, PDL_IRQ_LEVEL_MFS0_TX);
272  }
273 #endif
274 
275 #if (PDL_PERIPHERAL_ENABLE_MFS1 == PDL_ON)
276  if (pstcMfs == &MFS1)
277  {
278  /* MFS1 transmit interrupt settings */
279  NVIC_ClearPendingIRQ(MFS1_TX_IRQn);
280  NVIC_EnableIRQ(MFS1_TX_IRQn);
281  NVIC_SetPriority(MFS1_TX_IRQn, PDL_IRQ_LEVEL_MFS1_TX);
282  }
283 #endif
284 
285 #if (PDL_PERIPHERAL_ENABLE_MFS2 == PDL_ON)
286  if (pstcMfs == &MFS2)
287  {
288  /* MFS2 transmit interrupt settings */
289  NVIC_ClearPendingIRQ(MFS2_TX_IRQn);
290  NVIC_EnableIRQ(MFS2_TX_IRQn);
291  NVIC_SetPriority(MFS2_TX_IRQn, PDL_IRQ_LEVEL_MFS2_TX);
292  }
293 #endif
294 
295 #if (PDL_PERIPHERAL_ENABLE_MFS3 == PDL_ON)
296  if (pstcMfs == &MFS3)
297  {
298  /* MFS3 transmit interrupt settings */
299  NVIC_ClearPendingIRQ(MFS3_TX_IRQn);
300  NVIC_EnableIRQ(MFS3_TX_IRQn);
301  NVIC_SetPriority(MFS3_TX_IRQn, PDL_IRQ_LEVEL_MFS3_TX);
302  }
303 #endif
304 
305 #if (PDL_PERIPHERAL_ENABLE_MFS4 == PDL_ON)
306  if (pstcMfs == &MFS4)
307  {
308  /* MFS4 transmit interrupt settings */
309  NVIC_ClearPendingIRQ(MFS4_TX_IRQn);
310  NVIC_EnableIRQ(MFS4_TX_IRQn);
311  NVIC_SetPriority(MFS4_TX_IRQn, PDL_IRQ_LEVEL_MFS4_TX);
312  }
313 #endif
314 
315 #if (PDL_PERIPHERAL_ENABLE_MFS5 == PDL_ON)
316  if (pstcMfs == &MFS5)
317  {
318  /* MFS5 transmit interrupt settings */
319  NVIC_ClearPendingIRQ(MFS5_TX_IRQn);
320  NVIC_EnableIRQ(MFS5_TX_IRQn);
321  NVIC_SetPriority(MFS5_TX_IRQn, PDL_IRQ_LEVEL_MFS5_TX);
322  }
323 #endif
324 
325 #if (PDL_PERIPHERAL_ENABLE_MFS6 == PDL_ON)
326  if (pstcMfs == &MFS6)
327  {
328  /* MFS6 transmit interrupt settings */
329  NVIC_ClearPendingIRQ(MFS6_TX_IRQn);
330  NVIC_EnableIRQ(MFS6_TX_IRQn);
331  NVIC_SetPriority(MFS6_TX_IRQn, PDL_IRQ_LEVEL_MFS6_TX);
332  }
333 #endif
334 
335 #if (PDL_PERIPHERAL_ENABLE_MFS7 == PDL_ON)
336  if (pstcMfs == &MFS7)
337  {
338  /* MFS7 transmit interrupt settings */
339  NVIC_ClearPendingIRQ(MFS7_TX_IRQn);
340  NVIC_EnableIRQ(MFS7_TX_IRQn);
341  NVIC_SetPriority(MFS7_TX_IRQn, PDL_IRQ_LEVEL_MFS7_TX);
342  }
343 #endif
344 
345 #if (PDL_PERIPHERAL_ENABLE_MFS8 == PDL_ON)
346  if (pstcMfs == &MFS8)
347  {
348  /* MFS8 transmit interrupt settings */
349  NVIC_ClearPendingIRQ(MFS8_TX_IRQn);
350  NVIC_EnableIRQ(MFS8_TX_IRQn);
351  NVIC_SetPriority(MFS8_TX_IRQn, PDL_IRQ_LEVEL_MFS8_TX);
352  }
353 #endif
354 
355 #if (PDL_PERIPHERAL_ENABLE_MFS9 == PDL_ON)
356  if (pstcMfs == &MFS9)
357  {
358  /* MFS9 transmit interrupt settings */
359  NVIC_ClearPendingIRQ(MFS9_TX_IRQn);
360  NVIC_EnableIRQ(MFS9_TX_IRQn);
361  NVIC_SetPriority(MFS9_TX_IRQn, PDL_IRQ_LEVEL_MFS9_TX);
362  }
363 #endif
364 
365 #if (PDL_PERIPHERAL_ENABLE_MFS10 == PDL_ON)
366  if (pstcMfs == &MFS10)
367  {
368  /* MFS10 transmit interrupt settings */
369  NVIC_ClearPendingIRQ(MFS10_TX_IRQn);
370  NVIC_EnableIRQ(MFS10_TX_IRQn);
371  NVIC_SetPriority(MFS10_TX_IRQn, PDL_IRQ_LEVEL_MFS10_TX);
372  }
373 #endif
374 
375 #if (PDL_PERIPHERAL_ENABLE_MFS11 == PDL_ON)
376  if (pstcMfs == &MFS11)
377  {
378  /* MFS11 transmit interrupt settings */
379  NVIC_ClearPendingIRQ(MFS11_TX_IRQn);
380  NVIC_EnableIRQ(MFS11_TX_IRQn);
381  NVIC_SetPriority(MFS11_TX_IRQn, PDL_IRQ_LEVEL_MFS11_TX);
382  }
383 #endif
384 
385 #if (PDL_PERIPHERAL_ENABLE_MFS12 == PDL_ON)
386  if (pstcMfs == &MFS12)
387  {
388  /* MFS12 transmit interrupt settings */
389  NVIC_ClearPendingIRQ(MFS12_TX_IRQn);
390  NVIC_EnableIRQ(MFS12_TX_IRQn);
391  NVIC_SetPriority(MFS12_TX_IRQn, PDL_IRQ_LEVEL_MFS12_TX);
392  }
393 #endif
394 
395 #if (PDL_PERIPHERAL_ENABLE_MFS13 == PDL_ON)
396  if (pstcMfs == &MFS13)
397  {
398  /* MFS13 transmit interrupt settings */
399  NVIC_ClearPendingIRQ(MFS13_TX_IRQn);
400  NVIC_EnableIRQ(MFS13_TX_IRQn);
401  NVIC_SetPriority(MFS13_TX_IRQn, PDL_IRQ_LEVEL_MFS13_TX);
402  }
403 #endif
404 
405 #if (PDL_PERIPHERAL_ENABLE_MFS14 == PDL_ON)
406  if (pstcMfs == &MFS14)
407  {
408  /* MFS14 transmit interrupt settings */
409  NVIC_ClearPendingIRQ(MFS14_TX_IRQn);
410  NVIC_EnableIRQ(MFS14_TX_IRQn);
411  NVIC_SetPriority(MFS14_TX_IRQn, PDL_IRQ_LEVEL_MFS14_TX);
412  }
413 #endif
414 
415 #if (PDL_PERIPHERAL_ENABLE_MFS15 == PDL_ON)
416  if (pstcMfs == &MFS15)
417  {
418  /* MFS15 transmit interrupt settings */
419  NVIC_ClearPendingIRQ(MFS15_TX_IRQn);
420  NVIC_EnableIRQ(MFS15_TX_IRQn);
421  NVIC_SetPriority(MFS15_TX_IRQn, PDL_IRQ_LEVEL_MFS15_TX);
422  }
423 #endif
424 
425  return (Ok);
426 } /* Mfs_InitTxIrq */
427 
439 {
440 #if (PDL_PERIPHERAL_ENABLE_MFS0 == PDL_ON)
441  if (pstcMfs == &MFS0)
442  {
443  /* MFS0 receive interrupt settings */
444  NVIC_ClearPendingIRQ(MFS0_RX_IRQn);
445  NVIC_EnableIRQ(MFS0_RX_IRQn);
446  NVIC_SetPriority(MFS0_RX_IRQn, PDL_IRQ_LEVEL_MFS0_RX);
447  }
448 #endif
449 
450 #if (PDL_PERIPHERAL_ENABLE_MFS1 == PDL_ON)
451  if (pstcMfs == &MFS1)
452  {
453  /* MFS1 receive interrupt settings */
454  NVIC_ClearPendingIRQ(MFS1_RX_IRQn);
455  NVIC_EnableIRQ(MFS1_RX_IRQn);
456  NVIC_SetPriority(MFS1_RX_IRQn, PDL_IRQ_LEVEL_MFS1_RX);
457  }
458 #endif
459 
460 #if (PDL_PERIPHERAL_ENABLE_MFS2 == PDL_ON)
461  if (pstcMfs == &MFS2)
462  {
463  /* MFS2 receive interrupt settings */
464  NVIC_ClearPendingIRQ(MFS2_RX_IRQn);
465  NVIC_EnableIRQ(MFS2_RX_IRQn);
466  NVIC_SetPriority(MFS2_RX_IRQn, PDL_IRQ_LEVEL_MFS2_RX);
467  }
468 #endif
469 
470 #if (PDL_PERIPHERAL_ENABLE_MFS3 == PDL_ON)
471  if (pstcMfs == &MFS3)
472  {
473  /* MFS3 receive interrupt settings */
474  NVIC_ClearPendingIRQ(MFS3_RX_IRQn);
475  NVIC_EnableIRQ(MFS3_RX_IRQn);
476  NVIC_SetPriority(MFS3_RX_IRQn, PDL_IRQ_LEVEL_MFS3_RX);
477  }
478 #endif
479 
480 #if (PDL_PERIPHERAL_ENABLE_MFS4 == PDL_ON)
481  if (pstcMfs == &MFS4)
482  {
483  /* MFS4 receive interrupt settings */
484  NVIC_ClearPendingIRQ(MFS4_RX_IRQn);
485  NVIC_EnableIRQ(MFS4_RX_IRQn);
486  NVIC_SetPriority(MFS4_RX_IRQn, PDL_IRQ_LEVEL_MFS4_RX);
487  }
488 #endif
489 
490 #if (PDL_PERIPHERAL_ENABLE_MFS5 == PDL_ON)
491  if (pstcMfs == &MFS5)
492  {
493  /* MFS5 receive interrupt settings */
494  NVIC_ClearPendingIRQ(MFS5_RX_IRQn);
495  NVIC_EnableIRQ(MFS5_RX_IRQn);
496  NVIC_SetPriority(MFS5_RX_IRQn, PDL_IRQ_LEVEL_MFS5_RX);
497  }
498 #endif
499 
500 #if (PDL_PERIPHERAL_ENABLE_MFS6 == PDL_ON)
501  if (pstcMfs == &MFS6)
502  {
503  /* MFS6 receive interrupt settings */
504  NVIC_ClearPendingIRQ(MFS6_RX_IRQn);
505  NVIC_EnableIRQ(MFS6_RX_IRQn);
506  NVIC_SetPriority(MFS6_RX_IRQn, PDL_IRQ_LEVEL_MFS6_RX);
507  }
508 #endif
509 
510 #if (PDL_PERIPHERAL_ENABLE_MFS7 == PDL_ON)
511  if (pstcMfs == &MFS7)
512  {
513  /* MFS7 receive interrupt settings */
514  NVIC_ClearPendingIRQ(MFS7_RX_IRQn);
515  NVIC_EnableIRQ(MFS7_RX_IRQn);
516  NVIC_SetPriority(MFS7_RX_IRQn, PDL_IRQ_LEVEL_MFS7_RX);
517  }
518 #endif
519 
520 #if (PDL_PERIPHERAL_ENABLE_MFS8 == PDL_ON)
521  if (pstcMfs == &MFS8)
522  {
523  /* MFS8 receive interrupt settings */
524  NVIC_ClearPendingIRQ(MFS8_RX_IRQn);
525  NVIC_EnableIRQ(MFS8_RX_IRQn);
526  NVIC_SetPriority(MFS8_RX_IRQn, PDL_IRQ_LEVEL_MFS8_RX);
527  }
528 #endif
529 
530 #if (PDL_PERIPHERAL_ENABLE_MFS9 == PDL_ON)
531  if (pstcMfs == &MFS9)
532  {
533  /* MFS9 receive interrupt settings */
534  NVIC_ClearPendingIRQ(MFS9_RX_IRQn);
535  NVIC_EnableIRQ(MFS9_RX_IRQn);
536  NVIC_SetPriority(MFS9_RX_IRQn, PDL_IRQ_LEVEL_MFS9_RX);
537  }
538 #endif
539 
540 #if (PDL_PERIPHERAL_ENABLE_MFS10 == PDL_ON)
541  if (pstcMfs == &MFS10)
542  {
543  /* MFS10 receive interrupt settings */
544  NVIC_ClearPendingIRQ(MFS10_RX_IRQn);
545  NVIC_EnableIRQ(MFS10_RX_IRQn);
546  NVIC_SetPriority(MFS10_RX_IRQn, PDL_IRQ_LEVEL_MFS10_RX);
547  }
548 #endif
549 
550 #if (PDL_PERIPHERAL_ENABLE_MFS11 == PDL_ON)
551  if (pstcMfs == &MFS11)
552  {
553  /* MFS11 receive interrupt settings */
554  NVIC_ClearPendingIRQ(MFS11_RX_IRQn);
555  NVIC_EnableIRQ(MFS11_RX_IRQn);
556  NVIC_SetPriority(MFS11_RX_IRQn, PDL_IRQ_LEVEL_MFS11_RX);
557  }
558 #endif
559 
560 #if (PDL_PERIPHERAL_ENABLE_MFS12 == PDL_ON)
561  if (pstcMfs == &MFS12)
562  {
563  /* MFS12 receive interrupt settings */
564  NVIC_ClearPendingIRQ(MFS12_RX_IRQn);
565  NVIC_EnableIRQ(MFS12_RX_IRQn);
566  NVIC_SetPriority(MFS12_RX_IRQn, PDL_IRQ_LEVEL_MFS12_RX);
567  }
568 #endif
569 
570 #if (PDL_PERIPHERAL_ENABLE_MFS13 == PDL_ON)
571  if (pstcMfs == &MFS13)
572  {
573  /* MFS13 receive interrupt settings */
574  NVIC_ClearPendingIRQ(MFS13_RX_IRQn);
575  NVIC_EnableIRQ(MFS13_RX_IRQn);
576  NVIC_SetPriority(MFS13_RX_IRQn, PDL_IRQ_LEVEL_MFS13_RX);
577  }
578 #endif
579 
580 #if (PDL_PERIPHERAL_ENABLE_MFS14 == PDL_ON)
581  if (pstcMfs == &MFS14)
582  {
583  /* MFS14 receive interrupt settings */
584  NVIC_ClearPendingIRQ(MFS14_RX_IRQn);
585  NVIC_EnableIRQ(MFS14_RX_IRQn);
586  NVIC_SetPriority(MFS14_RX_IRQn, PDL_IRQ_LEVEL_MFS14_RX);
587  }
588 #endif
589 
590 #if (PDL_PERIPHERAL_ENABLE_MFS15 == PDL_ON)
591  if (pstcMfs == &MFS15)
592  {
593  /* MFS15 receive interrupt settings */
594  NVIC_ClearPendingIRQ(MFS15_RX_IRQn);
595  NVIC_EnableIRQ(MFS15_RX_IRQn);
596  NVIC_SetPriority(MFS15_RX_IRQn, PDL_IRQ_LEVEL_MFS15_RX);
597  }
598 #endif
599 
600  return (Ok);
601 } /* Mfs_InitRxIrq */
602 
613 {
614 #if (PDL_PERIPHERAL_ENABLE_MFS0 == PDL_ON)
615  if (pstcMfs == &MFS0)
616  {
617  /* MFS0 interrupt settings */
618  NVIC_ClearPendingIRQ(MFS0_TX_IRQn);
619  NVIC_DisableIRQ(MFS0_TX_IRQn);
620  NVIC_SetPriority(MFS0_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
621 
622  NVIC_ClearPendingIRQ(MFS0_RX_IRQn);
623  NVIC_DisableIRQ(MFS0_RX_IRQn);
624  NVIC_SetPriority(MFS0_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
625  }
626 #endif
627 
628 #if (PDL_PERIPHERAL_ENABLE_MFS1 == PDL_ON)
629  if (pstcMfs == &MFS1)
630  {
631  /* MFS1 interrupt settings */
632  NVIC_ClearPendingIRQ(MFS1_TX_IRQn);
633  NVIC_DisableIRQ(MFS1_TX_IRQn);
634  NVIC_SetPriority(MFS1_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
635 
636  NVIC_ClearPendingIRQ(MFS1_RX_IRQn);
637  NVIC_DisableIRQ(MFS1_RX_IRQn);
638  NVIC_SetPriority(MFS1_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
639  }
640 #endif
641 
642 #if (PDL_PERIPHERAL_ENABLE_MFS2 == PDL_ON)
643  if (pstcMfs == &MFS2)
644  {
645  /* MFS2 interrupt settings */
646  NVIC_ClearPendingIRQ(MFS2_TX_IRQn);
647  NVIC_DisableIRQ(MFS2_TX_IRQn);
648  NVIC_SetPriority(MFS2_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
649 
650  NVIC_ClearPendingIRQ(MFS2_RX_IRQn);
651  NVIC_DisableIRQ(MFS2_RX_IRQn);
652  NVIC_SetPriority(MFS2_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
653  }
654 #endif
655 
656 #if (PDL_PERIPHERAL_ENABLE_MFS3 == PDL_ON)
657  if (pstcMfs == &MFS3)
658  {
659  /* MFS3 interrupt settings */
660  NVIC_ClearPendingIRQ(MFS3_TX_IRQn);
661  NVIC_DisableIRQ(MFS3_TX_IRQn);
662  NVIC_SetPriority(MFS3_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
663 
664  NVIC_ClearPendingIRQ(MFS3_RX_IRQn);
665  NVIC_DisableIRQ(MFS3_RX_IRQn);
666  NVIC_SetPriority(MFS3_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
667  }
668 #endif
669 
670 #if (PDL_PERIPHERAL_ENABLE_MFS4 == PDL_ON)
671  if (pstcMfs == &MFS4)
672  {
673  /* MFS4 interrupt settings */
674  NVIC_ClearPendingIRQ(MFS4_TX_IRQn);
675  NVIC_DisableIRQ(MFS4_TX_IRQn);
676  NVIC_SetPriority(MFS4_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
677 
678  NVIC_ClearPendingIRQ(MFS4_RX_IRQn);
679  NVIC_DisableIRQ(MFS4_RX_IRQn);
680  NVIC_SetPriority(MFS4_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
681  }
682 #endif
683 
684 #if (PDL_PERIPHERAL_ENABLE_MFS5 == PDL_ON)
685  if (pstcMfs == &MFS5)
686  {
687  /* MFS5 interrupt settings */
688  NVIC_ClearPendingIRQ(MFS5_TX_IRQn);
689  NVIC_DisableIRQ(MFS5_TX_IRQn);
690  NVIC_SetPriority(MFS5_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
691 
692  NVIC_ClearPendingIRQ(MFS5_RX_IRQn);
693  NVIC_DisableIRQ(MFS5_RX_IRQn);
694  NVIC_SetPriority(MFS5_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
695  }
696 #endif
697 
698 #if (PDL_PERIPHERAL_ENABLE_MFS6 == PDL_ON)
699  if (pstcMfs == &MFS6)
700  {
701  /* MFS6 interrupt settings */
702  NVIC_ClearPendingIRQ(MFS6_TX_IRQn);
703  NVIC_DisableIRQ(MFS6_TX_IRQn);
704  NVIC_SetPriority(MFS6_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
705 
706  NVIC_ClearPendingIRQ(MFS6_RX_IRQn);
707  NVIC_DisableIRQ(MFS6_RX_IRQn);
708  NVIC_SetPriority(MFS6_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
709  }
710 #endif
711 
712 #if (PDL_PERIPHERAL_ENABLE_MFS7 == PDL_ON)
713  if (pstcMfs == &MFS7)
714  {
715  /* MFS7 interrupt settings */
716  NVIC_ClearPendingIRQ(MFS7_TX_IRQn);
717  NVIC_DisableIRQ(MFS7_TX_IRQn);
718  NVIC_SetPriority(MFS7_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
719 
720  NVIC_ClearPendingIRQ(MFS7_RX_IRQn);
721  NVIC_DisableIRQ(MFS7_RX_IRQn);
722  NVIC_SetPriority(MFS7_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
723  }
724 #endif
725 
726 #if (PDL_PERIPHERAL_ENABLE_MFS8 == PDL_ON)
727  if (pstcMfs == &MFS8)
728  {
729  /* MFS8 interrupt settings */
730  NVIC_ClearPendingIRQ(MFS8_TX_IRQn);
731  NVIC_DisableIRQ(MFS8_TX_IRQn);
732  NVIC_SetPriority(MFS8_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
733 
734  NVIC_ClearPendingIRQ(MFS8_RX_IRQn);
735  NVIC_DisableIRQ(MFS8_RX_IRQn);
736  NVIC_SetPriority(MFS8_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
737  }
738 #endif
739 
740 #if (PDL_PERIPHERAL_ENABLE_MFS9 == PDL_ON)
741  if (pstcMfs == &MFS9)
742  {
743  /* MFS9 interrupt settings */
744  NVIC_ClearPendingIRQ(MFS9_TX_IRQn);
745  NVIC_DisableIRQ(MFS9_TX_IRQn);
746  NVIC_SetPriority(MFS9_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
747 
748  NVIC_ClearPendingIRQ(MFS9_RX_IRQn);
749  NVIC_DisableIRQ(MFS9_RX_IRQn);
750  NVIC_SetPriority(MFS9_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
751  }
752 #endif
753 
754 #if (PDL_PERIPHERAL_ENABLE_MFS10 == PDL_ON)
755  if (pstcMfs == &MFS10)
756  {
757  /* MFS10 interrupt settings */
758  NVIC_ClearPendingIRQ(MFS10_TX_IRQn);
759  NVIC_DisableIRQ(MFS10_TX_IRQn);
760  NVIC_SetPriority(MFS10_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
761 
762  NVIC_ClearPendingIRQ(MFS10_RX_IRQn);
763  NVIC_DisableIRQ(MFS10_RX_IRQn);
764  NVIC_SetPriority(MFS10_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
765  }
766 #endif
767 
768 #if (PDL_PERIPHERAL_ENABLE_MFS11 == PDL_ON)
769  if (pstcMfs == &MFS11)
770  {
771  /* MFS11 interrupt settings */
772  NVIC_ClearPendingIRQ(MFS11_TX_IRQn);
773  NVIC_DisableIRQ(MFS11_TX_IRQn);
774  NVIC_SetPriority(MFS11_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
775 
776  NVIC_ClearPendingIRQ(MFS11_RX_IRQn);
777  NVIC_DisableIRQ(MFS11_RX_IRQn);
778  NVIC_SetPriority(MFS11_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
779  }
780 #endif
781 
782 #if (PDL_PERIPHERAL_ENABLE_MFS12 == PDL_ON)
783  if (pstcMfs == &MFS12)
784  {
785  /* MFS12 interrupt settings */
786  NVIC_ClearPendingIRQ(MFS12_TX_IRQn);
787  NVIC_DisableIRQ(MFS12_TX_IRQn);
788  NVIC_SetPriority(MFS12_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
789 
790  NVIC_ClearPendingIRQ(MFS12_RX_IRQn);
791  NVIC_DisableIRQ(MFS12_RX_IRQn);
792  NVIC_SetPriority(MFS12_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
793  }
794 #endif
795 
796 #if (PDL_PERIPHERAL_ENABLE_MFS13 == PDL_ON)
797  if (pstcMfs == &MFS13)
798  {
799  /* MFS13 interrupt settings */
800  NVIC_ClearPendingIRQ(MFS13_TX_IRQn);
801  NVIC_DisableIRQ(MFS13_TX_IRQn);
802  NVIC_SetPriority(MFS13_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
803 
804  NVIC_ClearPendingIRQ(MFS13_RX_IRQn);
805  NVIC_DisableIRQ(MFS13_RX_IRQn);
806  NVIC_SetPriority(MFS13_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
807  }
808 #endif
809 
810 #if (PDL_PERIPHERAL_ENABLE_MFS14 == PDL_ON)
811  if (pstcMfs == &MFS14)
812  {
813  /* MFS14 interrupt settings */
814  NVIC_ClearPendingIRQ(MFS14_TX_IRQn);
815  NVIC_DisableIRQ(MFS14_TX_IRQn);
816  NVIC_SetPriority(MFS14_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
817 
818  NVIC_ClearPendingIRQ(MFS14_RX_IRQn);
819  NVIC_DisableIRQ(MFS14_RX_IRQn);
820  NVIC_SetPriority(MFS14_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
821  }
822 #endif
823 
824 #if (PDL_PERIPHERAL_ENABLE_MFS15 == PDL_ON)
825  if (pstcMfs == &MFS15)
826  {
827  /* MFS15 interrupt settings */
828  NVIC_ClearPendingIRQ(MFS15_TX_IRQn);
829  NVIC_DisableIRQ(MFS15_TX_IRQn);
830  NVIC_SetPriority(MFS15_TX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
831 
832  NVIC_ClearPendingIRQ(MFS15_RX_IRQn);
833  NVIC_DisableIRQ(MFS15_RX_IRQn);
834  NVIC_SetPriority(MFS15_RX_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
835  }
836 #endif
837 
838  return (Ok);
839 } /* Mfs_DeInitIrq */
840 
848 void MfsIrqHandlerRx( volatile stc_mfsn_t* pstcMfs,
849  stc_mfs_intern_data_t* pstcMfsInternData
850  )
851 {
852  if ((NULL != pstcMfs) && (NULL != pstcMfsInternData))
853  {
854  if (NULL != pstcMfsInternData->pfnReceiveCbFunction)
855  {
856  pstcMfsInternData->pfnReceiveCbFunction(pstcMfs, pstcMfsInternData->pvUpperLayerHandle);
857  }
858  }
859 } /* MfsIrqHandlerRx */
860 
868 void MfsIrqHandlerTx( volatile stc_mfsn_t* pstcMfs,
869  stc_mfs_intern_data_t* pstcMfsInternData
870  )
871 {
872  if ((NULL != pstcMfs) && (NULL != pstcMfsInternData))
873  {
874  if (NULL != pstcMfsInternData->pfnTransmitCbFunction)
875  {
876  pstcMfsInternData->pfnTransmitCbFunction(pstcMfs, pstcMfsInternData->pvUpperLayerHandle);
877  }
878  }
879 } /* MfsIrqHandlerTx */
880 
888 void MfsIrqHandlerStatus( volatile stc_mfsn_t* pstcMfs,
889  stc_mfs_intern_data_t* pstcMfsInternData
890  )
891 {
892  if ((NULL != pstcMfs) && (NULL != pstcMfsInternData))
893  {
894  if (NULL != pstcMfsInternData->pfnStatusCbFunction)
895  {
896  pstcMfsInternData->pfnStatusCbFunction(pstcMfs, pstcMfsInternData->pvUpperLayerHandle);
897  }
898  }
899 } /* MfsIrqHandlerStatus */
900 
901 #if (PDL_MFS_USE_HL == PDL_OFF)
902 
920  const stc_mfs_uart_config_t* pstcConfig
921  )
922 {
923  /* Preset local register variables to zero */
924  stc_mfs_smr_field_t stcSMR = { 0 };
925  stc_mfs_scr_field_t stcSCR = { 0 };
926  stc_mfs_escr_field_t stcESCR = { 0 };
927 
928  /* Parameter check and get ptr to internal data struct */
929  if ((NULL == MfsGetInternDataPtr(pstcUart))
930  || (NULL == pstcConfig)
931  )
932  {
933  return (ErrorInvalidParameter);
934  }
935 
936  /* Set UART mode */
937  switch (pstcConfig->u8UartMode)
938  {
939  case MfsUartNormal:
940  stcSMR.MD = MFS_MD_UART_NORNAL; /* Normal mode */
941  break;
942  case MfsUartMulti:
943  stcSMR.MD = MFS_MD_UART_MULTI; /* Multi-processor mode */
944  break;
945  default:
946  return (ErrorInvalidParameter);
947  }
948 
949  /* Enable SOE */
950  stcSMR.SOE = TRUE;
951  /* Set Parity */
952  switch(pstcConfig->u8Parity)
953  {
954  case MfsParityNone:
955  stcESCR.P = FALSE; /* Parity type selection (0-even/1-odd) */
956  stcESCR.PEN = FALSE; /* Parity disable */
957  break;
958  case MfsParityEven:
959  stcESCR.P = FALSE; /* Parity type selection (0-even/1-odd) */
960  stcESCR.PEN = TRUE; /* Parity Enable */
961  break;
962  case MfsParityOdd:
963  stcESCR.P = TRUE; /* Parity type selection (0-even/1-odd) */
964  stcESCR.PEN = TRUE; /* Parity Enable */
965  break;
966  default:
967  return (ErrorInvalidParameter);
968  }
969  /* Set Stop bit length */
970  switch (pstcConfig->u8StopBit)
971  {
972  case MfsOneStopBit:
973  stcSMR.SBL = FALSE;
974  stcESCR.ESBL = FALSE;
975  break;
976  case MfsTwoStopBits:
977  stcSMR.SBL = TRUE;
978  stcESCR.ESBL = FALSE;
979  break;
980  case MfsThreeStopBits:
981  stcSMR.SBL = FALSE;
982  stcESCR.ESBL = TRUE;
983  break;
984  case MfsFourStopBits:
985  stcSMR.SBL = TRUE;
986  stcESCR.ESBL = TRUE;
987  break;
988  default:
989  return (ErrorInvalidParameter);
990  }
991  /* Set Data bit length (5 - 9bits) */
992  switch(pstcConfig->u8CharLength)
993  {
994  case MfsFiveBits:
995  stcESCR.L = MFS_DATA_LEN_5;
996  break;
997  case MfsSixBits:
998  stcESCR.L = MFS_DATA_LEN_6;
999  break;
1000  case MfsSevenBits:
1001  stcESCR.L = MFS_DATA_LEN_7;
1002  break;
1003  case MfsEightBits:
1004  stcESCR.L = MFS_DATA_LEN_8;
1005  break;
1006  case MfsNineBits:
1007  stcESCR.L = MFS_DATA_LEN_9;
1008  break;
1009  default:
1010  return (ErrorInvalidParameter);
1011  }
1012  /* Set Bit direction (LSB/MSB) */
1013  if (TRUE == pstcConfig->bBitDirection)
1014  {
1015  stcSMR.BDS = TRUE;
1016  }
1017  else
1018  {
1019  stcSMR.BDS = FALSE;
1020  }
1021 
1022  /* HW Flow */
1023  if (TRUE == pstcConfig->bHwFlow)
1024  {
1025  stcESCR.FLWEN = TRUE;
1026  }
1027  else
1028  {
1029  stcESCR.FLWEN = FALSE;
1030  }
1031 
1032  /* Set Signal system (NRZ/Int-NRZ) */
1033  if (TRUE == pstcConfig->bSignalSystem)
1034  {
1035  stcESCR.INV = TRUE;
1036  }
1037  else
1038  {
1039  stcESCR.INV = FALSE;
1040  }
1041 
1042  /* Clear MFS by setting the Software Reset bit */
1043  pstcUart->SCR_f.UPCL = TRUE;
1044 
1045  /* Set Baudrate */
1046  (void)Mfs_Uart_SetBaudRate(pstcUart, pstcConfig->u32DataRate);
1047  /* Set registers value */
1048  pstcUart->SMR_f = stcSMR;
1049  pstcUart->SCR_f = stcSCR;
1050  pstcUart->ESCR_f = stcESCR;
1051 
1052  return (Ok);
1053 } /* MFS_Uart_Init */
1054 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1055 
1056 #if (PDL_MFS_USE_HL == PDL_OFF)
1057 
1073 {
1074  en_result_t enResult;
1075  stc_mfs_intern_data_t* pstcMfsInternData;
1076 
1077  /* Check for valid pointer and get pointer to internal data struct ... */
1078  pstcMfsInternData = MfsGetInternDataPtr(pstcUart);
1079  /* ... and check */
1080  if (NULL == pstcMfsInternData)
1081  {
1082  enResult = ErrorInvalidParameter;
1083  }
1084  else
1085  {
1086  pstcUart->SCR_f.TXE = FALSE;
1087  pstcUart->SCR_f.RXE = FALSE;
1088 
1089  (void)Mfs_DeInitIrq(pstcUart); /* returns always en_result_t Ok */
1090 
1091  /* Baud Rate Generation Reload Reset */
1092  pstcUart->BGR = 0u;
1093 
1094  /* Serial Mode Register clear all bits (valid in any mode) */
1095  pstcUart->SMR = 0u;
1096 
1097  /* Reset Mfs receive and transmit bit to default */
1098  /* and clear all error flags */
1099  pstcUart->SCR = 0u;
1100 
1101  /* Clear reception Errors */
1102  pstcUart->SSR_f.REC = TRUE;
1103 
1104  /* Reset all other used register to default value */
1105  pstcUart->SSR = 0u;
1106  pstcUart->ESCR = 0u;
1107  pstcUart->FCR0 = 0u;
1108  pstcUart->FCR1 = 0u;
1109 
1110  /* Clear MFS by setting the Software Reset bit */
1111  pstcUart->SCR_f.UPCL = TRUE;
1112 
1113  /* Reset callback functions. */
1114  pstcMfsInternData->pfnTransmitCbFunction = NULL;
1115  pstcMfsInternData->pfnReceiveCbFunction = NULL;
1116  pstcMfsInternData->pfnStatusCbFunction = NULL;
1117  pstcMfsInternData->pvUpperLayerHandle = NULL;
1118 
1119  enResult = Ok;
1120  }
1121 
1122  return (enResult);
1123 } /* Mfs_Uart_DeInit */
1124 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1125 
1126 #if (PDL_MFS_USE_HL == PDL_OFF)
1127 
1144  uint32_t u32BaudRate
1145  )
1146 {
1147  en_result_t enResult;
1148  uint32_t u32ReloadValue;
1149 
1150 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1151  /* Parameter check and get ptr to internal data struct */
1152  if (NULL == MfsGetInternDataPtr(pstcUart))
1153  {
1154  enResult = ErrorInvalidParameter;
1155  }
1156  else
1157  {
1158 #endif
1159  /* Get reload value */
1160  u32ReloadValue = Mfs_GetReloadValue(u32BaudRate);
1161  /* For asynchronous communication, the reload value must be greater than */
1162  /* or equal to 4 because five times over-sampling is performed internally */
1163  if (MFS_NUM_4 > u32ReloadValue)
1164  {
1165  enResult = ErrorUninitialized;
1166  }
1167  else
1168  {
1169  /* Set baud rate generation reload register */
1170  pstcUart->BGR = (uint16_t)(u32ReloadValue & MFS_BGR_MASK);
1171  enResult = Ok;
1172  }
1173 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1174  }
1175 #endif
1176 
1177  return (enResult);
1178 } /* Mfs_Uart_SetBaudRate */
1179 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1180 
1181 #if (PDL_MFS_USE_HL == PDL_OFF)
1182 
1200  const stc_mfs_csio_config_t* pstcConfig
1201  )
1202 {
1203  /* Preset local register variables to zero */
1204  stc_mfs_smr_field_t stcSMR = { 0 };
1205  stc_mfs_scr_field_t stcSCR = { 0 };
1206  stc_mfs_ssr_field_t stcSSR = { 0 };
1207  stc_mfs_escr_field_t stcESCR = { 0 };
1208 
1209  /* Parameter check and get ptr to internal data struct */
1210  if ((NULL == MfsGetInternDataPtr(pstcCsio))
1211  || (NULL == pstcConfig)
1212  )
1213  {
1214  return (ErrorInvalidParameter);
1215  }
1216 
1217  /* Set CSIO mode */
1218  switch (pstcConfig->u8CsioMode)
1219  {
1220  case MfsCsioMaster:
1221  case MfsCsioSlave:
1222  stcSMR.MD = MFS_MD_CSIO;
1223  break;
1224  default:
1225  return (ErrorInvalidParameter);
1226  }
1227 
1228  /* Set master/slave mode */
1229  if (MfsCsioMaster == pstcConfig->u8CsioMode)
1230  {
1231  stcSCR.MS = FALSE; /* Master mode */
1232  }
1233  else
1234  {
1235  stcSCR.MS = TRUE; /* Slave mode */
1236  }
1237 
1238  /* Enable SOE */
1239  stcSMR.SOE = TRUE;
1240 
1241  /* Set normal/SPI mode */
1242  switch (pstcConfig->u8CsioActMode)
1243  {
1244  case MfsCsioActNormalMode:
1245  stcSCR.SPI = FALSE; /* Normal mode */
1246  break;
1247  case MfsCsioActSpiMode:
1248  stcSCR.SPI = TRUE; /* SPI mode */
1249  break;
1250  default:
1251  return (ErrorInvalidParameter);
1252  }
1253 
1254  /* Wait time insertion */
1255  switch(pstcConfig->u8SyncWaitTime)
1256  {
1257  case MfsSyncWaitZero:
1258  stcESCR.WT = MFS_WAIT_TIME_0BIT; /* 0bit */
1259  break;
1260  case MfsSyncWaitOne:
1261  stcESCR.WT = MFS_WAIT_TIME_1BIT; /* 1bit */
1262  break;
1263  case MfsSyncWaitTwo:
1264  stcESCR.WT = MFS_WAIT_TIME_2BITS; /* 2bits */
1265  break;
1266  case MfsSyncWaitThree:
1267  stcESCR.WT = MFS_WAIT_TIME_3BITS; /* 3bits */
1268  break;
1269  default:
1270  return (ErrorInvalidParameter);
1271  }
1272 
1273  stcSSR.AWC = 0; /* Default:16bit access for RDR/TDR */
1274  stcESCR.L3 = 0; /* Default:less than 13 bits */
1275 
1276  /* Set Data bit length (5-16,20,24,32 bits) */
1277  switch (pstcConfig->u8CharLength)
1278  {
1279  case MfsFiveBits:
1280  stcESCR.L = MFS_DATA_LEN_5;
1281  break;
1282  case MfsSixBits:
1283  stcESCR.L = MFS_DATA_LEN_6;
1284  break;
1285  case MfsSevenBits:
1286  stcESCR.L = MFS_DATA_LEN_7;
1287  break;
1288  case MfsEightBits:
1289  stcESCR.L = MFS_DATA_LEN_8;
1290  break;
1291  case MfsNineBits:
1292  stcESCR.L = MFS_DATA_LEN_9;
1293  break;
1294  case MfsTenBits:
1295  stcESCR.L = MFS_DATA_LEN_10;
1296  break;
1297  case MfsElevenBits:
1298  stcESCR.L = MFS_DATA_LEN_11;
1299  break;
1300  case MfsTwelveBits:
1301  stcESCR.L = MFS_DATA_LEN_12;
1302  break;
1303  case MfsThirteenBits:
1304  stcESCR.L = MFS_DATA_LEN_13;
1305  stcESCR.L3 = TRUE; /* More than 12 bits */
1306  break;
1307  case MfsFourteenBits:
1308  stcESCR.L = MFS_DATA_LEN_14;
1309  stcESCR.L3 = TRUE; /* More than 12 bits */
1310  break;
1311  case MfsFifteenBits:
1312  stcESCR.L = MFS_DATA_LEN_15;
1313  stcESCR.L3 = TRUE; /* More than 12 bits */
1314  break;
1315  case MfsSixteenBits:
1316  stcESCR.L = MFS_DATA_LEN_16;
1317  stcESCR.L3 = TRUE; /* More than 12 bits */
1318  break;
1319  case MfsTwentyBits:
1320  stcESCR.L = MFS_DATA_LEN_20;
1321  stcESCR.L3 = TRUE; /* More than 12 bits */
1322  stcSSR.AWC = TRUE; /* 32bit access for RDR/TDR (more than 16 bits) */
1323  break;
1324  case MfsTwentyFourBits:
1325  stcESCR.L = MFS_DATA_LEN_24;
1326  stcESCR.L3 = TRUE; /* More than 12 bits */
1327  stcSSR.AWC = TRUE; /* 32bit access for RDR/TDR (more than 16 bits) */
1328  break;
1329  case MfsThirtyTwoBits:
1330  stcESCR.L = MFS_DATA_LEN_32;
1331  stcESCR.L3 = TRUE; /* More than 12 bits */
1332  stcSSR.AWC = TRUE; /* 32bit access for RDR/TDR (more than 16 bits) */
1333  break;
1334  default:
1335  return (ErrorInvalidParameter);
1336  }
1337  /* Set Bit direction (LSB/MSB) */
1338  if (TRUE == pstcConfig->bBitDirection)
1339  {
1340  stcSMR.BDS = TRUE; /* MSB first */
1341  }
1342  else
1343  {
1344  stcSMR.BDS = FALSE; /* LSB first */
1345  }
1346 
1347  /* Set Signal system (SCK Mark Level) */
1348  if (TRUE == pstcConfig->bSignalSystem)
1349  {
1350  stcSMR.SCINV = TRUE; /* SCK Make Level : High */
1351  }
1352  else
1353  {
1354  stcSMR.SCINV = FALSE; /* SCK Make Level : Low */
1355  }
1356 
1357  stcSSR.REC = TRUE; /* Clear received error flag */
1358 
1359  /* Set Baudrate */
1360  (void)Mfs_Csio_SetBaudRate(pstcCsio, pstcConfig->u32DataRate);
1361  /* Set registers value */
1362  pstcCsio->SMR_f = stcSMR;
1363  pstcCsio->SCR_f = stcSCR;
1364  pstcCsio->ESCR_f = stcESCR;
1365  pstcCsio->SSR_f = stcSSR;
1366 
1367  return (Ok);
1368 } /* Mfs_Csio_Init */
1369 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1370 
1371 #if (PDL_MFS_USE_HL == PDL_OFF)
1372 
1388 {
1389  en_result_t enResult;
1390  stc_mfs_intern_data_t* pstcMfsInternData;
1391 
1392  /* Check for valid pointer and get pointer to internal data struct ... */
1393  pstcMfsInternData = MfsGetInternDataPtr(pstcCsio);
1394  /* ... and check */
1395  if (NULL == pstcMfsInternData)
1396  {
1397  enResult = ErrorInvalidParameter;
1398  }
1399  else
1400  {
1401  /* First of all disable receiver, transmitter and deinit interrupts */
1402  pstcCsio->SCR_f.TXE = FALSE;
1403  pstcCsio->SCR_f.RXE = FALSE;
1404 
1405  (void)Mfs_DeInitIrq(pstcCsio); /* returns always en_result_t Ok */
1406 
1407  /* Baud Rate Generation Reload Reset */
1408  pstcCsio->BGR = 0u;
1409 
1410  /* Serial Mode Register clear all bits (valid in any mode) */
1411  pstcCsio->SMR = 0u;
1412 
1413  /* Reset Mfs receive and transmit bit to default */
1414  /* and clear all error flags */
1415  pstcCsio->SCR = 0u;
1416 
1417  /* Clear reception Errors */
1418  pstcCsio->SSR_f.REC = TRUE;
1419 
1420  /* Reset all other used register to default value */
1421  pstcCsio->SSR = 0u;
1422  pstcCsio->ESCR = 0u;
1423  pstcCsio->FCR0 = 0u;
1424  pstcCsio->FCR1 = 0u;
1425  pstcCsio->SACSR = 0u;
1426  pstcCsio->STMCR = 0u;
1427  pstcCsio->SCSCR = 0u;
1428  pstcCsio->TBYTE0 = 0u;
1429 
1430  /* Reset callback functions. */
1431  pstcMfsInternData->pfnTransmitCbFunction = NULL;
1432  pstcMfsInternData->pfnReceiveCbFunction = NULL;
1433  pstcMfsInternData->pfnStatusCbFunction = NULL;
1434  pstcMfsInternData->pvUpperLayerHandle = NULL;
1435 
1436  enResult = Ok;
1437  }
1438 
1439  return (enResult);
1440 } /* Mfs_Csio_DeInit */
1441 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1442 
1443 #if (PDL_MFS_USE_HL == PDL_OFF)
1444 
1461  boolean_t bEnable
1462  )
1463 {
1464  en_result_t enResult;
1465 
1466 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1467  /* Parameter check and get ptr to internal data struct */
1468  if (NULL == MfsGetInternDataPtr(pstcCsio))
1469  {
1470  enResult = ErrorInvalidParameter;
1471  }
1472  else
1473  {
1474 #endif
1475  /* Disable Serial Clock Output */
1476  if (FALSE == bEnable)
1477  {
1478  pstcCsio->SMR_f.SCKE = FALSE;
1479  }
1480  /* Enable Serial Clock Output */
1481  else
1482  {
1483  pstcCsio->SMR_f.SCKE = TRUE;
1484  }
1485 
1486  enResult = Ok;
1487 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1488  }
1489 #endif
1490 
1491  return (enResult);
1492 } /* Mfs_Csio_SetSckOutEnable */
1493 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1494 
1495 #if (PDL_MFS_USE_HL == PDL_OFF)
1496 
1511 uint32_t Mfs_Csio_ReadData32(volatile stc_mfsn_t* pstcCsio)
1512 {
1513  uint32_t u32ReadData;
1514 
1515 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1516  /* Parameter check and get ptr to internal data struct */
1517  if (NULL == MfsGetInternDataPtr(pstcCsio))
1518  {
1519  u32ReadData = 0u;
1520  }
1521  else
1522  {
1523 #endif
1524  /* Return the Value of Received Data Register (RDR, 32bit) */
1525  u32ReadData = pstcCsio->RDR32;
1526 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1527  }
1528 #endif
1529 
1530  return (u32ReadData);
1531 } /* Mfs_Csio_ReadData32 */
1532 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1533 
1534 #if (PDL_MFS_USE_HL == PDL_OFF)
1535 
1556  const uint32_t u32Data
1557  )
1558 {
1559  en_result_t enResult;
1560 
1561 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1562  /* Parameter check and get ptr to internal data struct */
1563  if (NULL == MfsGetInternDataPtr(pstcCsio))
1564  {
1565  enResult = ErrorInvalidParameter;
1566  }
1567  else
1568  {
1569 #endif
1570  /* Put data to Transmit Data Register (TDR) */
1571  pstcCsio->TDR32 = (uint32_t)u32Data;
1572 
1573  enResult = Ok;
1574 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1575  }
1576 #endif
1577 
1578  return (enResult);
1579 } /* Mfs_Csio_WriteData32 */
1580 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1581 
1582 #if (PDL_MFS_USE_HL == PDL_OFF)
1583 
1600  boolean_t bEnable
1601  )
1602 {
1603  en_result_t enResult;
1604 
1605 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1606  /* Parameter check and get ptr to internal data struct */
1607  if (NULL == MfsGetInternDataPtr(pstcCsio))
1608  {
1609  enResult = ErrorInvalidParameter;
1610  }
1611  else
1612  {
1613 #endif
1614  /* Disable generating of chip select error */
1615  if (FALSE == bEnable)
1616  {
1617  pstcCsio->SACSR_f.TBEEN = FALSE;
1618  }
1619  /* Enable generating of chip select error */
1620  else
1621  {
1622  pstcCsio->SACSR_f.TBEEN = TRUE;
1623  }
1624 
1625  enResult = Ok;
1626 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1627  }
1628 #endif
1629 
1630  return (enResult);
1631 } /* Mfs_Csio_SetChipSelectErrEnable */
1632 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1633 
1634 #if (PDL_MFS_USE_HL == PDL_OFF)
1635 
1652  boolean_t bEnable
1653  )
1654 {
1655  en_result_t enResult;
1656 
1657 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1658  /* Parameter check and get ptr to internal data struct */
1659  if (NULL == MfsGetInternDataPtr(pstcCsio))
1660  {
1661  enResult = ErrorInvalidParameter;
1662  }
1663  else
1664  {
1665 #endif
1666  /* Disable interrupt of chip select error */
1667  if (FALSE == bEnable)
1668  {
1669  pstcCsio->SACSR_f.CSEIE = FALSE;
1670  }
1671  /* Enable interrupt of chip select error */
1672  else
1673  {
1674  pstcCsio->SACSR_f.CSEIE = TRUE;
1675  }
1676 
1677  enResult = Ok;
1678 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1679  }
1680 #endif
1681 
1682  return (enResult);
1683 } /* Mfs_Csio_SetChipSelectErrIntEnable */
1684 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1685 
1686 #if (PDL_MFS_USE_HL == PDL_OFF)
1687 
1699 uint16_t Mfs_Csio_GetStatus(volatile stc_mfsn_t* pstcCsio,
1700  uint16_t u16StatusMask
1701  )
1702 {
1703  uint16_t u16Status;
1704 
1705 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1706  /* Parameter check and get ptr to internal data struct */
1707  if (NULL == MfsGetInternDataPtr(pstcCsio))
1708  {
1709  u16Status = 0u;
1710  }
1711  else
1712  {
1713 #endif
1714  /* Return SACSR specified bits */
1715  u16Status = pstcCsio->SACSR & u16StatusMask;
1716 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1717  }
1718 #endif
1719 
1720  return (u16Status);
1721 } /* Mfs_Csio_GetStatus */
1722 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1723 
1724 #if (PDL_MFS_USE_HL == PDL_OFF)
1725 
1740 {
1741  en_result_t enResult;
1742 
1743 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1744  /* Parameter check and get ptr to internal data struct */
1745  if (NULL == MfsGetInternDataPtr(pstcCsio))
1746  {
1747  enResult = ErrorInvalidParameter;
1748  }
1749  else
1750  {
1751 #endif
1752  /* Clear SACSR CSE bit */
1753  pstcCsio->SACSR_f.CSE = FALSE;
1754 
1755  enResult = Ok;
1756 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1757  }
1758 #endif
1759 
1760  return (enResult);
1761 } /* Mfs_Csio_GetStatus */
1762 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1763 
1764 #if (PDL_MFS_USE_HL == PDL_OFF)
1765 
1780 {
1781  en_result_t enResult;
1782 
1783 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1784  /* Parameter check and get ptr to internal data struct */
1785  if (NULL == MfsGetInternDataPtr(pstcCsio))
1786  {
1787  enResult = ErrorInvalidParameter;
1788  }
1789  else
1790  {
1791 #endif
1792  /* Clear SACSR TINT bit */
1793  pstcCsio->SACSR_f.TINT = FALSE;
1794 
1795  enResult = Ok;
1796 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1797  }
1798 #endif
1799 
1800  return (enResult);
1801 } /* Mfs_Csio_ClrTimerIntReq */
1802 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1803 
1804 #if (PDL_MFS_USE_HL == PDL_OFF)
1805 
1822  boolean_t bEnable
1823  )
1824 {
1825  en_result_t enResult;
1826 
1827 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1828  /* Parameter check and get ptr to internal data struct */
1829  if (NULL == MfsGetInternDataPtr(pstcCsio))
1830  {
1831  enResult = ErrorInvalidParameter;
1832  }
1833  else
1834  {
1835 #endif
1836  /* Disable serial timer interrupt */
1837  if (FALSE == bEnable)
1838  {
1839  pstcCsio->SACSR_f.TINTE = FALSE;
1840  }
1841  /* Enable serial timer interrupt */
1842  else
1843  {
1844  pstcCsio->SACSR_f.TINTE = TRUE;
1845  }
1846 
1847  enResult = Ok;
1848 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1849  }
1850 #endif
1851 
1852  return (enResult);
1853 } /* Mfs_Csio_EnableSerialTimerInt */
1854 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1855 
1856 #if (PDL_MFS_USE_HL == PDL_OFF)
1857 
1874  boolean_t bEnable
1875  )
1876 {
1877  en_result_t enResult;
1878 
1879 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1880  /* Parameter check and get ptr to internal data struct */
1881  if (NULL == MfsGetInternDataPtr(pstcCsio))
1882  {
1883  enResult = ErrorInvalidParameter;
1884  }
1885  else
1886  {
1887 #endif
1888  /* Disable synchronous transfer */
1889  if (FALSE == bEnable)
1890  {
1891  pstcCsio->SACSR_f.TSYNE = FALSE;
1892  }
1893  /* Enable synchronous transfer */
1894  else
1895  {
1896  pstcCsio->SACSR_f.TSYNE = TRUE;
1897  }
1898 
1899  enResult = Ok;
1900 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1901  }
1902 #endif
1903 
1904  return (enResult);
1905 } /* Mfs_Csio_SetSyncTransEnable */
1906 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1907 
1908 #if (PDL_MFS_USE_HL == PDL_OFF)
1909 
1925  uint8_t u8Prescale
1926  )
1927 {
1928  en_result_t enResult;
1929 
1930 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1931  /* Parameter check and get ptr to internal data struct */
1932  if (NULL == MfsGetInternDataPtr(pstcCsio))
1933  {
1934  enResult = ErrorInvalidParameter;
1935  }
1936  else
1937  {
1938 #endif
1939  pstcCsio->SACSR_f.TDIV = u8Prescale;
1940 
1941  enResult = Ok;
1942 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1943  }
1944 #endif
1945 
1946  return (enResult);
1947 } /* Mfs_Csio_SetTimerPrescale */
1948 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
1949 
1950 #if (PDL_MFS_USE_HL == PDL_OFF)
1951 
1968  boolean_t bEnable
1969  )
1970 {
1971  en_result_t enResult;
1972 
1973 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1974  /* Parameter check and get ptr to internal data struct */
1975  if (NULL == MfsGetInternDataPtr(pstcCsio))
1976  {
1977  enResult = ErrorInvalidParameter;
1978  }
1979  else
1980  {
1981 #endif
1982  /* Disable serial timer */
1983  if (FALSE == bEnable)
1984  {
1985  pstcCsio->SACSR_f.TMRE = FALSE;
1986  }
1987  /* Enable serial timer */
1988  else
1989  {
1990  pstcCsio->SACSR_f.TMRE = TRUE;
1991  }
1992 
1993  enResult = Ok;
1994 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
1995  }
1996 #endif
1997 
1998  return (enResult);
1999 } /* Mfs_Csio_SetSerialTimerEnable */
2000 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2001 
2002 #if (PDL_MFS_USE_HL == PDL_OFF)
2003 
2013 uint16_t Mfs_Csio_GetSerialTimer(volatile stc_mfsn_t* pstcCsio)
2014 {
2015  uint16_t u16SerialTimer;
2016 
2017 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2018  /* Parameter check and get ptr to internal data struct */
2019  if (NULL == MfsGetInternDataPtr(pstcCsio))
2020  {
2021  u16SerialTimer = 0u;
2022  }
2023  else
2024  {
2025 #endif
2026  /* Return the serial timer */
2027  u16SerialTimer = pstcCsio->STMR;
2028 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2029  }
2030 #endif
2031 
2032  return (u16SerialTimer);
2033 } /* Mfs_Csio_GetSerialTimer */
2034 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2035 
2036 #if (PDL_MFS_USE_HL == PDL_OFF)
2037 
2053  uint16_t u16CompareValue
2054  )
2055 {
2056  en_result_t enResult;
2057 
2058 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2059  /* Parameter check and get ptr to internal data struct */
2060  if (NULL == MfsGetInternDataPtr(pstcCsio))
2061  {
2062  enResult = ErrorInvalidParameter;
2063  }
2064  else
2065  {
2066 #endif
2067  /* Set compare value for serial timer */
2068  pstcCsio->STMCR = u16CompareValue;
2069 
2070  enResult = Ok;
2071 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2072  }
2073 #endif
2074 
2075  return (enResult);
2076 } /* Mfs_Csio_SetCmpVal4SerialTimer */
2077 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2078 
2079 #if (PDL_MFS_USE_HL == PDL_OFF)
2080 
2097  boolean_t bHold
2098  )
2099 {
2100  en_result_t enResult;
2101 
2102 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2103  /* Parameter check and get ptr to internal data struct */
2104  if (NULL == MfsGetInternDataPtr(pstcCsio))
2105  {
2106  enResult = ErrorInvalidParameter;
2107  }
2108  else
2109  {
2110 #endif
2111  /* Not hold serial chip select */
2112  if (FALSE == bHold)
2113  {
2114  pstcCsio->SCSCR_f.SCAM = FALSE;
2115  }
2116  /* Hold serial chip select */
2117  else
2118  {
2119  pstcCsio->SCSCR_f.SCAM = TRUE;
2120  }
2121 
2122  enResult = Ok;
2123 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2124  }
2125 #endif
2126 
2127  return (enResult);
2128 } /* Mfs_Csio_SetCsHold */
2129 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2130 
2131 #if (PDL_MFS_USE_HL == PDL_OFF)
2132 
2148  uint8_t u8Prescale
2149  )
2150 {
2151  en_result_t enResult;
2152 
2153 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2154  /* Parameter check and get ptr to internal data struct */
2155  if (NULL == MfsGetInternDataPtr(pstcCsio))
2156  {
2157  enResult = ErrorInvalidParameter;
2158  }
2159  else
2160  {
2161 #endif
2162  pstcCsio->SCSCR_f.CDIV = u8Prescale;
2163 
2164  enResult = Ok;
2165 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2166  }
2167 #endif
2168 
2169  return (enResult);
2170 } /* Mfs_Csio_SetCsTimingPrescale */
2171 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2172 
2173 #if (PDL_MFS_USE_HL == PDL_OFF)
2174 
2191  boolean_t bLevel
2192  )
2193 {
2194  en_result_t enResult;
2195 
2196 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2197  /* Parameter check and get ptr to internal data struct */
2198  if (NULL == MfsGetInternDataPtr(pstcCsio))
2199  {
2200  enResult = ErrorInvalidParameter;
2201  }
2202  else
2203  {
2204 #endif
2205  /* In-active level is Low */
2206  if (FALSE == bLevel)
2207  {
2208  pstcCsio->SCSCR_f.CSLVL = FALSE;
2209  }
2210  /* In-active level is High */
2211  else
2212  {
2213  pstcCsio->SCSCR_f.CSLVL = TRUE;
2214  }
2215 
2216  enResult = Ok;
2217 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2218  }
2219 #endif
2220 
2221  return (enResult);
2222 } /* Mfs_Csio_SetCsInActiveLevel */
2223 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2224 
2225 #if (PDL_MFS_USE_HL == PDL_OFF)
2226 
2243  boolean_t bEnable
2244  )
2245 {
2246  en_result_t enResult;
2247 
2248 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2249  /* Parameter check and get ptr to internal data struct */
2250  if (NULL == MfsGetInternDataPtr(pstcCsio))
2251  {
2252  enResult = ErrorInvalidParameter;
2253  }
2254  else
2255  {
2256 #endif
2257  /* Disable chip select */
2258  if (FALSE == bEnable)
2259  {
2260  pstcCsio->SCSCR_f.CSEN0 = FALSE;
2261  }
2262  /* Enable chip select */
2263  else
2264  {
2265  pstcCsio->SCSCR_f.CSEN0 = TRUE;
2266  }
2267 
2268  enResult = Ok;
2269 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2270  }
2271 #endif
2272 
2273  return (enResult);
2274 } /* Mfs_Csio_EnableChipSelect */
2275 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2276 
2277 #if (PDL_MFS_USE_HL == PDL_OFF)
2278 
2295  boolean_t bEnable
2296  )
2297 {
2298  en_result_t enResult;
2299 
2300 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2301  /* Parameter check and get ptr to internal data struct */
2302  if (NULL == MfsGetInternDataPtr(pstcCsio))
2303  {
2304  enResult = ErrorInvalidParameter;
2305  }
2306  else
2307  {
2308 #endif
2309  /* Disable chip select output */
2310  if (FALSE == bEnable)
2311  {
2312  pstcCsio->SCSCR_f.CSOE = FALSE;
2313  }
2314  /* Enable chip select output */
2315  else
2316  {
2317  pstcCsio->SCSCR_f.CSOE = TRUE;
2318  }
2319 
2320  enResult = Ok;
2321 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2322  }
2323 #endif
2324 
2325  return (enResult);
2326 } /* Mfs_Csio_SetChipSelectOutEnable */
2327 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2328 
2329 #if (PDL_MFS_USE_HL == PDL_OFF)
2330 
2346  stc_mfs_csio_cs_timing_t* pstcCsTimingCfg
2347  )
2348 {
2349  en_result_t enResult;
2350 
2351 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2352  /* Parameter check and get ptr to internal data struct */
2353  if ((NULL == MfsGetInternDataPtr(pstcCsio))
2354  || (NULL == pstcCsTimingCfg)
2355  )
2356  {
2357  enResult = ErrorInvalidParameter;
2358  }
2359  else
2360  {
2361 #endif
2362  /* Set timing for setup delay */
2363  pstcCsio->SCSTR1 = pstcCsTimingCfg->u8CsSetupDelay;
2364  /* Set timing for hold delay */
2365  pstcCsio->SCSTR0 = pstcCsTimingCfg->u8CsHoldDelay;
2366  /* Set minimum time from inactivation until activation of chip select */
2367  pstcCsio->SCSTR32 = pstcCsTimingCfg->u16CsDeSelect;
2368 
2369  enResult = Ok;
2370 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2371  }
2372 #endif
2373 
2374  return (enResult);
2375 } /* Mfs_Csio_SetCsTimingConfig */
2376 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2377 
2378 #if (PDL_MFS_USE_HL == PDL_OFF)
2379 
2395  uint8_t u8TxBytes
2396  )
2397 {
2398  en_result_t enResult;
2399 
2400 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2401  /* Parameter check and get ptr to internal data struct */
2402  if (NULL == MfsGetInternDataPtr(pstcCsio))
2403  {
2404  enResult = ErrorInvalidParameter;
2405  }
2406  else
2407  {
2408 #endif
2409  /* Set transfer length */
2410  pstcCsio->TBYTE0 = u8TxBytes;
2411 
2412  enResult = Ok;
2413 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2414  }
2415 #endif
2416 
2417  return (enResult);
2418 } /* Mfs_Csio_SetTxLength */
2419 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2420 
2421 #if (PDL_MFS_USE_HL == PDL_OFF)
2422 
2439  uint32_t u32BaudRate
2440  )
2441 {
2442  en_result_t enResult;
2443  uint32_t u32ReloadValue;
2444 
2445 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2446  /* Parameter check and get ptr to internal data struct */
2447  if (NULL == MfsGetInternDataPtr(pstcCsio))
2448  {
2449  enResult = ErrorInvalidParameter;
2450  }
2451  else
2452  {
2453 #endif
2454  /* Get reload value */
2455  u32ReloadValue = Mfs_GetReloadValue(u32BaudRate);
2456  /* For asynchronous communication, the reload value must be greater than */
2457  /* or equal to 3 because four times over-sampling is performed internally */
2458  if (MFS_NUM_3 > u32ReloadValue)
2459  {
2460  enResult = ErrorUninitialized;
2461  }
2462  else
2463  {
2464  /* Set baud rate generation reload register */
2465  pstcCsio->BGR = (uint16_t)(u32ReloadValue & MFS_BGR_MASK);
2466 
2467  enResult = Ok;
2468  }
2469 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2470  }
2471 #endif
2472 
2473  return (enResult);
2474 } /* Mfs_Csio_SetBaudRate */
2475 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2476 
2477 #if (PDL_MFS_USE_HL == PDL_OFF)
2478 
2496  const stc_mfs_i2c_config_t* pstcConfig
2497  )
2498 {
2499  /* Preset local register variables to zero */
2500  stc_mfs_smr_field_t stcSMR = { 0 };
2501  stc_mfs_i2c_ibcr_field_t stcIBCR = { 0 };
2502  stc_mfs_i2c_isba_field_t stcISBA = { 0 };
2503  stc_mfs_i2c_ismk_field_t stcISMK = { 0 };
2504  uint8_t u8NFCR = 0u;
2505 
2506  /* Parameter check and get ptr to internal data struct */
2507  if ((NULL == MfsGetInternDataPtr(pstcI2c))
2508  || (NULL == pstcConfig)
2509  )
2510  {
2511  return (ErrorInvalidParameter);
2512  }
2513 
2514  /* Set I2C mode */
2515  switch (pstcConfig->u8I2cMode)
2516  {
2517  case MfsI2cMaster:
2518  case MfsI2cSlave:
2519  stcSMR.MD = MFS_MD_I2C;
2520  break;
2521  default:
2522  return (ErrorInvalidParameter);
2523  }
2524 
2525  /* Set noize filter */
2526  switch (pstcConfig->u8NoizeFilter)
2527  {
2547  u8NFCR = pstcConfig->u8NoizeFilter;
2548  break;
2549  default:
2550  return (ErrorInvalidParameter);
2551  }
2552 
2553  /* Fast mode selection */
2554  if ((pstcI2c == MFS_I2C_FAST_MODE_PLUS_CH_A)
2555  || (pstcI2c == MFS_I2C_FAST_MODE_PLUS_CH_B)
2556  )
2557  {
2558  switch (pstcConfig->u8FastMode)
2559  {
2560  /* Standard-mode or Fast-mode */
2562  if (pstcI2c == MFS_I2C_FAST_MODE_PLUS_CH_A)
2563  {
2564  FM4_GPIO->EPFR16_f.SFMPAC = FALSE;
2565  }
2566  else
2567  {
2568  FM4_GPIO->EPFR16_f.SFMPBC = FALSE;
2569  }
2570  break;
2571  /* Fast-mode Plus */
2573  if (pstcI2c == MFS_I2C_FAST_MODE_PLUS_CH_A)
2574  {
2575  FM4_GPIO->EPFR16_f.SFMPAC = TRUE;
2576  }
2577  else
2578  {
2579  FM4_GPIO->EPFR16_f.SFMPBC = TRUE;
2580  }
2581  break;
2582  default:
2583  return (ErrorInvalidParameter);
2584  }
2585  }
2586 
2587  /* Ack enable */
2588  stcIBCR.ACKE = TRUE;
2589 
2590  /* Slave mode */
2591  if (MfsI2cSlave == pstcConfig->u8I2cMode)
2592  {
2593  /* Set slave address */
2594  stcISBA.SA = pstcConfig->u8SlvAddr;
2595  /* Enable slave address detection */
2596  stcISBA.SAEN = TRUE;
2597  }
2598 
2599  /* Enable I2C, Enable bit comparing */
2600  stcISMK.SM = MFS_ISMK_SLV_ADDR_MASK;
2601  stcISMK.EN = TRUE;
2602 
2603  /* now setup hardware with correct mode first and then go on with */
2604  /* bit settings */
2605  pstcI2c->SMR_f = stcSMR;
2606 
2607  /* I2C disable before other registers are set. */
2608  pstcI2c->ISMK = 0u;
2609 
2610  /* Set baud rate generation */
2611  (void)Mfs_I2c_SetBaudRate(pstcI2c, pstcConfig->u32DataRate);
2612 
2613  /* Set registers value */
2614  pstcI2c->NFCR = u8NFCR;
2615  pstcI2c->IBCR_f = stcIBCR;
2616  pstcI2c->ISBA_f = stcISBA;
2617  pstcI2c->ISMK_f = stcISMK;
2618 
2619  return (Ok);
2620 } /* Mfs_I2c_Init */
2621 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2622 
2623 #if (PDL_MFS_USE_HL == PDL_OFF)
2624 
2640 {
2641  en_result_t enResult;
2642  stc_mfs_intern_data_t* pstcMfsInternData;
2643 
2644  /* Check for valid pointer and get pointer to internal data struct ... */
2645  pstcMfsInternData = MfsGetInternDataPtr(pstcI2c);
2646  /* ... and check */
2647  if (NULL == pstcMfsInternData)
2648  {
2649  enResult = ErrorInvalidParameter;
2650  }
2651  else
2652  {
2653  /* Disable I2C */
2654  pstcI2c->ISMK_f.EN = FALSE;
2655 
2656  (void)Mfs_DeInitIrq(pstcI2c); /* returns always en_result_t Ok */
2657 
2658  /* Serial Mode Register clear all bits (valid in any mode) */
2659  pstcI2c->SMR = 0u;
2660 
2661  /* Reset Mfs receive and transmit bit to default */
2662  /* and clear all error flags */
2663  pstcI2c->IBCR = 0u;
2664 
2665  /* Clear reception Errors */
2666  pstcI2c->SSR_f.REC = TRUE;
2667 
2668  /* Reset all other used register to default value */
2669  pstcI2c->SSR = 0u;
2670  pstcI2c->IBSR = 0u;
2671  pstcI2c->FCR0 = 0u;
2672  pstcI2c->FCR1 = 0u;
2673  pstcI2c->NFCR = 0u;
2674 
2675  /* Reset callback functions. */
2676  pstcMfsInternData->pfnTransmitCbFunction = NULL;
2677  pstcMfsInternData->pfnReceiveCbFunction = NULL;
2678  pstcMfsInternData->pfnStatusCbFunction = NULL;
2679  pstcMfsInternData->pvUpperLayerHandle = NULL;
2680 
2681  enResult = Ok;
2682  }
2683 
2684  return (enResult);
2685 } /* Mfs_I2c_DeInit */
2686 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2687 
2688 #if (PDL_MFS_USE_HL == PDL_OFF)
2689 
2706  boolean_t bEnable
2707  )
2708 {
2709  en_result_t enResult;
2710 
2711 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2712  /* Parameter check and get ptr to internal data struct */
2713  if (NULL == MfsGetInternDataPtr(pstcI2c))
2714  {
2715  enResult = ErrorInvalidParameter;
2716  }
2717  else
2718  {
2719 #endif
2720  /* Disable TX interrupt */
2721  if (FALSE == bEnable)
2722  {
2723  pstcI2c->SMR_f.TIE = FALSE;
2724  }
2725  /* Enable TX interrupt */
2726  else
2727  {
2728  pstcI2c->SMR_f.TIE = TRUE;
2729  }
2730 
2731  enResult = Ok;
2732 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2733  }
2734 #endif
2735 
2736  return (enResult);
2737 } /* Mfs_I2c_SetTxIntEnable */
2738 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2739 
2740 #if (PDL_MFS_USE_HL == PDL_OFF)
2741 
2758  boolean_t bEnable
2759  )
2760 {
2761  en_result_t enResult;
2762 
2763 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2764  /* Parameter check and get ptr to internal data struct */
2765  if (NULL == MfsGetInternDataPtr(pstcI2c))
2766  {
2767  enResult = ErrorInvalidParameter;
2768  }
2769  else
2770  {
2771 #endif
2772  /* Disable RX interrupt */
2773  if (FALSE == bEnable)
2774  {
2775  pstcI2c->SMR_f.RIE = FALSE;
2776  }
2777  /* Enable RX interrupt */
2778  else
2779  {
2780  pstcI2c->SMR_f.RIE = TRUE;
2781  }
2782 
2783  enResult = Ok;
2784 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2785  }
2786 #endif
2787 
2788  return (enResult);
2789 } /* Mfs_I2c_SetRxIntEnable */
2790 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2791 
2792 #if (PDL_MFS_USE_HL == PDL_OFF)
2793 
2810  boolean_t bEnable
2811  )
2812 {
2813  en_result_t enResult;
2814 
2815 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2816  /* Parameter check and get ptr to internal data struct */
2817  if (NULL == MfsGetInternDataPtr(pstcI2c))
2818  {
2819  enResult = ErrorInvalidParameter;
2820  }
2821  else
2822  {
2823 #endif
2824  /* Disable ACK */
2825  if (FALSE == bEnable)
2826  {
2827  pstcI2c->IBCR_f.ACKE = FALSE;
2828  }
2829  /* Enable ACK */
2830  else
2831  {
2832  pstcI2c->IBCR_f.ACKE = TRUE;
2833  }
2834 
2835  enResult = Ok;
2836 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2837  }
2838 #endif
2839 
2840  return (enResult);
2841 } /* Mfs_I2c_SetAckEnable */
2842 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2843 
2844 #if (PDL_MFS_USE_HL == PDL_OFF)
2845 
2861  uint8_t u8WaitSelect
2862  )
2863 {
2864  en_result_t enResult;
2865 
2866 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2867  /* Parameter check and get ptr to internal data struct */
2868  if (NULL == MfsGetInternDataPtr(pstcI2c))
2869  {
2870  enResult = ErrorInvalidParameter;
2871  }
2872  else
2873  {
2874 #endif
2875  /* Waits (8 bits) after data transmission or reception. */
2876  if (MfsI2cWaitSelDataTxRx == u8WaitSelect)
2877  {
2878  pstcI2c->IBCR_f.WSEL = TRUE;
2879  }
2880  /* Waits (9 bits) after acknowledgement. */
2881  else
2882  {
2883  pstcI2c->IBCR_f.WSEL = FALSE;
2884  }
2885 
2886  enResult = Ok;
2887 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2888  }
2889 #endif
2890 
2891  return (enResult);
2892 } /* Mfs_I2c_SetWaitSelect */
2893 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2894 
2895 #if (PDL_MFS_USE_HL == PDL_OFF)
2896 
2913  boolean_t bEnable
2914  )
2915 {
2916  en_result_t enResult;
2917 
2918 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2919  /* Parameter check and get ptr to internal data struct */
2920  if (NULL == MfsGetInternDataPtr(pstcI2c))
2921  {
2922  enResult = ErrorInvalidParameter;
2923  }
2924  else
2925  {
2926 #endif
2927  /* Disable condition detection interrupt */
2928  if (FALSE == bEnable)
2929  {
2930  pstcI2c->IBCR_f.CNDE = FALSE;
2931  }
2932  /* Enable condition detection interrupt */
2933  else
2934  {
2935  pstcI2c->IBCR_f.CNDE = TRUE;
2936  }
2937 
2938  enResult = Ok;
2939 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2940  }
2941 #endif
2942 
2943  return (enResult);
2944 } /* Mfs_I2c_SetCondDetIntEnable */
2945 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2946 
2947 #if (PDL_MFS_USE_HL == PDL_OFF)
2948 
2965  boolean_t bEnable
2966  )
2967 {
2968  en_result_t enResult;
2969 
2970 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2971  /* Parameter check and get ptr to internal data struct */
2972  if (NULL == MfsGetInternDataPtr(pstcI2c))
2973  {
2974  enResult = ErrorInvalidParameter;
2975  }
2976  else
2977  {
2978 #endif
2979  /* Disable interrupt */
2980  if (FALSE == bEnable)
2981  {
2982  pstcI2c->IBCR_f.INTE = FALSE;
2983  }
2984  /* Enable interrupt */
2985  else
2986  {
2987  pstcI2c->IBCR_f.INTE = TRUE;
2988  }
2989 
2990  enResult = Ok;
2991 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
2992  }
2993 #endif
2994 
2995  return (enResult);
2996 } /* Mfs_I2c_SetIntEnable */
2997 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
2998 
2999 #if (PDL_MFS_USE_HL == PDL_OFF)
3000 
3011 {
3012  boolean_t bErrStatus = FALSE;
3013 
3014 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3015  /* Parameter check and get ptr to internal data struct */
3016  if (NULL != MfsGetInternDataPtr(pstcI2c))
3017  {
3018 #endif
3019  /* Return the bus error status */
3020  if(TRUE == pstcI2c->IBCR_f.BER)
3021  {
3022  bErrStatus = TRUE;
3023  }
3024 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3025  }
3026 #endif
3027 
3028  return (bErrStatus);
3029 } /* Mfs_I2c_GetBusErrStatus */
3030 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3031 
3032 #if (PDL_MFS_USE_HL == PDL_OFF)
3033 
3044 {
3045  boolean_t bIntStatus = FALSE;
3046 
3047 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3048  /* Parameter check and get ptr to internal data struct */
3049  if (NULL != MfsGetInternDataPtr(pstcI2c))
3050  {
3051 #endif
3052  /* Set the interrupt status */
3053  if(TRUE == pstcI2c->IBCR_f.INT)
3054  {
3055  bIntStatus = TRUE;
3056  }
3057 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3058  }
3059 #endif
3060 
3061  return (bIntStatus);
3062 } /* Mfs_I2c_GetIntStatus */
3063 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3064 
3065 #if (PDL_MFS_USE_HL == PDL_OFF)
3066 
3081 {
3082  en_result_t enResult;
3083 
3084 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3085  /* Parameter check and get ptr to internal data struct */
3086  if (NULL == MfsGetInternDataPtr(pstcI2c))
3087  {
3088  enResult = ErrorInvalidParameter;
3089  }
3090  else
3091  {
3092 #endif
3093  /* Clear the interrupt status */
3094  pstcI2c->IBCR_f.INT = FALSE;
3095 
3096  enResult = Ok;
3097 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3098  }
3099 #endif
3100 
3101  return (enResult);
3102 } /* Mfs_I2c_ClearIntStatus */
3103 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3104 
3105 #if (PDL_MFS_USE_HL == PDL_OFF)
3106 
3123 {
3124  en_result_t enResult;
3125 
3126 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3127  /* Parameter check and get ptr to internal data struct */
3128  if (NULL == MfsGetInternDataPtr(pstcI2c))
3129  {
3130  enResult = ErrorInvalidParameter;
3131  }
3132  else
3133  {
3134 #endif
3135  /* Set the transmit empty flag set bit */
3136  pstcI2c->SSR_f.TSET = FALSE;
3137 
3138  enResult = Ok;
3139 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3140  }
3141 #endif
3142 
3143  return (enResult);
3144 } /* Mfs_I2c_SetTransmitEmpty */
3145 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3146 
3147 #if (PDL_MFS_USE_HL == PDL_OFF)
3148 
3165  boolean_t bEnable
3166  )
3167 {
3168  en_result_t enResult;
3169 
3170 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3171  /* Parameter check and get ptr to internal data struct */
3172  if (NULL == MfsGetInternDataPtr(pstcI2c))
3173  {
3174  enResult = ErrorInvalidParameter;
3175  }
3176  else
3177  {
3178 #endif
3179  /* Disable DMA mode */
3180  if (FALSE == bEnable)
3181  {
3182  pstcI2c->SSR_f.DMA = FALSE;
3183  }
3184  /* Enable DMA mode */
3185  else
3186  {
3187  pstcI2c->SSR_f.DMA = TRUE;
3188  }
3189 
3190  enResult = Ok;
3191 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3192  }
3193 #endif
3194 
3195  return (enResult);
3196 } /* Mfs_I2c_SetDmaModeEnable */
3197 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3198 
3199 #if (PDL_MFS_USE_HL == PDL_OFF)
3200 
3217  uint8_t u8NzFilter
3218  )
3219 {
3220  en_result_t enResult;
3221 
3222 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3223  /* Parameter check and get ptr to internal data struct */
3224  if ((NULL == MfsGetInternDataPtr(pstcI2c))
3225  || (MfsI2cNoizeFilterLess400M < u8NzFilter)
3226  )
3227  {
3228  enResult = ErrorInvalidParameter;
3229  }
3230  else
3231  {
3232 #endif
3233  /* Set noize filter setting */
3234  pstcI2c->NFCR = u8NzFilter;
3235 
3236  enResult = Ok;
3237 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3238  }
3239 #endif
3240 
3241  return (enResult);
3242 } /* Mfs_I2c_SetNoizeFilter */
3243 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3244 
3245 #if (PDL_MFS_USE_HL == PDL_OFF)
3246 
3264  boolean_t bLevel
3265  )
3266 {
3267  en_result_t enResult;
3268 
3269 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3270  /* Parameter check and get ptr to internal data struct */
3271  if (NULL == MfsGetInternDataPtr(pstcI2c))
3272  {
3273  enResult = ErrorInvalidParameter;
3274  }
3275  else
3276  {
3277 #endif
3278  /* Set "L" level after passing noize filter for SDA output */
3279  if (FALSE == bLevel)
3280  {
3281  pstcI2c->EIBCR_f.SDAC = FALSE;
3282  }
3283  /* Set "H" level after passing noize filter for SDA output */
3284  else
3285  {
3286  pstcI2c->EIBCR_f.SDAC = TRUE;
3287  }
3288 
3289  enResult = Ok;
3290 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3291  }
3292 #endif
3293 
3294  return (enResult);
3295 } /* Mfs_I2c_SetSdaOutLevel */
3296 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3297 
3298 #if (PDL_MFS_USE_HL == PDL_OFF)
3299 
3317  boolean_t bLevel
3318  )
3319 {
3320  en_result_t enResult;
3321 
3322 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3323  /* Parameter check and get ptr to internal data struct */
3324  if (NULL == MfsGetInternDataPtr(pstcI2c))
3325  {
3326  enResult = ErrorInvalidParameter;
3327  }
3328  else
3329  {
3330 #endif
3331  /* Set "L" level after passing noize filter for SCL output */
3332  if (PDLLow == bLevel)
3333  {
3334  pstcI2c->EIBCR_f.SCLC = FALSE;
3335  }
3336  /* Set "H" level after passing noize filter for SCL output */
3337  else
3338  {
3339  pstcI2c->EIBCR_f.SCLC = TRUE;
3340  }
3341 
3342  enResult = Ok;
3343 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3344  }
3345 #endif
3346 
3347  return (enResult);
3348 } /* Mfs_I2c_SetSclOutLevel */
3349 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3350 
3351 #if (PDL_MFS_USE_HL == PDL_OFF)
3352 
3369  boolean_t bEnable
3370  )
3371 {
3372  en_result_t enResult;
3373 
3374 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3375  /* Parameter check and get ptr to internal data struct */
3376  if (NULL == MfsGetInternDataPtr(pstcI2c))
3377  {
3378  enResult = ErrorInvalidParameter;
3379  }
3380  else
3381  {
3382 #endif
3383  /* Disable serial output */
3384  if (FALSE == bEnable)
3385  {
3386  pstcI2c->EIBCR_f.SOCE = FALSE;
3387  }
3388  /* Enable serial output */
3389  else
3390  {
3391  pstcI2c->EIBCR_f.SOCE = TRUE;
3392  }
3393 
3394  enResult = Ok;
3395 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3396  }
3397 #endif
3398 
3399  return (enResult);
3400 } /* Mfs_I2c_SetSerlalOutEnable */
3401 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3402 
3403 #if (PDL_MFS_USE_HL == PDL_OFF)
3404 
3421  boolean_t bEnable
3422  )
3423 {
3424  en_result_t enResult;
3425 
3426 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3427  /* Parameter check and get ptr to internal data struct */
3428  if (NULL == MfsGetInternDataPtr(pstcI2c))
3429  {
3430  enResult = ErrorInvalidParameter;
3431  }
3432  else
3433  {
3434 #endif
3435  /* Disable I2C continue after occuring bus error */
3436  if (FALSE == bEnable)
3437  {
3438  pstcI2c->EIBCR_f.BEC = FALSE;
3439  }
3440  /* Enable I2C continue after occuring bus error */
3441  else
3442  {
3443  pstcI2c->EIBCR_f.BEC = TRUE;
3444  }
3445 
3446  enResult = Ok;
3447 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3448  }
3449 #endif
3450 
3451  return (enResult);
3452 } /* Mfs_I2c_SetBusErrorControlEnable */
3453 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3454 
3455 #if (PDL_MFS_USE_HL == PDL_OFF)
3456 
3474  boolean_t bEnable,
3475  uint8_t u8AddrMask
3476  )
3477 {
3478  en_result_t enResult;
3479  stc_mfs_i2c_ismk_field_t stcISMK;
3480 
3481 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3482  /* Parameter check and get ptr to internal data struct */
3483  if (NULL == MfsGetInternDataPtr(pstcI2c))
3484  {
3485  enResult = ErrorInvalidParameter;
3486  }
3487  else
3488  {
3489 #endif
3490  /* Disable I2C interface */
3491  if (FALSE == bEnable)
3492  {
3493  stcISMK.EN = FALSE;
3494  stcISMK.SM = 0;
3495  }
3496  /* Enable I2C interface */
3497  else
3498  {
3499  stcISMK.EN = TRUE;
3500  /* Set slave address mask */
3501  stcISMK.SM = u8AddrMask & MFS_ISMK_SLV_ADDR_MASK;
3502  }
3503 
3504  /* Set to ISMK register */
3505  pstcI2c->ISMK_f = stcISMK;
3506 
3507  enResult = Ok;
3508 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3509  }
3510 #endif
3511 
3512  return (enResult);
3513 } /* Mfs_I2c_SetI2cIfEnable */
3514 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3515 
3516 #if (PDL_MFS_USE_HL == PDL_OFF)
3517 
3535  boolean_t bEnable,
3536  uint8_t u8SlvAdr
3537  )
3538 {
3539  en_result_t enResult;
3540  stc_mfs_i2c_isba_field_t stcISBA;
3541 
3542 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3543  /* Parameter check and get ptr to internal data struct */
3544  if (NULL == MfsGetInternDataPtr(pstcI2c))
3545  {
3546  enResult = ErrorInvalidParameter;
3547  }
3548  else
3549  {
3550 #endif
3551  /* Disable slave address */
3552  if (FALSE == bEnable)
3553  {
3554  stcISBA.SAEN = FALSE;
3555  stcISBA.SA = 0;
3556  }
3557  /* Enable I2C interface */
3558  else
3559  {
3560  stcISBA.SAEN = TRUE;
3561  /* Set slave address */
3562  stcISBA.SA = u8SlvAdr & MFS_ISBA_SLV_ADDR;
3563  }
3564 
3565  /* Set to ISBA register */
3566  pstcI2c->ISBA_f = stcISBA;
3567 
3568  enResult = Ok;
3569 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3570  }
3571 #endif
3572 
3573  return (enResult);
3574 } /* Mfs_I2c_SetSlvAddrEnable */
3575 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3576 
3577 #if (PDL_MFS_USE_HL == PDL_OFF)
3578 
3595  uint32_t u32BaudRate
3596  )
3597 {
3598  en_result_t enResult;
3599  uint32_t u32ReloadValue;
3600 
3601 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3602  /* Parameter check and get ptr to internal data struct */
3603  if (NULL == MfsGetInternDataPtr(pstcI2c))
3604  {
3605  enResult = ErrorInvalidParameter;
3606  }
3607  else
3608  {
3609 #endif
3610  enResult = Ok;
3611  /* Get reload value */
3612  u32ReloadValue = Mfs_I2c_GetReloadValue(u32BaudRate);
3613  /* For asynchronous communication, the reload value must be greater than 0 */
3614  /* because reload counter is stop */
3615  if (0u == u32ReloadValue)
3616  {
3617  enResult = ErrorUninitialized;
3618  }
3619 
3620  /* Set baud rate generation reload register */
3621  pstcI2c->BGR = (uint16_t)(u32ReloadValue & MFS_BGR_MASK);
3622 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3623  }
3624 #endif
3625 
3626  return (enResult);
3627 } /* Mfs_I2c_SetBaudRate */
3628 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3629 
3630 #if (PDL_MFS_USE_HL == PDL_OFF)
3631 
3649  const stc_mfs_lin_config_t* pstcConfig
3650  )
3651 {
3652  /* Preset local register variables to zero */
3653  stc_mfs_smr_field_t stcSMR = { 0 };
3654  stc_mfs_scr_field_t stcSCR = { 0 };
3655  stc_mfs_escr_field_t stcESCR = { 0 };
3656 
3657  /* Parameter check and get ptr to internal data struct */
3658  if ((NULL == MfsGetInternDataPtr(pstcLin))
3659  || (NULL == pstcConfig)
3660  )
3661  {
3662  return (ErrorInvalidParameter);
3663  }
3664 
3665  /* First of all set MFS to Asynchronous mode 0 */
3666  pstcLin->SMR = 0u;
3667 
3668  /* Then we disable TX and RX for safe operation */
3669  pstcLin->SCR = 0u;
3670 
3671  /* Clear MFS by setting the Software Reset bit */
3672  pstcLin->SCR_f.UPCL = TRUE;
3673 
3674  /* Set LIN mode to HW and preset variable */
3675  stcSMR.MD = MFS_MD_LIN;
3676 
3677  /* Enable serial output */
3678  stcSMR.SOE = TRUE;
3679 
3680  /* Operation Mode Selection */
3681  switch (pstcConfig->u8LinMode)
3682  {
3683  /* Master */
3684  case MfsLinMaster:
3685  stcSCR.MS = FALSE;
3686  break;
3687  /* Slave */
3688  case MfsLinSlave:
3689  stcSCR.MS = TRUE;
3690  break;
3691  default:
3692  return (ErrorInvalidParameter);
3693  }
3694 
3695  /* Set LIN master configuration */
3696  if (MfsLinMaster == pstcConfig->u8LinMode)
3697  {
3698  /* Stop bits configration */
3699  switch (pstcConfig->u8StopBits)
3700  {
3701  case MfsLinOneStopBit:
3702  stcSMR.SBL = FALSE;
3703  stcESCR.ESBL = FALSE;
3704  break;
3705  case MfsLinTwoStopBits:
3706  stcSMR.SBL = TRUE;
3707  stcESCR.ESBL = FALSE;
3708  break;
3709  case MfsLinThreeStopBits:
3710  stcSMR.SBL = FALSE;
3711  stcESCR.ESBL = TRUE;
3712  break;
3713  case MfsLinFourStopBits:
3714  stcSMR.SBL = TRUE;
3715  stcESCR.ESBL = TRUE;
3716  break;
3717  default:
3718  return (ErrorInvalidParameter);
3719  }
3720  /* Break length configration */
3721  switch (pstcConfig->u8BreakLength)
3722  {
3723  case MfsLinBreakLength13:
3724  stcESCR.LBL = MFS_LIN_BREAK_13BITS;
3725  break;
3726  case MfsLinBreakLength14:
3727  stcESCR.LBL = MFS_LIN_BREAK_14BITS;
3728  break;
3729  case MfsLinBreakLength15:
3730  stcESCR.LBL = MFS_LIN_BREAK_15BITS;
3731  break;
3732  case MfsLinBreakLength16:
3733  stcESCR.LBL = MFS_LIN_BREAK_16BITS;
3734  break;
3735  default:
3736  return (ErrorInvalidParameter);
3737  }
3738  /* Delimiter length configration */
3739  switch (pstcConfig->u8DelimiterLength)
3740  {
3742  stcESCR.DEL = MFS_LIN_DELIMITER_1BIT;
3743  break;
3745  stcESCR.DEL = MFS_LIN_DELIMITER_2BITS;
3746  break;
3748  stcESCR.DEL = MFS_LIN_DELIMITER_3BITS;
3749  break;
3751  stcESCR.DEL = MFS_LIN_DELIMITER_4BITS;
3752  break;
3753  default:
3754  return (ErrorInvalidParameter);
3755  }
3756  }
3757 
3758  /* Lin break interrupt */
3759  if (TRUE == pstcConfig->bLinBreakIrqEnable)
3760  {
3761  stcESCR.LBIE = TRUE;
3762  }
3763  else
3764  {
3765  stcESCR.LBIE = FALSE;
3766  }
3767 
3768  /* Clear MFS by setting the Software Reset bit */
3769  pstcLin->SCR_f.UPCL = TRUE;
3770 
3771  /* Set Baudrate */
3772  (void)Mfs_Lin_SetBaudRate(pstcLin, pstcConfig->u32DataRate);
3773 
3774  /* Set registers value */
3775  pstcLin->SMR_f = stcSMR;
3776  pstcLin->SCR_f = stcSCR;
3777  pstcLin->ESCR_f = stcESCR;
3778 
3779  return (Ok);
3780 } /* Mfs_Lin_Init */
3781 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3782 
3783 #if (PDL_MFS_USE_HL == PDL_OFF)
3784 
3800 {
3801  en_result_t enResult;
3802 
3803  enResult = Mfs_Uart_DeInit(pstcLin);
3804 
3805  return (enResult);
3806 } /* Mfs_Lin_DeInit */
3807 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3808 
3809 #if (PDL_MFS_USE_HL == PDL_OFF)
3810 
3830 {
3831  en_result_t enResult;
3832 
3833 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3834  /* Parameter check and get ptr to internal data struct */
3835  if (NULL == MfsGetInternDataPtr(pstcLin))
3836  {
3837  enResult = ErrorInvalidParameter;
3838  }
3839  else
3840  {
3841 #endif
3842  /* Generate LIN break with configured length and delimiter */
3843  pstcLin->SCR_f.LBR = TRUE;
3844 
3845  enResult = Ok;
3846 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3847  }
3848 #endif
3849 
3850  return (enResult);
3851 } /* Mfs_Lin_SetBreak */
3852 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3853 
3854 #if (PDL_MFS_USE_HL == PDL_OFF)
3855 
3869 {
3870  en_result_t enResult;
3871 
3872 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3873  /* Parameter check and get ptr to internal data struct */
3874  if (NULL == MfsGetInternDataPtr(pstcLin))
3875  {
3876  enResult = ErrorInvalidParameter;
3877  }
3878  else
3879  {
3880 #endif
3881  pstcLin->SSR_f.LBD = FALSE;
3882 
3883  enResult = Ok;
3884 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3885  }
3886 #endif
3887 
3888  return (enResult);
3889 } /* Mfs_Lin_ClearBrkFieldDetFlg */
3890 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3891 
3892 #if (PDL_MFS_USE_HL == PDL_OFF)
3893 
3910  boolean_t bEnable
3911  )
3912 {
3913  en_result_t enResult;
3914 
3915 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3916  /* Parameter check and get ptr to internal data struct */
3917  if (NULL == MfsGetInternDataPtr(pstcLin))
3918  {
3919  enResult = ErrorInvalidParameter;
3920  }
3921  else
3922  {
3923 #endif
3924  /* Disable LIN Break field detection interrupt */
3925  if (FALSE == bEnable)
3926  {
3927  pstcLin->ESCR_f.LBIE = FALSE;
3928  }
3929  /* Enable LIN Break field detection interrupt */
3930  else
3931  {
3932  pstcLin->ESCR_f.LBIE = TRUE;
3933  }
3934 
3935  enResult = Ok;
3936 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3937  }
3938 #endif
3939 
3940  return (enResult);
3941 } /* Mfs_Lin_SetBreakDetIntEnable */
3942 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
3943 
3944 #if (PDL_MFS_USE_HL == PDL_OFF)
3945 
3964  uint8_t u8BreakLen,
3965  uint8_t u8DelimiterLen
3966  )
3967 {
3968  stc_mfs_escr_field_t stcESCR;
3969  en_result_t enResult;
3970 
3971 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
3972  /* Parameter check and get ptr to internal data struct */
3973  if (NULL == MfsGetInternDataPtr(pstcLin))
3974  {
3975  enResult = ErrorInvalidParameter;
3976  }
3977  else
3978  {
3979 #endif
3980  enResult = Ok;
3981 
3982  stcESCR = pstcLin->ESCR_f;
3983 
3984  /* Break length configration */
3985  switch (u8BreakLen)
3986  {
3987  case MfsLinBreakLength13:
3988  stcESCR.LBL = MFS_LIN_BREAK_13BITS;
3989  break;
3990  case MfsLinBreakLength14:
3991  stcESCR.LBL = MFS_LIN_BREAK_14BITS;
3992  break;
3993  case MfsLinBreakLength15:
3994  stcESCR.LBL = MFS_LIN_BREAK_15BITS;
3995  break;
3996  case MfsLinBreakLength16:
3997  stcESCR.LBL = MFS_LIN_BREAK_16BITS;
3998  break;
3999  default:
4000  enResult = ErrorInvalidParameter;
4001  break;
4002  }
4003  /* Delimiter length configration */
4004  switch (u8DelimiterLen)
4005  {
4007  stcESCR.DEL = MFS_LIN_DELIMITER_1BIT;
4008  break;
4010  stcESCR.DEL = MFS_LIN_DELIMITER_2BITS;
4011  break;
4013  stcESCR.DEL = MFS_LIN_DELIMITER_3BITS;
4014  break;
4016  stcESCR.DEL = MFS_LIN_DELIMITER_4BITS;
4017  break;
4018  default:
4019  enResult = ErrorInvalidParameter;
4020  break;
4021  }
4022 
4023  if (Ok == enResult)
4024  {
4025  pstcLin->ESCR_f = stcESCR;
4026  }
4027 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4028  }
4029 #endif
4030 
4031  return (enResult);
4032 } /* Mfs_Lin_SetBreakConfig */
4033 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4034 
4035 #if (PDL_MFS_USE_HL == PDL_OFF)
4036 
4053  uint32_t u32BaudRate
4054  )
4055 {
4056  /* Same as Mfs_Csio_SetBaudRate() */
4057  return (Mfs_Csio_SetBaudRate(pstcLin, u32BaudRate));
4058 } /* Mfs_Lin_SetBaudRate */
4059 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4060 
4061 #if (PDL_MFS_USE_HL == PDL_OFF)
4062 
4079  boolean_t bEnable
4080  )
4081 {
4082  en_result_t enResult;
4083 
4084 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4085  /* Parameter check and get ptr to internal data struct */
4086  if (NULL == MfsGetInternDataPtr(pstcMfs))
4087  {
4088  enResult = ErrorInvalidParameter;
4089  }
4090  else
4091  {
4092 #endif
4093  /* Disable Serial Output */
4094  if (FALSE == bEnable)
4095  {
4096  pstcMfs->SMR_f.SOE = FALSE;
4097  }
4098  /* Enable Serial Output */
4099  else
4100  {
4101  pstcMfs->SMR_f.SOE = TRUE;
4102  }
4103 
4104  enResult = Ok;
4105 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4106  }
4107 #endif
4108 
4109  return (enResult);
4110 } /* Mfs_EnableSerialOutput */
4111 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4112 
4113 #if (PDL_MFS_USE_HL == PDL_OFF)
4114 
4131  boolean_t bEnable
4132  )
4133 {
4134  en_result_t enResult;
4135 
4136 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4137  /* Parameter check and get ptr to internal data struct */
4138  if (NULL == MfsGetInternDataPtr(pstcMfs))
4139  {
4140  enResult = ErrorInvalidParameter;
4141  }
4142  else
4143  {
4144 #endif
4145  /* Disable wake up control */
4146  if (FALSE == bEnable)
4147  {
4148  pstcMfs->SMR_f.WUCR = FALSE;
4149  }
4150  /* Enable wake up control */
4151  else
4152  {
4153  pstcMfs->SMR_f.WUCR = TRUE;
4154  }
4155 
4156  enResult = Ok;
4157 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4158  }
4159 #endif
4160 
4161  return (enResult);
4162 } /* Mfs_SetWakeUpControlEnable */
4163 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4164 
4165 #if (PDL_MFS_USE_HL == PDL_OFF)
4166 
4181 {
4182  en_result_t enResult;
4183 
4184 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4185  /* Parameter check and get ptr to internal data struct */
4186  if (NULL == MfsGetInternDataPtr(pstcMfs))
4187  {
4188  enResult = ErrorInvalidParameter;
4189  }
4190  else
4191  {
4192 #endif
4193  /* Initializes the UART internal state (Software Reset) */
4194  pstcMfs->SCR_f.UPCL = TRUE;
4195 
4196  enResult = Ok;
4197 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4198  }
4199 #endif
4200 
4201  return (enResult);
4202 } /* Mfs_SoftwareReset */
4203 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4204 
4205 #if (PDL_MFS_USE_HL == PDL_OFF)
4206 
4223  boolean_t bEnable
4224  )
4225 {
4226  en_result_t enResult;
4227 
4228 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4229  /* Parameter check and get ptr to internal data struct */
4230  if (NULL == MfsGetInternDataPtr(pstcMfs))
4231  {
4232  enResult = ErrorInvalidParameter;
4233  }
4234  else
4235  {
4236 #endif
4237  /* Disable RX interrupt */
4238  if (FALSE == bEnable)
4239  {
4240  pstcMfs->SCR_f.RIE = FALSE;
4241  }
4242  /* Enable RX interrupt */
4243  else
4244  {
4245  pstcMfs->SCR_f.RIE = TRUE;
4246  }
4247 
4248  enResult = Ok;
4249 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4250  }
4251 #endif
4252 
4253  return (enResult);
4254 } /* Mfs_SetRxIntEnable */
4255 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4256 
4257 #if (PDL_MFS_USE_HL == PDL_OFF)
4258 
4275  boolean_t bEnable
4276  )
4277 {
4278  en_result_t enResult;
4279 
4280 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4281  /* Parameter check and get ptr to internal data struct */
4282  if (NULL == MfsGetInternDataPtr(pstcMfs))
4283  {
4284  enResult = ErrorInvalidParameter;
4285  }
4286  else
4287  {
4288 #endif
4289  /* Disable TX interrupt */
4290  if (FALSE == bEnable)
4291  {
4292  pstcMfs->SCR_f.TIE = FALSE;
4293  }
4294  /* Enable TX interrupt */
4295  else
4296  {
4297  pstcMfs->SCR_f.TIE = TRUE;
4298  }
4299 
4300  enResult = Ok;
4301 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4302  }
4303 #endif
4304 
4305  return (enResult);
4306 } /* Mfs_SetTxIntEnable */
4307 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4308 
4309 #if (PDL_MFS_USE_HL == PDL_OFF)
4310 
4327  boolean_t bEnable
4328  )
4329 {
4330  en_result_t enResult;
4331 
4332 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4333  /* Parameter check and get ptr to internal data struct */
4334  if (NULL == MfsGetInternDataPtr(pstcMfs))
4335  {
4336  enResult = ErrorInvalidParameter;
4337  }
4338  else
4339  {
4340 #endif
4341  /* Disable TX bus ield interrupt */
4342  if (FALSE == bEnable)
4343  {
4344  pstcMfs->SCR_f.TBIE = FALSE;
4345  }
4346  /* Enable TX bus ield interrupt */
4347  else
4348  {
4349  pstcMfs->SCR_f.TBIE = TRUE;
4350  }
4351 
4352  enResult = Ok;
4353 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4354  }
4355 #endif
4356 
4357  return (enResult);
4358 } /* Mfs_SetTxBusIdleIntEnable */
4359 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4360 
4361 #if (PDL_MFS_USE_HL == PDL_OFF)
4362 
4379  boolean_t bEnable
4380  )
4381 {
4382  en_result_t enResult;
4383 
4384 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4385  /* Parameter check and get ptr to internal data struct */
4386  if (NULL == MfsGetInternDataPtr(pstcMfs))
4387  {
4388  enResult = ErrorInvalidParameter;
4389  }
4390  else
4391  {
4392 #endif
4393  /* Disable TX FIFO interrupt */
4394  if (FALSE == bEnable)
4395  {
4396  pstcMfs->FCR1_f.FTIE = FALSE;
4397  }
4398  /* Enable TX FIFO interrupt */
4399  else
4400  {
4401  pstcMfs->FCR1_f.FTIE = TRUE;
4402  }
4403 
4404  enResult = Ok;
4405 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4406  }
4407 #endif
4408 
4409  return (enResult);
4410 } /* Mfs_SetTxFifoIntEnable */
4411 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4412 
4413 #if (PDL_MFS_USE_HL == PDL_OFF)
4414 
4431  boolean_t bEnable
4432  )
4433 {
4434  en_result_t enResult;
4435 
4436 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4437  /* Parameter check and get ptr to internal data struct */
4438  if (NULL == MfsGetInternDataPtr(pstcMfs))
4439  {
4440  enResult = ErrorInvalidParameter;
4441  }
4442  else
4443  {
4444 #endif
4445  /* Disable RX */
4446  if (FALSE == bEnable)
4447  {
4448  pstcMfs->SCR_f.RXE = FALSE;
4449  }
4450  /* Enable RX */
4451  else
4452  {
4453  pstcMfs->SCR_f.RXE = TRUE;
4454  }
4455 
4456  enResult = Ok;
4457 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4458  }
4459 #endif
4460 
4461  return (enResult);
4462 } /* Mfs_SetRxEnable */
4463 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4464 
4465 #if (PDL_MFS_USE_HL == PDL_OFF)
4466 
4483  boolean_t bEnable
4484  )
4485 {
4486  en_result_t enResult;
4487 
4488 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4489  /* Parameter check and get ptr to internal data struct */
4490  if (NULL == MfsGetInternDataPtr(pstcMfs))
4491  {
4492  enResult = ErrorInvalidParameter;
4493  }
4494  else
4495  {
4496 #endif
4497  /* Disable TX */
4498  if (FALSE == bEnable)
4499  {
4500  pstcMfs->SCR_f.TXE = FALSE;
4501  }
4502  /* Enable TX */
4503  else
4504  {
4505  pstcMfs->SCR_f.TXE = TRUE;
4506  }
4507 
4508  enResult = Ok;
4509 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4510  }
4511 #endif
4512 
4513  return (enResult);
4514 } /* Mfs_SetTxEnable */
4515 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4516 
4517 #if (PDL_MFS_USE_HL == PDL_OFF)
4518 
4529 uint8_t Mfs_GetStatus(volatile stc_mfsn_t* pstcMfs,
4530  uint8_t u8StatusMask
4531  )
4532 {
4533  uint8_t u8Status;
4534 
4535 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4536  /* Parameter check and get ptr to internal data struct */
4537  if (NULL == MfsGetInternDataPtr(pstcMfs))
4538  {
4539  u8Status = 0u;
4540  }
4541  else
4542  {
4543 #endif
4544  /* Return masked SSR value */
4545  u8Status = pstcMfs->SSR & u8StatusMask;
4546 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4547  }
4548 #endif
4549 
4550  return (u8Status);
4551 } /* Mfs_GetStatus */
4552 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4553 
4554 #if (PDL_MFS_USE_HL == PDL_OFF)
4555 
4570 {
4571  en_result_t enResult;
4572 
4573 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4574  /* Parameter check and get ptr to internal data struct */
4575  if (NULL == MfsGetInternDataPtr(pstcMfs))
4576  {
4577  enResult = ErrorInvalidParameter;
4578  }
4579  else
4580  {
4581 #endif
4582  pstcMfs->SSR_f.REC = TRUE;
4583 
4584  enResult = Ok;
4585 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4586  }
4587 #endif
4588 
4589  return (enResult);
4590 } /* Mfs_ErrorClear */
4591 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4592 
4593 #if (PDL_MFS_USE_HL == PDL_OFF)
4594 
4609 uint16_t Mfs_ReadData(volatile stc_mfsn_t* pstcMfs)
4610 {
4611  uint16_t u16ReadData;
4612 
4613 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4614  /* Parameter check and get ptr to internal data struct */
4615  if (NULL == MfsGetInternDataPtr(pstcMfs))
4616  {
4617  u16ReadData = 0u;
4618  }
4619  else
4620  {
4621 #endif
4622  /* Return the value of Received Data Register (RDR) */
4623  u16ReadData = pstcMfs->RDR;
4624 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4625  }
4626 #endif
4627 
4628  return (u16ReadData);
4629 } /* Mfs_ReadData */
4630 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4631 
4632 #if (PDL_MFS_USE_HL == PDL_OFF)
4633 
4655  const uint16_t u16Data
4656  )
4657 {
4658  en_result_t enResult;
4659 
4660 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4661  /* Parameter check and get ptr to internal data struct */
4662  if (NULL == MfsGetInternDataPtr(pstcMfs))
4663  {
4664  enResult = ErrorInvalidParameter;
4665  }
4666  else
4667  {
4668 #endif
4669  /* Put data to Transmit Data Register (TDR) */
4670  pstcMfs->TDR = u16Data;
4671 
4672  enResult = Ok;
4673 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4674  }
4675 #endif
4676 
4677  return (enResult);
4678 } /* Mfs_WriteData */
4679 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4680 
4681 #if (PDL_MFS_USE_HL == PDL_OFF)
4682 
4701  stc_mfs_fifo_config_t* pstcFifoConfig
4702  )
4703 {
4704  en_result_t enResult;
4705 
4706 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4707  /* Parameter check and get ptr to internal data struct */
4708  if ((NULL == MfsGetInternDataPtr(pstcMfs))
4709  || (NULL == pstcFifoConfig)
4710  )
4711  {
4712  enResult = ErrorInvalidParameter;
4713  }
4714  else
4715  {
4716 #endif
4717  enResult = Ok;
4718 
4719  /* Set FSEL */
4720  switch (pstcFifoConfig->u8FifoSel)
4721  {
4722  case MfsTxFifo1RxFifo2:
4723  pstcMfs->FCR1_f.FSEL = FALSE;
4724  break;
4725  case MfsTxFifo2RxFifo1:
4726  pstcMfs->FCR1_f.FSEL = TRUE;
4727  break;
4728  default:
4729  enResult = ErrorInvalidParameter;
4730  break;
4731  }
4732 
4733  if (Ok == enResult)
4734  {
4735  /* Set FBYTE */
4736  pstcMfs->FBYTE1 = pstcFifoConfig->u8ByteCount1;
4737  pstcMfs->FBYTE2 = pstcFifoConfig->u8ByteCount2;
4738  }
4739 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4740  }
4741 #endif
4742 
4743  return (enResult);
4744 } /* Mfs_ConfigFifo */
4745 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4746 
4747 #if (PDL_MFS_USE_HL == PDL_OFF)
4748 
4764 {
4765  boolean_t bStatus = FALSE;
4766 
4767 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4768  /* Parameter check and get ptr to internal data struct */
4769  if (NULL != MfsGetInternDataPtr(pstcMfs))
4770  {
4771 #endif
4772  /* Return the TX FIFO request status */
4773  if(TRUE == pstcMfs->FCR1_f.FDRQ)
4774  {
4775  bStatus = TRUE;
4776  }
4777 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4778  }
4779 #endif
4780 
4781  return (bStatus);
4782 } /* Mfs_GetTxFifoReqStatus */
4783 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4784 
4785 #if (PDL_MFS_USE_HL == PDL_OFF)
4786 
4801 {
4802  en_result_t enResult;
4803 
4804 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4805  /* Parameter check and get ptr to internal data struct */
4806  if (NULL == MfsGetInternDataPtr(pstcMfs))
4807  {
4808  enResult = ErrorInvalidParameter;
4809  }
4810  else
4811  {
4812 #endif
4813  /* Clear the TX FIFO request status */
4814  pstcMfs->FCR1_f.FDRQ = FALSE;
4815 
4816  enResult = Ok;
4817 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4818  }
4819 #endif
4820 
4821  return (enResult);
4822 } /* Mfs_ClrTxFifoReqStatus */
4823 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4824 
4825 #if (PDL_MFS_USE_HL == PDL_OFF)
4826 
4843  uint8_t u8FifoNumber
4844  )
4845 {
4846  en_result_t enResult;
4847 
4848 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4849  /* Parameter check and get ptr to internal data struct */
4850  if (NULL == MfsGetInternDataPtr(pstcMfs))
4851  {
4852  enResult = ErrorInvalidParameter;
4853  }
4854  else
4855  {
4856 #endif
4857  enResult = Ok;
4858 
4859  /* Reset FIFO */
4860  switch (u8FifoNumber)
4861  {
4862  case MfsFifo1:
4863  pstcMfs->FCR0_f.FCL1 = TRUE;
4864  break;
4865  case MfsFifo2:
4866  pstcMfs->FCR0_f.FCL2 = TRUE;
4867  break;
4868  default:
4869  enResult = ErrorInvalidParameter;
4870  break;
4871  }
4872 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4873  }
4874 #endif
4875 
4876  return (enResult);
4877 } /* Mfs_ResetFifo */
4878 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4879 
4880 #if (PDL_MFS_USE_HL == PDL_OFF)
4881 
4900  uint8_t u8FifoNumber,
4901  boolean_t bEnable
4902  )
4903 {
4904  en_result_t enResult;
4905 
4906 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4907  /* Parameter check and get ptr to internal data struct */
4908  if (NULL == MfsGetInternDataPtr(pstcMfs))
4909  {
4910  enResult = ErrorInvalidParameter;
4911  }
4912  else
4913  {
4914 #endif
4915  enResult = Ok;
4916 
4917  switch (u8FifoNumber)
4918  {
4919  case MfsFifo1:
4920  /* Disable FIFO */
4921  if (FALSE == bEnable)
4922  {
4923  pstcMfs->FCR0_f.FE1 = FALSE;
4924  }
4925  /* Enable FIFO */
4926  else
4927  {
4928  pstcMfs->FCR0_f.FE1 = TRUE;
4929  }
4930  break;
4931  case MfsFifo2:
4932  /* Disable FIFO */
4933  if (FALSE == bEnable)
4934  {
4935  pstcMfs->FCR0_f.FE2 = FALSE;
4936  }
4937  /* Enable FIFO */
4938  else
4939  {
4940  pstcMfs->FCR0_f.FE2 = TRUE;
4941  }
4942  break;
4943  default:
4944  enResult = ErrorInvalidParameter;
4945  break;
4946  }
4947 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4948  }
4949 #endif
4950 
4951  return (enResult);
4952 } /* Mfs_SetFifoEnable */
4953 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
4954 
4955 #if (PDL_MFS_USE_HL == PDL_OFF)
4956 
4968 uint8_t Mfs_GetFifoBytes(volatile stc_mfsn_t* pstcMfs,
4969  uint8_t u8FifoNumber
4970  )
4971 {
4972  uint8_t u8FifoBytes;
4973 
4974 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4975  /* Parameter check and get ptr to internal data struct */
4976  if (NULL == MfsGetInternDataPtr(pstcMfs))
4977  {
4978  u8FifoBytes = 0u;
4979  }
4980  else
4981  {
4982 #endif
4983 
4984  /* Get FIFO counter */
4985  switch (u8FifoNumber)
4986  {
4987  case MfsFifo1:
4988  u8FifoBytes = pstcMfs->FBYTE1;
4989  break;
4990  case MfsFifo2:
4991  u8FifoBytes = pstcMfs->FBYTE2;
4992  break;
4993  default:
4994  u8FifoBytes = 0u;
4995  break;
4996  }
4997 
4998 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
4999  }
5000 #endif
5001 
5002  return(u8FifoBytes);
5003 } /* Mfs_GetFifoBytes */
5004 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5005 
5014 uint32_t Mfs_GetBusClock(void)
5015 {
5016  uint32_t u32BusClock;
5017 
5018  /* Get Master Clock */
5019  switch (FM4_CRG->SCM_CTL >> MFS_NUM_5)
5020  {
5021  case MFS_MASTER_CLK_HCR:
5022  u32BusClock = __CLKHC;
5023  break;
5024  case MFS_MASTER_CLK_MAIN:
5025  u32BusClock = __CLKMO;
5026  break;
5027  case MFS_MASTER_CLK_PLL:
5028  u32BusClock = (__CLKMO * (((uint32_t)(FM4_CRG->PLL_CTL2) & MFS_PLL_CTL2_MASK) + MFS_NUM_1));
5029  u32BusClock /= ((((uint32_t)(FM4_CRG->PLL_CTL1) >> MFS_NUM_4) & MFS_PLL_CTL1_MASK) + MFS_NUM_1);
5030  break;
5031  case MFS_MASTER_CLK_LCR:
5032  u32BusClock = __CLKLC;
5033  break;
5034  case MFS_MASTER_CLK_SUB:
5035  u32BusClock = __CLKSO;
5036  break;
5037  default:
5038  u32BusClock = 0;
5039  break;
5040  }
5041 
5042  /* Get Core Clock */
5043  switch (FM4_CRG->BSC_PSR & MFS_NUM_7)
5044  {
5045  case MFS_BASE_CLK_DIV1:
5046  u32BusClock /= MFS_NUM_1;
5047  break;
5048  case MFS_BASE_CLK_DIV2:
5049  u32BusClock /= MFS_NUM_2;
5050  break;
5051  case MFS_BASE_CLK_DIV3:
5052  u32BusClock /= MFS_NUM_3;
5053  break;
5054  case MFS_BASE_CLK_DIV4:
5055  u32BusClock /= MFS_NUM_4;
5056  break;
5057  case MFS_BASE_CLK_DIV6:
5058  u32BusClock /= MFS_NUM_6;
5059  break;
5060  case MFS_BASE_CLK_DIV8:
5061  u32BusClock /= MFS_NUM_8;
5062  break;
5063  case MFS_BASE_CLK_DIV16:
5064  u32BusClock /= MFS_NUM_16;
5065  break;
5066  default:
5067  u32BusClock = 0;
5068  break;
5069  }
5070 
5071  /* Get Clock Frequency for PCLK2 */
5072  switch (FM4_CRG->APBC2_PSR & MFS_NUM_3)
5073  {
5074  case MfsClkDiv0:
5075  u32BusClock /= MFS_NUM_1;
5076  break;
5077  case MfsClkDiv1:
5078  u32BusClock /= MFS_NUM_2;
5079  break;
5080  case MfsClkDiv2:
5081  u32BusClock /= MFS_NUM_4;
5082  break;
5083  case MfsClkDiv3:
5084  u32BusClock /= MFS_NUM_8;
5085  break;
5086  default:
5087  u32BusClock /= MFS_NUM_1;
5088  }
5089 
5090  return (u32BusClock);
5091 } /* Mfs_GetBusClock */
5092 
5105 uint32_t Mfs_GetReloadValue(uint32_t u32BaudRate)
5106 {
5107  uint32_t u32ReloadValue;
5108 
5109  /* Check if data rate is 0 (div by zero not wanted) */
5110  if (0u == u32BaudRate)
5111  {
5112  u32ReloadValue = 0u;
5113  }
5114  else
5115  {
5116  /* Get Clock Frequency for PCLK2 */
5117  u32ReloadValue = Mfs_GetBusClock();
5118  /* Calc reload value based on data rate set */
5119  u32ReloadValue /= u32BaudRate;
5120  u32ReloadValue -= MFS_NUM_1;
5121  }
5122 
5123  return (u32ReloadValue);
5124 } /* Mfs_GetReloadValue */
5125 
5136 uint32_t Mfs_I2c_GetReloadValue(uint32_t u32BaudRate)
5137 {
5138  uint32_t u32ReloadValue;
5139 
5140  /* Check if data rate is 0 (div by zero not wanted) */
5141  if (0u == u32BaudRate)
5142  {
5143  u32ReloadValue = 0u;
5144  }
5145  else
5146  {
5147  /* Get Clock Frequency for PCLK2 */
5148  u32ReloadValue = Mfs_GetBusClock();
5149  /* Calc reload value based on data rate set */
5150  u32ReloadValue /= u32BaudRate;
5151  u32ReloadValue -= MFS_NUM_3;
5152  }
5153 
5154  return (u32ReloadValue);
5155 } /* Mfs_I2c_GetReloadValue */
5156 
5157 #if (PDL_MFS_USE_HL == PDL_OFF)
5158 
5174  uint8_t u8SMR
5175  )
5176 {
5177  en_result_t enResult;
5178 
5179 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5180  /* Parameter check and get ptr to internal data struct */
5181  if (NULL == MfsGetInternDataPtr(pstcMfs))
5182  {
5183  enResult = ErrorInvalidParameter;
5184  }
5185  else
5186  {
5187 #endif
5188  /* Set the value to Serial Mode Register */
5189  pstcMfs->SMR = u8SMR;
5190 
5191  enResult = Ok;
5192 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5193  }
5194 #endif
5195 
5196  return (enResult);
5197 } /* Mfs_SetSMR */
5198 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5199 
5200 #if (PDL_MFS_USE_HL == PDL_OFF)
5201 
5211 uint8_t Mfs_GetSMR(volatile stc_mfsn_t* pstcMfs)
5212 {
5213  uint8_t u8Reg;
5214 
5215 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5216  /* Parameter check and get ptr to internal data struct */
5217  if (NULL == MfsGetInternDataPtr(pstcMfs))
5218  {
5219  u8Reg = 0u;
5220  }
5221  else
5222  {
5223 #endif
5224  /* Return the value of Serial Mode Register */
5225  u8Reg = pstcMfs->SMR;
5226 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5227  }
5228 #endif
5229 
5230  return (u8Reg);
5231 } /* Mfs_GetSMR */
5232 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5233 
5234 #if (PDL_MFS_USE_HL == PDL_OFF)
5235 
5251  uint8_t u8SCR
5252  )
5253 {
5254  en_result_t enResult;
5255 
5256 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5257  /* Parameter check and get ptr to internal data struct */
5258  if (NULL == MfsGetInternDataPtr(pstcMfs))
5259  {
5260  enResult = ErrorInvalidParameter;
5261  }
5262  else
5263  {
5264 #endif
5265  /* Set the value to Serial Control Register */
5266  pstcMfs->SCR = u8SCR;
5267 
5268  enResult = Ok;
5269 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5270  }
5271 #endif
5272 
5273  return (enResult);
5274 } /* Mfs_SetSCR */
5275 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5276 
5277 #if (PDL_MFS_USE_HL == PDL_OFF)
5278 
5288 uint8_t Mfs_GetSCR(volatile stc_mfsn_t* pstcMfs)
5289 {
5290  uint8_t u8Reg;
5291 
5292 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5293  /* Parameter check and get ptr to internal data struct */
5294  if (NULL == MfsGetInternDataPtr(pstcMfs))
5295  {
5296  u8Reg = 0u;
5297  }
5298  else
5299  {
5300 #endif
5301  /* Return the value of Serial Control Register */
5302  u8Reg = pstcMfs->SCR;
5303 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5304  }
5305 #endif
5306 
5307  return (u8Reg);
5308 } /* Mfs_GetSCR */
5309 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5310 
5311 #if (PDL_MFS_USE_HL == PDL_OFF)
5312 
5328  uint8_t u8ESCR
5329  )
5330 {
5331  en_result_t enResult;
5332 
5333 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5334  /* Parameter check and get ptr to internal data struct */
5335  if (NULL == MfsGetInternDataPtr(pstcMfs))
5336  {
5337  enResult = ErrorInvalidParameter;
5338  }
5339  else
5340  {
5341 #endif
5342  /* Set the value to Extended Serial Control Register */
5343  pstcMfs->ESCR = u8ESCR;
5344 
5345  enResult = Ok;
5346 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5347  }
5348 #endif
5349 
5350  return (enResult);
5351 } /* Mfs_SetESCR */
5352 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5353 
5354 #if (PDL_MFS_USE_HL == PDL_OFF)
5355 
5365 uint8_t Mfs_GetESCR(volatile stc_mfsn_t* pstcMfs)
5366 {
5367  uint8_t u8Reg;
5368 
5369 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5370  /* Parameter check and get ptr to internal data struct */
5371  if (NULL == MfsGetInternDataPtr(pstcMfs))
5372  {
5373  u8Reg = 0u;
5374  }
5375  else
5376  {
5377 #endif
5378  /* Return the value of Extended Serial Control Register */
5379  u8Reg = pstcMfs->ESCR;
5380 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5381  }
5382 #endif
5383 
5384  return (u8Reg);
5385 } /* Mfs_GetESCR */
5386 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5387 
5388 #if (PDL_MFS_USE_HL == PDL_OFF)
5389 
5405  uint16_t u16BGR
5406  )
5407 {
5408  en_result_t enResult;
5409 
5410 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5411  /* Parameter check and get ptr to internal data struct */
5412  if (NULL == MfsGetInternDataPtr(pstcMfs))
5413  {
5414  enResult = ErrorInvalidParameter;
5415  }
5416  else
5417  {
5418 #endif
5419  /* Set the value to Baudrate Generate Register */
5420  pstcMfs->BGR = u16BGR;
5421 
5422  enResult = Ok;
5423 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5424  }
5425 #endif
5426 
5427  return (enResult);
5428 } /* Mfs_SetBGR */
5429 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5430 
5431 #if (PDL_MFS_USE_HL == PDL_OFF)
5432 
5442 uint16_t Mfs_GetBGR(volatile stc_mfsn_t* pstcMfs)
5443 {
5444  uint16_t u16Reg;
5445 
5446 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5447  /* Parameter check and get ptr to internal data struct */
5448  if (NULL == MfsGetInternDataPtr(pstcMfs))
5449  {
5450  u16Reg = 0u;
5451  }
5452  else
5453  {
5454 #endif
5455  /* Return the value of Baud rate Generate Register */
5456  u16Reg = pstcMfs->BGR;
5457 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5458  }
5459 #endif
5460 
5461  return (u16Reg);
5462 } /* Mfs_GetBGR */
5463 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5464 
5465 #if (PDL_MFS_USE_HL == PDL_OFF)
5466 
5482  uint8_t u8FCR1
5483  )
5484 {
5485  en_result_t enResult;
5486 
5487 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5488  /* Parameter check and get ptr to internal data struct */
5489  if (NULL == MfsGetInternDataPtr(pstcMfs))
5490  {
5491  enResult = ErrorInvalidParameter;
5492  }
5493  else
5494  {
5495 #endif
5496  /* Set the value to FIFO Control Register 1 */
5497  pstcMfs->FCR1 = u8FCR1;
5498 
5499  enResult = Ok;
5500 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5501  }
5502 #endif
5503 
5504  return (enResult);
5505 } /* Mfs_SetFCR1 */
5506 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5507 
5508 #if (PDL_MFS_USE_HL == PDL_OFF)
5509 
5519 uint8_t Mfs_GetFCR1(volatile stc_mfsn_t* pstcMfs)
5520 {
5521  uint8_t u8Reg;
5522 
5523 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5524  /* Parameter check and get ptr to internal data struct */
5525  if (NULL == MfsGetInternDataPtr(pstcMfs))
5526  {
5527  u8Reg = 0u;
5528  }
5529  else
5530  {
5531 #endif
5532  /* Return the value of FIFO Control Register 1 */
5533  u8Reg = pstcMfs->FCR1;
5534 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5535  }
5536 #endif
5537 
5538  return (u8Reg);
5539 } /* Mfs_GetFCR1 */
5540 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5541 
5542 #if (PDL_MFS_USE_HL == PDL_OFF)
5543 
5559  uint8_t u8FCR0
5560  )
5561 {
5562  en_result_t enResult;
5563 
5564 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5565  /* Parameter check and get ptr to internal data struct */
5566  if (NULL == MfsGetInternDataPtr(pstcMfs))
5567  {
5568  enResult = ErrorInvalidParameter;
5569  }
5570  else
5571  {
5572 #endif
5573  /* Set the value to FIFO Control Register 0 */
5574  pstcMfs->FCR0 = u8FCR0;
5575 
5576  enResult = Ok;
5577 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5578  }
5579 #endif
5580 
5581  return (enResult);
5582 } /* Mfs_SetFCR0 */
5583 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5584 
5585 #if (PDL_MFS_USE_HL == PDL_OFF)
5586 
5596 uint8_t Mfs_GetFCR0(volatile stc_mfsn_t* pstcMfs)
5597 {
5598  uint8_t u8Reg;
5599 
5600 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5601  /* Parameter check and get ptr to internal data struct */
5602  if (NULL == MfsGetInternDataPtr(pstcMfs))
5603  {
5604  u8Reg = 0u;
5605  }
5606  else
5607  {
5608 #endif
5609  /* Return the value of FIFO Control Register 0 */
5610  u8Reg = pstcMfs->FCR0;
5611 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5612  }
5613 #endif
5614 
5615  return (u8Reg);
5616 } /* Mfs_GetFCR1 */
5617 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5618 
5619 #if (PDL_MFS_USE_HL == PDL_OFF)
5620 
5636  uint16_t u16SCSTR10
5637  )
5638 {
5639  en_result_t enResult;
5640 
5641 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5642  /* Parameter check and get ptr to internal data struct */
5643  if (NULL == MfsGetInternDataPtr(pstcMfs))
5644  {
5645  enResult = ErrorInvalidParameter;
5646  }
5647  else
5648  {
5649 #endif
5650  /* Set the value to Serial Chip Select Timing Register 1-0 (for CSIO) */
5651  pstcMfs->SCSTR10 = u16SCSTR10;
5652 
5653  enResult = Ok;
5654 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5655  }
5656 #endif
5657 
5658  return (enResult);
5659 } /* Mfs_SetSCSTR10 */
5660 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5661 
5662 #if (PDL_MFS_USE_HL == PDL_OFF)
5663 
5673 uint16_t Mfs_GetSCSTR10(volatile stc_mfsn_t* pstcMfs)
5674 {
5675  uint16_t u16Reg;
5676 
5677 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5678  /* Parameter check and get ptr to internal data struct */
5679  if (NULL == MfsGetInternDataPtr(pstcMfs))
5680  {
5681  u16Reg = 0u;
5682  }
5683  else
5684  {
5685 #endif
5686  /* Return the value of Serial Chip Select Timing Register 1-0 (for CSIO) */
5687  u16Reg = pstcMfs->SCSTR10;
5688 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5689  }
5690 #endif
5691 
5692  return (u16Reg);
5693 } /* Mfs_GetSCSTR10 */
5694 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5695 
5696 #if (PDL_MFS_USE_HL == PDL_OFF)
5697 
5713  uint16_t u16SCSTR32
5714  )
5715 {
5716  en_result_t enResult;
5717 
5718 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5719  /* Parameter check and get ptr to internal data struct */
5720  if (NULL == MfsGetInternDataPtr(pstcMfs))
5721  {
5722  enResult = ErrorInvalidParameter;
5723  }
5724  else
5725  {
5726 #endif
5727  /* Set the value to Serial Chip Select Timing Register 3-2 (for CSIO) */
5728  pstcMfs->SCSTR32 = u16SCSTR32;
5729 
5730  enResult = Ok;
5731 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5732  }
5733 #endif
5734 
5735  return (enResult);
5736 } /* Mfs_SetSCSTR32 */
5737 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5738 
5739 #if (PDL_MFS_USE_HL == PDL_OFF)
5740 
5750 uint16_t Mfs_GetSCSTR32(volatile stc_mfsn_t* pstcMfs)
5751 {
5752  uint16_t u16Reg;
5753 
5754 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5755  /* Parameter check and get ptr to internal data struct */
5756  if (NULL == MfsGetInternDataPtr(pstcMfs))
5757  {
5758  u16Reg = 0u;
5759  }
5760  else
5761  {
5762 #endif
5763  /* Return the value of Serial Chip Select Timing Register 3-2 (for CSIO) */
5764  u16Reg = pstcMfs->SCSTR32;
5765 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5766  }
5767 #endif
5768 
5769  return (u16Reg);
5770 } /* Mfs_GetSCSTR32 */
5771 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5772 
5773 #if (PDL_MFS_USE_HL == PDL_OFF)
5774 
5790  uint16_t u16SACSR
5791  )
5792 {
5793  en_result_t enResult;
5794 
5795 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5796  /* Parameter check and get ptr to internal data struct */
5797  if (NULL == MfsGetInternDataPtr(pstcMfs))
5798  {
5799  enResult = ErrorInvalidParameter;
5800  }
5801  else
5802  {
5803 #endif
5804  /* Set the value to Serial Assistant Status Control Register (for CSIO) */
5805  pstcMfs->SACSR = u16SACSR;
5806 
5807  enResult = Ok;
5808 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5809  }
5810 #endif
5811 
5812  return (enResult);
5813 } /* Mfs_SetSACSR */
5814 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5815 
5816 #if (PDL_MFS_USE_HL == PDL_OFF)
5817 
5827 uint16_t Mfs_GetSACSR(volatile stc_mfsn_t* pstcMfs)
5828 {
5829  uint16_t u16Reg;
5830 
5831 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5832  /* Parameter check and get ptr to internal data struct */
5833  if (NULL == MfsGetInternDataPtr(pstcMfs))
5834  {
5835  u16Reg = 0u;
5836  }
5837  else
5838  {
5839 #endif
5840  /* Return the value of Serial Assistant Status Control Register (for CSIO) */
5841  u16Reg = pstcMfs->SACSR;
5842 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5843  }
5844 #endif
5845 
5846  return (u16Reg);
5847 } /* Mfs_GetSACSR */
5848 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5849 
5850 #if (PDL_MFS_USE_HL == PDL_OFF)
5851 
5861 uint16_t Mfs_GetSTMCR(volatile stc_mfsn_t* pstcMfs)
5862 {
5863  uint16_t u16Reg;
5864 
5865 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5866  /* Parameter check and get ptr to internal data struct */
5867  if (NULL == MfsGetInternDataPtr(pstcMfs))
5868  {
5869  u16Reg = 0u;
5870  }
5871  else
5872  {
5873 #endif
5874  /* Return the value of Serial Timer Compare Register (for CSIO) */
5875  u16Reg = pstcMfs->STMCR;
5876 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5877  }
5878 #endif
5879 
5880  return (u16Reg);
5881 } /* Mfs_GetSTMCR */
5882 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5883 
5884 #if (PDL_MFS_USE_HL == PDL_OFF)
5885 
5901  uint16_t u16SCSCR
5902  )
5903 {
5904  en_result_t enResult;
5905 
5906 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5907  /* Parameter check and get ptr to internal data struct */
5908  if (NULL == MfsGetInternDataPtr(pstcMfs))
5909  {
5910  enResult = ErrorInvalidParameter;
5911  }
5912  else
5913  {
5914 #endif
5915  /* Set the value to Serial Chip Select Control Register (for CSIO) */
5916  pstcMfs->SCSCR = u16SCSCR;
5917 
5918  enResult = Ok;
5919 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5920  }
5921 #endif
5922 
5923  return (enResult);
5924 } /* Mfs_SetSCSCR */
5925 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5926 
5927 #if (PDL_MFS_USE_HL == PDL_OFF)
5928 
5939 uint16_t Mfs_GetSCSCR(volatile stc_mfsn_t* pstcMfs)
5940 {
5941  uint16_t u16Reg;
5942 
5943 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5944  /* Parameter check and get ptr to internal data struct */
5945  if (NULL == MfsGetInternDataPtr(pstcMfs))
5946  {
5947  u16Reg = 0u;
5948  }
5949  else
5950  {
5951 #endif
5952  /* Return the value of Serial Chip Select Control Register (for CSIO) */
5953  u16Reg = pstcMfs->SCSCR;
5954 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5955  }
5956 #endif
5957 
5958  return (u16Reg);
5959 } /* Mfs_GetSCSCR */
5960 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
5961 
5962 #if (PDL_MFS_USE_HL == PDL_OFF)
5963 
5979  uint8_t u8TBYTE0
5980  )
5981 {
5982  en_result_t enResult;
5983 
5984 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5985  /* Parameter check and get ptr to internal data struct */
5986  if (NULL == MfsGetInternDataPtr(pstcMfs))
5987  {
5988  enResult = ErrorInvalidParameter;
5989  }
5990  else
5991  {
5992 #endif
5993  /* Set the value to Transmission Byte 0 (for CSIO) */
5994  pstcMfs->TBYTE0 = u8TBYTE0;
5995 
5996  enResult = Ok;
5997 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
5998  }
5999 #endif
6000 
6001  return (enResult);
6002 } /* Mfs_SetTBYTE0 */
6003 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
6004 
6005 #if (PDL_MFS_USE_HL == PDL_OFF)
6006 
6021 uint8_t Mfs_GetTBYTE0(volatile stc_mfsn_t* pstcMfs)
6022 {
6023  uint8_t u8Reg;
6024 
6025 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6026  /* Parameter check and get ptr to internal data struct */
6027  if (NULL == MfsGetInternDataPtr(pstcMfs))
6028  {
6029  u8Reg = 0u;
6030  }
6031  else
6032  {
6033 #endif
6034  /* Return the value of Serial Chip Select Control Register (for CSIO) */
6035  u8Reg = pstcMfs->TBYTE0;
6036 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6037  }
6038 #endif
6039 
6040  return (u8Reg);
6041 } /* Mfs_GetTBYTE0 */
6042 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
6043 
6044 #if (PDL_MFS_USE_HL == PDL_OFF)
6045 
6061  uint8_t u8ISBA
6062  )
6063 {
6064  en_result_t enResult;
6065 
6066 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6067  /* Parameter check and get ptr to internal data struct */
6068  if (NULL == MfsGetInternDataPtr(pstcMfs))
6069  {
6070  enResult = ErrorInvalidParameter;
6071  }
6072  else
6073  {
6074 #endif
6075  /* Set the value to 7-bit Slave Address Register (for I2C) */
6076  pstcMfs->ISBA = u8ISBA;
6077 
6078  enResult = Ok;
6079 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6080  }
6081 #endif
6082 
6083  return (enResult);
6084 } /* Mfs_SetISBA */
6085 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
6086 
6087 #if (PDL_MFS_USE_HL == PDL_OFF)
6088 
6098 uint8_t Mfs_GetISBA(volatile stc_mfsn_t* pstcMfs)
6099 {
6100  uint8_t u8Reg;
6101 
6102 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6103  /* Parameter check and get ptr to internal data struct */
6104  if (NULL == MfsGetInternDataPtr(pstcMfs))
6105  {
6106  u8Reg = 0u;
6107  }
6108  else
6109  {
6110 #endif
6111  /* Return the value of 7-bit Slave Address Register (for I2C) */
6112  u8Reg = pstcMfs->ISBA;
6113 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6114  }
6115 #endif
6116 
6117  return (u8Reg);
6118 } /* Mfs_GetISBA */
6119 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
6120 
6121 #if (PDL_MFS_USE_HL == PDL_OFF)
6122 
6138  uint8_t u8ISMK
6139  )
6140 {
6141  en_result_t enResult;
6142 
6143 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6144  /* Parameter check and get ptr to internal data struct */
6145  if (NULL == MfsGetInternDataPtr(pstcMfs))
6146  {
6147  enResult = ErrorInvalidParameter;
6148  }
6149  else
6150  {
6151 #endif
6152  /* Set the value to 7-bit Slave Address Mask Register (for I2C) */
6153  pstcMfs->ISMK = u8ISMK;
6154 
6155  enResult = Ok;
6156 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6157  }
6158 #endif
6159 
6160  return (enResult);
6161 } /* Mfs_SetISMK */
6162 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
6163 
6164 #if (PDL_MFS_USE_HL == PDL_OFF)
6165 
6175 uint8_t Mfs_GetISMK(volatile stc_mfsn_t* pstcMfs)
6176 {
6177  uint8_t u8Reg;
6178 
6179 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6180  /* Parameter check and get ptr to internal data struct */
6181  if (NULL == MfsGetInternDataPtr(pstcMfs))
6182  {
6183  u8Reg = 0u;
6184  }
6185  else
6186  {
6187 #endif
6188  /* Return the value of 7-bit Slave Address Mask Register (for I2C) */
6189  u8Reg = pstcMfs->ISMK;
6190 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6191  }
6192 #endif
6193 
6194  return (u8Reg);
6195 } /* Mfs_GetISBA */
6196 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
6197 
6198 #if (PDL_MFS_USE_HL == PDL_OFF)
6199 
6209 uint8_t Mfs_GetNFCR(volatile stc_mfsn_t* pstcMfs)
6210 {
6211  uint8_t u8Reg;
6212 
6213 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6214  /* Parameter check and get ptr to internal data struct */
6215  if (NULL == MfsGetInternDataPtr(pstcMfs))
6216  {
6217  u8Reg = 0u;
6218  }
6219  else
6220  {
6221 #endif
6222  /* Return the value of Noize Filter Control Register (for I2C) */
6223  u8Reg = pstcMfs->NFCR;
6224 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6225  }
6226 #endif
6227 
6228  return (u8Reg);
6229 } /* Mfs_GetNFCR */
6230 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
6231 
6232 #if (PDL_MFS_USE_HL == PDL_OFF)
6233 
6249  uint8_t u8EIBCR
6250  )
6251 {
6252  en_result_t enResult;
6253 
6254 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6255  /* Parameter check and get ptr to internal data struct */
6256  if (NULL == MfsGetInternDataPtr(pstcMfs))
6257  {
6258  enResult = ErrorInvalidParameter;
6259  }
6260  else
6261  {
6262 #endif
6263  /* Set the value to 7-bit Slave Address Mask Register (for I2C) */
6264  pstcMfs->EIBCR = u8EIBCR & MFS_EIBCR_WRT_MASK;
6265 
6266  enResult = Ok;
6267 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6268  }
6269 #endif
6270 
6271  return (enResult);
6272 } /* Mfs_SetEIBCR */
6273 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
6274 
6275 #if (PDL_MFS_USE_HL == PDL_OFF)
6276 
6286 uint8_t Mfs_GetEIBCR(volatile stc_mfsn_t* pstcMfs)
6287 {
6288  uint8_t u8Reg;
6289 
6290 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6291  /* Parameter check and get ptr to internal data struct */
6292  if (NULL == MfsGetInternDataPtr(pstcMfs))
6293  {
6294  u8Reg = 0u;
6295  }
6296  else
6297  {
6298 #endif
6299  /* Return the value of Extended I2C Bus Control Register (for I2C) */
6300  u8Reg = pstcMfs->EIBCR;
6301 #if (PDL_MFS_NO_PARAM_CHK == PDL_OFF)
6302  }
6303 #endif
6304 
6305  return (u8Reg);
6306 } /* Mfs_GetEIBCR */
6307 #endif /* #if (PDL_MFS_USE_HL == PDL_OFF) */
6308 
6326  mfs_tx_cb_func_ptr_t pfnTxCbFunc
6327  )
6328 {
6329  en_result_t enResult;
6330  stc_mfs_intern_data_t* pstcMfsInternData;
6331 
6332  /* Check for valid pointer and get pointer to internal data struct ... */
6333  pstcMfsInternData = MfsGetInternDataPtr(pstcMfs);
6334  /* ... and check */
6335  if (NULL == pstcMfsInternData)
6336  {
6337  enResult = ErrorInvalidParameter;
6338  }
6339  else
6340  {
6341  pstcMfsInternData->pfnTransmitCbFunction = pfnTxCbFunc;
6342  enResult = Ok;
6343  }
6344 
6345  return (enResult);
6346 } /* Mfs_SetTxIntCallBack */
6347 
6365  mfs_rx_cb_func_ptr_t pfnRxCbFunc
6366  )
6367 {
6368  en_result_t enResult;
6369  stc_mfs_intern_data_t* pstcMfsInternData;
6370 
6371  /* Check for valid pointer and get pointer to internal data struct ... */
6372  pstcMfsInternData = MfsGetInternDataPtr(pstcMfs);
6373  /* ... and check */
6374  if (NULL == pstcMfsInternData)
6375  {
6376  enResult = ErrorInvalidParameter;
6377  }
6378  else
6379  {
6380  pstcMfsInternData->pfnReceiveCbFunction = pfnRxCbFunc;
6381  enResult = Ok;
6382  }
6383 
6384  return (enResult);
6385 } /* Mfs_SetRxIntCallBack */
6386 
6404  mfs_sts_cb_func_ptr_t pfnStsCbFunc
6405  )
6406 {
6407  en_result_t enResult;
6408  stc_mfs_intern_data_t* pstcMfsInternData;
6409 
6410  /* Check for valid pointer and get pointer to internal data struct ... */
6411  pstcMfsInternData = MfsGetInternDataPtr(pstcMfs);
6412  /* ... and check */
6413  if (NULL == pstcMfsInternData)
6414  {
6415  enResult = ErrorInvalidParameter;
6416  }
6417  else
6418  {
6419  pstcMfsInternData->pfnStatusCbFunction = pfnStsCbFunc;
6420  enResult = Ok;
6421  }
6422 
6423  return (enResult);
6424 } /* Mfs_SetStsIntCallBack */
6425 
6443  void* pvHandle
6444  )
6445 {
6446  en_result_t enResult;
6447  stc_mfs_intern_data_t* pstcMfsInternData;
6448 
6449  /* Check for valid pointer and get pointer to internal data struct ... */
6450  pstcMfsInternData = MfsGetInternDataPtr(pstcMfs);
6451  /* ... and check */
6452  if (NULL == pstcMfsInternData)
6453  {
6454  enResult = ErrorInvalidParameter;
6455  }
6456  else
6457  {
6458  pstcMfsInternData->pvUpperLayerHandle = pvHandle;
6459  enResult = Ok;
6460  }
6461 
6462  return (enResult);
6463 } /* Mfs_SetUpperLayerHandle */
6464 
6466 
6467 #endif /* #if (defined(PDL_PERIPHERAL_MFS_ACTIVE)) */
6468 /******************************************************************************/
6469 /* EOF (not truncated) */
6470 /******************************************************************************/