.

main.c - 使用PB12, PB13, PB14, PB15, PB5, PB6, PB7 这七个PB口点亮LED. 注意PB3和PB4是特殊口, 直接调用无效.

#include "delay.h"
#include "stm32f10x.h" int main(void) {
u16 i;
u8 j;
uint16_t gpios[] = {GPIO_Pin_12, GPIO_Pin_13, GPIO_Pin_14, GPIO_Pin_15, GPIO_Pin_5, GPIO_Pin_6, GPIO_Pin_7};
GPIO_InitTypeDef GPIO_InitStructure;
delay_init(); //延时函数初始化
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); /使能PB端口时钟 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz
GPIO_Init(GPIOB, &GPIO_InitStructure); //根据设定参数初始化GPIOB.5 while() {
i = (i+) % ;
for (j = ; j < ; j++) {
GPIO_SetBits(GPIOB, gpios[j]);
delay_ms(i);
GPIO_ResetBits(GPIOB,gpios[j]);
}
for (j = ; j > ; j--) {
GPIO_SetBits(GPIOB, gpios[j]);
delay_ms(i);
GPIO_ResetBits(GPIOB,gpios[j]);
}
}
}

.

makefile

#工程的名称及最后生成文件的名字
TARGET = test001 #设定临时性环境变量
export CC = arm-none-eabi-gcc
export AS = arm-none-eabi-as
export LD = arm-none-eabi-ld
export OBJCOPY = arm-none-eabi-objcopy #读取当前工作目录
TOP=$(shell pwd) #设定包含文件目录
INC_FLAGS= -I $(TOP)/core \
-I $(TOP)/stm32f10x_lib/inc \
-I $(TOP)/system \
-I $(TOP)/user CFLAGS = -W -Wall -g -mcpu=cortex-m3 -mthumb -D STM32F10X_HD -D USE_STDPERIPH_DRIVER $(INC_FLAGS) -O0 -std=gnu11
C_SRC=$(shell find ./ -name '*.c')
C_OBJ=$(C_SRC:%.c=%.o) .PHONY: all clean update all:$(C_OBJ)
$(CC) $(C_OBJ) -T stm32_f103ze_gcc.ld -o $(TARGET).elf -mthumb -mcpu=cortex-m3 -Wl,--start-group -lc -lm -Wl,--end-group -specs=nano.specs -specs=nosys.specs -static -Wl,-cref,-u,Reset_Handler -Wl,-Map=Project.map -Wl,--gc-sections -Wl,--defsym=malloc_getpagesize_P=0x80
$(OBJCOPY) $(TARGET).elf $(TARGET).bin -Obinary
$(OBJCOPY) $(TARGET).elf $(TARGET).hex -Oihex $(C_OBJ):%.o:%.c
$(CC) -c $(CFLAGS) -o $@ $<
clean:
rm -f $(shell find ./ -name '*.o')
rm -f $(shell find ./ -name '*.d')
rm -f $(shell find ./ -name '*.map')
rm -f $(shell find ./ -name '*.elf')
rm -f $(shell find ./ -name '*.bin')
rm -f $(shell find ./ -name '*.hex') update:
openocd \
-f /usr/local/share/openocd/scripts/interface/stlink-v2.cfg \
-f /usr/local/share/openocd/scripts/target/stm32f1x.cfg \
-c init \
-c halt \
-c "flash write_image erase $(TOP)/test001.hex" \
-c reset \
-c shutdown

目录结构

├── core
│   ├── core_cm3.h
│   ├── core_cmFunc.h
│   └── core_cmInstr.h
├── LICENSE
├── makefile
├── README.md
├── stm32_f103ze_gcc.ld
├── stm32f10x_lib
│   ├── inc
│   │   ├── misc.h
│   │   ├── stm32f10x_adc.h
│   │   ├── stm32f10x_bkp.h
│   │   ├── stm32f10x_can.h
│   │   ├── stm32f10x_cec.h
│   │   ├── stm32f10x_conf.h
│   │   ├── stm32f10x_crc.h
│   │   ├── stm32f10x_dac.h
│   │   ├── stm32f10x_dbgmcu.h
│   │   ├── stm32f10x_dma.h
│   │   ├── stm32f10x_exti.h
│   │   ├── stm32f10x_flash.h
│   │   ├── stm32f10x_fsmc.h
│   │   ├── stm32f10x_gpio.h
│   │   ├── stm32f10x.h
│   │   ├── stm32f10x_i2c.h
│   │   ├── stm32f10x_iwdg.h
│   │   ├── stm32f10x_pwr.h
│   │   ├── stm32f10x_rcc.h
│   │   ├── stm32f10x_rtc.h
│   │   ├── stm32f10x_sdio.h
│   │   ├── stm32f10x_spi.h
│   │   ├── stm32f10x_tim.h
│   │   ├── stm32f10x_usart.h
│   │   └── stm32f10x_wwdg.h
│   └── src
│   ├── misc.c
│   ├── stm32f10x_adc.c
│   ├── stm32f10x_bkp.c
│   ├── stm32f10x_can.c
│   ├── stm32f10x_cec.c
│   ├── stm32f10x_crc.c
│   ├── stm32f10x_dac.c
│   ├── stm32f10x_dbgmcu.c
│   ├── stm32f10x_dma.c
│   ├── stm32f10x_exti.c
│   ├── stm32f10x_flash.c
│   ├── stm32f10x_fsmc.c
│   ├── stm32f10x_gpio.c
│   ├── stm32f10x_i2c.c
│   ├── stm32f10x_iwdg.c
│   ├── stm32f10x_pwr.c
│   ├── stm32f10x_rcc.c
│   ├── stm32f10x_rtc.c
│   ├── stm32f10x_sdio.c
│   ├── stm32f10x_spi.c
│   ├── stm32f10x_tim.c
│   ├── stm32f10x_usart.c
│   └── stm32f10x_wwdg.c
├── system
│   ├── delay.c
│   ├── delay.h
│   ├── startup_stm32f10x_hd.c
│   ├── system_stm32f10x.c
│   └── system_stm32f10x.h
└── user
└── main.c directories, files

