⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm8l15x_irtim.c

📁 STM8L的tim4定时器使用
💻 C
字号:
/**
  ******************************************************************************
  * @file    stm8l15x_irtim.c
  * @author  MCD Application Team
  * @version V1.5.0
  * @date    13-May-2011
  * @brief   This file provides firmware functions to configure the IRTIM peripheral.
  *
  *  @verbatim
  *  
  *          ===================================================================
  *                                 How to use this driver
  *          ===================================================================
  *          This driver provides functions to:
  *             1. Enable the IRTIM peripheral
  *             2. Enable the high sink mode on the IRTIM pin 
  *               
  *  @endverbatim
  *    
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  ******************************************************************************  
  */


/* Includes ------------------------------------------------------------------*/
#include "stm8l15x_irtim.h"

/** @addtogroup STM8L15x_StdPeriph_Driver
  * @{
  */
  
/** @defgroup IRTIM 
  * @brief IRTIM driver modules
  * @{
  */
   
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/

/** @defgroup IRTIM_Private_Functions
  * @{
  */

/** @defgroup IRTIM_Group1 IRTIM configuration functions
 *  @brief   IRTIM configuration functions 
 *
@verbatim   
 ===============================================================================
                       IRTIM configuration functions
 ===============================================================================  
  
       ===================================================================      
                       IRTIM Driver: how to use it
       =================================================================== 
       To generate the infrared remote control signal, perform the following steps:
          1. Use TIM2 channel 1 to generate the high frequency carrier signal
             by calling TIM2_OC1Init()
          2. Use TIM3 channel 1 to generate the modulation envelope by
             calling TIM3_OC1Init()
          3. Enable the IRTIM peripheral using IRTIM_Cmd()

          Note1: When IRTIM peripheral is enabled, TIM2 channel 1 and TIM3 channel 1
                 become inactive (no signal on output) and can be used as GPIO.
                 
          Note2: The high sink LED driver capability (only available on the IRTIM pin)
                 can be activated using IRTIM_HighSinkODCmd() to sink the high 
                 current needed to directly control an infrared LED

@endverbatim
  * @{
  */

/**
  * @brief  Deinitializes the IRTIM peripheral registers to their default reset values.
  * @param  None
  * @retval None
  */
void IRTIM_DeInit(void)
{
  IRTIM->CR = IRTIM_CR_RESET_VALUE;
}

/**
  * @brief  Enables or disables the IRTIM peripheral.
  * @param  NewState : The new state of the IRTIM peripheral.
    *         This parameter can be: ENABLE or DISABLE.
  * @retval None
  */
void IRTIM_Cmd(FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_FUNCTIONAL_STATE(NewState));

  /* set or Reset the EN Bit */
  if (NewState ==   DISABLE)
  {
    IRTIM->CR &= (uint8_t)(~IRTIM_CR_EN) ;
  }
  else
  {
    IRTIM->CR |= IRTIM_CR_EN ;
  }
}

/**
  * @brief  Enables or disables the High sink open drain buffer of the IRTIM peripheral.
  * @param  NewState : The new state of the High sink open drain buffer.
    *         This parameter can be: ENABLE or DISABLE.
  * @retval None
  */
void IRTIM_HighSinkODCmd(FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_FUNCTIONAL_STATE(NewState));

  /* set or Reset the EN Bit */
  if (NewState == DISABLE)
  {
    IRTIM->CR &= (uint8_t)(~IRTIM_CR_HSEN) ;
  }
  else
  {
    IRTIM->CR |= IRTIM_CR_HSEN ;
  }
}

/**
  * @}
  */

/** @defgroup IRTIM_Group2 IRITM status management functions
 *  @brief    IRITM status management functions 
 *
@verbatim   
 ===============================================================================
                     IRITM status management functions
 ===============================================================================  

@endverbatim
  * @{
  */

/**
  * @brief  Checks whether the IRTIM device is enabled or not.
  * @param  None
  * @retval state of the IRTIM device.
  */

FunctionalState IRTIM_GetStatus(void)
{
  return ((FunctionalState) (IRTIM->CR & IRTIM_CR_EN));
}

/**
  * @brief  Checks whether the IRTIM High Sink Open Drain buffer is Enabled or not.
  * @param  None
  * @retval state of High Sink Open Drain buffer.
  */
FunctionalState IRTIM_GetHighSinkODStatus(void)
{
  return ((FunctionalState)(IRTIM->CR & IRTIM_CR_HSEN));
}

/**
  * @}
  */ 

/**
  * @}
  */ 
  
/**
  * @}
  */

/**
  * @}
  */
  
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -