/**
******************************************************************************
* @file stm8l15x_tim1.c
* @author MCD Application Team
* @version V1.4.0
* @date 09/24/2010
* @brief This file provides all the TIM1 firmware functions.
******************************************************************************
* @copy
*
* 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>© COPYRIGHT 2010 STMicroelectronics</center></h2>
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8l15x_tim1.h"
/** @addtogroup STM8L15x_StdPeriph_Driver
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
static void TI1_Config(uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection,
uint8_t TIM1_ICFilter);
static void TI2_Config(uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection,
uint8_t TIM1_ICFilter);
static void TI3_Config(uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection,
uint8_t TIM1_ICFilter);
static void TI4_Config(uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection,
uint8_t TIM1_ICFilter);
/**
* @addtogroup TIM1_Public_Functions
* @{
*/
/**
* @brief Deinitializes the TIM1 peripheral registers to their default reset values.
* @param None
* @retval None
*/
void TIM1_DeInit(void)
{
TIM1->CR1 = TIM1_CR1_RESET_VALUE;
TIM1->CR2 = TIM1_CR2_RESET_VALUE;
TIM1->SMCR = TIM1_SMCR_RESET_VALUE;
TIM1->ETR = TIM1_ETR_RESET_VALUE;
TIM1->IER = TIM1_IER_RESET_VALUE;
/* Disable channels */
TIM1->CCER1 = TIM1_CCER1_RESET_VALUE;
TIM1->CCER2 = TIM1_CCER2_RESET_VALUE;
/* Configure channels as inputs: it is necessary if lock level is equal to 2 or 3 */
TIM1->CCMR1 = 0x01;
TIM1->CCMR2 = 0x01;
TIM1->CCMR3 = 0x01;
TIM1->CCMR4 = 0x01;
/* Then reset channel registers: it also works if lock level is equal to 2 or 3 */
TIM1->CCER1 = TIM1_CCER1_RESET_VALUE;
TIM1->CCER2 = TIM1_CCER2_RESET_VALUE;
TIM1->CCMR1 = TIM1_CCMR1_RESET_VALUE;
TIM1->CCMR2 = TIM1_CCMR2_RESET_VALUE;
TIM1->CCMR3 = TIM1_CCMR3_RESET_VALUE;
TIM1->CCMR4 = TIM1_CCMR4_RESET_VALUE;
TIM1->CNTRH = TIM1_CNTRH_RESET_VALUE;
TIM1->CNTRL = TIM1_CNTRL_RESET_VALUE;
TIM1->PSCRH = TIM1_PSCRH_RESET_VALUE;
TIM1->PSCRL = TIM1_PSCRL_RESET_VALUE;
TIM1->ARRH = TIM1_ARRH_RESET_VALUE;
TIM1->ARRL = TIM1_ARRL_RESET_VALUE;
TIM1->CCR1H = TIM1_CCR1H_RESET_VALUE;
TIM1->CCR1L = TIM1_CCR1L_RESET_VALUE;
TIM1->CCR2H = TIM1_CCR2H_RESET_VALUE;
TIM1->CCR2L = TIM1_CCR2L_RESET_VALUE;
TIM1->CCR3H = TIM1_CCR3H_RESET_VALUE;
TIM1->CCR3L = TIM1_CCR3L_RESET_VALUE;
TIM1->CCR4H = TIM1_CCR4H_RESET_VALUE;
TIM1->CCR4L = TIM1_CCR4L_RESET_VALUE;
TIM1->OISR = TIM1_OISR_RESET_VALUE;
TIM1->EGR = 0x01; /* TIM1_EGR_UG */
TIM1->DTR = TIM1_DTR_RESET_VALUE;
TIM1->BKR = TIM1_BKR_RESET_VALUE;
TIM1->RCR = TIM1_RCR_RESET_VALUE;
TIM1->SR1 = TIM1_SR1_RESET_VALUE;
TIM1->SR2 = TIM1_SR2_RESET_VALUE;
}
/**
* @brief Initializes the TIM1 Time Base Unit according to the specified parameters.
* @param TIM1_Prescaler specifies the Prescaler value.
* @param TIM1_CounterMode specifies the counter mode from
* @ref TIM1_CounterMode_TypeDef .
* @param TIM1_Period specifies the Period value.
* @param TIM1_RepetitionCounter specifies the Repetition counter value
* @retval None
*/
void TIM1_TimeBaseInit(uint16_t TIM1_Prescaler,
TIM1_CounterMode_TypeDef TIM1_CounterMode,
uint16_t TIM1_Period,
uint8_t TIM1_RepetitionCounter)
{
/* Check parameters */
assert_param(IS_TIM1_COUNTER_MODE(TIM1_CounterMode));
/* Set the Autoreload value */
TIM1->ARRH = (uint8_t)(TIM1_Period >> 8);
TIM1->ARRL = (uint8_t)(TIM1_Period);
/* Set the Prescaler value */
TIM1->PSCRH = (uint8_t)(TIM1_Prescaler >> 8);
TIM1->PSCRL = (uint8_t)(TIM1_Prescaler);
/* Select the Counter Mode */
TIM1->CR1 = (uint8_t)((uint8_t)(TIM1->CR1 & (uint8_t)(~(TIM1_CR1_CMS | TIM1_CR1_DIR)))
| (uint8_t)(TIM1_CounterMode));
/* Set the Repetition Counter value */
TIM1->RCR = TIM1_RepetitionCounter;
}
/**
* @brief Initializes the TIM1 Channel1 according to the specified parameters.
* @param TIM1_OCMode specifies the Output Compare mode from
* @ref TIM1_OCMode_TypeDef.
* @param TIM1_OutputState specifies the Output State from
* @ref TIM1_OutputState_TypeDef.
* @param TIM1_OutputNState specifies the Complementary Output State from
* @ref TIM1_OutputNState_TypeDef.
* @param TIM1_Pulse specifies the Pulse width value.
* @param TIM1_OCPolarity specifies the Output Compare Polarity from
* @ref TIM1_OCPolarity_TypeDef.
* @param TIM1_OCNPolarity specifies the Complementary Output Compare
* Polarity from @ref TIM1_OCNPolarity_TypeDef.
* @param TIM1_OCIdleState specifies the Output Compare Idle State from
* @ref TIM1_OCIdleState_TypeDef.
* @param TIM1_OCNIdleState specifies the Complementary Output Compare
* Idle State from @ref TIM1_OCIdleState_TypeDef.
* @retval None
*/
void TIM1_OC1Init(TIM1_OCMode_TypeDef TIM1_OCMode,
TIM1_OutputState_TypeDef TIM1_OutputState,
TIM1_OutputNState_TypeDef TIM1_OutputNState,
uint16_t TIM1_Pulse,
TIM1_OCPolarity_TypeDef TIM1_OCPolarity,
TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity,
TIM1_OCIdleState_TypeDef TIM1_OCIdleState,
TIM1_OCNIdleState_TypeDef TIM1_OCNIdleState)
{
/* Check the parameters */
assert_param(IS_TIM1_OC_MODE(TIM1_OCMode));
assert_param(IS_TIM1_OUTPUT_STATE(TIM1_OutputState));
assert_param(IS_TIM1_OUTPUTN_STATE(TIM1_OutputNState));
assert_param(IS_TIM1_OC_POLARITY(TIM1_OCPolarity));
assert_param(IS_TIM1_OCN_POLARITY(TIM1_OCNPolarity));
assert_param(IS_TIM1_OCIDLE_STATE(TIM1_OCIdleState));
assert_param(IS_TIM1_OCNIDLE_STATE(TIM1_OCNIdleState));
/* Disable the Channel 1: Reset the CCE Bit, Set the Output State ,
the Output N State, the Output Polarity & the Output N Polarity*/
TIM1->CCER1 &= (uint8_t)(~(TIM1_CCER1_CC1E | TIM1_CCER1_CC1NE
| TIM1_CCER1_CC1P | TIM1_CCER1_CC1NP));
/* Set the Output State & Set the Output N State & Set the Output Polarity
& Set the Output N Polarity */
TIM1->CCER1 |= (uint8_t)((uint8_t)((uint8_t)(TIM1_OutputState & TIM1_CCER1_CC1E)
| (uint8_t)(TIM1_OutputNState & TIM1_CCER1_CC1NE))
| (uint8_t)( (uint8_t)(TIM1_OCPolarity & TIM1_CCER1_CC1P)
| (uint8_t)(TIM1_OCNPolarity & TIM1_CCER1_CC1NP)));
/* Reset the Output Compare Bits & Set the Ouput Compare Mode */
TIM1->CCMR1 = (uint8_t)((uint8_t)(TIM1->CCMR1 & (uint8_t)(~TIM1_CCMR_OCM))
| (uint8_t)TIM1_OCMode);
/* Reset the Output Idle state & the Outp
没有合适的资源?快使用搜索试试~ 我知道了~
STM8L052 halt.rar_STM8L052_Stm8l052低功耗_stm8L052 HALT_stm8l052 低功
共173个文件
h:31个
cout:30个
o:30个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 138 浏览量
2022-09-23
19:29:53
上传
评论
收藏 5.78MB RAR 举报
温馨提示
stm8l052 是一个低功耗单片机, halt低功耗模式可以最大降低功耗
资源推荐
资源详情
资源评论
收起资源包目录
STM8L052 halt.rar_STM8L052_Stm8l052低功耗_stm8L052 HALT_stm8l052 低功 (173个子文件)
BoYue_STM8L15xC6_Library.Debug.cspy.bat 1KB
BoYue_STM8L15xC6_Library.cspy.bat 1KB
BoYue_STM8L15xC6_Library.pbd.browse 1.02MB
stm8l15x_tim1.c 79KB
stm8l15x_rtc.c 57KB
stm8l15x_tim2.c 49KB
stm8l15x_tim5.c 49KB
stm8l15x_tim3.c 49KB
stm8l15x_i2c.c 41KB
stm8l15x_usart.c 26KB
stm8l15x_flash.c 24KB
stm8l15x_dac.c 21KB
stm8l15x_clk.c 20KB
stm8l15x_adc.c 20KB
stm8l15x_spi.c 16KB
stm8l15x_comp.c 16KB
stm8l15x_dma.c 16KB
stm8l15x_tim4.c 15KB
stm8l15x_it.c 13KB
stm8l15x_exti.c 13KB
stm8l15x_lcd.c 12KB
stm8l15x_syscfg.c 11KB
stm8l15x_aes.c 10KB
stm8l15x_itc.c 10KB
stm8l15x_gpio.c 9KB
stm8l15x_pwr.c 6KB
stm8l15x_wfe.c 6KB
stm8l15x_beep.c 5KB
stm8l15x_wwdg.c 4KB
stm8l15x_irtim.c 4KB
stm8l15x_iwdg.c 3KB
stm8l15x_rst.c 3KB
main.c 2KB
stm8l15x_syscfg.pbi.cout 11KB
stm8l15x_flash.pbi.cout 11KB
stm8l15x_irtim.pbi.cout 11KB
stm8l15x_usart.pbi.cout 11KB
stm8l15x_tim1.pbi.cout 11KB
stm8l15x_iwdg.pbi.cout 11KB
stm8l15x_tim4.pbi.cout 11KB
stm8l15x_beep.pbi.cout 11KB
stm8l15x_tim5.pbi.cout 11KB
stm8l15x_exti.pbi.cout 11KB
stm8l15x_gpio.pbi.cout 11KB
stm8l15x_comp.pbi.cout 11KB
stm8l15x_tim2.pbi.cout 11KB
stm8l15x_tim3.pbi.cout 11KB
stm8l15x_wwdg.pbi.cout 11KB
stm8l15x_wfe.pbi.cout 11KB
stm8l15x_rtc.pbi.cout 11KB
stm8l15x_dma.pbi.cout 11KB
stm8l15x_pwr.pbi.cout 11KB
stm8l15x_dac.pbi.cout 11KB
stm8l15x_aes.pbi.cout 11KB
stm8l15x_spi.pbi.cout 11KB
stm8l15x_lcd.pbi.cout 11KB
stm8l15x_i2c.pbi.cout 11KB
stm8l15x_adc.pbi.cout 11KB
stm8l15x_itc.pbi.cout 11KB
stm8l15x_rst.pbi.cout 11KB
stm8l15x_clk.pbi.cout 11KB
stm8l15x_it.pbi.cout 11KB
main.pbi.cout 11KB
BoYue_STM8L15xC6_Library.dbgdt 5KB
BoYue_STM8L15xC6_Library.dep 30KB
BoYue_STM8L15xC6_Library.dni 968B
BoYue_STM8L15xC6_Library.ewd 12KB
Backup (3) of BoYue_STM8L15xC6_Library.ewd 11KB
Backup (2) of BoYue_STM8L15xC6_Library.ewd 11KB
Backup of BoYue_STM8L15xC6_Library.ewd 11KB
BoYue_STM8L15xC6_Library.ewp 46KB
Backup (2) of BoYue_STM8L15xC6_Library.ewp 44KB
Backup of BoYue_STM8L15xC6_Library.ewp 44KB
Backup (3) of BoYue_STM8L15xC6_Library.ewp 44KB
BoYue_STM8L15xC6_Library.ewt 3KB
BoYue_STM8L15xC6_Library.eww 178B
stm8l15x.h 121KB
stm8l15x_rtc.h 34KB
stm8l15x_tim1.h 34KB
stm8l15x_i2c.h 34KB
stm8l15x_tim2.h 27KB
stm8l15x_tim5.h 27KB
stm8l15x_tim3.h 27KB
stm8l15x_lcd.h 21KB
stm8l15x_syscfg.h 19KB
stm8l15x_clk.h 18KB
stm8l15x_adc.h 16KB
stm8l15x_usart.h 15KB
stm8l15x_spi.h 14KB
stm8l15x_dma.h 13KB
stm8l15x_flash.h 13KB
stm8l15x_tim4.h 11KB
stm8l15x_itc.h 11KB
stm8l15x_dac.h 10KB
stm8l15x_comp.h 10KB
stm8l15x_exti.h 9KB
stm8l15x_wfe.h 8KB
stm8l15x_gpio.h 6KB
stm8l15x_aes.h 5KB
stm8l15x_iwdg.h 5KB
共 173 条
- 1
- 2
资源评论
alvarocfc
- 粉丝: 105
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功