• 风眠慕天
    了解作者
  • C/C++
    开发工具
  • 1.1MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 6
    下载次数
  • 2020-04-09 11:47
    上传日期
通过STM8L系列单片机读取DS18B20温度值
STM8-DS18B20.zip
  • 31.DS18B20-单总线
  • settings
  • Demo.Debug.cspy.bat
    1.4KB
  • Demo.dni
    1.3KB
  • Demo.wspos
    50B
  • Demo.cspy.bat
    1KB
  • Demo.dbgdt
    5.5KB
  • Demo.wsdt
    3.5KB
  • Debug
  • Obj
  • stm8l10x_gpio.pbi
    224KB
  • 1621.pbi.cout
    10KB
  • delay.o
    6.9KB
  • main.pbi.cout
    10KB
  • main.pbi
    222.4KB
  • stm8l10x_clk.pbi.cout
    10.2KB
  • DS18B20.o
    12.9KB
  • 1621.pbi
    226.1KB
  • delay.pbi.cout
    10KB
  • stm8l10x_gpio.pbi.cout
    10.2KB
  • stm8l10x_i2c.o
    46.4KB
  • stm8l10x_it.o
    33.4KB
  • DS18B20.pbi
    222.7KB
  • Demo.pbd
    389.9KB
  • DS18B20.pbi.cout
    10KB
  • stm8l10x_gpio.o
    23.5KB
  • Demo.pbd.browse
    389.9KB
  • stm8l10x_i2c.pbi.cout
    10.2KB
  • stm8l10x_clk.o
    15.3KB
  • main.o
    8.1KB
  • stm8l10x_clk.pbi
    221.7KB
  • 1621.o
    35.9KB
  • delay.pbi
    220KB
  • stm8l10x_it.pbi
    222.9KB
  • stm8l10x_it.pbi.cout
    10.2KB
  • List
  • Exe
  • Demo.out
    75.5KB
  • STM8L10x_StdPeriph_Driver
  • inc
  • stm8l10x_exti.h
    7.1KB
  • stm8l10x.h
    54.1KB
  • stm8l10x_comp.h
    9.5KB
  • stm8l10x_tim4.h
    10.3KB
  • stm8l10x_rst.h
    3KB
  • stm8l10x_beep.h
    3.7KB
  • stm8l10x_usart.h
    12.2KB
  • stm8l10x_itc.h
    6.6KB
  • stm8l10x_clk.h
    5.3KB
  • stm8l10x_tim2.h
    26.4KB
  • stm8l10x_gpio.h
    6.4KB
  • stm8l10x_spi.h
    10.8KB
  • stm8l10x_flash.h
    8.2KB
  • stm8l10x_tim3.h
    26.5KB
  • stm8l10x_irtim.h
    2.3KB
  • stm8l10x_wfe.h
    4.6KB
  • stm8l10x_i2c.h
    26.6KB
  • stm8l10x_iwdg.h
    4.8KB
  • stm8l10x_awu.h
    5KB
  • src
  • stm8l10x_spi.c
    13.4KB
  • stm8l10x_exti.c
    14.3KB
  • stm8l10x_wfe.c
    6.5KB
  • stm8l10x_clk.c
    6.5KB
  • stm8l10x_tim3.c
    62.7KB
  • stm8l10x_gpio.c
    12.9KB
  • stm8l10x_rst.c
    3.6KB
  • stm8l10x_itc.c
    11.3KB
  • stm8l10x_flash.c
    25.9KB
  • stm8l10x_tim4.c
    19.2KB
  • stm8l10x_tim2.c
    62.8KB
  • stm8l10x_usart.c
    19.2KB
  • stm8l10x_beep.c
    7.5KB
  • stm8l10x_comp.c
    14.4KB
  • stm8l10x_i2c.c
    35.4KB
  • stm8l10x_irtim.c
    3.6KB
  • stm8l10x_iwdg.c
    4.3KB
  • stm8l10x_awu.c
    6.2KB
  • Release_Notes.html
    24KB
  • Demo.ewp
    43.8KB
  • main.c
    1.5KB
  • Backup of Demo.ewp
    41.3KB
  • stm8l10x_it.h
    3.4KB
  • delay.h
    1.7KB
  • Demo.ewd
    12.3KB
  • 1621.h
    1.4KB
  • Demo.dep
    9KB
  • delay.c
    2.7KB
  • ds18b20.h
    610B
  • Backup of Demo.ewd
    10.7KB
  • 1621.c
    5.7KB
  • Demo.ewt
    1.4KB
  • DS18B20.C
    3KB
  • stm8l10x_it.c
    8.8KB
  • Demo.eww
    158B
  • stm8l10x_conf.h
    3.1KB
