资源简介

STM32 F103R6 寄存器方式读写GPIO实例源代码(Keil)及protues 8.6 sp2 仿真工程,源代码编译用Keil MDK 5.23版本,亲测实现发光二极管闪烁效果

资源截图

代码片段和文件信息

/**
  ********************************  STM32F10x  *********************************
  * @文件名     : main.c
  * @作者       : happyrabbit456
  * @库版本     : V3.5.0
  * @文件版本   : V1.0.0
  * @日期       : 2018年4月26日
  * @摘要       : 主函数 - Demo软件工程
  ******************************************************************************/
/*----------------------------------------------------------------------------
  更新日志:
  2018-4-26 V1.0.0:初始版本
  ----------------------------------------------------------------------------*/
/* 包含的头文件 --------------------------------------------------------------*/
#include “stm32f10x.h“


/* 宏定义 --------------------------------------------------------------------*/
#define PORT_LED                  GPIOB
#define PIN_LED                   GPIO_Pin_0

/* LED开关 */
#define LED_ON                    (PORT_LED->BRR  = PIN_LED)
#define LED_OFF                   (PORT_LED->BSRR = PIN_LED)
#define LED_TOGGLE                (PORT_LED->ODR ^= PIN_LED)

/************************************************
函数名称 : SoftwareDelay
功    能 : 软件延时
参    数 : Cnt --- 延时计数
返 回 值 : 无
作    者 : strongerHuang
*************************************************/
void SoftwareDelay(uint32_t Cnt)
{
  while(Cnt--);
}

/************************************************
函数名称 : RCC_Configuration
功    能 : 时钟配置
参    数 : 无
返 回 值 : 无
作    者 : strongerHuang
*************************************************/
void RCC_Configuration(void)
{  
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO  ENABLE);

#if 0
  /* 使能APB1时钟 */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3 ENABLE);

  /* 使能AHB时钟 */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1 ENABLE);
#endif
}

/************************************************
函数名称 : GPIO_Basic_Configuration
功    能 : 基本输入输出引脚配置
参    数 : 无
返 回 值 : 无
作    者 : strongerHuang
*************************************************/
void GPIO_Basic_Configuration(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  GPIO_InitStructure.GPIO_Pin =  PIN_LED;                            //引脚  
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;                  //频率(10M)
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                   //输出类型(推挽式输出)
  GPIO_Init(PORT_LED &GPIO_InitStructure);

#if 0
  /* 时钟输出 */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOA &GPIO_InitStructure);

  RCC_MCOConfig(RCC_MCO_SYSCLK);
#endif
}

/************************************************
函数名称 : main
功    能 : 主函数入口
参    数 : 无
返 回 值 : int
作    者 : strongerHuang
*************************************************/
int main(void)
{
  RCC_Configuration(); //时钟配置

// 库方法
/*
  GPIO_Basic_Configuration();                    //IO配置

  while(1)
  {
    LED_TOGGLE;                                  //LED变化
    SoftwareDelay(

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-04-26 12:52  stm32demo\
     目录           0  2018-04-26 16:52  stm32demo\stm32f103r6\
     目录           0  2018-04-26 16:49  stm32demo\stm32f103r6\App\
     文件        3564  2018-04-26 16:49  stm32demo\stm32f103r6\App\main.c
     文件        3259  2016-10-18 12:00  stm32demo\stm32f103r6\App\stm32f10x_conf.h
     文件        4179  2016-10-18 12:00  stm32demo\stm32f103r6\App\stm32f10x_it.c
     文件        2086  2016-10-18 12:00  stm32demo\stm32f103r6\App\stm32f10x_it.h
     目录           0  2018-04-26 10:21  stm32demo\stm32f103r6\Libraries\
     目录           0  2018-04-26 10:21  stm32demo\stm32f103r6\Libraries\CMSIS\
     目录           0  2018-04-26 10:21  stm32demo\stm32f103r6\Libraries\CMSIS\CoreSupport\
     文件       17273  2010-06-07 10:25  stm32demo\stm32f103r6\Libraries\CMSIS\CoreSupport\core_cm3.c
     文件       85714  2011-02-09 14:59  stm32demo\stm32f103r6\Libraries\CMSIS\CoreSupport\core_cm3.h
     目录           0  2018-04-26 10:21  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\
     目录           0  2018-04-26 10:21  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\startup\
     文件       15766  2011-03-10 10:52  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\startup\startup_stm32f10x_cl.s
     文件       15503  2011-03-10 10:52  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\startup\startup_stm32f10x_hd.s
     文件       15692  2011-03-10 10:52  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\startup\startup_stm32f10x_hd_vl.s
     文件       12376  2011-03-10 10:52  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\startup\startup_stm32f10x_ld.s
     文件       13656  2011-03-10 10:52  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\startup\startup_stm32f10x_ld_vl.s
     文件       12765  2011-03-10 10:52  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\startup\startup_stm32f10x_md.s
     文件       14073  2011-03-10 10:51  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\startup\startup_stm32f10x_md_vl.s
     文件       15955  2011-03-10 10:51  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\startup\startup_stm32f10x_xl.s
     文件      633931  2016-10-18 12:00  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\stm32f10x.h
     文件       36557  2011-03-10 10:51  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\system_stm32f10x.c
     文件        2085  2011-03-10 10:51  stm32demo\stm32f103r6\Libraries\CMSIS\DeviceSupport\system_stm32f10x.h
     目录           0  2018-04-26 10:21  stm32demo\stm32f103r6\Libraries\STM32F10x_StdPeriph_Driver\
     目录           0  2018-04-26 10:21  stm32demo\stm32f103r6\Libraries\STM32F10x_StdPeriph_Driver\inc\
     文件        8982  2011-03-10 10:47  stm32demo\stm32f103r6\Libraries\STM32F10x_StdPeriph_Driver\inc\misc.h
     文件       21690  2011-03-10 10:47  stm32demo\stm32f103r6\Libraries\STM32F10x_StdPeriph_Driver\inc\stm32f10x_adc.h
     文件        7555  2011-03-10 10:47  stm32demo\stm32f103r6\Libraries\STM32F10x_StdPeriph_Driver\inc\stm32f10x_bkp.h
     文件       27559  2011-03-10 10:47  stm32demo\stm32f103r6\Libraries\STM32F10x_StdPeriph_Driver\inc\stm32f10x_can.h
............此处省略58个文件信息

评论

共有 条评论