/**
******************************************************************************
* @file stm8s_tim1.c
* @author MCD Application Team
* @version V2.2.0
* @date 30-September-2014
* @brief This file contains all the functions for the TIM1 peripheral.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2014 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 "stm8s_tim1.h"
/** @addtogroup STM8S_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;
TIM1->SR2 = TIM1_SR2_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;
}
/**
* @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_OK(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_OK(TIM1_OCMode));
assert_param(IS_TIM1_OUTPUT_STATE_OK(TIM1_OutputState));
assert_param(IS_TIM1_OUTPUTN_STATE_OK(TIM1_OutputNState));
assert_param(IS_TIM1_OC_POLARITY_OK(TIM1_OCPolarity));
assert_param(IS_TIM1_OCN_POLARITY_OK(TIM1_OCNPolarity));
assert_param(IS_TIM1_OCIDLE_STATE_OK(TIM1_OCIdleState));
assert_param(IS_TIM1_OCNIDLE_STATE_OK(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)))
没有合适的资源?快使用搜索试试~ 我知道了~
STM8S005K6与W25Qxx系列Flash的硬件SPI代码
共96个文件
h:30个
c:27个
o:5个
5星 · 超过95%的资源 需积分: 15 115 下载量 61 浏览量
2015-01-26
12:46:50
上传
评论
收藏 1.33MB ZIP 举报
温馨提示
基于IAR STM8 2.10开发环境,STM8S005K6单片机,采用硬件SPI通信,能读写华邦W25Qxx系列Flash,包含读、写、擦除扇区、擦除块等操作,已测试成功,含完整工程文件。
资源推荐
资源详情
资源评论
收起资源包目录
STM8S005K6_W25Qxx_SPI.zip (96个子文件)
STM8S005K6_W25Qxx_SPI
STM8S005K6_W25Qxx_SPI.IAB 196KB
STM8S005K6_W25Qxx_SPI.PS 346KB
STM8S005K6_W25Qxx_SPI.PR 4KB
Debug
Obj
main.o 13KB
stm8s_gpio.o 22KB
STM8S005K6_W25Qxx_SPI.pbd.browse 406KB
stm8s_spi.pbi 330KB
stm8s_clk.o 54KB
stm8s_gpio.pbi 324KB
main.pbi.cout 10KB
STM8S005K6_W25Qxx_SPI.pbd 406KB
main.pbi 354KB
Flash_25Q16.pbi 369KB
stm8s_clk.pbi.cout 10KB
stm8s_clk.pbi 340KB
stm8s_spi.pbi.cout 10KB
Flash_25Q16.o 35KB
stm8s_gpio.pbi.cout 10KB
Flash_25Q16.pbi.cout 10KB
stm8s_spi.o 37KB
List
STM8S005K6_W25Qxx_SPI.map 16KB
Exe
STM8S005K6_W25Qxx_SPI.out 63KB
STM8S005K6_W25Qxx_SPI.IMB 48KB
STM8S005K6_W25Qxx_SPI.WK3 24KB
STM8S005K6_W25Qxx_SPI.ewt 940B
STM8S005K6_W25Qxx_SPI.PFI 48B
STM8S005K6_W25Qxx_SPI.IMD 808B
user
inc
def.h 741B
Flash_25Q16.h 681B
port_def.h 796B
stm8s_conf.h 5KB
Src
Flash_25Q16.c 10KB
main.c 5KB
STM8S005K6_W25Qxx_SPI.PO 776B
STM8S005K6_W25Qxx_SPI.ewp 43KB
STM8S_StdPeriph_Driver
inc
stm8s_tim5.h 20KB
stm8s_spi.h 13KB
stm8s_clk.h 17KB
stm8s_tim3.h 13KB
stm8s_uart3.h 15KB
stm8s_can.h 25KB
stm8s_tim6.h 9KB
stm8s_iwdg.h 4KB
stm8s_beep.h 4KB
stm8s_flash.h 14KB
stm8s_wwdg.h 3KB
stm8s_uart4.h 19KB
stm8s_tim4.h 5KB
stm8s_rst.h 3KB
stm8s_uart1.h 16KB
stm8s_uart2.h 19KB
stm8s_tim1.h 26KB
stm8s_adc2.h 11KB
stm8s.h 119KB
stm8s_tim2.h 14KB
stm8s_exti.h 5KB
stm8s_adc1.h 15KB
stm8s_i2c.h 27KB
stm8s_awu.h 5KB
stm8s_itc.h 7KB
stm8s_gpio.h 6KB
src
stm8s_adc2.c 13KB
stm8s_spi.c 14KB
stm8s_iwdg.c 3KB
stm8s_beep.c 5KB
stm8s_tim4.c 12KB
stm8s_awu.c 6KB
stm8s_tim1.c 82KB
stm8s_exti.c 6KB
stm8s_itc.c 11KB
stm8s_clk.c 21KB
stm8s_rst.c 3KB
stm8s_uart1.c 25KB
stm8s_adc1.c 22KB
stm8s_tim6.c 15KB
stm8s_flash.c 25KB
stm8s_can.c 45KB
stm8s_tim5.c 48KB
stm8s_wwdg.c 4KB
stm8s_uart3.c 23KB
stm8s_uart2.c 27KB
stm8s_uart4.c 28KB
stm8s_tim2.c 45KB
stm8s_tim3.c 36KB
stm8s_gpio.c 8KB
stm8s_i2c.c 32KB
settings
STM8S005K6_W25Qxx_SPI.wsdt 5KB
STM8S005K6_W25Qxx_SPI.dbgdt 7KB
STM8S005K6_W25Qxx_SPI.dni 947B
STM8S005K6_W25Qxx_SPI.Debug.cspy.bat 1KB
STM8S005K6_W25Qxx_SPI.wspos 51B
STM8S005K6_W25Qxx_SPI.eww 175B
STM8S005K6_W25Qxx_SPI.IAD 2KB
STM8S005K6_W25Qxx_SPI.PRI 24KB
STM8S005K6_W25Qxx_SPI.dep 7KB
STM8S005K6_W25Qxx_SPI.ewd 12KB
共 96 条
- 1
湘雪龙
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- NetOps-py通过sftp替换网络设备启动文件
- STM32单片机FPGA毕设电路原理论文报告任务驱动教学法在单片机课程教学中的应用
- STM32单片机FPGA毕设电路原理论文报告任务驱动法在单片机教学中的应用
- STM32单片机FPGA毕设电路原理论文报告人造金刚石压机智能化压力测控系统设计
- 以某列为依据匹配多项(Excel版)
- STM32单片机FPGA毕设电路原理论文报告人体短臂离心机实验台的显示控制系统
- STM32单片机FPGA毕设电路原理论文报告人工气候室监控系统的环境控制器研究
- STM32单片机FPGA毕设电路原理论文报告染整自动线张力控制系统的设计
- 数据挖掘与机器学习-实验
- 基于Linux系统Nginx的动态网站的LNMP环境源码包
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页