示例#1
0
/**
 * \brief      Enables or disables the SysTick counter.
 * \param SysTick_Counter new state of the SysTick counter.
*                    This parameter can be one of the following values:
*                       - SysTick_Counter_Disable: Disable counter
*                       - SysTick_Counter_Enable: Enable counter
*                       - SysTick_Counter_Clear: Clear counter value to 0
 */
void
SysTick_CounterCmd(uint32_t SysTick_Counter)
{
  /* Check the parameters */
  assert_param(IS_SYSTICK_COUNTER(SysTick_Counter));

  if(SysTick_Counter == SysTick_Counter_Enable) {
    SysTick->CTRL |= SysTick_Counter_Enable;
  } else if(SysTick_Counter == SysTick_Counter_Disable) {
    SysTick->CTRL &= SysTick_Counter_Disable;
  } else {                      /* SysTick_Counter == SysTick_Counter_Clear */
    SysTick->VAL = SysTick_Counter_Clear;
  }
}
/*********************************************************************************************************//**
  * @brief  Enable or Disable the SysTick counter.
  * @param  SysTick_Counter: new state of the SysTick counter.
  *   This parameter can be one of the following values:
  *     @arg SYSTICK_COUNTER_DISABLE  : Disable counter
  *     @arg SYSTICK_COUNTER_ENABLE   : Enable counter
  *     @arg SYSTICK_COUNTER_CLEAR    : Clear counter value to 0
  * @retval None
  ***********************************************************************************************************/
void SYSTICK_CounterCmd(u32 SysTick_Counter)
{
  /* Check the parameters                                                                                   */
  Assert_Param(IS_SYSTICK_COUNTER(SysTick_Counter));

  if (SysTick_Counter == SYSTICK_COUNTER_CLEAR)
  {
    SysTick->VAL = SYSTICK_COUNTER_CLEAR;
  }
  else
  {
    if (SysTick_Counter == SYSTICK_COUNTER_ENABLE)
    {
      SysTick->CTRL |= SYSTICK_COUNTER_ENABLE;
    }
    else
    {
      SysTick->CTRL &= SYSTICK_COUNTER_DISABLE;
    }
  }
}
/*******************************************************************************
* Function Name  : SysTick_CounterCmd
* Description    : Enables or disables the SysTick counter.
* Input          : - SysTick_Counter: new state of the SysTick counter.
*                    This parameter can be one of the following values:
*                       - SysTick_Counter_Disable: Disable counter
*                       - SysTick_Counter_Enable: Enable counter
*                       - SysTick_Counter_Clear: Clear counter value to 0
* Output         : None
* Return         : None
*******************************************************************************/
void SysTick_CounterCmd(u32 SysTick_Counter)
{
  /* Check the parameters */
  assert(IS_SYSTICK_COUNTER(SysTick_Counter));

  if (SysTick_Counter == SysTick_Counter_Clear)
  {
    SysTick->VAL = SysTick_Counter_Clear;
  }
  else
  {
    if (SysTick_Counter == SysTick_Counter_Enable)
    {
      SysTick->CTRL |= SysTick_Counter_Enable;
    }
    else
    {
      SysTick->CTRL &= SysTick_Counter_Disable;
    }
  }
}