###### tags: `AEWIN` `ARM CortexMx` `RTOS` `Eclipse` `Author:John Chen`
# Eclipse + ARM GCC + STM32CubeMX CortexM0 freeRTOS + Doxygen
---
## Steps
### 1. Install Java JDK
* #### Downlaod [**Java**](https://www.java.com/zh_TW/download/)
* #### Execute Java

---
### 2. Download Toolchain form NAS
**2.1 從下列NAS位置將資料夾Tools內的資料全部複製到你自己的電腦上之任意資料夾中
(EX: D:\Eeclips_Neno3_Toolchain)
==\\\192.168.1.209\se00軟體研發處\04-個人資料\John\Projects\SVA-1000\GNU_ARM_Toolchain\Tools==**
**2.2 Install ==gnu-mcu-eclipse-build-tools-2.9-20170607-0922-win32-setup.exe==**
**2.2.1 Next**

**2.2.2 I Agree**

**2.2.3 Next**

**2.2.4 Install**

**2.2.5 Finish**

---
### **2.3 Install ==gcc-arm-none-eabi-6-2017-q2-update-win32.exe==**
**2.3.1 Double click the executable file.**

**2.3.2 Press [OK] to continue...**

**2.3.3 按[下一步]; Click [Next]**

**2.3.4 按[我接受] ; Click [Acccept]**

**2.3.5 按[安裝] ; Click [Install]**

**2.3.6 如下塗勾選後,按[完成]; Click [Finish]**

### 2.4 Install **==Doxygene==**
* **2.4.1 Execute doxygen-1.8.13-setup.exe and click [Next]**
* 
* **2.4.2 Accept and click [Next]**

* **2.4.3 Click [Next]**

* **2.4.4 Click [Next]**

* **2.4.5 Click [Next]**

* **2.4.6 Click [Install] and wait...**

* **2.4.7 Click [Next]**

* **2.4.7 Click [Finish]**

2.5 Insall **==JLink_Windows_V620f==**
* **2.5.1 Execute JLink_Windows_V620f**

* **2.5.2 Click [Next]**

* **2.5.3 Click [I Agree]**

* **2.5.4 Confirm "Check Boxes" and click [Next]**

* **2.5.6 Click [Install]**

---
### 3. Install Eclipse neno.3
* #### Unzip `eclipse-cpp-neon-3-win32.zip`
不可置於中文路徑下(No chinese path)
* 取消勾選唯讀 (After unzipping, unselect [Read only])


* #### Execute `eclipse.exe`

#### 3.1 安裝GNU MCE Eclipse Plug-ins
**3.1.1 Eclipse --> Help --> Install New Software**

