42 static void IfxPsi5s_Psi5s_enableModule(Ifx_PSI5S *psi5s);
48 static uint32 IfxPsi5s_Psi5s_getFracDivClock(Ifx_PSI5S *psi5s);
61 static void IfxPsi5s_Psi5s_resetModule(Ifx_PSI5S *psi5s);
79 Ifx_PSI5S *psi5sSFR = psi5s->
psi5s;
80 IfxPsi5s_Psi5s_resetModule(psi5sSFR);
84 static void IfxPsi5s_Psi5s_enableModule(Ifx_PSI5S *psi5s)
86 psi5s->CLC.U = 0x00000100;
90 static uint32 IfxPsi5s_Psi5s_getFracDivClock(Ifx_PSI5S *psi5s)
95 switch (psi5s->FDR.B.DM)
119 boolean status =
TRUE;
128 Ifx_PSI5S_PGC tempPGC;
138 tempPGC.B.PTE =
TRUE;
139 tempPGC.B.ETE =
FALSE;
143 tempPGC.B.PTE =
FALSE;
144 tempPGC.B.ETE =
TRUE;
148 psi5s->PGC[config->
channelId].U = tempPGC.U;
150 Ifx_PSI5S_CTV tempCTV;
153 psi5s->CTV[config->
channelId].U = tempCTV.U;
157 Ifx_PSI5S_RCRA tempRCRA;
175 psi5s->RCRA[config->
channelId].U = tempRCRA.U;
177 Ifx_PSI5S_RCRB tempRCRB;
184 psi5s->RCRB[config->
channelId].U = tempRCRB.U;
188 Ifx_PSI5S_SCR tempSCR;
194 psi5s->SCR[config->
channelId].U = tempSCR.U;
216 .channelTriggerValue = 0x20,
217 .channelTriggerCounter = 0x0
219 .watchdogTimerLimit = 0x0,
227 .timestampEnabled =
FALSE,
238 .payloadLength[0] = 0,
239 .payloadLength[1] = 0,
240 .payloadLength[2] = 0,
241 .payloadLength[3] = 0,
242 .payloadLength[4] = 0,
243 .payloadLength[5] = 0,
249 .bitStuffControl =
FALSE,
250 .crcGenerationControl =
FALSE,
251 .startSequenceGenerationControl =
FALSE
254 *config = IfxPsi5s_Psi5s_defaultChannelConfig;
261 boolean status =
TRUE;
263 Ifx_PSI5S *psi5sSFR = config->
module;
264 psi5s->
psi5s = psi5sSFR;
268 IfxPsi5s_Psi5s_enableModule(psi5sSFR);
270 if (IfxPsi5s_Psi5s_initializeClock(psi5sSFR, &config->
fracDiv) == 0)
278 if (IfxPsi5s_Psi5s_initializeClock(psi5sSFR, &config->
timestampClock) == 0)
286 Ifx_PSI5S_CON tempCON;
298 psi5sSFR->CON.U = tempCON.U;
317 Ifx_PSI5S_TSCNTA tempTSCNTA;
320 psi5sSFR->TSCNTA.U = tempTSCNTA.U;
322 Ifx_PSI5S_TSCNTB tempTSCNTB;
325 psi5sSFR->TSCNTB.U = tempTSCNTB.U;
327 Ifx_PSI5S_GCR tempGCR;
338 psi5sSFR->GCR.U = tempGCR.U;
425 Ifx_PSI5S_FDR tempFDR;
426 Ifx_PSI5S_FDRT tempFDRT;
427 Ifx_PSI5S_FDO tempFDO;
440 fInput = IfxPsi5s_Psi5s_getFracDivClock(psi5s);
454 step = stepRange - (fInput / clockFrequency);
456 if (step > (stepRange - 1))
458 step = stepRange - 1;
465 result = fInput / (stepRange - step);
469 step = (clockFrequency * stepRange) / fInput;
471 if (step > (stepRange - 1))
473 step = stepRange - 1;
480 result = (fInput * step) / stepRange;
495 tempFDR.B.DM = divMode;
496 tempFDR.B.STEP = step;
497 psi5s->FDR.U = tempFDR.U;
501 tempFDRT.B.DM = divMode;
502 tempFDRT.B.STEP = step;
503 psi5s->FDRT.U = tempFDRT.U;
507 tempFDO.B.DM = divMode;
508 tempFDO.B.STEP = step;
509 psi5s->FDO.U = tempFDO.U;
526 channel->
module->
psi5s->INTCLR[channel->
channelId].U = IFX_PSI5S_INTCLR_RDI_MSK << IFX_PSI5S_INTCLR_RDI_OFF;
537 static void IfxPsi5s_Psi5s_resetModule(Ifx_PSI5S *psi5s)
541 psi5s->KRST1.B.RST = 1;
542 psi5s->KRST0.B.RST = 1;
544 while (psi5s->KRST0.B.RSTSTAT == 0)
549 psi5s->KRSTCLR.B.CLR = 1;
640 psi5s->FDV.U = fdValue;
641 psi5s->BG.U = bgValue;