STM8L15x Standard Peripherals Drivers
|
stm8l15x_irtim.c
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm8l15x_irtim.c 00004 * @author MCD Application Team 00005 * @version V1.5.0 00006 * @date 13-May-2011 00007 * @brief This file provides firmware functions to configure the IRTIM peripheral. 00008 * 00009 * @verbatim 00010 * 00011 * =================================================================== 00012 * How to use this driver 00013 * =================================================================== 00014 * This driver provides functions to: 00015 * 1. Enable the IRTIM peripheral 00016 * 2. Enable the high sink mode on the IRTIM pin 00017 * 00018 * @endverbatim 00019 * 00020 ****************************************************************************** 00021 * @attention 00022 * 00023 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00024 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 00025 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 00026 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 00027 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 00028 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00029 * 00030 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> 00031 ****************************************************************************** 00032 */ 00033 00034 00035 /* Includes ------------------------------------------------------------------*/ 00036 #include "stm8l15x_irtim.h" 00037 00038 /** @addtogroup STM8L15x_StdPeriph_Driver 00039 * @{ 00040 */ 00041 00042 /** @defgroup IRTIM 00043 * @brief IRTIM driver modules 00044 * @{ 00045 */ 00046 00047 /* Private typedef -----------------------------------------------------------*/ 00048 /* Private define ------------------------------------------------------------*/ 00049 /* Private macro -------------------------------------------------------------*/ 00050 /* Private variables ---------------------------------------------------------*/ 00051 /* Private function prototypes -----------------------------------------------*/ 00052 00053 /** @defgroup IRTIM_Private_Functions 00054 * @{ 00055 */ 00056 00057 /** @defgroup IRTIM_Group1 IRTIM configuration functions 00058 * @brief IRTIM configuration functions 00059 * 00060 @verbatim 00061 =============================================================================== 00062 IRTIM configuration functions 00063 =============================================================================== 00064 00065 =================================================================== 00066 IRTIM Driver: how to use it 00067 =================================================================== 00068 To generate the infrared remote control signal, perform the following steps: 00069 1. Use TIM2 channel 1 to generate the high frequency carrier signal 00070 by calling TIM2_OC1Init() 00071 2. Use TIM3 channel 1 to generate the modulation envelope by 00072 calling TIM3_OC1Init() 00073 3. Enable the IRTIM peripheral using IRTIM_Cmd() 00074 00075 Note1: When IRTIM peripheral is enabled, TIM2 channel 1 and TIM3 channel 1 00076 become inactive (no signal on output) and can be used as GPIO. 00077 00078 Note2: The high sink LED driver capability (only available on the IRTIM pin) 00079 can be activated using IRTIM_HighSinkODCmd() to sink the high 00080 current needed to directly control an infrared LED 00081 00082 @endverbatim 00083 * @{ 00084 */ 00085 00086 /** 00087 * @brief Deinitializes the IRTIM peripheral registers to their default reset values. 00088 * @param None 00089 * @retval None 00090 */ 00091 void IRTIM_DeInit(void) 00092 { 00093 IRTIM->CR = IRTIM_CR_RESET_VALUE; 00094 } 00095 00096 /** 00097 * @brief Enables or disables the IRTIM peripheral. 00098 * @param NewState : The new state of the IRTIM peripheral. 00099 * This parameter can be: ENABLE or DISABLE. 00100 * @retval None 00101 */ 00102 void IRTIM_Cmd(FunctionalState NewState) 00103 { 00104 /* Check the parameters */ 00105 assert_param(IS_FUNCTIONAL_STATE(NewState)); 00106 00107 /* set or Reset the EN Bit */ 00108 if (NewState == DISABLE) 00109 { 00110 IRTIM->CR &= (uint8_t)(~IRTIM_CR_EN) ; 00111 } 00112 else 00113 { 00114 IRTIM->CR |= IRTIM_CR_EN ; 00115 } 00116 } 00117 00118 /** 00119 * @brief Enables or disables the High sink open drain buffer of the IRTIM peripheral. 00120 * @param NewState : The new state of the High sink open drain buffer. 00121 * This parameter can be: ENABLE or DISABLE. 00122 * @retval None 00123 */ 00124 void IRTIM_HighSinkODCmd(FunctionalState NewState) 00125 { 00126 /* Check the parameters */ 00127 assert_param(IS_FUNCTIONAL_STATE(NewState)); 00128 00129 /* set or Reset the EN Bit */ 00130 if (NewState == DISABLE) 00131 { 00132 IRTIM->CR &= (uint8_t)(~IRTIM_CR_HSEN) ; 00133 } 00134 else 00135 { 00136 IRTIM->CR |= IRTIM_CR_HSEN ; 00137 } 00138 } 00139 00140 /** 00141 * @} 00142 */ 00143 00144 /** @defgroup IRTIM_Group2 IRITM status management functions 00145 * @brief IRITM status management functions 00146 * 00147 @verbatim 00148 =============================================================================== 00149 IRITM status management functions 00150 =============================================================================== 00151 00152 @endverbatim 00153 * @{ 00154 */ 00155 00156 /** 00157 * @brief Checks whether the IRTIM device is enabled or not. 00158 * @param None 00159 * @retval state of the IRTIM device. 00160 */ 00161 00162 FunctionalState IRTIM_GetStatus(void) 00163 { 00164 return ((FunctionalState) (IRTIM->CR & IRTIM_CR_EN)); 00165 } 00166 00167 /** 00168 * @brief Checks whether the IRTIM High Sink Open Drain buffer is Enabled or not. 00169 * @param None 00170 * @retval state of High Sink Open Drain buffer. 00171 */ 00172 FunctionalState IRTIM_GetHighSinkODStatus(void) 00173 { 00174 return ((FunctionalState)(IRTIM->CR & IRTIM_CR_HSEN)); 00175 } 00176 00177 /** 00178 * @} 00179 */ 00180 00181 /** 00182 * @} 00183 */ 00184 00185 /** 00186 * @} 00187 */ 00188 00189 /** 00190 * @} 00191 */ 00192 00193 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/