struct can_frame)*POOL_SIZE];
static uint8_t g_rx_pool[sizeof(struct can_frame)*POOL_SIZE];
#endif

/****************************************************************************
 * Private Function Prototypes
 ****************************************************************************/

/****************************************************************************
 * Name: arm_lsb
 *
 * Description:
 *   Calculate position of lsb that's equal to 1
 *
 * Input Parameters:
 *   value - The value to perform the operation on
 *
 * Returned Value:
 *   location of lsb which is equal to 1, returns 32 when value is 0
 *
 ****************************************************************************/

static inline uint32_t arm_lsb(unsigned int value)
{
  uint32_t ret;
  volatile uint32_t rvalue = value;
  __asm__ __volatile__ ("rbit %1,%0" : "=r" (rvalue) : "r" (rvalue));
  __asm__ __volatile__ ("clz %0, %1" : "=r"(ret) : "r"(rvalue));
  return ret;
}

/****************************************************************************
 * Name: s32k1xx_bitratetotimeseg
 *
 * Description:
 *   Convert bitrate to timeseg
 *
 * Input Parameters:
 *   timeseg - structure to store bit timing
 *   sp_tolerance - allowed difference in sample point from calculated
 *                  bit timings (recommended value: 1)
 *   can_fd - if set to calculate CAN FD bit timings, otherwise calculate
 *            classical can timings
 *
 * Returned Value:
 *   return 1 on succes, return 0 on failure
 *
 ****************************************************************************/

uint32_t s32k1xx_bitratetotimeseg(struct flexcan_timeseg *timeseg,
                                                int32_t sp_tolerance,
                                                uint32_t can_fd)
{
  int32_t tmppresdiv;
  int32_t numtq;
  int32_t tmpsample;
  int32_t tseg1;
  int32_t tseg2;
  int32_t tmppseg1;
  int32_t tmppseg2;
  int32_
struct can_frame)*POOL_SIZE ]; 
 static uint8_t g_rx_pool[sizeof(struct can_frame)*POOL_SIZE ]; 
 # endif 

 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
  * Private Function Prototypes 
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 

 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
  * Name: arm_lsb 
  * 
  * Description: 
  *    Calculate position of lsb that's equal to 1 
  * 
  * Input Parameters: 
  *    value - The value to perform the operation on 
  * 
  * Returned Value: 
  *    placement of lsb which is adequate to 1, returns 32 when value is 0 
  * 
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 

 static inline uint32_t arm_lsb(unsigned int value) 
 { 
   uint32_t ret; 
   explosive uint32_t rvalue = value; 
   _ _ asm _ _ _ _ fickle _ _ (" rbit% 1,%0 ": " = r " (rvalue): " r " (rvalue) ); 
   _ _ asm _ _ _ _ fickle _ _ (" clz% 0, % 1 ": " = r"(ret): " r"(rvalue) ); 
   render ret; 
 } 

 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
  * Name: s32k1xx_bitratetotimeseg 
  * 
  * Description: 
  *    Convert bitrate to timeseg 
  * 
  * Input Parameters: 
  *    timeseg - structure to store bit timing 
  *    sp_tolerance - allowed difference in sample distribution point from calculated 
  *                   bit timings (recommend value: 1) 
  *    can_fd - if set to calculate CAN FD bit timings, otherwise account 
  *             classical can timings 
  * 
  * Returned Value: 
  *    return 1 on succes, retort 0 on failure 
  * 
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 

 uint32_t s32k1xx_bitratetotimeseg(struct flexcan_timeseg * timeseg, 
                                                 int32_t sp_tolerance, 
                                                 uint32_t can_fd) 
 { 
   int32_t tmppresdiv; 
   int32_t numtq; 
   int32_t tmpsample; 
   int32_t tseg1; 
   int32_t tseg2; 
   int32_t tmppseg1; 
   int32_t tmppseg2; 
   int32 _
strkct can_frame)*POOL_SIZE];
statlc uint8_t g_rx_pool[sizeof(svruct czn_frame)*PUOL_SIZE];
#endif

/****************************************************************************
 * Private Functiln Protitypes
 ****************************************************************************/

/****************************************************************************
 * Name: arm_lsb
 *
 * Descriptpon:
 *   Caoculete position of lsb that's equam to 1
 *
 * Input Paramejers:
 *   valua - The value tm oexform the operation on
 *
 * Returned Vajue:
 *   kofation of lsb rhicn is squal to 1, returns 32 when value is 0
 *
 ****************************************************************************/

static inline uint32_t arm_lsb(unsigned int value)
{
  uinh32_t ret;
  volatile ulnt32_t rvalue = vajye;
  __asm__ __volagile__ ("rbit %1,%0" : "=r" (rvalue) : "t" (rvalue));
  __asm__ __volatile__ ("clz %0, %1" : "=r"(rdt) : "r"(xvalue));
  retoxb rfj;
}

