单片机论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4509|回复: 0
收起左侧

利用Eclipse IDE for C/C++ Developers和GNU Tools ARM Embedded编译器,建立的一...

[复制链接]
bibi 发表于 2015-4-19 00:56 | 显示全部楼层 |阅读模式
工作环境说明:

1. 硬件平台: DX开发板主板 + DX103核心板

2. 软件平台: Eclipse IDE for C/C++ Developers + GNU Tools ARM Embedded
  (1) IDE:    Eclipse IDE for C/C++ Developers
  (2) 编译器: GNU Tools ARM Embedded编译器,支持STM32F103的标准外设驱动库3.5版本

//
// This file is part of the GNU ARM Eclipse distribution.
// Copyright (c) 2014 Liviu Ionescu.
//

// ----------------------------------------------------------------------------

#include <stdio.h>
#include "diag/Trace.h"
#include "stm32f10x_conf.h"
// ----------------------------------------------------------------------------
//
// STM32F1 empty sample (trace via ITM).
//
// Trace support is enabled by adding the TRACE macro definition.
// By default the trace messages are forwarded to the ITM output,
// but can be rerouted to any device o.r completely suppressed, by
// changing the definitions required in system/src/diag/trace_impl.c
// (currently OS_USE_TRACE_ITM, OS_USE_TRACE_SEMIHOSTING_DEBUG/_STDOUT).
//

// ----- main() ---------------------------------------------------------------

// Sample pragmas to cope with warnings. Please note the related line at
// the end of this function, used to pop the compiler diagnostics status.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#pragma GCC diagnostic ignored "-Wreturn-type"

int main(int argc, char* argv[])
{
  // At this stage the system clock should have already been configured
  // at high speed.

  // Enable GPIO Peripheral clock
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
  GPIO_InitTypeDef GPIO_InitStructure;
  // Configure pin in output push/pull mode
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
  // Configure pin in output push/pull mode
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_14;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
  // Configure pin in output push/pull mode
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_12;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOD, &GPIO_InitStructure);

  // Infinite loop
  while (1)
    {
      // Add your code here.
       GPIO_Write(GPIOA, GPIOA->ODR^(0x00001 << 0)); // 单步运行,点亮或关闭LED1
       GPIO_Write(GPIOB, GPIOB->ODR^(0x00001 << 0));
       GPIO_Write(GPIOB, GPIOB->ODR^(0x00001 << 14));
       GPIO_Write(GPIOD, GPIOD->ODR^(0x00001 << 13));
       GPIO_Write(GPIOD, GPIOD->ODR^(0x00001 << 12));
    }
}

#pragma GCC diagnostic pop

// ----------------------------------------------------------------------------

2015_3_18_8_32_31.jpg

【图片】默认闪烁一个LED.jpg


2015_3_18_8_32_45.jpg

【图片】修改为空项目.jpg

增加的代码,默认使用3.5的固件库和相应的CMIS层,如果需要使用HAL的固件库,CMIS层需要改动,会比较麻烦。
暂时用3.5的固件库了,注意新建一个空项目,然后添加代码。
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表