close

ST_logo_20130425.png

STM32F10x_StdPeriph_Lib_V3.5.0下載點如下,

STM32F10x_StdPeriph_Lib_V3.5.0

下載完成檔案如下,

2.JPG

接下來建立專案資料夾,本人習慣分類方式如下,

3.JPG

CMSIS->CORTEX微控制器軟件介面標準

ExtDevices_Configuration->外部裝置驅動程式配置

MDK->MCU核心程式

Project->存放專案uvprojx檔與hex等文件檔

STM32F103_Configuration->STM32F103各個介面配置

STM32F103_StdDriver->STM32F103標準函示庫驅動程式

User->存放main.c等撰寫者寫的其他程式

接下來一步步STM32F10x_StdPeriph_Lib_V3.5.0裡的程式正確底放在適當的資料夾內,

在CMSIS裡新增inc與src資料夾,

10.JPG

CMSIS中的inc須放置的程式如下,

路徑\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\CoreSupport,把core_cm3.h複製至\CMSIS\inc,

5.JPG

路徑\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x,把stm32f10x.hsystem_stm32f10x.h複製至\CMSIS\inc,

6.JPG

路徑\STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Template,把stm32f10x_conf.hstm32f10x_it.h複製至\CMSIS\inc,

9.JPG

複製完成後的結果如下所示,

11.JPG

CMSIS中的src須放置的程式如下,

路徑\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\CoreSupport,把core_cm3.c複製至\CMSIS\src,

4.JPG

路徑\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10,system_stm32f10x.c複製至\CMSIS\src,

7.JPG

路徑\STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Template,把stm32f10x_it.c複製至\CMSIS\src,

10.JPG

複製完成後的結果如下所示,

12.JPG

路徑\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm,全部檔案至MDK資料夾中,如下所示,

8.JPG

Project資料夾暫時不放程式文件,

STM32F407_Configuration資料夾暫時不放程式文件,

ExtDevices_Configuration資料夾暫時不放程式文件,

在STM32F103_StdDriver資料夾裡新增inc與src資料夾,

10.JPG

路徑\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\STM32F10x_StdPeriph_Driver,incsrc複製至STM32F103_StdDriver,

13.JPG

在User資料夾裡新增inc與src資料夾,

10.JPG

個人在\User\inc需增加bsp.h,global_variable.h,main.h,如下所示,

14.JPG

bsp.h程式如下,

#ifndef __BSP_H
#define __BSP_H

#include "main.h"

/* 開發板全域變數初始化 */
void BSP_VariableInit(void);

/* 開發板整體系統初始化 */
void BSP_Init(void);

#endif
global_variable.h程式如下,

#ifndef __GLOBAL_VARIABLE_H__
#define __GLOBAL_VARIABLE_H__
 
#include "bsp.h" 

#endif 

main.h程式如下,

#ifndef __MAIN_H
#define __MAIN_H

#include "stm32f10x.h"
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h> 
#include <stdlib.h>

/* STM32F429_Configuration */
 

/* User */
#include "main.h"
#include "bsp.h"
#include "global_variable.h"

#endif

個人在\User\src需增加bsp.c,global_variable.c,main.c,如下所示,

15.JPG

bsp.c程式如下,

#include "bsp.h"

/*
程式名稱:開發板全域變數初始化
程式版本:V1.0
程式撰寫者:Michael Jheng(鄭智遠)
程式撰寫日期:2018/3/6
程式修改日期:N/A
程式說明:

*/
void BSP_VariableInit(void){

}

/*
程式名稱:開發板整體系統初始化
程式版本:V1.0
程式撰寫者:Michael Jheng(鄭智遠)
程式撰寫日期:2018/3/6
程式修改日期:N/A
程式說明:

*/
void BSP_Init(void){
   
}

global_variable.c程式如下,

#include "global_variable.h"

main.c程式如下,

#include "main.h"

/*
程式名稱:主程式
程式版本:V1.0
程式撰寫者:Michael Jheng(鄭智遠)
程式撰寫日期:2018/1/6
程式修改日期:N/A
程式說明:

*/
int main(void){

    /* 開發板全域變數初始化 */
    BSP_VariableInit();
    /* 開發板整體系統初始化 */
    BSP_Init();
     
  /* Infinite loop */
  for(;;){

  }
}

#ifdef  USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)

  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}
#endif

arrow
arrow
    文章標籤
    ARM ST MCU
    全站熱搜

    鄭智遠 發表在 痞客邦 留言(0) 人氣()