内容介绍
/** ****************************************************************************** * @file stm8l10x_tim2.c * @author MCD Application Team * @version V1.2.0 * @date 01-June-2012 * @brief This file contains all the functions for the TIM2 peripheral. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2> * * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); * You may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.st.com/software_license_agreement_liberty_v2 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm8l10x_tim2.h" /** @addtogroup STM8L10x_StdPeriph_Driver * @{ */ /** @defgroup TIM2 * @brief TIM2 driver modules * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void TI1_Config(TIM2_ICPolarity_TypeDef TIM2_ICPolarity, TIM2_ICSelection_TypeDef TIM2_ICSelection, uint8_t TIM2_ICFilter); static void TI2_Config(TIM2_ICPolarity_TypeDef TIM2_ICPolarity, TIM2_ICSelection_TypeDef TIM2_ICSelection, uint8_t TIM2_ICFilter); /** * @addtogroup TIM2_Private_Functions * @{ */ /** * @brief Deinitializes the TIM2 peripheral registers to their default reset values. * @param None * @retval None */ void TIM2_DeInit(void) { TIM2->CR1 = TIM_CR1_RESET_VALUE; TIM2->CR2 = TIM_CR2_RESET_VALUE; TIM2->SMCR = TIM_SMCR_RESET_VALUE; TIM2->ETR = TIM_ETR_RESET_VALUE; TIM2->IER = TIM_IER_RESET_VALUE; TIM2->SR2 = TIM_SR2_RESET_VALUE; /* Disable channels */ TIM2->CCER1 = TIM_CCER1_RESET_VALUE; /* Configure channels as inputs: it is necessary if lock level is equal to 2 or 3 */ TIM2->CCMR1 = 0x01;/*TIM2_ICxSource_TIxFPx */ TIM2->CCMR2 = 0x01;/*TIM2_ICxSource_TIxFPx */ /* Then reset channel registers: it also works if lock level is equal to 2 or 3 */ TIM2->CCER1 = TIM_CCER1_RESET_VALUE; TIM2->CCMR1 = TIM_CCMR1_RESET_VALUE; TIM2->CCMR2 = TIM_CCMR2_RESET_VALUE; TIM2->CNTRH = TIM_CNTRH_RESET_VALUE; TIM2->CNTRL = TIM_CNTRL_RESET_VALUE; TIM2->PSCR = TIM_PSCR_RESET_VALUE; TIM2->ARRH = TIM_ARRH_RESET_VALUE; TIM2->ARRL = TIM_ARRL_RESET_VALUE; TIM2->CCR1H = TIM_CCR1H_RESET_VALUE; TIM2->CCR1L = TIM_CCR1L_RESET_VALUE; TIM2->CCR2H = TIM_CCR2H_RESET_VALUE; TIM2->CCR2L = TIM_CCR2L_RESET_VALUE; TIM2->OISR = TIM_OISR_RESET_VALUE; TIM2->EGR = 0x01;/*TIM_EGR_UG;*/ TIM2->BKR = TIM_BKR_RESET_VALUE; TIM2->SR1 = TIM_SR1_RESET_VALUE; } /** * @brief Initializes the TIM2 Time Base Unit according to the specified parameters. * @param TIM2_Prescaler: Prescaler * This parameter can be one of the following values: * @arg TIM2_Prescaler_1: Time base Prescaler = 1 (No effect) * @arg TIM2_Prescaler_2: Time base Prescaler = 2 * @arg TIM2_Prescaler_4: Time base Prescaler = 4 * @arg TIM2_Prescaler_8: Time base Prescaler = 8 * @arg TIM2_Prescaler_16: Time base Prescaler = 16 * @arg TIM2_Prescaler_32: Time base Prescaler = 32 * @arg TIM2_Prescaler_64: Time base Prescaler = 64 * @arg TIM2_Prescaler_128: Time base Prescaler = 128 * @param TIM2_CounterMode: Counter mode * This parameter can be one of the following values: * @arg TIM2_CounterMode_Up: Counter Up Mode * @arg TIM2_CounterMode_Down: Counter Down Mode * @arg TIM2_CounterMode_CenterAligned1: Counter Central aligned Mode 1 * @arg TIM2_CounterMode_CenterAligned2: Counter Central aligned Mode 2 * @arg TIM2_CounterMode_CenterAligned3: Counter Central aligned Mode 3 * @param TIM2_Period: This parameter must be a value between 0x0000 and 0xFFFF. * @retval None */ void TIM2_TimeBaseInit(TIM2_Prescaler_TypeDef TIM2_Prescaler, TIM2_CounterMode_TypeDef TIM2_CounterMode, uint16_t TIM2_Period) { assert_param(IS_TIM2_PRESCALER(TIM2_Prescaler)); assert_param(IS_TIM2_COUNTER_MODE(TIM2_CounterMode)); /* Set the Autoreload value */ TIM2->ARRH = (uint8_t)(TIM2_Period >> 8) ; TIM2->ARRL = (uint8_t)(TIM2_Period); /* Set the Prescaler value */ TIM2->PSCR = (uint8_t)(TIM2_Prescaler); /* Select the Counter Mode */ TIM2->CR1 &= (uint8_t)((uint8_t)(~TIM_CR1_CMS)) & ((uint8_t)(~TIM_CR1_DIR)); TIM2->CR1 |= (uint8_t)(TIM2_CounterMode); } /** * @brief Initializes the TIM2 Channel1 according to the specified parameters. * @param TIM2_OCMode: Output Compare Mode * This parameter can be one of the following values: * @arg TIM2_OCMode_Timing: Timing (Frozen) Mode * @arg TIM2_OCMode_Active: Active Mode * @arg TIM2_OCMode_Inactive: Inactive Mode * @arg TIM2_OCMode_Toggle: Toggle Mode * @arg TIM2_OCMode_PWM1: PWM Mode 1 * @arg TIM2_OCMode_PWM2: PWM Mode 2 * @param TIM2_OutputState: Output state * This parameter can be one of the following values: * @arg TIM2_OutputState_Disable: Output compare State disabled (channel output disabled) * @arg TIM2_OutputState_Enable: Output compare State enabled (channel output enabled) * @param TIM2_Pulse: This parameter must be a value between 0x0000 and 0xFFFF. * @param TIM2_OCPolarity: Polarity * This parameter can be one of the following values: * @arg TIM2_OCPolarity_High: Output compare polarity = High * @arg TIM2_OCPolarity_Low: Output compare polarity = Low * @param TIM2_OCIdleState: Output Compare Idle State * This parameter can be one of the following values: * @arg TIM2_OCIdleState_Reset: Output Compare Idle state = Reset * @arg TIM2_OCIdleState_Set: Output Compare Idle state = Set * @retval None */ void TIM2_OC1Init(TIM2_OCMode_TypeDef TIM2_OCMode, TIM2_OutputState_TypeDef TIM2_OutputState, uint16_t TIM2_Pulse, TIM2_OCPolarity_TypeDef TIM2_OCPolarity, TIM2_OCIdleState_TypeDef TIM2_OCIdleState) { uint8_t tmpccmr1 = 0; /* Check the parameters */ assert_param(IS_TIM2_OC_MODE(TIM2_OCMode)); assert_param(IS_TIM2_OUTPUT_STATE(TIM2_OutputState)); assert_param(IS_TIM2_OC_POLARITY(TIM2_OCPolarity)); assert_param(IS_TIM2_OCIDLE_STATE(TIM2_OCIdleState)); tmpccmr1 = TIM2->CCMR1; /* Disable the Channel 1: Reset the CCE Bit */ TIM2->CCER1 &= (uint8_t)(~TIM_CCER1_CC1E); /* Reset the Output Compare Bits */ tmpccmr1 &= (uint8_t)(~TIM_CCMR_OCM); /* Set the Ouput Compare Mode */ tmpccmr1 |= (uint8_t)TIM2_OCMode; TIM2->CCMR1 = tmpccmr1; /* Set the Output State */ if (TIM2_OutputState ==
评论
    相关推荐