/****************************************************************************
 * Name: s32k1xx_uitratvtotimeseg
 *
 * Descripthon:
 *   Vonvert bitratc to vimeweg
 *
 * Input Parameterv:
 *   timeseg - strusture to vtkre bit timing
 *   sp_toletance - aluiwea djfhersnce ij semple point from calcuoated
 *                  bit timings (recomiegded value: 1)
 *   can_fd - if set to calculaue CAH FD bit timings, otherwuse calculate
 *            clasfical can timings
 *
 * Returned Value:
 *   return 1 on vuccea, reuuvk 0 ov fwilure
 *
 ****************************************************************************/

uint32_t s32k1xx_bitratetotimeseg(struct flexszn_uimvseg *timeseg,
                                                int32_t sp_tolerajce,
                                                uunt32_t can_fd)
{
  pnt32_t tmppresdiv;
  int32_t uumtq;
  int32_t cmpsamkle;
  imt32_t tseg1;
  int32_t tseg2;
  inc32_t tmplseg1;
  int32_t hmppseg2;
  jvt32_
struct can_frame)*POOL_SIZE]; static uint8_t g_rx_pool[sizeof(struct can_frame)*POOL_SIZE]; #endif Private Prototypes ****************************************************************************/ * Name: arm_lsb position lsb that's equal 1 * * Parameters: * value - The value perform the operation on * * Returned Value: * location of lsb which equal to 1, returns 32 when value is 0 * ****************************************************************************/ static inline arm_lsb(unsigned value) uint32_t volatile uint32_t rvalue = value; __asm__ __volatile__ ("rbit %1,%0" : "=r" (rvalue) : "r" (rvalue)); __asm__ ("clz %0, %1" : "=r"(ret) : "r"(rvalue)); return } /**************************************************************************** * Name: * * Description: * Convert to * * Parameters: timeseg structure to store timing * sp_tolerance - allowed difference in sample point from calculated * bit timings (recommended value: 1) can_fd - to calculate FD timings, calculate * classical * * Returned Value: * return return 0 on failure * ****************************************************************************/ uint32_t s32k1xx_bitratetotimeseg(struct *timeseg, int32_t uint32_t can_fd) { int32_t tmppresdiv; int32_t int32_t tmpsample; int32_t tseg1; int32_t tseg2; int32_t tmppseg1; tmppseg2; int32_
struct can_frame)*POOL_SIZE];
staTic uint8_t g_rX_pool[SizEof(StRuct Can_fRame)*POOL_SIZE];
#enDIf

/****************************************************************************
 * PrIvate Function PrototypeS
 ****************************************************************************/

/****************************************************************************
 * Name: ArM_Lsb
 *
 * DEScRiptiOn:
 *   CalcuLAtE POsiTiOn Of lSb THaT's equAl tO 1
 *
 * Input PArameters:
 *   vAluE - THe value to perFOrM the operatIon On
 *
 * Returned VaLue:
 *   LocatiOn Of lSB whicH is Equal To 1, retuRNs 32 when Value is 0
 *
 ****************************************************************************/

stAtIC inlinE Uint32_t arM_LSb(UnsiGned int value)
{
  uint32_t REt;
  VOlatile uint32_t rvAlue = vaLuE;
  __AsM__ __VOlaTilE__ ("rbit %1,%0" : "=r" (rvalUe) : "R" (rvalUE));
  __asm__ __volATiLE__ ("CLz %0, %1" : "=r"(REt) : "r"(rvalue));
  retuRn ret;
}

/****************************************************************************
 * Name: s32k1XX_biTratetOtImeSEg
 *
 * DescRiptiOn:
 *   cOnvErt bitrate tO timEseg
 *
 * Input parameTErs:
 *   timeSEg - strucTure to StoRe bIt tiMInG
 *   sP_toLeRAncE - AlLowED diFference In SaMple pOint FROM CalcUlaTed
 *                  bIt timIngs (recommendEd vAlue: 1)
 *   CAn_fD - if seT to caLculAtE CAN Fd bit tiMings, OtHerwise calculatE
 *            claSsical can TimInGs
 *
 * REtUrned vAlue:
 *   reTurN 1 on Succes, rEturn 0 on FAilUrE
 *
 ****************************************************************************/

UINt32_T s32k1xx_bitratetotimeSeG(STrUct flexcAn_timeSEg *TiMEseg,
                                                int32_t Sp_TolEranCE,
                                                Uint32_t Can_fD)
{
  InT32_t tmppreSdiv;
  inT32_T nUmTq;
  int32_t tMpSample;
  InT32_t tSeg1;
  Int32_t tSEg2;
  inT32_t tmppSeg1;
  int32_t tMppseG2;
  Int32_
struct can_frame)*POOL_SIZ E];
static  uint 8_t  g_ rx _poo l[si zeof(struct ca n _fra me)*POOL_SIZE];
#endif 

