我们从2011年坚守至今,只想做存粹的技术论坛。  由于网站在外面,点击附件后要很长世间才弹出下载,请耐心等待,勿重复点击不要用Edge和IE浏览器下载,否则提示不安全下载不了

 找回密码
 立即注册
搜索
查看: 948|回复: 0

stm32  io口测试程序

[复制链接]

该用户从未签到

191

主题

296

回帖

58

积分

二级逆天

我的肚子饿了,你呢?

积分
58

社区居民忠实会员终身成就奖

QQ
发表于 2015-5-4 12:51:18 | 显示全部楼层 |阅读模式
#include "led.h"
#include "delay.h"
#include "sys.h"

int main(void)
{
u8 i;
    SystemInit();
    delay_init(72);         //Ñóê±3õê¼»ˉ
    NVIC_Configuration();
   GPIO_TEST();
   

    while(1)
        {   


     if(i==0)
     {   
  GPIO_SetBits(GPIOA,GPIO_Pin_All );     
  GPIO_SetBits(GPIOB,GPIO_Pin_All );
  GPIO_SetBits(GPIOC,GPIO_Pin_All );
  GPIO_SetBits(GPIOD,GPIO_Pin_All );  
    GPIO_SetBits(GPIOE,GPIO_Pin_All );
    GPIO_SetBits(GPIOF,GPIO_Pin_All );
    GPIO_SetBits(GPIOG,GPIO_Pin_All );
     }
     else
     {
  GPIO_ResetBits(GPIOA,GPIO_Pin_All );     
  GPIO_ResetBits(GPIOB,GPIO_Pin_All );
  GPIO_ResetBits(GPIOC,GPIO_Pin_All );
    GPIO_ResetBits(GPIOD,GPIO_Pin_All );  
    GPIO_ResetBits(GPIOE,GPIO_Pin_All );
    GPIO_ResetBits(GPIOF,GPIO_Pin_All );
    GPIO_ResetBits(GPIOG,GPIO_Pin_All );

      }i++;if(i>1)i=0;
                    delay_ms(50);
         
        
}      
}



#include "stm32f10x.h"
#include "led.h"

//////////////////////////////////////////////////////////////////////////////////     
//±¾3ìDòÖ»1©Ñ§Ï°ê1óã¬Î′¾-×÷ÕßDí¿é£¬2»μÃóÃóúÆäËüèÎoÎóÃí¾
//Mini STM32¿a·¢°å
//LEDÇy¶ˉ′úÂë      
//ÕyμãÔ-×ó@ALIENTEK
//¼¼êõÂÛì3:www.openedv.com
//DT¸ÄèÕÆú:2012/5/27
//°æ±¾£oV1.0
//°æè¨ËùóD£¬μá°æ±Ø¾¿¡£
//Copyright(C) ÕyμãÔ-×ó 2009-2019
//All rights reserved                                             
//////////////////////////////////////////////////////////////////////////////////        

//3õê¼»ˉPA8oíPD2Îaêä3ö¿ú.2¢ê1ÄüÕaὸö¿úμÄê±Öó            
//LED IO3õê¼»ˉ
void LED_Init(void)
{

GPIO_InitTypeDef  GPIO_InitStructure;
     
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);     //ê1ÄüPA¶Ë¿úê±Öó
   
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;                 //LED0--&gtA.8 ¶Ë¿úÅäÖÃ
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;          //íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_SetBits(GPIOD,GPIO_Pin_8);                         //PA.8 êä3ö¸ß


RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);   //ê1ÄüPD¶Ë¿úê±Öó

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;                 //LED1--&gtD.2 ¶Ë¿úÅäÖÃ
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;          //íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);   
GPIO_SetBits(GPIOD,GPIO_Pin_2);                          //PD.2 êä3ö¸ß
}


void GPIO_TEST(void)
{
GPIO_InitTypeDef  GPIO_InitStructure;
  
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|
  RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE|RCC_APB2Periph_GPIOF|RCC_APB2Periph_GPIOG, ENABLE);   

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All ;                 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;         
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  
  
  GPIO_Init(GPIOA, &GPIO_InitStructure);   
  GPIO_Init(GPIOB, &GPIO_InitStructure);   
  GPIO_Init(GPIOC, &GPIO_InitStructure);   
  GPIO_Init(GPIOD, &GPIO_InitStructure);   
  GPIO_Init(GPIOE, &GPIO_InitStructure);   
    GPIO_Init(GPIOF, &GPIO_InitStructure);   
    GPIO_Init(GPIOG, &GPIO_InitStructure);   
  
  
GPIO_SetBits(GPIOA,GPIO_Pin_All );     
GPIO_SetBits(GPIOB,GPIO_Pin_All );
GPIO_SetBits(GPIOC,GPIO_Pin_All );
GPIO_SetBits(GPIOD,GPIO_Pin_All );  
GPIO_SetBits(GPIOE,GPIO_Pin_All );
GPIO_SetBits(GPIOF,GPIO_Pin_All );
GPIO_SetBits(GPIOG,GPIO_Pin_All );
  
   

}
四不四傻
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

论坛开启做任务可以
额外奖励金币快速赚
积分升级了


Copyright ©2011-2024 NTpcb.com All Right Reserved.  Powered by Discuz! (NTpcb)

本站信息均由会员发表,不代表NTpcb立场,如侵犯了您的权利请发帖投诉

平平安安
TOP
快速回复 返回顶部 返回列表