###### 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 ![](https://i.imgur.com/KFmC8nY.png) --- ### 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** ![](https://i.imgur.com/ipPFjVM.png) **2.2.2 I Agree** ![](https://i.imgur.com/ApQPrfV.png) **2.2.3 Next** ![](https://i.imgur.com/EptQFpy.png) **2.2.4 Install** ![](https://i.imgur.com/xmYyWgs.png) **2.2.5 Finish** ![](https://i.imgur.com/vUhf9JI.png) --- ### **2.3 Install ==gcc-arm-none-eabi-6-2017-q2-update-win32.exe==** **2.3.1 Double click the executable file.** ![](https://i.imgur.com/rHfXxsn.png) **2.3.2 Press [OK] to continue...** ![](https://i.imgur.com/PnJm4Ic.png) **2.3.3 按[下一步]; Click [Next]** ![](https://i.imgur.com/acKJfvv.png) **2.3.4 按[我接受] ; Click [Acccept]** ![](https://i.imgur.com/MFqtvnL.png) **2.3.5 按[安裝] ; Click [Install]** ![](https://i.imgur.com/JSgfKmI.png) **2.3.6 如下塗勾選後,按[完成]; Click [Finish]** ![](https://i.imgur.com/ta0P4ig.png) ### 2.4 Install **==Doxygene==** * **2.4.1 Execute doxygen-1.8.13-setup.exe and click [Next]** * ![](https://i.imgur.com/eKTpz9V.png) * **2.4.2 Accept and click [Next]** ![](https://i.imgur.com/ET1ylAY.png) * **2.4.3 Click [Next]** ![](https://i.imgur.com/J6Hxzwj.png) * **2.4.4 Click [Next]** ![](https://i.imgur.com/QN8YtyT.png) * **2.4.5 Click [Next]** ![](https://i.imgur.com/SZoZqqk.png) * **2.4.6 Click [Install] and wait...** ![](https://i.imgur.com/q6PaLLU.png) * **2.4.7 Click [Next]** ![](https://i.imgur.com/OFxJ0Ve.png) * **2.4.7 Click [Finish]** ![](https://i.imgur.com/xD5U65z.png) 2.5 Insall **==JLink_Windows_V620f==** * **2.5.1 Execute JLink_Windows_V620f** ![](https://i.imgur.com/a5RgynH.png) * **2.5.2 Click [Next]** ![](https://i.imgur.com/6OgLAdQ.png) * **2.5.3 Click [I Agree]** ![](https://i.imgur.com/gSPNWyP.png) * **2.5.4 Confirm "Check Boxes" and click [Next]** ![](https://i.imgur.com/23ioNUA.png) * **2.5.6 Click [Install]** ![](https://i.imgur.com/o12DUuQ.png) --- ### 3. Install Eclipse neno.3 * #### Unzip `eclipse-cpp-neon-3-win32.zip` 不可置於中文路徑下(No chinese path) * 取消勾選唯讀 (After unzipping, unselect [Read only]) ![](https://i.imgur.com/6dqfNNU.png) ![](https://i.imgur.com/4V3gKp7.png) * #### Execute `eclipse.exe` ![](https://i.imgur.com/4XfzslU.png) #### 3.1 安裝GNU MCE Eclipse Plug-ins **3.1.1 Eclipse --> Help --> Install New Software** ![](https://i.imgur.com/nUmnpTl.png) **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/) ![](https://i.imgur.com/6ibY03O.png) **3.1.3 Click [Next] again** ![](https://i.imgur.com/F1sBn50.png) **3.1.4 [Accept] and [Finish]** ![](https://i.imgur.com/BW2tyHU.png) **3.1.4 Clcik [OK]** ![](https://i.imgur.com/sH5vYiN.png) --- ### 4. STM32CubeMX Installation #### 4.1 Eclipsr --> Help --> Install New Software ![](https://i.imgur.com/EsH4sHO.png) #### 4.2 Click [Add] ![](https://i.imgur.com/OS72aUu.png) #### 4.3 Set name as ==STM32CubeMX== asn clcik [Archive] ![](https://i.imgur.com/eV5qX6u.png) #### 4.4 Select the ==en.stsw-stm32095.zip== ![](https://i.imgur.com/Kmrr0JN.png) #### 4.5 Click [OK] ![](https://i.imgur.com/GWkVqky.png) ![](https://i.imgur.com/JRa2WFt.png) --- ### 5. Creat Project #### 5.1 Right click at Project Explorer page at left hand side. Select **New->Project...** ![](https://i.imgur.com/0lUzrn2.png) #### 5.2 Select **C/C++ -> C Project** ![](https://i.imgur.com/LeOpmvn.png) #### 5.3 Select **Hello World ARM C Project** on *Project type* field. Select **Cross ARM GCC** at Toolchains field. Enter the Project name. ![](https://i.imgur.com/xvUUZCd.png) #### 5.4 Modify the **Linker semi-hosting options:** :::success \-\-specs=nosys.specs ::: ![](https://i.imgur.com/8iDDqa7.png) #### 5.5 Click **Next**. ![](https://i.imgur.com/Q0AVmRd.png) #### 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**. ![](https://i.imgur.com/JSfSCzW.png) ### 6 Implement STM32CubeMX Library #### 6.1 Click **Window->Show View->Other...** ![](https://i.imgur.com/mLWDkth.png) #### 6.2 Select **STM32CubeMX**. ![](https://i.imgur.com/GgbuOXi.png) #### 6.3 Click **New Project**. ![](https://i.imgur.com/uQeS7Hf.png) #### 6.4 Select and double click the target MCU. ![](https://i.imgur.com/ISI5UOm.png) #### 6.5 Select **Project->Settings...**. ![](https://i.imgur.com/qHPhXbG.png) #### 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**. ![](https://i.imgur.com/Ib9Gore.png) ![](https://i.imgur.com/WNuPxkD.png) #### 6.7 Code Generator page Check the item as belows. Then click **OK**. ![](https://i.imgur.com/9tsKhxb.png) #### 6.8 Click ![](https://i.imgur.com/prlnx2d.png) to generate source code based on user settings. #### 6.9 Generating ![](https://i.imgur.com/7e6yqsY.png) #### 6.10 Click **Close**. ![](https://i.imgur.com/VhAQuy5.png) #### 6.11 Right click on the existing project, then click **Refresh**. (or select the existing project and push **F5**) ![](https://i.imgur.com/7JhM62d.png) #### 6.12 The generated files will shown on workspace. ![](https://i.imgur.com/Cc43a7P.png) #### 6.13 Right click on existing project then click Properties. ![](https://i.imgur.com/AqbONCG.png) #### 6.14 Select ==**cortex-m0**==(SVA1000) or ==**cortex-m4**==(R666) at ARM family, and click apply. ![](https://i.imgur.com/qgAUQ6V.png) #### 6.15 C/C++ Build/Tool Chain Editor * Debug ![](https://i.imgur.com/E3uO4aQ.png) * Release ![](https://i.imgur.com/JFx6KEd.png) #### 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** ::: ![](https://i.imgur.com/GlxLPKI.png) #### 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 ::: ![](https://i.imgur.com/UvsLWDI.png) #### 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**]. ![](https://i.imgur.com/AdLFFq5.png) #### 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**]. ![](https://i.imgur.com/4dS49bQ.png) #### 6.20 Copy the STM32FXXXX.ld file name ==STM32F091RCTx_FLASH.ld== or ==STM32F412ZGTx_FLASH.ld== ![](https://i.imgur.com/p1YNpMF.png) #### 6.21 Setup linker script. :::success ${ProjDirPath}\SW4STM32\Project_Name\STM32F091RCTx_FLASH.ld ::: or :::success ${ProjDirPath}\SW4STM32\Project_Name\STM32F412ZGTx_FLASH.ld ::: ![](https://i.imgur.com/6UkuDVJ.png) #### 6.22 Create a file to include assembler code file name to created: ==startup_stm32f091xc.asm== or ==startup_stm32f412zx.asm== ![](https://i.imgur.com/dvwRSzx.png) #### 6.23 Add ==.include "../SW4STM32/startup_stm32f091xc.s"== or #### ==.include "../SW4STM32/startup_stm32f412zx.s"== in the .asm file. ![](https://i.imgur.com/KsciCen.png) #### 6.24 Optimization Level * Debug ![](https://i.imgur.com/TW2bYcc.png) * Release ![](https://i.imgur.com/yEFx8uD.png) 26. Warnings ![](https://i.imgur.com/eDCZRP1.png) :::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"** ![](https://i.imgur.com/reUY4YQ.png) * **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** ![](https://i.imgur.com/5gddfCK.png) **[Target Interface] = ==SWD==** ![](https://i.imgur.com/NNwSddc.png) **[MCU] = STM32F091RC** ![](https://i.imgur.com/dnVFENC.png) ![](https://i.imgur.com/0mxwAeh.png) #### 6.4 Get MCU name * **Select [Target] --> [connect]** ![](https://i.imgur.com/g6rT7Ds.png) * **You can get the MCU information ==(remember the MCU name)== and connection details including "connected successfully", otherwise you need to check your wires.** ![](https://i.imgur.com/7N9WnEU.png) #### 6.5 Save J-Link Project ![](https://i.imgur.com/kizk07Y.png) ![](https://i.imgur.com/TEzflgp.png) #### 6.6 Set global variable to show all message and open the recent project ![](https://i.imgur.com/sRg87La.png) ![](https://i.imgur.com/tqQDjFZ.png) --- ### 7. Integrating Doxygen with Eclipse #### 7.1 Open up Eclipse and navigate to **Help --> Install New Software** ![](https://camo.githubusercontent.com/4380f78b8e843718c6cb400a0c4f57144baeec97/687474703a2f2f692e696d6775722e636f6d2f4348424b586c782e706e67) #### 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]**. ![](https://i.imgur.com/2vgHK2u.png) #### 7.3 Click **[Next]** ![](https://i.imgur.com/5hG6IUa.png) #### 7.4 Accept and click **[Finish]** ![](https://i.imgur.com/QV0FGrw.png) #### 7.5 Pops out progress bar** ![](https://i.imgur.com/qSuxZwi.png) #### 7.6 Click [OK] to continue** ![](https://i.imgur.com/LHjEODU.png) #### 7.7 Click [Yes] to re-start teh Eclipse** ![](https://i.imgur.com/mZwF7sP.png) #### 7.8 If you're on Windows, go to **"Window --> Preferences --> Doxygen"**, if you're on Mac, go to **"Eclipse --> Preferences --> Doxygen"**. ![](https://i.imgur.com/1yLcT1p.png) ![](https://i.imgur.com/82ai3l2.png) #### 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) ![](https://i.imgur.com/TaiewhX.png) ![](https://i.imgur.com/pHIbUlA.png) #### 7.9 Generate project HTML files. ![](https://i.imgur.com/sNWAX3l.png) #### 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. ![](https://i.imgur.com/qlBzxBq.png) ![](https://i.imgur.com/IeENI0R.png) ![](https://i.imgur.com/2hDW0OK.png) #### 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>&copy; 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 檔案開頭資料範例網頁顯示結果 ![](https://i.imgur.com/NfraTZn.png) --- #### 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 網頁顯示結果 ![](https://i.imgur.com/5yH72m5.png) ![](https://i.imgur.com/UJHkVLb.png) ![](https://i.imgur.com/AWCYu3U.png) ![](https://i.imgur.com/cL6qgcH.png) #### 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 顯示結果 ![](https://i.imgur.com/g6pOR3G.png) ![](https://i.imgur.com/BMRDD40.png) ![](https://i.imgur.com/ZaKMWds.png) --- #### 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 定義範例網頁顯示結果 ![](https://i.imgur.com/GST7kpZ.png) #### 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 變數、單行與多行註解網頁顯示結果 ![](https://i.imgur.com/wEIEzIG.png) #### 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網頁 ![](https://i.imgur.com/8sJJHVJ.png) ```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) ![](https://i.imgur.com/8EvS7WL.png) * #### Git [**Installation Steps**](https://gitbook.tw/chapters/environment/install-git-in-windows.html) * #### Execute "Git Bash" ![](https://i.imgur.com/rIOQcpK.png) * #### 輸入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...** ![](https://i.imgur.com/eCBIfwk.png) #### 10.2 Double click **GDB SEGGER J-Link Debugging** ![](https://i.imgur.com/unyxyff.png) #### 10.3 Select **Main** and enter Debug\STM32F091RCTx_freeRTOS.elf in **C/C++ Application** ![](https://i.imgur.com/sAtEBSv.png) #### 10.4 Select **Debugger** -> Enter the Device name: **STM32F091RC** -> Click **Debug** ![](https://i.imgur.com/WQo4mOp.png)