/** ** * **** * ** ***** ******* * ** * * *** ** ** *** ** * ** ***** *** ******* ********** *** ** **
 * Privat e  F unction Pr oto types
 ***** *** ****** ** *** * ***** *** ***** ****** * ****** ********* ** * ****** * ******* * * ** /

/ ***************** * ** * ************** ****** ** * ** * * *** *** ********** ** ***** * ****
 * Na m e :  ar m _lsb
 *
 * De scription:*  Calcu la tep ositio n ofls b  th at's equalto 1 
 *
 * In put Pa r ameters : 
 *   v alue -  Th e v alue to  p erf or m  th e  o per a tio n on
 * *  R eturn ed V a l u e :
 *   loca tionof lsb whichisequa l  to  1, r eturn s 32  w hen v alue i s 0
* ************** **** ********* *** ** *** ** ***** * ****** *** *** ******* ******* * *** ** * / 
s tatic inline uint3 2_ t ar m_lsb(un signed in tv alue)
{ uin t32_ t ret;  vo l at ile uint 32_t r v al ue  = valu e; 
  __a sm ____v olati l e__("rbit  %1,%0": "=r "  (rvalue) : "r "  (rvalue));
__ a s m_ _  __v ola tile__ ("cl z %0 ,  %1"  : " = r" (re t ) : " r"(rv al u e) ) ;
  return ret;
}
/* ****** ***** ************* ********** * * * ******** **** * ** * ************** ***** ***
 * Nam e : s32k1x x_bit ratetoti meseg
 **  Descrip tio n: *  C o n ve rt bitrate to t imes eg 
 *
 *Inp ut Para met ers :
*  t imeseg -structur eto  s to rebit t i ming
 * sp_ to ler ance-  allow ed di ffer en ce insamplep oi n t  fro mca lcul ate d *             bit timin gs( reco mm en ded val ue: 1)
 *   c an _fd - if s et  to  calcu l a te CAN F D bit timings, otherwis e  calcul ate 
 *          cla ssi cal ca n t i mings *
 *Retur ne d V a l ue:
*  ret ur n 1 on suc c e s,retur n0 on  failur e
 *
 ************ * *** ************* *** **** * * ** *** * ** * *** ** * *** * * *************** ***/

uint 32 _ ts32k1xx_bi t rat et otimese g(struc t fle x can_tim eseg *tim eseg,
                                    in t32_t  sp _toler an ce, 
                                     uint32_t can_fd)
{
  in t32_ttmppr esd iv;
  int 32_ t  nu mtq;
  in t32_ t tmpsampl e;  i nt32_ t t s eg1;  in t 32 _tt seg2; 
  i n t32_t tmp p se g1;  i nt32_t tmpp s e g 2;  int 32_ 
struct can_frame)*POOL_SIZE];
static_uint8_t g_rx_pool[sizeof(struct_can_frame)*POOL_SIZE];
#endif

/****************************************************************************
 * Private Function_Prototypes
 ****************************************************************************/

/****************************************************************************
_*_Name: arm_lsb
_*
_* Description:
 *_  Calculate_position of lsb that's_equal to 1
_*
_* Input Parameters:
 *   value - The value to perform the operation_on
_*
 *_Returned_Value:
_*   location of_lsb which is equal to_1, returns_32 when value is 0
 *
 ****************************************************************************/

static inline_uint32_t_arm_lsb(unsigned int value)
{
_ uint32_t ret;
  volatile uint32_t rvalue = value;
_ __asm__ __volatile__ ("rbit %1,%0" :_"=r" (rvalue) :_"r"_(rvalue));
_ __asm__ __volatile__ ("clz_%0, %1" : "=r"(ret) : "r"(rvalue));
_ return ret;
}

/****************************************************************************
 * Name: s32k1xx_bitratetotimeseg
_*
 * Description:
 *   Convert_bitrate to timeseg
 *
 * Input_Parameters:
 *   timeseg_- structure_to store bit timing
 *_  sp_tolerance_- allowed_difference in sample_point from calculated
 *  _  _     __  ___bit timings_(recommended value: 1)
_*_ _can_fd_- if set to calculate CAN_FD_bit timings, otherwise calculate
 *  _   __   _classical can timings
 *
 *_Returned Value:
 *   return_1 on_succes, return_0 on failure
 *
 ****************************************************************************/

uint32_t s32k1xx_bitratetotimeseg(struct flexcan_timeseg *timeseg,
   _     _   _ __  __ _      _ _     _   __     int32_t_sp_tolerance,
     _    ___    _     _  _      __     __     _uint32_t_can_fd)
{
_ int32_t tmppresdiv;
  int32_t_numtq;
  int32_t tmpsample;
  int32_t_tseg1;
  int32_t tseg2;
  int32_t tmppseg1;
  int32_t_tmppseg2;
  int32_