ch32f103点亮灯

//基本头文件和外设GPID头文件

#include "stm32f10x.h"
#include "GPIOLIKE51.h"

//声明所有端口初始化
void GPIO_Configuration(void);

//延时函数
void Delay(uint32_t nCount)
{
  for(; nCount != 0; nCount--);
}

//主函数

int main(void)
{


      GPIO_Configuration();


        PBout(14)=0;
    while (1)
    {
       

PCout(13)=1;    PCout(14)=1;    PCout(15)=1;    

PBout(0)=1;        PBout(1)=1;        PBout(3)=1;        PBout(4)=1;        PBout(5)=1;        PBout(6)=1;        PBout(7)=1;        PBout(8)=1;        PBout(9)=1;        PBout(10)=1;    PBout(11)=1;    PBout(12)=1;    PBout(13)=1;        PBout(14)=1;    PBout(15)=1;


        PAout(0) =1;     PAout(1) =1;    PAout(2)=1;        PAout(3) =1;    PAout(4) =1;    PAout(5) =1;    PAout(6) =1;     PAout(7) =1;    PAout(8) =1;     PAout(9) =1;    PAout(10) =1;    PAout(11) =1;    PAout(12) =1;      PAout(15) =1;


        Delay(0xbfffff);
    
        PCout(13)=0;    PCout(14)=0;    PCout(15)=0;    


        PBout(0)=0;        PBout(1)=0;         PBout(3)=0;        PBout(4)=0;         PBout(5)=0;     PBout(6)=0;     PBout(7)=0;     PBout(8)=0;        PBout(9)=0;     PBout(10)=0;    PBout(11)=0;     PBout(12)=0;        PBout(13)=0;        PBout(14)=0;        PBout(15)=0;


        PAout(0) =0;     PAout(1) =0;    PAout(2) =0;    PAout(3) =0;    PAout(4) =0;    PAout(5) =0;    PAout(6) =0;     PAout(7) =0;    PAout(8) =0;     PAout(9) =0;    PAout(10) =0;    PAout(11) =0;        PAout(12) =0;        PAout(15) =0;


        Delay(0xbfffff);
   
        
    }
}


void GPIO_Configuration(void)
{

        //定义一个结构体
  GPIO_InitTypeDef GPIO_InitStructure;

        //开启APB上GPIO上ABC时钟
    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC , ENABLE);         
    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA , ENABLE);
    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB , ENABLE); 

    //   赋值引脚
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 |GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14 | GPIO_Pin_15;

//设置端口速率
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

//输出模式
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 

//初始化每个端口
    GPIO_Init(GPIOC, &GPIO_InitStructure);
    GPIO_Init(GPIOB, &GPIO_InitStructure);
    GPIO_Init(GPIOA, &GPIO_InitStructure);
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值