亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? stm8_tsl_rc_multichannelkey.c

?? 基于STM8 的電容按鍵算法, 方案便宜
?? C
?? 第 1 頁 / 共 3 頁
字號:
u8 TSL_MCKey_Position(void)
{

  u8 Index1, Index2;
#if CHANNEL_PER_MCKEY == 8  
  u8 Index3;
#endif
  u16 Major, Minor, SectorComputation;
  s16 NewPosition;
  u8 uNewPosition;
  u32 tmpdelta;
  u8 PositionCorrection;
  u8 retval = 0x00;
  
  Delta1 = 0;
  Delta2 = 0;
  Delta3 = 0;

  Index1 = 0;
  Index2 = 0;
#if CHANNEL_PER_MCKEY == 8  
  Index3 = 0;
#endif

  for ( ChannelIndex = 0; ChannelIndex < CHANNEL_PER_MCKEY; ChannelIndex++ )
  {
    
    TSL_MCKey_DeltaCalculation( ChannelIndex );
   
    // Delta must be positive only otherwise it is noise
    if ( Delta < 0 )
    {
      Delta = 0;
    }
    
    /* We normalize the Delta */
    tmpdelta = (u32)(Delta * (u32)(pMCKeyStruct->Channel[0].Reference));
    tmpdelta = tmpdelta / pMCKeyStruct->Channel[ChannelIndex].Reference;
    Delta = (s16)tmpdelta;
   
    /* Apply a fixed coefficient */
#if NUMBER_OF_MULTI_CHANNEL_KEYS > 1
  if (KeyIndex == 0) // MCKEY1
    {
#endif
      if (MCKEY1_DELTA_COEFF[ChannelIndex] != 0x0100)
      {
        tmpdelta = (u32)(Delta * MCKEY1_DELTA_COEFF[ChannelIndex]);
        Delta = (s16)(tmpdelta >> (u8)8);
      }
#if NUMBER_OF_MULTI_CHANNEL_KEYS > 1
    }   
    else // MCKEY2
    {
      if (MCKEY2_DELTA_COEFF[ChannelIndex] != 0x0100)
      {
        tmpdelta = (u32)(Delta * MCKEY2_DELTA_COEFF[ChannelIndex]);
        Delta = (s16)(tmpdelta >> (u8)8);
      }
    }
#endif
   
    /* Sort the biggest, middle and lowest signals measured
       - Delta1 and Index1 = biggest
       - Delta2 and Index2 = middle
       - Delta3 and Index3 = lowest */
    if ( Delta > Delta1 )
    {
      Delta3 = Delta2;
      Delta2 = Delta1;
      Delta1 = Delta;
#if CHANNEL_PER_MCKEY == 8
      Index3 = Index2;
#endif
      Index2 = Index1;
      Index1 = ChannelIndex;
    }
    else
    {
      if ( Delta > Delta2 )
      {
        Delta3 = Delta2;
        Delta2 = Delta;
#if CHANNEL_PER_MCKEY == 8        
        Index3 = Index2;
#endif
        Index2 = ChannelIndex;
      }
      else
      {
        if ( Delta > Delta3 )
        {
#if CHANNEL_PER_MCKEY == 8          
          Index3 = ChannelIndex;
#endif
          Delta3 = Delta;
        }
      }
    }

  } /* for all channels */

  /* Noise filter: we need at least two significant Delta measurements */
  if (Delta2 < ((u8)(pMCKeyStruct->EndDetectThreshold >> 1)) - 1)
  {
    return retval;
  }

  //----------------------------------------------------------------------------
  // Position calculation...
  //----------------------------------------------------------------------------
  
  /*----------------------------------------------------------------------------
    B = Biggest signal measured (Delta1/Index1)
    M = Middle signal measured (Delta2/Index2)
    S = Smallest signal measured (Delta3/Index3)
    
    - The equation to find the position is:
      Position = Offset +/- [ Sector_Size x ( Major / (Major + Minor) ) ]
   
    - The Offset is the position of the middle of the Middle signal segment.
      All the Offset values are stored in the ROM table Table_POSITION_OFFSET.
   
    - Major = Biggest - Smallest signals
      Minor = Middle - Smallest signals
   
    - The Sector_Size depends of the number of channels used
  ----------------------------------------------------------------------------*/

  /* Calculates the Major and Minor parameters */
  Minor = Delta2 - Delta3; // Middle - Smallest signals
  Major = Delta1 - Delta3; // Biggest - Smallest signals

#if NUMBER_OF_MULTI_CHANNEL_KEYS > 1
  if (KeyIndex == 0) // MCKEY1
  {
#endif
    NewPosition = MCKEY1_TABLE_POSITION_OFFSET[Index1][Index2];
    SectorComputation = MCKEY1_SECTOR_COMPUTATION;
    PositionCorrection = MCKEY1_POSITION_CORRECTION;
#if NUMBER_OF_MULTI_CHANNEL_KEYS > 1
  }
  else // MCKEY2
  {
    NewPosition = MCKEY2_TABLE_POSITION_OFFSET[Index1][Index2];
    SectorComputation = MCKEY2_SECTOR_COMPUTATION;
    PositionCorrection = MCKEY2_POSITION_CORRECTION;
  }
#endif

  /* Calculates: [ Sector_Size x ( Major / (Major + Minor) ) ] */
  SectorComputation = Major * SectorComputation;
  SectorComputation = SectorComputation / ( Major + Minor );

  // Use the sign bit from table to define the interpretation direction.
  // The NewPosition is multiplied by 2 because the Offset stored in the ROM
  // table is divided by 2...
  if ( NewPosition > 0 ) // means Offset is > 0 in the ROM table
  {
    NewPosition = (s16)(NewPosition << 1); /*lint !e701 suppress info on this line only */
    NewPosition += SectorComputation;
  }
  else // means Offset is <= 0 in the ROM table
  {
    NewPosition = (s16)((-NewPosition) << 1); /*lint !e701 suppress info on this line only */
    NewPosition -= SectorComputation;
  }

  if (pMCKeyStruct->Setting.b.MCKEY_TYPE) // It's a Slider...
  {
    
    /* First adjustment used to shift all the values to obtain the "zero" */
    if (NewPosition > 0)
    {
      NewPosition -= PositionCorrection;
    }
    else
    {
      NewPosition = NewPosition + 256 - PositionCorrection;
    }
    
    /* Second adjustment used to clamp the values at extremities of slider */
    if (NewPosition < 0)
    {
      NewPosition = 0;
    }
    
    if (NewPosition > 255)
    {
      NewPosition = 255;
    }
   
  }
  else // It's a Wheel: we keep only the low byte
  {
    NewPosition = (u8)NewPosition;
  }
  
  //----------------------------------------------------------------------------
  // Direction Change Process
  //----------------------------------------------------------------------------

#if MCKEY_DIRECTION_CHANGE_ENABLED > 0

  if (pMCKeyStruct->Setting.b.DIRECTION) // Anticlockwise direction ...
  {
   
    // Check Direction changed and Position overflow from 0x00 to 0xFF not realized !
    if ( ((u8)NewPosition > pMCKeyStruct->UnScaledPosition) && (((u8)NewPosition - pMCKeyStruct->UnScaledPosition) < MCKEY_DIRECTION_CHANGE_MAX_DISPLACEMENT) )
    {
      if ( NewPosition < (u16)(pMCKeyStruct->UnScaledPosition + pMCKeyStruct->DirectionChangeThreshold) )
      {
        pMCKeyStruct->Channel[1].IntegratorCounter = pMCKeyStruct->DirectionChangeIntegrator;
        return retval;
      }
      else
      {
        pMCKeyStruct->Channel[1].IntegratorCounter--;
        if ( !pMCKeyStruct->Channel[1].IntegratorCounter )
        {
          pMCKeyStruct->Channel[1].IntegratorCounter = pMCKeyStruct->DirectionChangeIntegrator;
          pMCKeyStruct->Setting.b.DIRECTION = 0;  // New direction accepted: clockwise.
        }
        else
        {
          return retval;
        }
      }
    }
    
    // Check position overflow from 0xFF to 0x00 to be filtered !
    if ( (NewPosition + MCKEY_DIRECTION_CHANGE_MAX_DISPLACEMENT) < pMCKeyStruct->UnScaledPosition )
    {
      if ( (NewPosition + MCKEY_DIRECTION_CHANGE_TOTAL_STEPS) < (u16)(pMCKeyStruct->UnScaledPosition + pMCKeyStruct->DirectionChangeThreshold) )
      {
        pMCKeyStruct->Channel[1].IntegratorCounter = pMCKeyStruct->DirectionChangeIntegrator;
        return retval;
      }
      else
      {
        pMCKeyStruct->Channel[1].IntegratorCounter--;
        if ( !pMCKeyStruct->Channel[1].IntegratorCounter )
        {
          pMCKeyStruct->Channel[1].IntegratorCounter = pMCKeyStruct->DirectionChangeIntegrator;
          pMCKeyStruct->Setting.b.DIRECTION = 0;  // New direction accepted: clockwise.
        }
        else
        {
          return retval;
        }
      }
    }
    
  }
  else // Clockwise direction... DEFAULT SETTING !
  {
    
    // Check Direction changed and Position overflow from 0xFF to 0x00 not realized !
    if ( ((u8)NewPosition < pMCKeyStruct->UnScaledPosition) && ((pMCKeyStruct->UnScaledPosition - (u8)NewPosition) < MCKEY_DIRECTION_CHANGE_MAX_DISPLACEMENT) )
    {
      if ( (NewPosition + pMCKeyStruct->DirectionChangeThreshold) > pMCKeyStruct->UnScaledPosition )
      {
        pMCKeyStruct->Channel[1].IntegratorCounter = pMCKeyStruct->DirectionChangeIntegrator;
        return retval;
      }
      else
      {
        pMCKeyStruct->Channel[1].IntegratorCounter--;
        if ( !pMCKeyStruct->Channel[1].IntegratorCounter )
        {
          pMCKeyStruct->Channel[1].IntegratorCounter = pMCKeyStruct->DirectionChangeIntegrator;
          pMCKeyStruct->Setting.b.DIRECTION = 1;  // New direction accepted: anticlockwise.
        }
        else
        {
          return retval;
        }
      }
    }
    
    // Check position overflow from 0x00 to 0xFF to be filtered !
    if ( NewPosition > (u16)(pMCKeyStruct->UnScaledPosition + MCKEY_DIRECTION_CHANGE_MAX_DISPLACEMENT) )
    {
      if ( (NewPosition + pMCKeyStruct->DirectionChangeThreshold) > (u16)(pMCKeyStruct->UnScaledPosition + MCKEY_DIRECTION_CHANGE_TOTAL_STEPS) )
      {
        pMCKeyStruct->Channel[1].IntegratorCounter = pMCKeyStruct->DirectionChangeIntegrator;
        return retval;
      }
      else
      {
        pMCKeyStruct->Channel[1].IntegratorCounter--;
        if ( !pMCKeyStruct->Channel[1].IntegratorCounter )
        {
          pMCKeyStruct->Channel[1].IntegratorCounter = pMCKeyStruct->DirectionChangeIntegrator;
          pMCKeyStruct->Setting.b.DIRECTION = 1;  // New direction accepted: anticlockwise.
        }
        else
        {
          return retval;
        }
      }
    }
    
  }

#endif // MCKEY_DIRECTION_CHANGE_ENABLED

  //----------------------------------------------------------------------------
  // Final result...
  //----------------------------------------------------------------------------
  
  // The UnScaledPosition parameter is always updated
  // The Position parameter is updated only if different from the previous one  

  pMCKeyStruct->UnScaledPosition = (u8)NewPosition;
  
  uNewPosition = (u8)((u8)NewPosition >> (MCKEY_RESOLUTION_CALCULATION - pMCKeyStruct->Resolution));
  
  if ( pMCKeyStruct->Position != uNewPosition )
  {
    pMCKeyStruct->Position = uNewPosition;
    pMCKeyStruct->Setting.b.POSCHANGED = 1; /* Warning: Application layer must reset this flag */
    retval = 0xFF;
  }

  return retval;
  
}


