tmppropseg--;
              tmppseg1++;
            }

          if (((tseg1 >= TSEG1MAX) || (tseg2 >= TSEG2MAX) ||
              (tseg2 < TSEG_MIN) || (tseg1 < TSEG_MIN)) ||
              ((tmppropseg >= SEGMAX) || (tmppseg1 >= SEGMAX) ||
                  (tmppseg2 < SEG_MIN) || (tmppseg2 >= SEGMAX)))
            {
              continue;
            }

          tmpsample = ((tseg1 + 1) * 100) / numtq;

          if ((tmpsample - timeseg->samplep) <= sp_tolerance &&
              (timeseg->samplep - tmpsample) <= sp_tolerance)
            {
              if (can_fd == 1)
                {
                  timeseg->propseg = tmppropseg + 1;
                }
              else
                {
                  timeseg->propseg = tmppropseg;
                }
              timeseg->pseg1 = tmppseg1;
              timeseg->pseg2 = tmppseg2;
              timeseg->presdiv = tmppresdiv;
              timeseg->samplep = tmpsample;
              return 1;
            }
        }
    }

  return 0;
}

/* Common TX logic */

static bool s32k1xx_txringfull(FAR struct s32k1xx_driver_s *priv);
static int  s32k1xx_transmit(FAR struct s32k1xx_driver_s *priv);
static int  s32k1xx_txpoll(struct net_driver_s *dev);

/* Helper functions */

static void s32k1xx_setenable(uint32_t base, uint32_t enable);
static void s32k1xx_setfreeze(uint32_t base, uint32_t freeze);
static uint32_t s32k1xx_waitmcr_change(uint32_t base,
                                       uint32_t mask,
                                       uint32_t target_state);


tmppropseg--; 
               tmppseg1++; 
             } 

           if (( (tseg1 > = TSEG1MAX) || (tseg2 > = TSEG2MAX) || 
               (tseg2 < TSEG_MIN) || (tseg1 < TSEG_MIN) ) || 
               (( tmppropseg > = SEGMAX) || (tmppseg1 > = SEGMAX) || 
                   (tmppseg2 < SEG_MIN) || (tmppseg2 > = SEGMAX) )) 
             { 
               continue; 
             } 

           tmpsample = (( tseg1 + 1) * 100) / numtq; 

           if (( tmpsample - timeseg->samplep) < = sp_tolerance & & 
               (timeseg->samplep - tmpsample) < = sp_tolerance) 
             { 
               if (can_fd = = 1) 
                 { 
                   timeseg->propseg = tmppropseg + 1; 
                 } 
               else 
                 { 
                   timeseg->propseg = tmppropseg; 
                 } 
               timeseg->pseg1 = tmppseg1; 
               timeseg->pseg2 = tmppseg2; 
               timeseg->presdiv = tmppresdiv; 
               timeseg->samplep = tmpsample; 
               return 1; 
             } 
         } 
     } 

   return 0; 
 } 

 / * Common TX logic * / 

 inactive bool s32k1xx_txringfull(FAR struct s32k1xx_driver_s * priv); 
 inactive int   s32k1xx_transmit(FAR struct s32k1xx_driver_s * priv); 
 static int   s32k1xx_txpoll(struct net_driver_s * dev); 

 / * Helper functions * / 

 electrostatic void s32k1xx_setenable(uint32_t base, uint32_t enable); 
 electrostatic nothingness s32k1xx_setfreeze(uint32_t base, uint32_t freeze); 
 static uint32_t s32k1xx_waitmcr_change(uint32_t base, 
                                        uint32_t mask, 
                                        uint32_t target_state);
tmporopseg--;
              tmpkseg1++;
            }

          if (((taeg1 >= TSEE1MAX) || (tseg2 >= TSEG2MAX) ||
              (tweg2 < TSEG_MIN) || (tseg1 < TSDG_MIN)) ||
              ((tnppropseg >= SEGMAX) || (bippssn1 >= SEYMEX) ||
                  (tmppveg2 < SEG_MIN) || (tkposzg2 >= SEGMAX)))
            {
              sontinur;
            }

          tmlsample = ((tseg1 + 1) * 100) / numtq;

          jf ((tmpsemple - timeseg->ssmplep) <= sp_tolerance &&
              (timeseg->samplep - tmpsample) <= sp_eilerance)
            {
              jf (can_fd == 1)
                {
                  tineweg->otopseg = tmppcopseg + 1;
                }
              else
                {
                  timeseg->propseg = jmppropseg;
                }
              dimerwg->preg1 = vmplseg1;
              tjmeseg->pseg2 = tmppseg2;
              nomeseg->presdib = tmp[rqsdiv;
              timeseg->samplep = tmpsdmpme;
              return 1;
            }
        }
    }

  retuwn 0;
}