源码下载 https://pan.baidu.com/s/1J6qEPQIhBId-Zo5nUzOgAQ 密码: 5t3d

.

stm32点亮LED 测试代码及目录结构的更多相关文章

  1. 【Django】基于Django架构网站代码的目录结构

     经典的Django项目源码目录结构 Django在一个项目的目录结构划分方面缺乏必要的规范.在Django的官方文档中并没有给出大型项目的代码建议目录结构,网上的文章也是根据项目的不同结构也有适当的 ...

  2. mybatis学习笔记(六)使用generator生成mybatis基础配置代码和目录结构

    原文:http://blog.csdn.net/oh_mourinho/article/details/51463413 创建maven项目 <span style="font-siz ...

  3. java代码实现目录结构

    今天用java代码来实现.像我们电脑盘符那样的目录结构.在代码开始之前首先.介绍一下.用.java代码实现目录的思想. 第一步:完成基础的.大家想.我们是如何获取文件的.是不是用File类,直接就获取 ...

  4. STM32点亮LED

    原理图 测试灯,接GPIO外设B,Pin 12 举例 前提,工程模版建立好 #include "stm32f10x.h" void delay(u32 i) { while(i-- ...

  5. 第7章 使用寄存器点亮LED灯

    第7章     使用寄存器点亮LED灯 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/fir ...

  6. 第7章 使用寄存器点亮LED灯—零死角玩转STM32-F429系列

    第7章     使用寄存器点亮LED灯 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/fir ...

  7. Mini2440上的第一个程序——点亮Led

    手头的Mini2440搁置了两年半之后,我再次决定拿出它,重新尝试嵌入式Linux的学习. 我使用的是友善之臂的Mini2440开发板.韦东山的<嵌入式Linux应用开发完成手册>及其视频 ...

  8. 使用寄存器点亮LED

    1. 项目:使用stm32寄存器点亮LED, 分别点亮红.绿.蓝3个灯. 2. 代码: 只需要编写main.c程序,stm3210x.h程序为空(只需要新建即可). 2.1 点亮绿灯main.c程序 ...

  9. Android学习笔记一:项目目录结构

    一:Android目录 主要内容有: app目录下: manifests目录: AndroidManifest.xml:APP的配置 java目录:主要为源代码和测试代码 res目录:主要是资源文件, ...

随机推荐

  1. POJO与PO、VO的区别

    http://www.cnblogs.com/wangjunwei/p/3859360.html POCO的概念是从java的POJO借用而来,而两者的含义是一致的,不同的仅仅是使用的语言不一样.所以 ...

  2. VS2010新建Web网站与新建Web应用程序的区别 (转)

    在Visual Studio 2010中,除了可以使用“创建Web应用程序”的方式来构建自己的Web项目之外,还可以通过创建“Web网站”的方式来构建Web项其中,Web网站的创建方法:打开Visua ...

  3. DICOM-RT:放疗领域中的各种影像

    背景: DICOM-RT系列博文着眼于DICOM3.0中对放疗领域的补充标准,即DICOM-RT.为了方便兴许对DICOM-RT中相关IOD.SOP概念的理解,专栏最近做了放疗相关知识点的普及. PS ...

  4. ProBase

    http://haixun.olidu.com/probase.html A Data Driven Semantic Network for Text Understanding Probase i ...

  5. (转)【风宇冲】Unity3D教程宝典之AssetBundles:第二讲

    原创文章如需转载请注明:转载自风宇冲Unity3D教程学院                             AssetBundles第二讲:AssetBundles与脚本 所有Unity的As ...

  6. Hibernate中得fetch

    fetch ,可以设置fetch = "select" 和 fetch = "join" 用一对多来举例:fetch = "select"是 ...

  7. ASP入门(十五)- Global.asa

    Global.asa 文件是一个可选文件,它可包含被 ASP 应用程序中每个页面访问的对象.变量和方法的声明.所有合法的浏览器脚本都可以在 Global.asa 中使用. Global.asa 文件只 ...

  8. 一个十年IT从业者的职场感言:为什么不要自称是“程序员”

    转载:https://blog.csdn.net/S_king_/article/details/78529089 如果我可以给每个工程教育增加一门课,它不会涉及编译器.门电路或是时间复杂度,而是一门 ...

  9. 虚拟机Linux下解决ping时出现 unknown host问题

    在虚拟机中使用CentOS6.5时,ping www.baidu.com出现报错信息:“ping: unknown hostwww.baidu.com”,虚拟机和物理机网络连接是NAT方式,物理机访问 ...

  10. 扩展一个boot的插件—tooltip&做一个基于boot的表达验证

    在线演示 本地下载 (代码太多请查看原文) 加班,加班加班,我爱加班··· 我已经疯了,哦也. 这次发一个刚接触boot的时候用boot做的表单验证,我们扩展一下tooltip的插件,让他可以换颜色. ...