/**
  ******************************************************************************
  * @brief Check for customer code setting and adapt key state.
  * @par Parameters:
  * None
  * @retval void None
  * @par Required preconditions:
  * None
  ******************************************************************************
  */
void TSL_MCKey_CheckDisabled(void)
{

  if ( !pMCKeyStruct->Setting.b.ENABLED )
  {
    TSL_MCKey_SetDisabledState( );
  }

}


/**
  ******************************************************************************
  * @brief Check for customer code setting and adapt key state.
  * @par Parameters:
  * None
  * @retval void None
  * @par Required preconditions:
  * None
  ******************************************************************************
  */
void TSL_MCKey_CheckEnabled(void)
{

  if ( pMCKeyStruct->Setting.b.ENABLED && pMCKeyStruct->Setting.b.IMPLEMENTED )
  {
    TSL_MCKey_SetCalibrationState( );
  }

}


/**
  ******************************************************************************
  * @brief Verify the last burst sequence gave a result within the authorized range.
  * @par Parameters:
  * None
  * @retval u8 Return 0 if OK, 0xFF if Error.
  * @par Required preconditions:
  * None
  ******************************************************************************
  */
u8 TSL_MCKey_CheckErrorCondition(void)
{

  for ( ChannelIndex = 0; ChannelIndex < CHANNEL_PER_MCKEY; ChannelIndex++ )
  {
    if ( (pMCKeyStruct->Channel[ChannelIndex].LastMeas < MCKEY_MIN_ACQUISITION)
         || (pMCKeyStruct->Channel[ChannelIndex].LastMeas > MCKEY_MAX_ACQUISITION) )
    {
      return 0xFF;  // Error case !
    }
  }
  
  return 0;
  
}