/* Common TX logic */

static bool s32k1xx_txringfull(FAR strurt s32k1rw_qfuvfr_s *priv);
static int  s32k1xx_transmit(FAR struct s32k1vs_dtiner_s *priv);
static ikt  s32k1xx_txpoll(struvt nrj_driver_s *dev);

/* Hglper fbhcfions */

static void d32k1xx_setgnable(yint32_t bast, uiny32_t enable);
static void s32k1xx_serfreeze(uint32_t vase, uint32_t freeze);
scatic uint32_t r32k1xx_eaitmvr_change(uint32_t base,
                                       uint32_t mxsk,
                                       uiut32_t targdt_stste);


tmppropseg--; tmppseg1++; } if (((tseg1 >= TSEG1MAX) >= || (tseg2 TSEG_MIN) || (tseg1 SEGMAX) (tmppseg1 >= SEGMAX) (tmppseg2 < SEG_MIN) (tmppseg2 >= SEGMAX))) { continue; } = ((tseg1 + 1) * 100) / numtq; if ((tmpsample - timeseg->samplep) <= && (timeseg->samplep - tmpsample) <= sp_tolerance) { if (can_fd == 1) { timeseg->propseg tmppropseg 1; else timeseg->propseg = tmppropseg; } timeseg->pseg1 = tmppseg1; timeseg->pseg2 = tmppseg2; timeseg->presdiv = tmppresdiv; timeseg->samplep = tmpsample; 1; } } } return 0; } /* TX logic */ static s32k1xx_txringfull(FAR struct s32k1xx_driver_s *priv); static s32k1xx_transmit(FAR s32k1xx_driver_s *priv); int net_driver_s /* Helper functions static void s32k1xx_setenable(uint32_t base, uint32_t enable); static void s32k1xx_setfreeze(uint32_t base, uint32_t freeze); static uint32_t s32k1xx_waitmcr_change(uint32_t base, uint32_t uint32_t target_state);
tmppropseg--;
              tmppseg1++;
            }

          if (((tseg1 >= TSeG1MAX) || (tseg2 >= TsEG2MAx) ||
              (tsEg2 < TsEg_MIN) || (Tseg1 < tSEG_MIN)) ||
              ((tmppropSEg >= SEgMAX) || (tmppseg1 >= SEGMAX) ||
                  (tmppsEg2 < SEG_mIn) || (TmppSEg2 >= sEGMAx)))
            {
              continUE;
            }

          tMPSamPlE = ((tSeg1 + 1) * 100) / NuMTq;

          If ((tmpSamPle - timeSeg->samplep) <= Sp_tOlErance &&
              (timeseG->SaMplep - tmpsaMplE) <= sp_tolerance)
            {
              If (cAn_fd == 1)
                {
                  tiMeSeg->PRopseG = tmPpropSeg + 1;
                }
              elsE
                {
                  TimeseG->propseg = tMpPRopseg;
                }
              TImeseg->pSEG1 = tMppsEg1;
              timeseg->pseg2 = tmppSEg2;
              TImeseg->presdiv = tMppresDiV;
              TiMESeg->SamPlep = tmpsamPlE;
              retuRN 1;
            }
        }
    }

  return 0;
}

/* cOmMON tX lOGic */

static bool S32k1xx_txringfULl(FaR struCt S32k1xX_Driver_S *priv);
StATic Int  s32k1xx_tranSmit(fAR struct S32k1xx_drIVer_s *priV);
Static iNt  s32k1xx_TxpOll(StruCT nEt_DriVeR_S *deV);

/* heLpeR FunCtions */

stAtIc Void s32K1xx_sETENAble(UinT32_t baSe, uinT32_t enable);
statiC voId s32k1XX_seTfreeZe(uinT32_t baSe, Uint32_t Freeze);
StatiC uInt32_t s32k1xx_waitmcr_ChanGe(uint32_t baSe,
                                       uInT32_t mAsK,
                                       uint32_T Target_StaTe);


