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 = 0x00000000;
90 static uint32 IfxPsi5s_Psi5s_getFracDivClock(Ifx_PSI5S *psi5s)
95 switch (psi5s->FDR.B.DM)
119 boolean status =
TRUE;
128 Ifx_PSI5S_PGC tempPGC;
129 tempPGC.U = psi5s->PGC[config->
channelId].U;
139 tempPGC.B.PTE =
TRUE;
140 tempPGC.B.ETE =
FALSE;
144 tempPGC.B.PTE =
FALSE;
145 tempPGC.B.ETE =
TRUE;
149 psi5s->PGC[config->
channelId].U = tempPGC.U;
151 Ifx_PSI5S_CTV tempCTV;
152 tempCTV.U = psi5s->CTV[config->
channelId].U;
155 psi5s->CTV[config->
channelId].U = tempCTV.U;
159 Ifx_PSI5S_RCRA tempRCRA;
160 tempRCRA.U = psi5s->RCRA[config->
channelId].U;
178 psi5s->RCRA[config->
channelId].U = tempRCRA.U;
180 Ifx_PSI5S_RCRB tempRCRB;
181 tempRCRB.U = psi5s->RCRB[config->
channelId].U;
188 psi5s->RCRB[config->
channelId].U = tempRCRB.U;
192 Ifx_PSI5S_SCR tempSCR;
193 tempSCR.U = psi5s->SCR[config->
channelId].U;
199 psi5s->SCR[config->
channelId].U = tempSCR.U;
221 .channelTriggerValue = 0x20,
222 .channelTriggerCounter = 0x0
224 .watchdogTimerLimit = 0x0,
232 .timestampEnabled =
FALSE,
243 .payloadLength[0] = 0,
244 .payloadLength[1] = 0,
245 .payloadLength[2] = 0,
246 .payloadLength[3] = 0,
247 .payloadLength[4] = 0,
248 .payloadLength[5] = 0,
254 .bitStuffControl =
FALSE,
255 .crcGenerationControl =
FALSE,
256 .startSequenceGenerationControl =
FALSE
259 *config = IfxPsi5s_Psi5s_defaultChannelConfig;
266 boolean status =
TRUE;
268 Ifx_PSI5S *psi5sSFR = config->
module;
269 psi5s->
psi5s = psi5sSFR;
273 IfxPsi5s_Psi5s_enableModule(psi5sSFR);
275 if (IfxPsi5s_Psi5s_initializeClock(psi5sSFR, &config->
fracDiv) == 0)
283 if (IfxPsi5s_Psi5s_initializeClock(psi5sSFR, &config->
timestampClock) == 0)
291 Ifx_PSI5S_CON tempCON;
292 tempCON.U = psi5sSFR->CON.U;
304 psi5sSFR->CON.U = tempCON.U;
323 Ifx_PSI5S_TSCNTA tempTSCNTA;
324 tempTSCNTA.U = psi5sSFR->TSCNTA.U;
327 psi5sSFR->TSCNTA.U = tempTSCNTA.U;
329 Ifx_PSI5S_TSCNTB tempTSCNTB;
330 tempTSCNTB.U = psi5sSFR->TSCNTB.U;
333 psi5sSFR->TSCNTB.U = tempTSCNTB.U;
335 Ifx_PSI5S_GCR tempGCR;
336 tempGCR.U = psi5sSFR->GCR.U;
347 psi5sSFR->GCR.U = tempGCR.U;
434 Ifx_PSI5S_FDR tempFDR;
435 Ifx_PSI5S_FDRT tempFDRT;
436 Ifx_PSI5S_FDO tempFDO;
449 fInput = IfxPsi5s_Psi5s_getFracDivClock(psi5s);
463 step = stepRange - (fInput / clockFrequency);
465 if (step > (stepRange - 1))
467 step = stepRange - 1;
474 result = (
uint32)(fInput / (stepRange - step));
478 step = (
uint64)((
uint64)clockFrequency * stepRange) / fInput;
480 if (step > (stepRange - 1))
482 step = stepRange - 1;
505 tempFDR.B.DM = divMode;
506 tempFDR.B.STEP = (
uint32)step;
507 psi5s->FDR.U = tempFDR.U;
512 tempFDRT.B.DM = divMode;
513 tempFDRT.B.STEP = (
uint32)step;
514 psi5s->FDRT.U = tempFDRT.U;
519 tempFDO.B.DM = divMode;
520 tempFDO.B.STEP = (
uint32)step;
521 psi5s->FDO.U = tempFDO.U;
538 channel->
module->
psi5s->INTCLR[channel->
channelId].U |= (IFX_PSI5S_INTCLR_RDI_MSK << IFX_PSI5S_INTCLR_RDI_OFF) | (IFX_PSI5S_INTCLR_RSI_MSK << IFX_PSI5S_INTCLR_RSI_OFF);
542 static void IfxPsi5s_Psi5s_resetModule(Ifx_PSI5S *psi5s)
546 psi5s->KRST1.B.RST = 1;
547 psi5s->KRST0.B.RST = 1;
549 while (psi5s->KRST0.B.RSTSTAT == 0)
554 psi5s->KRSTCLR.B.CLR = 1;
623 if (fdValue > (IFXPSI5S_FDV_RANGE - 1))
625 fdValue = IFXPSI5S_FDV_RANGE - 1;
626 bgValue = ((float)fdValue / IFXPSI5S_FDV_RANGE) * (fInput / (16 * baudrate)) - 1;
642 result = ((float)fdValue / IFXPSI5S_FDV_RANGE) * (fInput / (16 * (bgValue + 1)));
645 psi5s->FDV.U = fdValue;
646 psi5s->BG.U = bgValue;