久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

標題: 利用Eclipse IDE for C/C++ Developers和GNU Tools ARM Embedded編譯器 [打印本頁]

作者: bibi    時間: 2015-4-19 00:57
標題: 利用Eclipse IDE for C/C++ Developers和GNU Tools ARM Embedded編譯器
工作環境說明:

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編譯器,支持STM32F407最新的HAL驅動庫


用Eclipse IDE for C/C++ Developers新建一個C工程模板,主函數代碼如下:

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

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

#include <stdio.h>
#include "diag/Trace.h"

#include "Timer.h"
#include "BlinkLed.h"

// ----------------------------------------------------------------------------
//
// STM32F4 led blink sample (trace via ITM).
//
// In debug configurations, demonstrate how to print a greeting message
// on the trace device. In release configurations the message is
// simply discarded.
//
// To demonstrate POSIX retargetting, reroute the STDOUT a.n.d STDERR to the
// trace device a.n.d display messages on both of them.
//
// Then demonstrates how to blink a led with 1Hz, using a
// continuous loop a.n.d SysTick delays.
//
// On DEBUG, the uptime in seconds is also displayed on the trace device.
//
// 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).
//

// ----- Timing definitions -------------------------------------------------

// Keep the LED on for 2/3 of a second.
#define BLINK_ON_TICKS  (TIMER_FREQUENCY_HZ * 2 / 3)
#define BLINK_OFF_TICKS (TIMER_FREQUENCY_HZ - BLINK_ON_TICKS)

// ----- 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"

/*
* 大蝦開發板的5個LED指示燈對應的GPIO
* PA0:  LED1
* PB0:  LED2
* PB14: LED3
* PD13: LED4
* PD12: LED5
*
* 大蝦開發板的按鍵對應的GPIO
* PB10: K1
* PC2:  K2
*
* */

int main(int argc, char* argv[])
{
  // By customising __initialize_args() it is possible to pass arguments,
  // for example when running tests with semihosting you can pass various
  // options to the test.
  // trace_dump_args(argc, argv);

  // Send a greeting to the trace device (skipped on Release).
  trace_puts("Hello ARM World!");

  // The standard output a.n.d the standard error should be forwarded to
  // the trace device. For this to work, a redirection in _write.c is
  // required.
  puts("Standard output message.");
  fprintf(stderr, "Standard error message.");

  // At this stage the system clock should have already been configured
  // at high speed.
  trace_printf("System clock: %uHz", SystemCoreClock);

  timer_start();

  blink_led_init();
  


  uint32_t seconds = 0;

  while (1)
    {
//      blink_led_on();
      timer_sleep(BLINK_ON_TICKS);

//      blink_led_off();
      timer_sleep(BLINK_OFF_TICKS);

      ++seconds;
      HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_0);
      HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
      HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);
      HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13);
      HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12);
      // Count seconds on the trace device.
      trace_printf("Second %u", seconds);
    }
}
#pragma GCC diagnostic pop


// 在BlinkLed.c中初始化DX開發板的5個LED指示燈,以及K1、K2鍵對應的GPIO
// 用STM32CubeMX生成的兩個中斷函數整個拷貝過來

void blink_led_init()
{
  // Enable GPIO Peripheral clock
  RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
  RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN;
  RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN;

  GPIO_InitTypeDef GPIO_InitStructure;

  // Configure pin in output push/pull mode
  GPIO_InitStructure.Pin  = GPIO_PIN_0;
  GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
  GPIO_InitStructure.Pull = GPIO_PULLUP;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);

  HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);

  GPIO_InitStructure.Pin  = GPIO_PIN_14;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);

  GPIO_InitStructure.Pin  = GPIO_PIN_13 | GPIO_PIN_12;
  HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);


  /*Configure GPIO pin : PB10 */
  GPIO_InitStructure.Pin = GPIO_PIN_10;
  GPIO_InitStructure.Mode = GPIO_MODE_IT_FALLING; /* 下降沿中斷 */
  GPIO_InitStructure.Pull = GPIO_PULLUP;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);

  /* EXTI interrupt init */
  HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);

}

// 以下兩個中斷函數由stm32cubemx軟件自動生成,很方便

/**
* @brief This function handles EXTI Line[15:10] interrupts.
*/
void EXTI15_10_IRQHandler(void)
{
  /* USER CODE BEGIN EXTI15_10_IRQn 0 */

  /* USER CODE END EXTI15_10_IRQn 0 */
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_10); /* 此處設置斷點,全速運行,然后按下K1,就能到達這里 */
  /* USER CODE BEGIN EXTI15_10_IRQn 1 */
   
  /* USER CODE END EXTI15_10_IRQn 1 */
}

/**
* @brief This function handles EXTI Line2 interrupt.
*/
void EXTI2_IRQHandler(void)
{
  /* USER CODE BEGIN EXTI2_IRQn 0 */

  /* USER CODE END EXTI2_IRQn 0 */
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); /* 此處設置斷點,全速運行,然后按下K2,就能到達這里 */
  /* USER CODE BEGIN EXTI2_IRQn 1 */

  /* USER CODE END EXTI2_IRQn 1 */
}




【圖片】進入KEY1按鍵中斷(PB10).jpg,在中斷函數中設置斷點,全速運行,然后按開發板的K1鍵





歡迎光臨 (http://m.zg4o1577.cn/bbs/) Powered by Discuz! X3.1
主站蜘蛛池模板: 午夜成人影片 | 国产日韩欧美精品 | 一级欧美一级日韩 | 天天插天天射 | 日韩大片在线观看 | 黄网站免费看 | 亚洲成人中文字幕 | 亚洲青涩 | 91在线看片 | 97精品国产97久久久久久免费 | 欧美在线日韩 | 天堂影院av | 美女综合网 | 天天天天干 | 亚洲无人区一线二线三线 | 福利视频一区二区 | 久久一级视频 | 国产日韩欧美一区 | 国产视频一| 久久综合国产 | 国产精品99久久久久久久久 | 欧美999 | 伊人网av| 日本一级淫片色费放 | 91亚洲国产 | 欧美在线免费 | a毛片免费看 | 国产精品99久久久久久www | 欧美精品在线视频 | 在线免费黄色 | 久热伊人| 五月天黄色网址 | 色综合五月天 | 黄色片视频在线观看 | 日韩在线成人 | 国产精品av一区二区 | www.4hu95.com四虎| 成年视频在线观看 | 中文字幕在线播放视频 | 国产又色又爽又黄又免费 | 毛片av在线 |