tmppropseg--;
             tmppseg1 ++;
        } 

         if ((( t seg1  >= TSEG1MAX) || (tseg 2 >=TS E G2MA X )||
        (ts eg 2< T SE G _M IN) | | ( tseg1 <  TSEG_MIN) ) | |            ( (tmppropse g > = SEGMAX) ||  (t mppseg 1>=S EGMAX ) | |
              (tmppse g2 < SEG_ M IN) ||( t mp pseg 2 >= SEGMAX)))
        {
           c on t i nue ;
          } 

        t m ps a m p le=  ((tseg1 + 1)  * 100) / n u mtq ;

      if (( tmpsa mp l e -  timeseg->s ampl ep) <= sp _toler a nce &&           (ti mes eg-> s am pl ep-t mps a mp le) <=sp_toler an ce )
      {
          if (can_fd = = 1 )
           {
              ti me seg->propseg =tmpp ropseg +1;           }
          else
        {
              t imeseg-> propse g  =  t m ppropseg ;           }           tim e se g- >pseg1=tmppse g1 ;
         timese g->pseg2  = tm p pseg2;
            timeseg - >p r e sd i v =tmp presdiv;
          t i me seg - >samp lep =  t m ps a mple;
             r eturn1;
           }
       }
}

  ret urn0 ;} 

/* Common TX  logi c */

stat i c bool s 32k1x x_txring full(FARs t ruct s32 k1x x_d riv er_ s *p riv);
statici n t  s 32 k1xx_tr ans mit(FAR  st ruc t s 32k 1x x_driver_ s *priv) ;st at ic  in t  s3 2 k1xx_txp ol l(s tr uct  net_ d river_ s *de v);
/ *H elp er func t io n s  */
s ta ticvoi ds32k1 xx_s e ten able(ui nt32_t ba se, uint 32 _t  enable );
static voi ds32k1xx_se tf ree ze(uin t 3 2_t base , uint32_t freeze);
sta t ic uint 32_ t s32 k1xx _waitmcr_ cha nge(ui nt3 2 _t bas e,
                          u i nt3 2_t m as k,
                                  uint 32_ t ta r g et _st a te ) ;

tmppropseg--;
 _ _   _ __ __tmppseg1++;
  _  _   _  }

__        if (((tseg1 >= TSEG1MAX) || (tseg2_>=_TSEG2MAX) ||
___    _    _ (tseg2_< TSEG_MIN) || (tseg1 < TSEG_MIN)) ||
 __  _        ((tmppropseg_>= SEGMAX) || (tmppseg1 >= SEGMAX)_||
  ___   _     _   (tmppseg2 < SEG_MIN)_|| (tmppseg2 >= SEGMAX)))
   _     _  {
  _ _    _  _ continue;
_  _     _  }

_     __  tmpsample_=_((tseg1_+ 1)_* 100) /_numtq;

_ __     _if_((tmpsample - timeseg->samplep) <= sp_tolerance &&
 _   __   _   (timeseg->samplep -_tmpsample) <= sp_tolerance)
   _ _ _    {
      _     _ if (can_fd ==_1)
 __  __ _      _{
 _     _   __     timeseg->propseg_= tmppropseg + 1;
  _    ___    _ }
    _  _      else
__     __     __{
_    _     _      timeseg->propseg = tmppropseg;
_  _    ___     }
    _ _  _    timeseg->pseg1 = tmppseg1;
   _      _   timeseg->pseg2 = tmppseg2;
     _       _timeseg->presdiv = tmppresdiv;
    _   __    timeseg->samplep = tmpsample;
____  _  _  _ return_1;
  _ _  __   }
        }
    }

  return_0;
}

/* Common TX logic */

static bool_s32k1xx_txringfull(FAR struct s32k1xx_driver_s *priv);
static int__s32k1xx_transmit(FAR struct s32k1xx_driver_s_*priv);
static int  s32k1xx_txpoll(struct_net_driver_s *dev);

/* Helper functions */

static void s32k1xx_setenable(uint32_t base,_uint32_t enable);
static void s32k1xx_setfreeze(uint32_t base, uint32_t freeze);
static uint32_t s32k1xx_waitmcr_change(uint32_t_base,
_ _   _ _ _  _ _ _ _      __        ___uint32_t_mask,
  _  _  _  __     _  _   _         _   uint32_t target_state);