**3.1.2 Copy the following URL to the [Work with], and confirm GNU items are all selected. Finally, click [Next]**
**http://gnuarmeclipse.sourceforge.net/updates/**
[**參考網站**](https://gnu-mcu-eclipse.github.io/plugins/install/)

**3.1.3 Click [Next] again**

**3.1.4 [Accept] and [Finish]**

**3.1.4 Clcik [OK]**

---
### 4. STM32CubeMX Installation
#### 4.1 Eclipsr --> Help --> Install New Software

#### 4.2 Click [Add]

#### 4.3 Set name as ==STM32CubeMX== asn clcik [Archive]

#### 4.4 Select the ==en.stsw-stm32095.zip==

#### 4.5 Click [OK]


---
### 5. Creat Project
#### 5.1 Right click at Project Explorer page at left hand side. Select **New->Project...**

#### 5.2 Select **C/C++ -> C Project**

#### 5.3 Select **Hello World ARM C Project** on *Project type* field. Select **Cross ARM GCC** at Toolchains field. Enter the Project name.

#### 5.4 Modify the **Linker semi-hosting options:**
:::success
\-\-specs=nosys.specs
:::

#### 5.5 Click **Next**.

#### 5.6
* Toolchain name: **GNU Tools for ARM Embedded Processors (arm-none-eabi-gcc)**
* Toolchain Path: **C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin**
* Click **Finish**.

### 6 Implement STM32CubeMX Library
#### 6.1 Click **Window->Show View->Other...**

#### 6.2 Select **STM32CubeMX**.

#### 6.3 Click **New Project**.

#### 6.4 Select and double click the target MCU.

#### 6.5 Select **Project->Settings...**.

#### 6.6 Project page
Enter Project Name and Project Location. Use the same name and location of the created project in Eclipse workspace.
Select **SW4STM32** at Toolchain/IDE pull-down menu.
**==Uncheck==** **Generate Under Root**.


#### 6.7 Code Generator page
Check the item as belows.
Then click **OK**.

#### 6.8 Click  to generate source code based on user settings.
#### 6.9 Generating

#### 6.10 Click **Close**.

#### 6.11 Right click on the existing project, then click **Refresh**. (or select the existing project and push **F5**)

#### 6.12 The generated files will shown on workspace.

#### 6.13 Right click on existing project then click Properties.

#### 6.14 Select ==**cortex-m0**==(SVA1000) or ==**cortex-m4**==(R666) at ARM family, and click apply.

#### 6.15 C/C++ Build/Tool Chain Editor
* Debug

* Release

#### 6.16 Add Preprocessor/Defined symbols of Cross ARM GNU C Commpiler.
* SVA1000
:::success
__weak="\_\_attribute\_\_((weak))"
__packed="\_\_attribute\_\_((\_\_packed\_\_))"
USE_HAL_DRIVER
**STM32F091xC**
:::
**or**
* R666
:::success
__weak="\_\_attribute\_\_((weak))"
__packed="\_\_attribute\_\_((\_\_packed\_\_))"
USE_HAL_DRIVER
**STM32F412Zx**
:::

#### 6.17 Add Include paths of Cross ARM GNU C Commpiler.
**STM32F4**
:::success
${ProjDirPath}/Inc
${ProjDirPath}/Drivers/STM32F4xx_HAL_Driver/Inc ${ProjDirPath}/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy ${ProjDirPath}/Drivers/CMSIS/Device/ST/STM32F4xx/Include
${ProjDirPath}/Drivers/CMSIS/Include
${ProjDirPath}/Middlewares/Third_Party/FatFs/src
${ProjDirPath}/Middlewares/Third_Party/STM32_USB_Host_Library/Class/MSC/Inc
${ProjDirPath}/Middlewares/Third_Party/STM32_USB_Host_Library/Core/Inc
:::
**STM32F0**
:::success
${ProjDirPath}/Inc
${ProjDirPath}/Drivers/STM32F0xx_HAL_Driver/Inc/Legacy
${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM0
${ProjDirPath}/Drivers/CMSIS/Device/ST/STM32F0xx/Include
${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/include
${ProjDirPath}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
${ProjDirPath}/Drivers/CMSIS/Include
${ProjDirPath}/Drivers/STM32F0xx_HAL_Driver/Inc
:::

#### 6.18 Right click on Driver, Middlewares and SW4STM32 then click **Properties**.Select **C/C++ Build**, then uncheck **Exclude resource from build** and click [**Apply**].

#### 6.19 Right click on existing project, then click **Properties**.Select **Resource**, then check **Other** in *Text file encoding* field and choose **UTF-8** and click [**Apply**].

#### 6.20 Copy the STM32FXXXX.ld file name ==STM32F091RCTx_FLASH.ld== or ==STM32F412ZGTx_FLASH.ld==

#### 6.21 Setup linker script.
:::success
${ProjDirPath}\SW4STM32\Project_Name\STM32F091RCTx_FLASH.ld
:::
or
:::success
${ProjDirPath}\SW4STM32\Project_Name\STM32F412ZGTx_FLASH.ld
:::

#### 6.22 Create a file to include assembler code
file name to created: ==startup_stm32f091xc.asm== or ==startup_stm32f412zx.asm==

#### 6.23 Add ==.include "../SW4STM32/startup_stm32f091xc.s"== or
#### ==.include "../SW4STM32/startup_stm32f412zx.s"== in the .asm file.

#### 6.24 Optimization Level
* Debug

* Release

26. Warnings

:::info
* 雖然我放在Git的專案已都設定好,但若想自己學習從頭到尾的安裝與設定,可以參考資料夾裡的影片==Eclipse_STM32CubeMX_Windows.mp4==,過程一樣,但toolchain不一樣,toolchain就用上述**步驟 2.** 那些
:::
---
### 6. Program/debug ARM Cortex Mx series
#### 6.1 Power cable connection
* **Double click "J-Flash V6.20f"**

* **JLINK USB cable is connected to your working NB/PC.**
* **NUCLEO-F091RC USB cable is connected to your working NB/PC.**
#### 6.2 JLink & STM32F072RB wires
:::info
* **JLINK[TMS/SWDIO] <---> STM32F091RC[PA13/SWDIO]**
* **JLINK[TCK/SWCLK] <---> STM32F091RC[PA14/SWCLK]**
* **JLINK[GND] <---> STM32F091RC[GND]**
:::
#### 6.3 Set MCU name
**Option --> Project settings**

**[Target Interface] = ==SWD==**

**[MCU] = STM32F091RC**


#### 6.4 Get MCU name
* **Select [Target] --> [connect]**

* **You can get the MCU information ==(remember the MCU name)== and connection details including "connected successfully", otherwise you need to check your wires.**

#### 6.5 Save J-Link Project


#### 6.6 Set global variable to show all message and open the recent project


---
### 7. Integrating Doxygen with Eclipse
#### 7.1 Open up Eclipse and navigate to **Help --> Install New Software**

#### 7.2 In the new window that has appeared, **copy paste following link** to the textfield next to **"Work with:"**:
[**https://anb0s.github.io/eclox/**](http://download.gna.org/eclox/update)
Also **Check the box** next to =="Eclox Doxygen"== in the list and then press **[Next]**.

#### 7.3 Click **[Next]**

#### 7.4 Accept and click **[Finish]**

#### 7.5 Pops out progress bar**

#### 7.6 Click [OK] to continue**

#### 7.7 Click [Yes] to re-start teh Eclipse**

#### 7.8 If you're on Windows, go to **"Window --> Preferences --> Doxygen"**, if you're on Mac, go to **"Eclipse --> Preferences --> Doxygen"**.


#### 7.9 Now you need to add the Doxygen files.
* The location you should add differs from the operating systems.
* **Mac OS**: Press Shift+CMD+G then Add: "/Applications/Doxygen.app/Contents/Resources/doxygen"
* **Windows OS**: Add "C:\\Program Files\\doxygen\\bin"
* **Linux OS**: Add "/usr/local/bin"
(The image below demonstrates the procedure in Windows)


#### 7.9 Generate project HTML files.

#### 7.10 Reference
* [**MCU On Eclipse**](https://mcuoneclipse.com/2012/06/25/5-best-eclipse-plugins-1-eclox-with-doxygen-graphviz-and-mscgen/)
* [**Using Doxygen within Eclipse to document projects**](https://bitknitting.wordpress.com/2015/09/08/using-doxygen-within-eclipse-to-document-projects/)
#### 7.11 Open HTML directory and double click "index.html". You will see the the documents of whole programs.



#### 7.12 Usage
* How to properly comment the source code for Doxygen compatibility can be read in the [**Coding Convention wiki**](https://github.com/theolind/mahm3lib/wiki/Coding-Convention)
---
### 8. Doxygen 教學
:::warning
**請一定要知道Doxygen的函式、struct、enum與變數的註解格式,之後若新增任何東西,都需要依照Doxygen的註解規範。**
:::
#### 8.1 Doxygen檔案開頭資料格式
```clike=
/**
******************************************************************************
* @file 檔案名稱
* @author 所有權人
* @brief 檔案簡介
******************************************************************************
* @attention
* ...顯示訊息內容...
* ................
* ................
******************************************************************************
*/
```
##### 8.1.1 檔案開頭資料格式範例
```clike=
/**
******************************************************************************
* @file stm32f0xx_hal_i2c.h
* @author MCD Application Team
* @brief Header file of I2C HAL module.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
```
##### 8.1.2 檔案開頭資料範例網頁顯示結果

---
#### 8.2 Doxygen **defgroup** 模組定義(單獨顯示一頁)
```clike=
/**
* @defgroup 模組名 模組的說明文字
* @{
*/
...定義的內容...
...............
...............
/** // 模組結尾
* @} // 模組結尾
*/ // 模組結尾
```
#### 8.2.1 **defgroup** struct 模組定義範例
```clike=
/** @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition
* @brief I2C Configuration Structure definition
* @{
*/
typedef struct
{
uint32_t Timing; /*!< Specifies the I2C_TIMINGR_register value.
This parameter calculated by referring to I2C initialization
section in Reference manual */
uint32_t OwnAddress1; /*!< Specifies the first device own address.
This parameter can be a 7-bit or 10-bit address. */
uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
This parameter can be a value of @ref I2C_ADDRESSING_MODE */
uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
This parameter can be a value of @ref I2C_DUAL_ADDRESSING_MODE */
uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
This parameter can be a 7-bit address. */
uint32_t OwnAddress2Masks; /*!< Specifies the acknowledge mask address second device own address if dual addressing mode is selected
This parameter can be a value of @ref I2C_OWN_ADDRESS2_MASKS */
uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
This parameter can be a value of @ref I2C_GENERAL_CALL_ADDRESSING_MODE */
uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
This parameter can be a value of @ref I2C_NOSTRETCH_MODE */
} I2C_InitTypeDef;
/**
* @}
*/
```
#### 8.2.2 **defgroup** struct 網頁顯示結果




#### 8.2.3 **defgroup** enum 範例
```clike=
/** @defgroup HAL_state_structure_definition HAL state structure definition
* @brief HAL State structure definition
* @note HAL I2C State value coding follow below described bitmap :\n
* b7-b6 Error information\n
* 00 : No Error\n
* 01 : Abort (Abort user request on going)\n
* 10 : Timeout\n
* 11 : Error\n
* b5 IP initilisation status\n
* 0 : Reset (IP not initialized)\n
* 1 : Init done (IP initialized and ready to use. HAL I2C Init function called)\n
* b4 (not used)\n
* x : Should be set to 0\n
* b3\n
* 0 : Ready or Busy (No Listen mode ongoing)\n
* 1 : Listen (IP in Address Listen Mode)\n
* b2 Intrinsic process state\n
* 0 : Ready\n
* 1 : Busy (IP busy with some configuration or internal operations)\n
* b1 Rx state\n
* 0 : Ready (no Rx operation ongoing)\n
* 1 : Busy (Rx operation ongoing)\n
* b0 Tx state\n
* 0 : Ready (no Tx operation ongoing)\n
* 1 : Busy (Tx operation ongoing)
* @{
*/
typedef enum
{
HAL_I2C_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
HAL_I2C_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use */
HAL_I2C_STATE_BUSY = 0x24U, /*!< An internal process is ongoing */
HAL_I2C_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing */
HAL_I2C_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
HAL_I2C_STATE_LISTEN = 0x28U, /*!< Address Listen Mode is ongoing */
HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, /*!< Address Listen Mode and Data Transmission
process is ongoing */
HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
process is ongoing */
HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
HAL_I2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */
HAL_I2C_STATE_ERROR = 0xE0U /*!< Error */
} HAL_I2C_StateTypeDef;
/**
* @}
*/
```
#### 8.2.4 **defgroup** enum 顯示結果



---
#### 8.3 變數、巨集定義、類型定義資料格式
```clike=
/** 簡要說明文字 */
#define FLOAT float
```
#### 8.3.1 定義範例
```clike=
/** __FPU_USED indicates whether an FPU is used or not.
This core does not support an FPU at all
*/
#define __FPU_USED 0U
```
#### 8.3.2 定義範例網頁顯示結果

#### 8.4 變數、單行與多行註解與註解
```clike=
/**
* 分行的簡要說明 \\n
* 這是第二行的簡要說明
*/
/// 也可用此方法行註解
int b;
變數的說明可以撰寫如下:
/// \note 這裡是補充說明
void test(void){
int b = 0; ///< 用來撰寫單行註解的寫法
int a = 0; /**< 可以撰寫多行註解的寫法*/ /*!< 也可用此方法做多行註解 */
}
```
#### 8.4.1 變數、單行與多行註解範例
```clike=
/// Priority used for thread control.
/// \note MUST REMAIN UNCHANGED: \b osPriority shall be consistent in every CMSIS-RTOS.
typedef enum {
osPriorityIdle = -3, ///< priority: idle (lowest)
osPriorityLow = -2, ///< priority: low
osPriorityBelowNormal = -1, ///< priority: below normal
osPriorityNormal = 0, ///< priority: normal (default)
osPriorityAboveNormal = +1, ///< priority: above normal
osPriorityHigh = +2, ///< priority: high
osPriorityRealtime = +3, ///< priority: realtime (highest)
osPriorityError = 0x84 ///< system cannot determine priority or thread has illegal priority
} osPriority;
```
#### 8.4.2 變數、單行與多行註解網頁顯示結果

#### 8.4.3 變數、單行與多行註解範例2
```clike=
/**
* @brief Error status returned by some functions in the library.
*/
typedef enum
{
ARM_MATH_SUCCESS = 0, /**< No error */
ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */
ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */
ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation. */
ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */
ARM_MATH_SINGULAR = -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */
ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */
} arm_status;
```
#### 8.4.4 變數、單行與多行註解範例2網頁

```clike=
4. 函數說明
/**
* 簡要的函數說明文字
* @param \[in\] param1 參數1說明 * @param \[out\] param2 參數2說明
* @return 返回值說明
*/
int func(int param1, int param2);
/*
* 打開文件 \\n
* 檔打開成功後,必須使用 ::CloseFile 函數關閉。
\* @param\[in\] file_name 檔案名字串
\* @param\[in\] file_mode 檔打開模式字串,可以由以下幾個模組組合而成:
\* \- r 讀取
\* \- w 可寫
\* \- a 添加
\* \- t 文字模式(不能與 b 聯用)
\* \- b 二進位模式(不能與 t 聯用)
\* @return 返回文件編號
\* \- -1 表示打開檔失敗
\* @note 檔打開成功後,必須使用 ::CloseFile 函數關閉
\* @par 示例:
\* @code
// 用文本唯讀方式打開檔
int f = OpenFile(”d:\\\test.txt”, “rt”);
\* @endcode
\* @see ::ReadFile ::WriteFile ::CloseFile
\* @deprecated 由於特殊的原因,這個函數可能會在將來的版本中取消。
*/
int OpenFile(const char* file_name, const char* file_mode);
6. 專案符號標記
/*
\* A list of events:
\* \- mouse events
\* -# mouse move event
\* -# mouse click event\\n
\* More info about the click event.
\* -# mouse double click event
\* \- keyboard events
\* -# key down event
\* -# key up event
*
\* More text here.
*/
結果為:
A list of events:
mouse events
mouse move event
mouse click event
More info about the click event.
mouse double click event
keyboard events
key down event
key up event
More text here.
代碼示範:
/*
\* @defgroup EXAMPLES 自動注釋文檔範例
\* @author minidxer
\* @version 1.0
\* @date 2007-2008
\* @{
*/
/*
\* @name 檔案名常量
\* @{
*/
/** 日誌檔案名 */
#define LOG_FILENAME “c:\\\log\\\debug.log”
/** 資料檔案名 */
#define DATA_FILENAME “c:\\\data\\\detail.dat”
/** 存檔檔案名 */
#define BAK_FILENAME “c:\\\data\\\backup.dat”
/\*\* @}*/ // 檔案名常量
/*
\* @name 系統狀態常量
\* @{
*/
/** 正常狀態 */
#define SYS_NORMAL 0
/** 故障狀態 */
#define SYS_FAULT 1
/** 警告狀態 */
#define SYS_WARNNING 2
/\*\* @}*/ // 系統狀態常量
/** 枚舉常量 */
typedef enum TDayOfWeek
{
SUN = 0, /**< 星期天 */
MON = 1, /**< 星期一 */
TUE = 2, /**< 星期二 */
WED = 3, /**< 星期三 */
THU = 4, /**< 星期四 */
FRI = 5, /**< 星期五 */
SAT = 6 /**< 星期六 */
}
/** 定義類型 TEnumDayOfWeek */
TEnumDayOfWeek;
/** 定義類型 PEnumDayOfWeek */
typedef TEnumDayOfWeek* PEnumDayOfWeek;
/** 定義枚舉變數 enum1 */
TEnumDayOfWeek enum1;
/** 定義枚舉指標變數 enum2 */
PEnumDayOfWeek p_enum2;
/*
\* @defgroup FileUtils 檔操作函數
\* @{
*/
/*
* 打開文件 \\n
* 檔打開成功後,必須使用 ::CloseFile 函數關閉。
\* @param\[in\] file_name 檔案名字串
\* @param\[in\] file_mode 檔打開模式字串,可以由以下幾個模組組合而成:
\* \- r 讀取
\* \- w 可寫
\* \- a 添加
\* \- t 文字模式(不能與 b 聯用)
\* \- b 二進位模式(不能與 t 聯用)
\* @return 返回文件編號
\* \- -1 表示打開檔失敗
\* @note 檔打開成功後,必須使用 ::CloseFile 函數關閉
\* @par 示例:
\* @code
// 用文本唯讀方式打開檔
int f = OpenFile(”c:\\\test.txt”, “rt”);
\* @endcode
\* @see ::ReadFile ::WriteFile ::CloseFile
\* @deprecated 由於特殊的原因,這個函數可能會在將來的版本中取消。
*/
int OpenFile(const char* file\_name, const char* file\_mode);
/*
* 讀取文件
\* @param\[in\] file 文件編號,參見:::OpenFile
\* @param\[out\] buffer 用於存放讀取的檔內容
\* @param\[in\] len 需要讀取的檔長度
\* @return 返回讀取文件的長度
\* \- -1 表示讀取檔失敗
\* @pre \\e file 變數必須使用 ::OpenFile 返回值
\* @pre \\e buffer 不能為 NULL
\* @see ::OpenFile ::WriteFile ::CloseFile
*/
int ReadFile(int file, char* buffer, int len);
/*
* 寫入文件
\* @param\[in\] file 文件編號,參見:::OpenFile
\* @param\[in\] buffer 用於存放將要寫入的檔內容
\* @param\[in\] len 需要寫入的檔長度
\* @return 返回寫入的長度
\* \- -1 表示寫入檔失敗
\* @pre \\e file 變數必須使用 ::OpenFile 返回值
\* @see ::OpenFile ::ReadFile ::CloseFile
*/
int WriteFile(int file, const char* buffer, int len);
/*
* 關閉文件
\* @param file 文件編號,參見:::OpenFile
\* @retval 0 為成功
\* @retval -1 表示失敗
\* @see ::OpenFile ::WriteFile ::ReadFile
\* @deprecated 由於特殊的原因,這個函數可能會在將來的版本中取消。
*/
int CloseFile(int file);
/\*\* @}*/ // 檔操作函數
/\*\* @}*/ // 自動注釋文檔範例
```
### 9. Install Git
* #### Download [**Git**](https://git-scm.com/download)

* #### Git [**Installation Steps**](https://gitbook.tw/chapters/environment/install-git-in-windows.html)
* #### Execute "Git Bash"

* #### 輸入Git使用者名稱與email address
[**Git 初始化**](https://git-scm.com/book/zh-tw/v2/%E9%96%8B%E5%A7%8B-%E5%88%9D%E6%AC%A1%E8%A8%AD%E5%AE%9A-Git)
```shell=
git config --global user.name "YOUR NAME"
git config --global user.email "公司Email"
```
### 10. Debug
#### 10.1 Click **Debug->Debug Configurations...**

#### 10.2 Double click **GDB SEGGER J-Link Debugging**

#### 10.3 Select **Main** and enter Debug\STM32F091RCTx_freeRTOS.elf in **C/C++ Application**

#### 10.4 Select **Debugger** -> Enter the Device name: **STM32F091RC** -> Click **Debug**