//============================================================================
//-----         CONDITIONAL COMPILING FOR MCKEYS !!!               -----------
#endif
//============================================================================

/*********************** (c) 2009 STMicroelectronics **************************/

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美亚日韩国产aⅴ精品中极品| 裸体一区二区三区| 欧美国产一区视频在线观看| 日韩欧美国产三级| 亚洲国产精品ⅴa在线观看| 成人欧美一区二区三区视频网页| 亚洲一区二区三区中文字幕| 香蕉久久夜色精品国产使用方法 | 狂野欧美性猛交blacked| 高清成人在线观看| 精品少妇一区二区三区视频免付费 | 国产三级欧美三级日产三级99 | 亚洲一区二区综合| 成人午夜电影网站| 日韩欧美区一区二| 视频一区二区欧美| 欧美久久一二区| 亚洲国产视频一区| 日本韩国欧美在线| 一区二区三区在线视频播放| 成人a免费在线看| 国产日韩欧美一区二区三区综合| 久久国产福利国产秒拍| 日韩一本二本av| 日本最新不卡在线| 日韩欧美另类在线| 日韩av一区二区在线影视| 91精品国产综合久久久蜜臀粉嫩| 国产成人综合视频| 午夜影院久久久| 日韩美女久久久| 国产精品免费丝袜| 日韩亚洲欧美综合| 一本到不卡精品视频在线观看| 黄页网站大全一区二区| 午夜免费久久看| 亚洲成人动漫精品| 亚洲主播在线播放| 亚洲亚洲精品在线观看| 丁香另类激情小说| 国产日韩亚洲欧美综合| 欧美精品国产精品| 99精品国产视频| 国产一区二区三区四区五区美女| 亚洲欧美日韩精品久久久久| 日韩亚洲欧美成人一区| 91福利小视频| 成人免费视频视频| 亚洲国产欧美日韩另类综合 | 亚洲一区二区三区小说| 国产拍欧美日韩视频二区| 日韩三级高清在线| 欧美日韩精品一区二区三区四区 | 国产精品久久久久久久久晋中 | 精品动漫一区二区三区在线观看| 国产高清精品在线| 日本欧美一区二区在线观看| 亚洲乱码日产精品bd| 亚洲日本韩国一区| 亚洲欧美日韩一区二区| 亚洲精品成人a在线观看| 亚洲精品你懂的| 日本欧美一区二区三区乱码| 日本不卡视频在线| 国产激情一区二区三区四区 | 国产三级久久久| 中文字幕在线免费不卡| 亚洲在线中文字幕| 日日夜夜免费精品| 成人一区二区三区在线观看| 色婷婷综合久久久久中文 | 日韩av在线发布| 国产黄色精品视频| 欧美日韩国产高清一区二区三区 | 日本成人在线一区| 成人黄色国产精品网站大全在线免费观看 | 色一情一乱一乱一91av| 欧美军同video69gay| 中文字幕欧美激情| 免费观看日韩电影| 日本高清无吗v一区| 精品国产1区2区3区| 亚洲在线视频一区| 国产成人鲁色资源国产91色综| 在线视频国内自拍亚洲视频| 久久人人97超碰com| 日本美女视频一区二区| 欧美在线啊v一区| 成人免费小视频| 岛国一区二区三区| 久久综合狠狠综合| 美腿丝袜一区二区三区| 欧美性做爰猛烈叫床潮| 一区二区在线免费观看| 国产高清精品在线| 国产视频视频一区| 激情综合网激情| 久久亚洲精华国产精华液 | 亚洲不卡在线观看| 欧美三级日本三级少妇99| 亚洲麻豆国产自偷在线| 色天使久久综合网天天| 亚洲欧美成人一区二区三区| av成人免费在线观看| 国产精品久久久久久久久搜平片 | 国产大陆精品国产| 国产日韩欧美一区二区三区乱码 | 亚洲乱码中文字幕综合| av亚洲精华国产精华精华| 亚洲欧洲精品天堂一级| 色综合色综合色综合色综合色综合| 国产精品乱码一区二三区小蝌蚪| 成人激情小说网站| 国产精品成人免费在线| 色综合天天综合色综合av | 一区二区三区久久| 欧美夫妻性生活| 国内精品国产三级国产a久久| 久久久久99精品国产片| 色综合天天综合网天天看片| 午夜精品福利一区二区三区蜜桃| 91精品国产一区二区人妖| 国产99久久久国产精品免费看 | 国产精品久久久久影院亚瑟 | 一区二区三区在线观看视频| 这里只有精品免费| 不卡视频免费播放| 麻豆精品一区二区三区| 亚洲美女精品一区| 久久久亚洲精华液精华液精华液| 欧洲日韩一区二区三区| 国产美女精品一区二区三区| 亚洲成人在线网站| 国产精品久久久久久久岛一牛影视 | 成人av网站在线观看| 久久精品国产第一区二区三区| 综合久久给合久久狠狠狠97色| 欧美r级电影在线观看| 91久久一区二区| 成人aa视频在线观看| 久久99深爱久久99精品| 午夜精品视频一区| 亚洲美女区一区| 国产精品久久久久桃色tv| 精品国内二区三区| 日韩一区二区免费高清| 欧美日韩黄色影视| 欧美亚洲日本国产| 日本高清不卡在线观看| 日本精品一级二级| 91麻豆123| 91电影在线观看| 欧美日韩一区二区电影| 欧美视频一区在线| 7777精品伊人久久久大香线蕉最新版| 欧美中文字幕一区二区三区亚洲 | 欧洲精品一区二区| 欧美揉bbbbb揉bbbbb| 这里只有精品视频在线观看| 欧美α欧美αv大片| 欧美国产精品劲爆| 首页综合国产亚洲丝袜| 日本中文字幕一区二区视频| 麻豆免费看一区二区三区| 国产一区二区91| 91尤物视频在线观看| 欧美日韩中文精品| 精品国产一区二区三区av性色| 久久精品一区二区三区不卡| 亚洲色欲色欲www| 五月综合激情日本mⅴ| 国产福利精品导航| 91久久人澡人人添人人爽欧美| 欧美一区二区久久久| 亚洲天堂2014| 九一九一国产精品| 欧美系列亚洲系列| 欧美国产成人在线| 久久不见久久见免费视频7| 99久久精品免费| 3atv在线一区二区三区| 国产精品久久福利| 精品一区二区在线视频| 色综合一个色综合| 国产精品美女久久久久高潮| 日韩精品一卡二卡三卡四卡无卡| 国产成人久久精品77777最新版本| 欧美日韩一区小说| 亚洲免费毛片网站| fc2成人免费人成在线观看播放| 欧美α欧美αv大片| 日韩成人一级大片| 91精品国产免费久久综合| |精品福利一区二区三区| 不卡在线观看av| **欧美大码日韩| 99国产精品久久久久久久久久| 欧美激情综合五月色丁香 | 亚洲一区成人在线| 精品视频在线视频|