├── Hardware ├── Gerber_QCopterNano_v1.0.rar ├── QCopterNano.PrjPCB ├── QCopterNano_Pcb.PcbDoc └── QCopterNano_Sch.SchDoc ├── LICENSE ├── README.md └── Software └── QCopterNano_FlightControl ├── Libraries ├── CMSIS │ ├── MathARM │ │ ├── arm_cos_f32.c │ │ └── arm_sin_f32.c │ ├── arm_common_tables.h │ ├── arm_const_structs.h │ ├── arm_math.h │ ├── core_cm4.h │ ├── core_cm4_simd.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── startup_stm32f401xc.s │ ├── stm32f4xx.h │ ├── system_stm32f4xx.c │ └── system_stm32f4xx.h └── STM32F4xx_StdPeriph_Driver │ ├── inc │ ├── misc.h │ ├── stm32f4xx_adc.h │ ├── stm32f4xx_can.h │ ├── stm32f4xx_crc.h │ ├── stm32f4xx_cryp.h │ ├── stm32f4xx_dac.h │ ├── stm32f4xx_dbgmcu.h │ ├── stm32f4xx_dcmi.h │ ├── stm32f4xx_dma.h │ ├── stm32f4xx_dma2d.h │ ├── stm32f4xx_exti.h │ ├── stm32f4xx_flash.h │ ├── stm32f4xx_fmc.h │ ├── stm32f4xx_fsmc.h │ ├── stm32f4xx_gpio.h │ ├── stm32f4xx_hash.h │ ├── stm32f4xx_i2c.h │ ├── stm32f4xx_iwdg.h │ ├── stm32f4xx_ltdc.h │ ├── stm32f4xx_pwr.h │ ├── stm32f4xx_rcc.h │ ├── stm32f4xx_rng.h │ ├── stm32f4xx_rtc.h │ ├── stm32f4xx_sai.h │ ├── stm32f4xx_sdio.h │ ├── stm32f4xx_spi.h │ ├── stm32f4xx_syscfg.h │ ├── stm32f4xx_tim.h │ ├── stm32f4xx_usart.h │ └── stm32f4xx_wwdg.h │ └── src │ ├── misc.c │ ├── stm32f4xx_adc.c │ ├── stm32f4xx_can.c │ ├── stm32f4xx_crc.c │ ├── stm32f4xx_cryp.c │ ├── stm32f4xx_cryp_aes.c │ ├── stm32f4xx_cryp_des.c │ ├── stm32f4xx_cryp_tdes.c │ ├── stm32f4xx_dac.c │ ├── stm32f4xx_dbgmcu.c │ ├── stm32f4xx_dcmi.c │ ├── stm32f4xx_dma.c │ ├── stm32f4xx_dma2d.c │ ├── stm32f4xx_exti.c │ ├── stm32f4xx_flash.c │ ├── stm32f4xx_fmc.c │ ├── stm32f4xx_fsmc.c │ ├── stm32f4xx_gpio.c │ ├── stm32f4xx_hash.c │ ├── stm32f4xx_hash_md5.c │ ├── stm32f4xx_hash_sha1.c │ ├── stm32f4xx_i2c.c │ ├── stm32f4xx_iwdg.c │ ├── stm32f4xx_ltdc.c │ ├── stm32f4xx_pwr.c │ ├── stm32f4xx_rcc.c │ ├── stm32f4xx_rng.c │ ├── stm32f4xx_rtc.c │ ├── stm32f4xx_sai.c │ ├── stm32f4xx_sdio.c │ ├── stm32f4xx_spi.c │ ├── stm32f4xx_syscfg.c │ ├── stm32f4xx_tim.c │ ├── stm32f4xx_usart.c │ └── stm32f4xx_wwdg.c ├── Program ├── Algorithms │ ├── algorithm_ahrs.c │ ├── algorithm_ahrs.h │ ├── algorithm_mathUnit.h │ ├── algorithm_moveAve.c │ ├── algorithm_moveAve.h │ ├── algorithm_pid.c │ ├── algorithm_pid.h │ ├── algorithm_quaternion.c │ ├── algorithm_quaternion.h │ ├── algorithm_string.c │ └── algorithm_string.h ├── Dirvers │ ├── stm32f4_delay.c │ ├── stm32f4_delay.h │ ├── stm32f4_spi.c │ ├── stm32f4_spi.h │ ├── stm32f4_system.h │ ├── stm32f4_usart.c │ └── stm32f4_usart.h ├── Modules │ ├── module_imu.c │ ├── module_imu.h │ ├── module_mpu9250.c │ ├── module_mpu9250.h │ ├── module_nrf24l01.c │ ├── module_nrf24l01.h │ ├── module_rs232.c │ └── module_rs232.h ├── QCopterNano.c ├── QCopterNano.h ├── QCopterNano_ctrl.c ├── QCopterNano_ctrl.h ├── QCopterNano_it.c ├── QCopterNano_transport.c ├── QCopterNano_transport.h └── stm32f4xx_conf.h ├── ProjectIMU ├── ClearFile.bat ├── Program_STM32.uvgui.Hom ├── Program_STM32.uvopt └── Program_STM32.uvproj └── VisualScope ├── VisualScope.exe └── config.dat /Hardware/Gerber_QCopterNano_v1.0.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitSprout/QCopterNano/926637209d0051d8d4bd4299ed4504e62b30c40f/Hardware/Gerber_QCopterNano_v1.0.rar -------------------------------------------------------------------------------- /Hardware/QCopterNano.PrjPCB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitSprout/QCopterNano/926637209d0051d8d4bd4299ed4504e62b30c40f/Hardware/QCopterNano.PrjPCB -------------------------------------------------------------------------------- /Hardware/QCopterNano_Pcb.PcbDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitSprout/QCopterNano/926637209d0051d8d4bd4299ed4504e62b30c40f/Hardware/QCopterNano_Pcb.PcbDoc -------------------------------------------------------------------------------- /Hardware/QCopterNano_Sch.SchDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitSprout/QCopterNano/926637209d0051d8d4bd4299ed4504e62b30c40f/Hardware/QCopterNano_Sch.SchDoc -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ========================================================================================== 2 | 3 | *** QCopter Nano v1.0 Hardware License *** 4 | 5 | CC BY-SA 4.0 6 | (http://creativecommons.org/licenses/by-sa/4.0/deed.zh_TW) 7 | 8 | 9 | 你可自由: 10 | 11 | 分享 — 以任何媒介或格式重製及散布本素材。 12 | 修改 — 重混、轉換本素材、及依本素材建立新素材。 13 | 且為任何目的,包含商業性質之使用。 14 | 只要你遵守授權條款規定,授權人不能撤回你使用本素材的自由。 15 | 16 | 惟需遵照下列條件: 17 | 18 | 姓名標示 — 19 | 你必須給予適當表彰、提供指向本授權條款的連結,以及指出本素材是否已被變更。你可以任何合理方式為前述表彰,但不得以任何方式暗示授權人為你或你的使用方式背書。 20 | 21 | 相同方式分享 — 22 | 若你重混、轉換本素材,或依本素材建立新素材,你必須依本素材的授權條款來散布你的貢獻物。 23 | 24 | 不得增加額外限制 — 25 | 你不能增設法律條款或科技措施,來限制別人依授權條款本已許可的作為。 26 | 27 | 28 | ------------------------------------------------------------------------------------------ 29 | 30 | *** QCopter Nano Software License *** 31 | 32 | The MIT License (MIT) 33 | (http://opensource.org/licenses/MIT) 34 | 35 | Copyright (c) 2014 Hom 36 | 37 | Permission is hereby granted, free of charge, to any person obtaining a copy of 38 | this software and associated documentation files (the "Software"), to deal in 39 | the Software without restriction, including without limitation the rights to 40 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 41 | the Software, and to permit persons to whom the Software is furnished to do so, 42 | subject to the following conditions: 43 | 44 | The above copyright notice and this permission notice shall be included in all 45 | copies or substantial portions of the Software. 46 | 47 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 48 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 49 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 50 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 51 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 52 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 53 | 54 | ========================================================================================== 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [QCopterNano](https://github.com/QCopter/QCopterNano) 2 | ======== 3 | * Author : [Hom](about.me/Hom) 4 | * Version : v1.0 測試中 ... 5 | * Update : 2014/09/12 6 | 7 | Description 8 | ======== 9 | QCopterNano 是一個基於Cortex-M4 的微型四軸飛行器,飛控採用 SmartIMU,搭載 STM32F401CU 和 MPU9250,並透過 nRF24L01P 來做無線的資料傳輸、遙控,馬達座採用 3D Printer 製作。 10 | 11 | License 12 | ======== 13 | * 硬體(Hardware)採用 [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/deed.zh_TW) 方式授權 14 | 15 |   創用 CC 授權條款 16 |    QCopterNano v1.0 Hom 製作,以 創用CC 姓名標示-相同方式分享 4.0 國際 授權條款 釋出。 17 | 18 | * 軟體(Software)採用 [MIT License](http://opensource.org/licenses/MIT) 方式授權 19 | 20 | Hardware 21 | ======== 22 | * 控制器  : [STM32F401C](http://www.st.com/web/en/catalog/mmc/FM141/SC1169/SS1577/LN1810/PF258491) 48Pin 84MHz DSP FPU 23 | * 感測器  : [MPU9250](http://www.invensense.com/mems/gyro/mpu9250.html) 24 | * 無線傳輸 : [nRF24L01P](http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P) + PA + LNA 25 | * 外接介面 : 1*SPI ( FFC16 ) 26 | * PCB 尺寸 : Motor to Motor ~80mm 27 | * 設計軟體 [Altium Designer 14](http://www.altium.com/en/products/altium-designer) ( PcbLib use AD [PcbLib v?](https://github.com/OpenPCB/AltiumDesigner_PcbLibrary) ) 28 | 29 | Related Documents 30 | ======== 31 | * [Update Records - Hackpad](https://hom.hackpad.com/QCopterNano-iIRgMU2Scgx) 32 | * [Datasheet & BOM - Google Drive](http://goo.gl/Bqsjgs) 33 | 34 | Software 35 | ======== 36 | * QCopterNano FlightControl 37 | 38 | View 39 | ======== 40 | 41 | 42 |
43 | 更多圖片 [Google+ albums](https://plus.google.com/u/0/photos/112822505513154783828/albums/6012450476465469281) 44 | 45 | Config 46 | ======== 47 | 48 | 49 | Schematic 50 | ======== 51 | 52 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/CMSIS/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2013 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 17. January 2013 5 | * $Revision: V1.4.1 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_common_tables.h 9 | * 10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met: 17 | * - Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * - Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in 21 | * the documentation and/or other materials provided with the 22 | * distribution. 23 | * - Neither the name of ARM LIMITED nor the names of its contributors 24 | * may be used to endorse or promote products derived from this 25 | * software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * -------------------------------------------------------------------- */ 40 | 41 | #ifndef _ARM_COMMON_TABLES_H 42 | #define _ARM_COMMON_TABLES_H 43 | 44 | #include "arm_math.h" 45 | 46 | extern const uint16_t armBitRevTable[1024]; 47 | extern const q15_t armRecipTableQ15[64]; 48 | extern const q31_t armRecipTableQ31[64]; 49 | extern const q31_t realCoefAQ31[1024]; 50 | extern const q31_t realCoefBQ31[1024]; 51 | extern const float32_t twiddleCoef_16[32]; 52 | extern const float32_t twiddleCoef_32[64]; 53 | extern const float32_t twiddleCoef_64[128]; 54 | extern const float32_t twiddleCoef_128[256]; 55 | extern const float32_t twiddleCoef_256[512]; 56 | extern const float32_t twiddleCoef_512[1024]; 57 | extern const float32_t twiddleCoef_1024[2048]; 58 | extern const float32_t twiddleCoef_2048[4096]; 59 | extern const float32_t twiddleCoef_4096[8192]; 60 | #define twiddleCoef twiddleCoef_4096 61 | extern const q31_t twiddleCoefQ31[6144]; 62 | extern const q15_t twiddleCoefQ15[6144]; 63 | extern const float32_t twiddleCoef_rfft_32[32]; 64 | extern const float32_t twiddleCoef_rfft_64[64]; 65 | extern const float32_t twiddleCoef_rfft_128[128]; 66 | extern const float32_t twiddleCoef_rfft_256[256]; 67 | extern const float32_t twiddleCoef_rfft_512[512]; 68 | extern const float32_t twiddleCoef_rfft_1024[1024]; 69 | extern const float32_t twiddleCoef_rfft_2048[2048]; 70 | extern const float32_t twiddleCoef_rfft_4096[4096]; 71 | 72 | 73 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) 74 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) 75 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) 76 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) 77 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) 78 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) 79 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) 80 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) 81 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) 82 | 83 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH]; 84 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH]; 85 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH]; 86 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; 87 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; 88 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; 89 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH]; 90 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH]; 91 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH]; 92 | 93 | #endif /* ARM_COMMON_TABLES_H */ 94 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/CMSIS/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2013 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 17. January 2013 5 | * $Revision: V1.4.1 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len16 = { 50 | 16, twiddleCoef_16, armBitRevIndexTable16, ARMBITREVINDEXTABLE__16_TABLE_LENGTH 51 | }; 52 | 53 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len32 = { 54 | 32, twiddleCoef_32, armBitRevIndexTable32, ARMBITREVINDEXTABLE__32_TABLE_LENGTH 55 | }; 56 | 57 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len64 = { 58 | 64, twiddleCoef_64, armBitRevIndexTable64, ARMBITREVINDEXTABLE__64_TABLE_LENGTH 59 | }; 60 | 61 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len128 = { 62 | 128, twiddleCoef_128, armBitRevIndexTable128, ARMBITREVINDEXTABLE_128_TABLE_LENGTH 63 | }; 64 | 65 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len256 = { 66 | 256, twiddleCoef_256, armBitRevIndexTable256, ARMBITREVINDEXTABLE_256_TABLE_LENGTH 67 | }; 68 | 69 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len512 = { 70 | 512, twiddleCoef_512, armBitRevIndexTable512, ARMBITREVINDEXTABLE_512_TABLE_LENGTH 71 | }; 72 | 73 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024 = { 74 | 1024, twiddleCoef_1024, armBitRevIndexTable1024, ARMBITREVINDEXTABLE1024_TABLE_LENGTH 75 | }; 76 | 77 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048 = { 78 | 2048, twiddleCoef_2048, armBitRevIndexTable2048, ARMBITREVINDEXTABLE2048_TABLE_LENGTH 79 | }; 80 | 81 | const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096 = { 82 | 4096, twiddleCoef_4096, armBitRevIndexTable4096, ARMBITREVINDEXTABLE4096_TABLE_LENGTH 83 | }; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/CMSIS/stm32f4xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitSprout/QCopterNano/926637209d0051d8d4bd4299ed4504e62b30c40f/Software/QCopterNano_FlightControl/Libraries/CMSIS/stm32f4xx.h -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/CMSIS/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /** @addtogroup CMSIS 29 | * @{ 30 | */ 31 | 32 | /** @addtogroup stm32f4xx_system 33 | * @{ 34 | */ 35 | 36 | /** 37 | * @brief Define to prevent recursive inclusion 38 | */ 39 | #ifndef __SYSTEM_STM32F4XX_H 40 | #define __SYSTEM_STM32F4XX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** @addtogroup STM32F4xx_System_Includes 47 | * @{ 48 | */ 49 | 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @addtogroup STM32F4xx_System_Exported_types 56 | * @{ 57 | */ 58 | 59 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 60 | 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup STM32F4xx_System_Exported_Constants 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32F4xx_System_Exported_Macros 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @addtogroup STM32F4xx_System_Exported_Functions 83 | * @{ 84 | */ 85 | 86 | extern void SystemInit(void); 87 | extern void SystemCoreClockUpdate(void); 88 | /** 89 | * @} 90 | */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /*__SYSTEM_STM32F4XX_H */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** 103 | * @} 104 | */ 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 106 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file misc.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the miscellaneous 8 | * firmware library functions (add-on to CMSIS functions). 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __MISC_H 31 | #define __MISC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup MISC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | 50 | /** 51 | * @brief NVIC Init Structure definition 52 | */ 53 | 54 | typedef struct 55 | { 56 | uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. 57 | This parameter can be an enumerator of @ref IRQn_Type 58 | enumeration (For the complete STM32 Devices IRQ Channels 59 | list, please refer to stm32f4xx.h file) */ 60 | 61 | uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel 62 | specified in NVIC_IRQChannel. This parameter can be a value 63 | between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table 64 | A lower priority value indicates a higher priority */ 65 | 66 | uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified 67 | in NVIC_IRQChannel. This parameter can be a value 68 | between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table 69 | A lower priority value indicates a higher priority */ 70 | 71 | FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel 72 | will be enabled or disabled. 73 | This parameter can be set either to ENABLE or DISABLE */ 74 | } NVIC_InitTypeDef; 75 | 76 | /* Exported constants --------------------------------------------------------*/ 77 | 78 | /** @defgroup MISC_Exported_Constants 79 | * @{ 80 | */ 81 | 82 | /** @defgroup MISC_Vector_Table_Base 83 | * @{ 84 | */ 85 | 86 | #define NVIC_VectTab_RAM ((uint32_t)0x20000000) 87 | #define NVIC_VectTab_FLASH ((uint32_t)0x08000000) 88 | #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ 89 | ((VECTTAB) == NVIC_VectTab_FLASH)) 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup MISC_System_Low_Power 95 | * @{ 96 | */ 97 | 98 | #define NVIC_LP_SEVONPEND ((uint8_t)0x10) 99 | #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) 100 | #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) 101 | #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ 102 | ((LP) == NVIC_LP_SLEEPDEEP) || \ 103 | ((LP) == NVIC_LP_SLEEPONEXIT)) 104 | /** 105 | * @} 106 | */ 107 | 108 | /** @defgroup MISC_Preemption_Priority_Group 109 | * @{ 110 | */ 111 | 112 | #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority 113 | 4 bits for subpriority */ 114 | #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority 115 | 3 bits for subpriority */ 116 | #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority 117 | 2 bits for subpriority */ 118 | #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority 119 | 1 bits for subpriority */ 120 | #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority 121 | 0 bits for subpriority */ 122 | 123 | #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ 124 | ((GROUP) == NVIC_PriorityGroup_1) || \ 125 | ((GROUP) == NVIC_PriorityGroup_2) || \ 126 | ((GROUP) == NVIC_PriorityGroup_3) || \ 127 | ((GROUP) == NVIC_PriorityGroup_4)) 128 | 129 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 130 | 131 | #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 132 | 133 | #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) 134 | 135 | /** 136 | * @} 137 | */ 138 | 139 | /** @defgroup MISC_SysTick_clock_source 140 | * @{ 141 | */ 142 | 143 | #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) 144 | #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) 145 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ 146 | ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) 147 | /** 148 | * @} 149 | */ 150 | 151 | /** 152 | * @} 153 | */ 154 | 155 | /* Exported macro ------------------------------------------------------------*/ 156 | /* Exported functions --------------------------------------------------------*/ 157 | 158 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 159 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 160 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); 161 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); 162 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); 163 | 164 | #ifdef __cplusplus 165 | } 166 | #endif 167 | 168 | #endif /* __MISC_H */ 169 | 170 | /** 171 | * @} 172 | */ 173 | 174 | /** 175 | * @} 176 | */ 177 | 178 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 179 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_crc.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_CRC_H 31 | #define __STM32F4xx_CRC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup CRC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup CRC_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /* Exported macro ------------------------------------------------------------*/ 60 | /* Exported functions --------------------------------------------------------*/ 61 | 62 | void CRC_ResetDR(void); 63 | uint32_t CRC_CalcCRC(uint32_t Data); 64 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 65 | uint32_t CRC_GetCRC(void); 66 | void CRC_SetIDRegister(uint8_t IDValue); 67 | uint8_t CRC_GetIDRegister(void); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* __STM32F4xx_CRC_H */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 84 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the DBGMCU firmware library. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32F4xx_DBGMCU_H 30 | #define __STM32F4xx_DBGMCU_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "stm32f4xx.h" 38 | 39 | /** @addtogroup STM32F4xx_StdPeriph_Driver 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup DBGMCU 44 | * @{ 45 | */ 46 | 47 | /* Exported types ------------------------------------------------------------*/ 48 | /* Exported constants --------------------------------------------------------*/ 49 | 50 | /** @defgroup DBGMCU_Exported_Constants 51 | * @{ 52 | */ 53 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 54 | #define DBGMCU_STOP ((uint32_t)0x00000002) 55 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 56 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFF8) == 0x00) && ((PERIPH) != 0x00)) 57 | 58 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000001) 59 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00000002) 60 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00000004) 61 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00000008) 62 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00000010) 63 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00000020) 64 | #define DBGMCU_TIM12_STOP ((uint32_t)0x00000040) 65 | #define DBGMCU_TIM13_STOP ((uint32_t)0x00000080) 66 | #define DBGMCU_TIM14_STOP ((uint32_t)0x00000100) 67 | #define DBGMCU_RTC_STOP ((uint32_t)0x00000400) 68 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000800) 69 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00001000) 70 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00200000) 71 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00400000) 72 | #define DBGMCU_I2C3_SMBUS_TIMEOUT ((uint32_t)0x00800000) 73 | #define DBGMCU_CAN1_STOP ((uint32_t)0x02000000) 74 | #define DBGMCU_CAN2_STOP ((uint32_t)0x04000000) 75 | #define IS_DBGMCU_APB1PERIPH(PERIPH) ((((PERIPH) & 0xF91FE200) == 0x00) && ((PERIPH) != 0x00)) 76 | 77 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000001) 78 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00000002) 79 | #define DBGMCU_TIM9_STOP ((uint32_t)0x00010000) 80 | #define DBGMCU_TIM10_STOP ((uint32_t)0x00020000) 81 | #define DBGMCU_TIM11_STOP ((uint32_t)0x00040000) 82 | #define IS_DBGMCU_APB2PERIPH(PERIPH) ((((PERIPH) & 0xFFF8FFFC) == 0x00) && ((PERIPH) != 0x00)) 83 | /** 84 | * @} 85 | */ 86 | 87 | /* Exported macro ------------------------------------------------------------*/ 88 | /* Exported functions --------------------------------------------------------*/ 89 | uint32_t DBGMCU_GetREVID(void); 90 | uint32_t DBGMCU_GetDEVID(void); 91 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 92 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 93 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* __STM32F4xx_DBGMCU_H */ 100 | 101 | /** 102 | * @} 103 | */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 110 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_exti.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_exti.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the EXTI firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_EXTI_H 31 | #define __STM32F4xx_EXTI_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup EXTI 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | 50 | /** 51 | * @brief EXTI mode enumeration 52 | */ 53 | 54 | typedef enum 55 | { 56 | EXTI_Mode_Interrupt = 0x00, 57 | EXTI_Mode_Event = 0x04 58 | }EXTIMode_TypeDef; 59 | 60 | #define IS_EXTI_MODE(MODE) (((MODE) == EXTI_Mode_Interrupt) || ((MODE) == EXTI_Mode_Event)) 61 | 62 | /** 63 | * @brief EXTI Trigger enumeration 64 | */ 65 | 66 | typedef enum 67 | { 68 | EXTI_Trigger_Rising = 0x08, 69 | EXTI_Trigger_Falling = 0x0C, 70 | EXTI_Trigger_Rising_Falling = 0x10 71 | }EXTITrigger_TypeDef; 72 | 73 | #define IS_EXTI_TRIGGER(TRIGGER) (((TRIGGER) == EXTI_Trigger_Rising) || \ 74 | ((TRIGGER) == EXTI_Trigger_Falling) || \ 75 | ((TRIGGER) == EXTI_Trigger_Rising_Falling)) 76 | /** 77 | * @brief EXTI Init Structure definition 78 | */ 79 | 80 | typedef struct 81 | { 82 | uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled. 83 | This parameter can be any combination value of @ref EXTI_Lines */ 84 | 85 | EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines. 86 | This parameter can be a value of @ref EXTIMode_TypeDef */ 87 | 88 | EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines. 89 | This parameter can be a value of @ref EXTITrigger_TypeDef */ 90 | 91 | FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines. 92 | This parameter can be set either to ENABLE or DISABLE */ 93 | }EXTI_InitTypeDef; 94 | 95 | /* Exported constants --------------------------------------------------------*/ 96 | 97 | /** @defgroup EXTI_Exported_Constants 98 | * @{ 99 | */ 100 | 101 | /** @defgroup EXTI_Lines 102 | * @{ 103 | */ 104 | 105 | #define EXTI_Line0 ((uint32_t)0x00001) /*!< External interrupt line 0 */ 106 | #define EXTI_Line1 ((uint32_t)0x00002) /*!< External interrupt line 1 */ 107 | #define EXTI_Line2 ((uint32_t)0x00004) /*!< External interrupt line 2 */ 108 | #define EXTI_Line3 ((uint32_t)0x00008) /*!< External interrupt line 3 */ 109 | #define EXTI_Line4 ((uint32_t)0x00010) /*!< External interrupt line 4 */ 110 | #define EXTI_Line5 ((uint32_t)0x00020) /*!< External interrupt line 5 */ 111 | #define EXTI_Line6 ((uint32_t)0x00040) /*!< External interrupt line 6 */ 112 | #define EXTI_Line7 ((uint32_t)0x00080) /*!< External interrupt line 7 */ 113 | #define EXTI_Line8 ((uint32_t)0x00100) /*!< External interrupt line 8 */ 114 | #define EXTI_Line9 ((uint32_t)0x00200) /*!< External interrupt line 9 */ 115 | #define EXTI_Line10 ((uint32_t)0x00400) /*!< External interrupt line 10 */ 116 | #define EXTI_Line11 ((uint32_t)0x00800) /*!< External interrupt line 11 */ 117 | #define EXTI_Line12 ((uint32_t)0x01000) /*!< External interrupt line 12 */ 118 | #define EXTI_Line13 ((uint32_t)0x02000) /*!< External interrupt line 13 */ 119 | #define EXTI_Line14 ((uint32_t)0x04000) /*!< External interrupt line 14 */ 120 | #define EXTI_Line15 ((uint32_t)0x08000) /*!< External interrupt line 15 */ 121 | #define EXTI_Line16 ((uint32_t)0x10000) /*!< External interrupt line 16 Connected to the PVD Output */ 122 | #define EXTI_Line17 ((uint32_t)0x20000) /*!< External interrupt line 17 Connected to the RTC Alarm event */ 123 | #define EXTI_Line18 ((uint32_t)0x40000) /*!< External interrupt line 18 Connected to the USB OTG FS Wakeup from suspend event */ 124 | #define EXTI_Line19 ((uint32_t)0x80000) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */ 125 | #define EXTI_Line20 ((uint32_t)0x00100000) /*!< External interrupt line 20 Connected to the USB OTG HS (configured in FS) Wakeup event */ 126 | #define EXTI_Line21 ((uint32_t)0x00200000) /*!< External interrupt line 21 Connected to the RTC Tamper and Time Stamp events */ 127 | #define EXTI_Line22 ((uint32_t)0x00400000) /*!< External interrupt line 22 Connected to the RTC Wakeup event */ 128 | 129 | #define IS_EXTI_LINE(LINE) ((((LINE) & (uint32_t)0xFF800000) == 0x00) && ((LINE) != (uint16_t)0x00)) 130 | 131 | #define IS_GET_EXTI_LINE(LINE) (((LINE) == EXTI_Line0) || ((LINE) == EXTI_Line1) || \ 132 | ((LINE) == EXTI_Line2) || ((LINE) == EXTI_Line3) || \ 133 | ((LINE) == EXTI_Line4) || ((LINE) == EXTI_Line5) || \ 134 | ((LINE) == EXTI_Line6) || ((LINE) == EXTI_Line7) || \ 135 | ((LINE) == EXTI_Line8) || ((LINE) == EXTI_Line9) || \ 136 | ((LINE) == EXTI_Line10) || ((LINE) == EXTI_Line11) || \ 137 | ((LINE) == EXTI_Line12) || ((LINE) == EXTI_Line13) || \ 138 | ((LINE) == EXTI_Line14) || ((LINE) == EXTI_Line15) || \ 139 | ((LINE) == EXTI_Line16) || ((LINE) == EXTI_Line17) || \ 140 | ((LINE) == EXTI_Line18) || ((LINE) == EXTI_Line19) || \ 141 | ((LINE) == EXTI_Line20) || ((LINE) == EXTI_Line21) ||\ 142 | ((LINE) == EXTI_Line22)) 143 | 144 | /** 145 | * @} 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /* Exported macro ------------------------------------------------------------*/ 153 | /* Exported functions --------------------------------------------------------*/ 154 | 155 | /* Function used to set the EXTI configuration to the default reset state *****/ 156 | void EXTI_DeInit(void); 157 | 158 | /* Initialization and Configuration functions *********************************/ 159 | void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct); 160 | void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct); 161 | void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line); 162 | 163 | /* Interrupts and flags management functions **********************************/ 164 | FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line); 165 | void EXTI_ClearFlag(uint32_t EXTI_Line); 166 | ITStatus EXTI_GetITStatus(uint32_t EXTI_Line); 167 | void EXTI_ClearITPendingBit(uint32_t EXTI_Line); 168 | 169 | #ifdef __cplusplus 170 | } 171 | #endif 172 | 173 | #endif /* __STM32F4xx_EXTI_H */ 174 | 175 | /** 176 | * @} 177 | */ 178 | 179 | /** 180 | * @} 181 | */ 182 | 183 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 184 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_iwdg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_IWDG_H 31 | #define __STM32F4xx_IWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup IWDG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup IWDG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup IWDG_WriteAccess 56 | * @{ 57 | */ 58 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 59 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 60 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 61 | ((ACCESS) == IWDG_WriteAccess_Disable)) 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup IWDG_prescaler 67 | * @{ 68 | */ 69 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 70 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 71 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 72 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 73 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 74 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 75 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 76 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 77 | ((PRESCALER) == IWDG_Prescaler_8) || \ 78 | ((PRESCALER) == IWDG_Prescaler_16) || \ 79 | ((PRESCALER) == IWDG_Prescaler_32) || \ 80 | ((PRESCALER) == IWDG_Prescaler_64) || \ 81 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 82 | ((PRESCALER) == IWDG_Prescaler_256)) 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup IWDG_Flag 88 | * @{ 89 | */ 90 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 91 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 92 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) 93 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 94 | /** 95 | * @} 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /* Exported macro ------------------------------------------------------------*/ 103 | /* Exported functions --------------------------------------------------------*/ 104 | 105 | /* Prescaler and Counter configuration functions ******************************/ 106 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 107 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 108 | void IWDG_SetReload(uint16_t Reload); 109 | void IWDG_ReloadCounter(void); 110 | 111 | /* IWDG activation function ***************************************************/ 112 | void IWDG_Enable(void); 113 | 114 | /* Flag management function ***************************************************/ 115 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | #endif /* __STM32F4xx_IWDG_H */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 132 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_pwr.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the PWR firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_PWR_H 31 | #define __STM32F4xx_PWR_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup PWR 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup PWR_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup PWR_PVD_detection_level 56 | * @{ 57 | */ 58 | #define PWR_PVDLevel_0 PWR_CR_PLS_LEV0 59 | #define PWR_PVDLevel_1 PWR_CR_PLS_LEV1 60 | #define PWR_PVDLevel_2 PWR_CR_PLS_LEV2 61 | #define PWR_PVDLevel_3 PWR_CR_PLS_LEV3 62 | #define PWR_PVDLevel_4 PWR_CR_PLS_LEV4 63 | #define PWR_PVDLevel_5 PWR_CR_PLS_LEV5 64 | #define PWR_PVDLevel_6 PWR_CR_PLS_LEV6 65 | #define PWR_PVDLevel_7 PWR_CR_PLS_LEV7 66 | 67 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_0) || ((LEVEL) == PWR_PVDLevel_1)|| \ 68 | ((LEVEL) == PWR_PVDLevel_2) || ((LEVEL) == PWR_PVDLevel_3)|| \ 69 | ((LEVEL) == PWR_PVDLevel_4) || ((LEVEL) == PWR_PVDLevel_5)|| \ 70 | ((LEVEL) == PWR_PVDLevel_6) || ((LEVEL) == PWR_PVDLevel_7)) 71 | /** 72 | * @} 73 | */ 74 | 75 | 76 | /** @defgroup PWR_Regulator_state_in_STOP_mode 77 | * @{ 78 | */ 79 | #define PWR_MainRegulator_ON ((uint32_t)0x00000000) 80 | #define PWR_LowPowerRegulator_ON PWR_CR_LPDS 81 | 82 | /* --- PWR_Legacy ---*/ 83 | #define PWR_Regulator_ON PWR_MainRegulator_ON 84 | #define PWR_Regulator_LowPower PWR_LowPowerRegulator_ON 85 | 86 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MainRegulator_ON) || \ 87 | ((REGULATOR) == PWR_LowPowerRegulator_ON)) 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** @defgroup PWR_Regulator_state_in_UnderDrive_mode 94 | * @{ 95 | */ 96 | #define PWR_MainRegulator_UnderDrive_ON PWR_CR_MRUDS 97 | #define PWR_LowPowerRegulator_UnderDrive_ON ((uint32_t)(PWR_CR_LPDS | PWR_CR_LPUDS)) 98 | 99 | #define IS_PWR_REGULATOR_UNDERDRIVE(REGULATOR) (((REGULATOR) == PWR_MainRegulator_UnderDrive_ON) || \ 100 | ((REGULATOR) == PWR_LowPowerRegulator_UnderDrive_ON)) 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | /** @defgroup PWR_STOP_mode_entry 107 | * @{ 108 | */ 109 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 110 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 111 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) 112 | /** 113 | * @} 114 | */ 115 | 116 | /** @defgroup PWR_Regulator_Voltage_Scale 117 | * @{ 118 | */ 119 | #define PWR_Regulator_Voltage_Scale1 ((uint32_t)0x0000C000) 120 | #define PWR_Regulator_Voltage_Scale2 ((uint32_t)0x00008000) 121 | #define PWR_Regulator_Voltage_Scale3 ((uint32_t)0x00004000) 122 | #define IS_PWR_REGULATOR_VOLTAGE(VOLTAGE) (((VOLTAGE) == PWR_Regulator_Voltage_Scale1) || \ 123 | ((VOLTAGE) == PWR_Regulator_Voltage_Scale2) || \ 124 | ((VOLTAGE) == PWR_Regulator_Voltage_Scale3)) 125 | /** 126 | * @} 127 | */ 128 | 129 | /** @defgroup PWR_Flag 130 | * @{ 131 | */ 132 | #define PWR_FLAG_WU PWR_CSR_WUF 133 | #define PWR_FLAG_SB PWR_CSR_SBF 134 | #define PWR_FLAG_PVDO PWR_CSR_PVDO 135 | #define PWR_FLAG_BRR PWR_CSR_BRR 136 | #define PWR_FLAG_VOSRDY PWR_CSR_VOSRDY 137 | #define PWR_FLAG_ODRDY PWR_CSR_ODRDY 138 | #define PWR_FLAG_ODSWRDY PWR_CSR_ODSWRDY 139 | #define PWR_FLAG_UDRDY PWR_CSR_UDSWRDY 140 | 141 | /* --- FLAG Legacy ---*/ 142 | #define PWR_FLAG_REGRDY PWR_FLAG_VOSRDY 143 | 144 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 145 | ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_BRR) || \ 146 | ((FLAG) == PWR_FLAG_VOSRDY) || ((FLAG) == PWR_FLAG_ODRDY) || \ 147 | ((FLAG) == PWR_FLAG_ODSWRDY) || ((FLAG) == PWR_FLAG_UDRDY)) 148 | 149 | 150 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 151 | ((FLAG) == PWR_FLAG_UDRDY)) 152 | 153 | /** 154 | * @} 155 | */ 156 | 157 | /** 158 | * @} 159 | */ 160 | 161 | /* Exported macro ------------------------------------------------------------*/ 162 | /* Exported functions --------------------------------------------------------*/ 163 | 164 | /* Function used to set the PWR configuration to the default reset state ******/ 165 | void PWR_DeInit(void); 166 | 167 | /* Backup Domain Access function **********************************************/ 168 | void PWR_BackupAccessCmd(FunctionalState NewState); 169 | 170 | /* PVD configuration functions ************************************************/ 171 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 172 | void PWR_PVDCmd(FunctionalState NewState); 173 | 174 | /* WakeUp pins configuration functions ****************************************/ 175 | void PWR_WakeUpPinCmd(FunctionalState NewState); 176 | 177 | /* Main and Backup Regulators configuration functions *************************/ 178 | void PWR_BackupRegulatorCmd(FunctionalState NewState); 179 | void PWR_MainRegulatorModeConfig(uint32_t PWR_Regulator_Voltage); 180 | void PWR_OverDriveCmd(FunctionalState NewState); 181 | void PWR_OverDriveSWCmd(FunctionalState NewState); 182 | void PWR_UnderDriveCmd(FunctionalState NewState); 183 | 184 | /* FLASH Power Down configuration functions ***********************************/ 185 | void PWR_FlashPowerDownCmd(FunctionalState NewState); 186 | 187 | /* Low Power modes configuration functions ************************************/ 188 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 189 | void PWR_EnterUnderDriveSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 190 | void PWR_EnterSTANDBYMode(void); 191 | 192 | /* Flags management functions *************************************************/ 193 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 194 | void PWR_ClearFlag(uint32_t PWR_FLAG); 195 | 196 | #ifdef __cplusplus 197 | } 198 | #endif 199 | 200 | #endif /* __STM32F4xx_PWR_H */ 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | /** 207 | * @} 208 | */ 209 | 210 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 211 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rng.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_rng.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the Random 8 | * Number Generator(RNG) firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_RNG_H 31 | #define __STM32F4xx_RNG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup RNG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup RNG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup RNG_flags_definition 56 | * @{ 57 | */ 58 | #define RNG_FLAG_DRDY ((uint8_t)0x0001) /*!< Data ready */ 59 | #define RNG_FLAG_CECS ((uint8_t)0x0002) /*!< Clock error current status */ 60 | #define RNG_FLAG_SECS ((uint8_t)0x0004) /*!< Seed error current status */ 61 | 62 | #define IS_RNG_GET_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_DRDY) || \ 63 | ((RNG_FLAG) == RNG_FLAG_CECS) || \ 64 | ((RNG_FLAG) == RNG_FLAG_SECS)) 65 | #define IS_RNG_CLEAR_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_CECS) || \ 66 | ((RNG_FLAG) == RNG_FLAG_SECS)) 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup RNG_interrupts_definition 72 | * @{ 73 | */ 74 | #define RNG_IT_CEI ((uint8_t)0x20) /*!< Clock error interrupt */ 75 | #define RNG_IT_SEI ((uint8_t)0x40) /*!< Seed error interrupt */ 76 | 77 | #define IS_RNG_IT(IT) ((((IT) & (uint8_t)0x9F) == 0x00) && ((IT) != 0x00)) 78 | #define IS_RNG_GET_IT(RNG_IT) (((RNG_IT) == RNG_IT_CEI) || ((RNG_IT) == RNG_IT_SEI)) 79 | /** 80 | * @} 81 | */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /* Exported macro ------------------------------------------------------------*/ 88 | /* Exported functions --------------------------------------------------------*/ 89 | 90 | /* Function used to set the RNG configuration to the default reset state *****/ 91 | void RNG_DeInit(void); 92 | 93 | /* Configuration function *****************************************************/ 94 | void RNG_Cmd(FunctionalState NewState); 95 | 96 | /* Get 32 bit Random number function ******************************************/ 97 | uint32_t RNG_GetRandomNumber(void); 98 | 99 | /* Interrupts and flags management functions **********************************/ 100 | void RNG_ITConfig(FunctionalState NewState); 101 | FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG); 102 | void RNG_ClearFlag(uint8_t RNG_FLAG); 103 | ITStatus RNG_GetITStatus(uint8_t RNG_IT); 104 | void RNG_ClearITPendingBit(uint8_t RNG_IT); 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | #endif /*__STM32F4xx_RNG_H */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 121 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_syscfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_syscfg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the SYSCFG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_SYSCFG_H 31 | #define __STM32F4xx_SYSCFG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup SYSCFG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup SYSCFG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup SYSCFG_EXTI_Port_Sources 56 | * @{ 57 | */ 58 | #define EXTI_PortSourceGPIOA ((uint8_t)0x00) 59 | #define EXTI_PortSourceGPIOB ((uint8_t)0x01) 60 | #define EXTI_PortSourceGPIOC ((uint8_t)0x02) 61 | #define EXTI_PortSourceGPIOD ((uint8_t)0x03) 62 | #define EXTI_PortSourceGPIOE ((uint8_t)0x04) 63 | #define EXTI_PortSourceGPIOF ((uint8_t)0x05) 64 | #define EXTI_PortSourceGPIOG ((uint8_t)0x06) 65 | #define EXTI_PortSourceGPIOH ((uint8_t)0x07) 66 | #define EXTI_PortSourceGPIOI ((uint8_t)0x08) 67 | #define EXTI_PortSourceGPIOJ ((uint8_t)0x09) 68 | #define EXTI_PortSourceGPIOK ((uint8_t)0x0A) 69 | 70 | #define IS_EXTI_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == EXTI_PortSourceGPIOA) || \ 71 | ((PORTSOURCE) == EXTI_PortSourceGPIOB) || \ 72 | ((PORTSOURCE) == EXTI_PortSourceGPIOC) || \ 73 | ((PORTSOURCE) == EXTI_PortSourceGPIOD) || \ 74 | ((PORTSOURCE) == EXTI_PortSourceGPIOE) || \ 75 | ((PORTSOURCE) == EXTI_PortSourceGPIOF) || \ 76 | ((PORTSOURCE) == EXTI_PortSourceGPIOG) || \ 77 | ((PORTSOURCE) == EXTI_PortSourceGPIOH) || \ 78 | ((PORTSOURCE) == EXTI_PortSourceGPIOI) || \ 79 | ((PORTSOURCE) == EXTI_PortSourceGPIOJ) || \ 80 | ((PORTSOURCE) == EXTI_PortSourceGPIOK)) 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | 87 | /** @defgroup SYSCFG_EXTI_Pin_Sources 88 | * @{ 89 | */ 90 | #define EXTI_PinSource0 ((uint8_t)0x00) 91 | #define EXTI_PinSource1 ((uint8_t)0x01) 92 | #define EXTI_PinSource2 ((uint8_t)0x02) 93 | #define EXTI_PinSource3 ((uint8_t)0x03) 94 | #define EXTI_PinSource4 ((uint8_t)0x04) 95 | #define EXTI_PinSource5 ((uint8_t)0x05) 96 | #define EXTI_PinSource6 ((uint8_t)0x06) 97 | #define EXTI_PinSource7 ((uint8_t)0x07) 98 | #define EXTI_PinSource8 ((uint8_t)0x08) 99 | #define EXTI_PinSource9 ((uint8_t)0x09) 100 | #define EXTI_PinSource10 ((uint8_t)0x0A) 101 | #define EXTI_PinSource11 ((uint8_t)0x0B) 102 | #define EXTI_PinSource12 ((uint8_t)0x0C) 103 | #define EXTI_PinSource13 ((uint8_t)0x0D) 104 | #define EXTI_PinSource14 ((uint8_t)0x0E) 105 | #define EXTI_PinSource15 ((uint8_t)0x0F) 106 | #define IS_EXTI_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == EXTI_PinSource0) || \ 107 | ((PINSOURCE) == EXTI_PinSource1) || \ 108 | ((PINSOURCE) == EXTI_PinSource2) || \ 109 | ((PINSOURCE) == EXTI_PinSource3) || \ 110 | ((PINSOURCE) == EXTI_PinSource4) || \ 111 | ((PINSOURCE) == EXTI_PinSource5) || \ 112 | ((PINSOURCE) == EXTI_PinSource6) || \ 113 | ((PINSOURCE) == EXTI_PinSource7) || \ 114 | ((PINSOURCE) == EXTI_PinSource8) || \ 115 | ((PINSOURCE) == EXTI_PinSource9) || \ 116 | ((PINSOURCE) == EXTI_PinSource10) || \ 117 | ((PINSOURCE) == EXTI_PinSource11) || \ 118 | ((PINSOURCE) == EXTI_PinSource12) || \ 119 | ((PINSOURCE) == EXTI_PinSource13) || \ 120 | ((PINSOURCE) == EXTI_PinSource14) || \ 121 | ((PINSOURCE) == EXTI_PinSource15)) 122 | /** 123 | * @} 124 | */ 125 | 126 | 127 | /** @defgroup SYSCFG_Memory_Remap_Config 128 | * @{ 129 | */ 130 | #define SYSCFG_MemoryRemap_Flash ((uint8_t)0x00) 131 | #define SYSCFG_MemoryRemap_SystemFlash ((uint8_t)0x01) 132 | #define SYSCFG_MemoryRemap_SRAM ((uint8_t)0x03) 133 | #define SYSCFG_MemoryRemap_SDRAM ((uint8_t)0x04) 134 | 135 | #if defined (STM32F40_41xxx) 136 | #define SYSCFG_MemoryRemap_FSMC ((uint8_t)0x02) 137 | #endif /* STM32F40_41xxx */ 138 | 139 | #if defined (STM32F427_437xx) || defined (STM32F429_439xx) 140 | #define SYSCFG_MemoryRemap_FMC ((uint8_t)0x02) 141 | #endif /* STM32F427_437xx || STM32F429_439xx */ 142 | 143 | #if defined (STM32F40_41xxx) 144 | #define IS_SYSCFG_MEMORY_REMAP_CONFING(REMAP) (((REMAP) == SYSCFG_MemoryRemap_Flash) || \ 145 | ((REMAP) == SYSCFG_MemoryRemap_SystemFlash) || \ 146 | ((REMAP) == SYSCFG_MemoryRemap_SRAM) || \ 147 | ((REMAP) == SYSCFG_MemoryRemap_FSMC)) 148 | #endif /* STM32F40_41xxx */ 149 | 150 | #if defined (STM32F401xx) 151 | #define IS_SYSCFG_MEMORY_REMAP_CONFING(REMAP) (((REMAP) == SYSCFG_MemoryRemap_Flash) || \ 152 | ((REMAP) == SYSCFG_MemoryRemap_SystemFlash) || \ 153 | ((REMAP) == SYSCFG_MemoryRemap_SRAM)) 154 | #endif /* STM32F401xx */ 155 | 156 | #if defined (STM32F427_437xx) || defined (STM32F429_439xx) 157 | #define IS_SYSCFG_MEMORY_REMAP_CONFING(REMAP) (((REMAP) == SYSCFG_MemoryRemap_Flash) || \ 158 | ((REMAP) == SYSCFG_MemoryRemap_SystemFlash) || \ 159 | ((REMAP) == SYSCFG_MemoryRemap_SRAM) || \ 160 | ((REMAP) == SYSCFG_MemoryRemap_SDRAM) || \ 161 | ((REMAP) == SYSCFG_MemoryRemap_FMC)) 162 | #endif /* STM32F427_437xx || STM32F429_439xx */ 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | 169 | /** @defgroup SYSCFG_ETHERNET_Media_Interface 170 | * @{ 171 | */ 172 | #define SYSCFG_ETH_MediaInterface_MII ((uint32_t)0x00000000) 173 | #define SYSCFG_ETH_MediaInterface_RMII ((uint32_t)0x00000001) 174 | 175 | #define IS_SYSCFG_ETH_MEDIA_INTERFACE(INTERFACE) (((INTERFACE) == SYSCFG_ETH_MediaInterface_MII) || \ 176 | ((INTERFACE) == SYSCFG_ETH_MediaInterface_RMII)) 177 | /** 178 | * @} 179 | */ 180 | 181 | /** 182 | * @} 183 | */ 184 | 185 | /* Exported macro ------------------------------------------------------------*/ 186 | /* Exported functions --------------------------------------------------------*/ 187 | 188 | void SYSCFG_DeInit(void); 189 | void SYSCFG_MemoryRemapConfig(uint8_t SYSCFG_MemoryRemap); 190 | void SYSCFG_MemorySwappingBank(FunctionalState NewState); 191 | void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex); 192 | void SYSCFG_ETH_MediaInterfaceConfig(uint32_t SYSCFG_ETH_MediaInterface); 193 | void SYSCFG_CompensationCellCmd(FunctionalState NewState); 194 | FlagStatus SYSCFG_GetCompensationCellStatus(void); 195 | 196 | #ifdef __cplusplus 197 | } 198 | #endif 199 | 200 | #endif /*__STM32F4xx_SYSCFG_H */ 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | /** 207 | * @} 208 | */ 209 | 210 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 211 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_wwdg.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2013 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F4xx_WWDG_H 31 | #define __STM32F4xx_WWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f4xx.h" 39 | 40 | /** @addtogroup STM32F4xx_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup WWDG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup WWDG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup WWDG_Prescaler 56 | * @{ 57 | */ 58 | 59 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 60 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 61 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 62 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 63 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 64 | ((PRESCALER) == WWDG_Prescaler_2) || \ 65 | ((PRESCALER) == WWDG_Prescaler_4) || \ 66 | ((PRESCALER) == WWDG_Prescaler_8)) 67 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 68 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /* Exported macro ------------------------------------------------------------*/ 79 | /* Exported functions --------------------------------------------------------*/ 80 | 81 | /* Function used to set the WWDG configuration to the default reset state ****/ 82 | void WWDG_DeInit(void); 83 | 84 | /* Prescaler, Refresh window and Counter configuration functions **************/ 85 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 86 | void WWDG_SetWindowValue(uint8_t WindowValue); 87 | void WWDG_EnableIT(void); 88 | void WWDG_SetCounter(uint8_t Counter); 89 | 90 | /* WWDG activation function ***************************************************/ 91 | void WWDG_Enable(uint8_t Counter); 92 | 93 | /* Interrupts and flags management functions **********************************/ 94 | FlagStatus WWDG_GetFlagStatus(void); 95 | void WWDG_ClearFlag(void); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __STM32F4xx_WWDG_H */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 112 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_crc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_crc.c 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file provides all the CRC firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_crc.h" 30 | 31 | /** @addtogroup STM32F4xx_StdPeriph_Driver 32 | * @{ 33 | */ 34 | 35 | /** @defgroup CRC 36 | * @brief CRC driver modules 37 | * @{ 38 | */ 39 | 40 | /* Private typedef -----------------------------------------------------------*/ 41 | /* Private define ------------------------------------------------------------*/ 42 | /* Private macro -------------------------------------------------------------*/ 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* Private function prototypes -----------------------------------------------*/ 45 | /* Private functions ---------------------------------------------------------*/ 46 | 47 | /** @defgroup CRC_Private_Functions 48 | * @{ 49 | */ 50 | 51 | /** 52 | * @brief Resets the CRC Data register (DR). 53 | * @param None 54 | * @retval None 55 | */ 56 | void CRC_ResetDR(void) 57 | { 58 | /* Reset CRC generator */ 59 | CRC->CR = CRC_CR_RESET; 60 | } 61 | 62 | /** 63 | * @brief Computes the 32-bit CRC of a given data word(32-bit). 64 | * @param Data: data word(32-bit) to compute its CRC 65 | * @retval 32-bit CRC 66 | */ 67 | uint32_t CRC_CalcCRC(uint32_t Data) 68 | { 69 | CRC->DR = Data; 70 | 71 | return (CRC->DR); 72 | } 73 | 74 | /** 75 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). 76 | * @param pBuffer: pointer to the buffer containing the data to be computed 77 | * @param BufferLength: length of the buffer to be computed 78 | * @retval 32-bit CRC 79 | */ 80 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) 81 | { 82 | uint32_t index = 0; 83 | 84 | for(index = 0; index < BufferLength; index++) 85 | { 86 | CRC->DR = pBuffer[index]; 87 | } 88 | return (CRC->DR); 89 | } 90 | 91 | /** 92 | * @brief Returns the current CRC value. 93 | * @param None 94 | * @retval 32-bit CRC 95 | */ 96 | uint32_t CRC_GetCRC(void) 97 | { 98 | return (CRC->DR); 99 | } 100 | 101 | /** 102 | * @brief Stores a 8-bit data in the Independent Data(ID) register. 103 | * @param IDValue: 8-bit value to be stored in the ID register 104 | * @retval None 105 | */ 106 | void CRC_SetIDRegister(uint8_t IDValue) 107 | { 108 | CRC->IDR = IDValue; 109 | } 110 | 111 | /** 112 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register 113 | * @param None 114 | * @retval 8-bit value of the ID register 115 | */ 116 | uint8_t CRC_GetIDRegister(void) 117 | { 118 | return (CRC->IDR); 119 | } 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | /** 130 | * @} 131 | */ 132 | 133 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 134 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_dbgmcu.c 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file provides all the DBGMCU firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_dbgmcu.h" 30 | 31 | /** @addtogroup STM32F4xx_StdPeriph_Driver 32 | * @{ 33 | */ 34 | 35 | /** @defgroup DBGMCU 36 | * @brief DBGMCU driver modules 37 | * @{ 38 | */ 39 | 40 | /* Private typedef -----------------------------------------------------------*/ 41 | /* Private define ------------------------------------------------------------*/ 42 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) 43 | 44 | /* Private macro -------------------------------------------------------------*/ 45 | /* Private variables ---------------------------------------------------------*/ 46 | /* Private function prototypes -----------------------------------------------*/ 47 | /* Private functions ---------------------------------------------------------*/ 48 | 49 | /** @defgroup DBGMCU_Private_Functions 50 | * @{ 51 | */ 52 | 53 | /** 54 | * @brief Returns the device revision identifier. 55 | * @param None 56 | * @retval Device revision identifier 57 | */ 58 | uint32_t DBGMCU_GetREVID(void) 59 | { 60 | return(DBGMCU->IDCODE >> 16); 61 | } 62 | 63 | /** 64 | * @brief Returns the device identifier. 65 | * @param None 66 | * @retval Device identifier 67 | */ 68 | uint32_t DBGMCU_GetDEVID(void) 69 | { 70 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); 71 | } 72 | 73 | /** 74 | * @brief Configures low power mode behavior when the MCU is in Debug mode. 75 | * @param DBGMCU_Periph: specifies the low power mode. 76 | * This parameter can be any combination of the following values: 77 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode 78 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode 79 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode 80 | * @param NewState: new state of the specified low power mode in Debug mode. 81 | * This parameter can be: ENABLE or DISABLE. 82 | * @retval None 83 | */ 84 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) 85 | { 86 | /* Check the parameters */ 87 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); 88 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 89 | if (NewState != DISABLE) 90 | { 91 | DBGMCU->CR |= DBGMCU_Periph; 92 | } 93 | else 94 | { 95 | DBGMCU->CR &= ~DBGMCU_Periph; 96 | } 97 | } 98 | 99 | /** 100 | * @brief Configures APB1 peripheral behavior when the MCU is in Debug mode. 101 | * @param DBGMCU_Periph: specifies the APB1 peripheral. 102 | * This parameter can be any combination of the following values: 103 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted 104 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted 105 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted 106 | * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted 107 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted 108 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted 109 | * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted 110 | * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted 111 | * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted 112 | * @arg DBGMCU_RTC_STOP: RTC Calendar and Wakeup counter stopped when Core is halted. 113 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted 114 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted 115 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted 116 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted 117 | * @arg DBGMCU_I2C3_SMBUS_TIMEOUT: I2C3 SMBUS timeout mode stopped when Core is halted 118 | * @arg DBGMCU_CAN2_STOP: Debug CAN1 stopped when Core is halted 119 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted 120 | * This parameter can be: ENABLE or DISABLE. 121 | * @retval None 122 | */ 123 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState) 124 | { 125 | /* Check the parameters */ 126 | assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph)); 127 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 128 | 129 | if (NewState != DISABLE) 130 | { 131 | DBGMCU->APB1FZ |= DBGMCU_Periph; 132 | } 133 | else 134 | { 135 | DBGMCU->APB1FZ &= ~DBGMCU_Periph; 136 | } 137 | } 138 | 139 | /** 140 | * @brief Configures APB2 peripheral behavior when the MCU is in Debug mode. 141 | * @param DBGMCU_Periph: specifies the APB2 peripheral. 142 | * This parameter can be any combination of the following values: 143 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted 144 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted 145 | * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted 146 | * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted 147 | * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted 148 | * @param NewState: new state of the specified peripheral in Debug mode. 149 | * This parameter can be: ENABLE or DISABLE. 150 | * @retval None 151 | */ 152 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState) 153 | { 154 | /* Check the parameters */ 155 | assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph)); 156 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 157 | 158 | if (NewState != DISABLE) 159 | { 160 | DBGMCU->APB2FZ |= DBGMCU_Periph; 161 | } 162 | else 163 | { 164 | DBGMCU->APB2FZ &= ~DBGMCU_Periph; 165 | } 166 | } 167 | 168 | /** 169 | * @} 170 | */ 171 | 172 | /** 173 | * @} 174 | */ 175 | 176 | /** 177 | * @} 178 | */ 179 | 180 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 181 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_md5.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hash_md5.c 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file provides high level functions to compute the HASH MD5 and 8 | * HMAC MD5 Digest of an input message. 9 | * It uses the stm32f4xx_hash.c/.h drivers to access the STM32F4xx HASH 10 | * peripheral. 11 | * 12 | @verbatim 13 | =================================================================== 14 | ##### How to use this driver ##### 15 | =================================================================== 16 | [..] 17 | (#) Enable The HASH controller clock using 18 | RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_HASH, ENABLE); function. 19 | 20 | (#) Calculate the HASH MD5 Digest using HASH_MD5() function. 21 | 22 | (#) Calculate the HMAC MD5 Digest using HMAC_MD5() function. 23 | 24 | @endverbatim 25 | * 26 | ****************************************************************************** 27 | * @attention 28 | * 29 | *

© COPYRIGHT 2013 STMicroelectronics

30 | * 31 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 32 | * You may not use this file except in compliance with the License. 33 | * You may obtain a copy of the License at: 34 | * 35 | * http://www.st.com/software_license_agreement_liberty_v2 36 | * 37 | * Unless required by applicable law or agreed to in writing, software 38 | * distributed under the License is distributed on an "AS IS" BASIS, 39 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 40 | * See the License for the specific language governing permissions and 41 | * limitations under the License. 42 | * 43 | ****************************************************************************** 44 | */ 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f4xx_hash.h" 48 | 49 | /** @addtogroup STM32F4xx_StdPeriph_Driver 50 | * @{ 51 | */ 52 | 53 | /** @defgroup HASH 54 | * @brief HASH driver modules 55 | * @{ 56 | */ 57 | 58 | /* Private typedef -----------------------------------------------------------*/ 59 | /* Private define ------------------------------------------------------------*/ 60 | #define MD5BUSY_TIMEOUT ((uint32_t) 0x00010000) 61 | 62 | /* Private macro -------------------------------------------------------------*/ 63 | /* Private variables ---------------------------------------------------------*/ 64 | /* Private function prototypes -----------------------------------------------*/ 65 | /* Private functions ---------------------------------------------------------*/ 66 | 67 | /** @defgroup HASH_Private_Functions 68 | * @{ 69 | */ 70 | 71 | /** @defgroup HASH_Group7 High Level MD5 functions 72 | * @brief High Level MD5 Hash and HMAC functions 73 | * 74 | @verbatim 75 | =============================================================================== 76 | ##### High Level MD5 Hash and HMAC functions ##### 77 | =============================================================================== 78 | 79 | 80 | @endverbatim 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @brief Compute the HASH MD5 digest. 86 | * @param Input: pointer to the Input buffer to be treated. 87 | * @param Ilen: length of the Input buffer. 88 | * @param Output: the returned digest 89 | * @retval An ErrorStatus enumeration value: 90 | * - SUCCESS: digest computation done 91 | * - ERROR: digest computation failed 92 | */ 93 | ErrorStatus HASH_MD5(uint8_t *Input, uint32_t Ilen, uint8_t Output[16]) 94 | { 95 | HASH_InitTypeDef MD5_HASH_InitStructure; 96 | HASH_MsgDigest MD5_MessageDigest; 97 | __IO uint16_t nbvalidbitsdata = 0; 98 | uint32_t i = 0; 99 | __IO uint32_t counter = 0; 100 | uint32_t busystatus = 0; 101 | ErrorStatus status = SUCCESS; 102 | uint32_t inputaddr = (uint32_t)Input; 103 | uint32_t outputaddr = (uint32_t)Output; 104 | 105 | 106 | /* Number of valid bits in last word of the Input data */ 107 | nbvalidbitsdata = 8 * (Ilen % 4); 108 | 109 | /* HASH peripheral initialization */ 110 | HASH_DeInit(); 111 | 112 | /* HASH Configuration */ 113 | MD5_HASH_InitStructure.HASH_AlgoSelection = HASH_AlgoSelection_MD5; 114 | MD5_HASH_InitStructure.HASH_AlgoMode = HASH_AlgoMode_HASH; 115 | MD5_HASH_InitStructure.HASH_DataType = HASH_DataType_8b; 116 | HASH_Init(&MD5_HASH_InitStructure); 117 | 118 | /* Configure the number of valid bits in last word of the data */ 119 | HASH_SetLastWordValidBitsNbr(nbvalidbitsdata); 120 | 121 | /* Write the Input block in the IN FIFO */ 122 | for(i=0; i 64) 197 | { 198 | /* HMAC long Key */ 199 | MD5_HASH_InitStructure.HASH_HMACKeyType = HASH_HMACKeyType_LongKey; 200 | } 201 | else 202 | { 203 | /* HMAC short Key */ 204 | MD5_HASH_InitStructure.HASH_HMACKeyType = HASH_HMACKeyType_ShortKey; 205 | } 206 | HASH_Init(&MD5_HASH_InitStructure); 207 | 208 | /* Configure the number of valid bits in last word of the Key */ 209 | HASH_SetLastWordValidBitsNbr(nbvalidbitskey); 210 | 211 | /* Write the Key */ 212 | for(i=0; i
© COPYRIGHT 2013 STMicroelectronics
68 | * 69 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 70 | * You may not use this file except in compliance with the License. 71 | * You may obtain a copy of the License at: 72 | * 73 | * http://www.st.com/software_license_agreement_liberty_v2 74 | * 75 | * Unless required by applicable law or agreed to in writing, software 76 | * distributed under the License is distributed on an "AS IS" BASIS, 77 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 78 | * See the License for the specific language governing permissions and 79 | * limitations under the License. 80 | * 81 | ****************************************************************************** 82 | */ 83 | 84 | /* Includes ------------------------------------------------------------------*/ 85 | #include "stm32f4xx_iwdg.h" 86 | 87 | /** @addtogroup STM32F4xx_StdPeriph_Driver 88 | * @{ 89 | */ 90 | 91 | /** @defgroup IWDG 92 | * @brief IWDG driver modules 93 | * @{ 94 | */ 95 | 96 | /* Private typedef -----------------------------------------------------------*/ 97 | /* Private define ------------------------------------------------------------*/ 98 | 99 | /* KR register bit mask */ 100 | #define KR_KEY_RELOAD ((uint16_t)0xAAAA) 101 | #define KR_KEY_ENABLE ((uint16_t)0xCCCC) 102 | 103 | /* Private macro -------------------------------------------------------------*/ 104 | /* Private variables ---------------------------------------------------------*/ 105 | /* Private function prototypes -----------------------------------------------*/ 106 | /* Private functions ---------------------------------------------------------*/ 107 | 108 | /** @defgroup IWDG_Private_Functions 109 | * @{ 110 | */ 111 | 112 | /** @defgroup IWDG_Group1 Prescaler and Counter configuration functions 113 | * @brief Prescaler and Counter configuration functions 114 | * 115 | @verbatim 116 | =============================================================================== 117 | ##### Prescaler and Counter configuration functions ##### 118 | =============================================================================== 119 | 120 | @endverbatim 121 | * @{ 122 | */ 123 | 124 | /** 125 | * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers. 126 | * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers. 127 | * This parameter can be one of the following values: 128 | * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers 129 | * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers 130 | * @retval None 131 | */ 132 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess) 133 | { 134 | /* Check the parameters */ 135 | assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); 136 | IWDG->KR = IWDG_WriteAccess; 137 | } 138 | 139 | /** 140 | * @brief Sets IWDG Prescaler value. 141 | * @param IWDG_Prescaler: specifies the IWDG Prescaler value. 142 | * This parameter can be one of the following values: 143 | * @arg IWDG_Prescaler_4: IWDG prescaler set to 4 144 | * @arg IWDG_Prescaler_8: IWDG prescaler set to 8 145 | * @arg IWDG_Prescaler_16: IWDG prescaler set to 16 146 | * @arg IWDG_Prescaler_32: IWDG prescaler set to 32 147 | * @arg IWDG_Prescaler_64: IWDG prescaler set to 64 148 | * @arg IWDG_Prescaler_128: IWDG prescaler set to 128 149 | * @arg IWDG_Prescaler_256: IWDG prescaler set to 256 150 | * @retval None 151 | */ 152 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler) 153 | { 154 | /* Check the parameters */ 155 | assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler)); 156 | IWDG->PR = IWDG_Prescaler; 157 | } 158 | 159 | /** 160 | * @brief Sets IWDG Reload value. 161 | * @param Reload: specifies the IWDG Reload value. 162 | * This parameter must be a number between 0 and 0x0FFF. 163 | * @retval None 164 | */ 165 | void IWDG_SetReload(uint16_t Reload) 166 | { 167 | /* Check the parameters */ 168 | assert_param(IS_IWDG_RELOAD(Reload)); 169 | IWDG->RLR = Reload; 170 | } 171 | 172 | /** 173 | * @brief Reloads IWDG counter with value defined in the reload register 174 | * (write access to IWDG_PR and IWDG_RLR registers disabled). 175 | * @param None 176 | * @retval None 177 | */ 178 | void IWDG_ReloadCounter(void) 179 | { 180 | IWDG->KR = KR_KEY_RELOAD; 181 | } 182 | 183 | /** 184 | * @} 185 | */ 186 | 187 | /** @defgroup IWDG_Group2 IWDG activation function 188 | * @brief IWDG activation function 189 | * 190 | @verbatim 191 | =============================================================================== 192 | ##### IWDG activation function ##### 193 | =============================================================================== 194 | 195 | @endverbatim 196 | * @{ 197 | */ 198 | 199 | /** 200 | * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). 201 | * @param None 202 | * @retval None 203 | */ 204 | void IWDG_Enable(void) 205 | { 206 | IWDG->KR = KR_KEY_ENABLE; 207 | } 208 | 209 | /** 210 | * @} 211 | */ 212 | 213 | /** @defgroup IWDG_Group3 Flag management function 214 | * @brief Flag management function 215 | * 216 | @verbatim 217 | =============================================================================== 218 | ##### Flag management function ##### 219 | =============================================================================== 220 | 221 | @endverbatim 222 | * @{ 223 | */ 224 | 225 | /** 226 | * @brief Checks whether the specified IWDG flag is set or not. 227 | * @param IWDG_FLAG: specifies the flag to check. 228 | * This parameter can be one of the following values: 229 | * @arg IWDG_FLAG_PVU: Prescaler Value Update on going 230 | * @arg IWDG_FLAG_RVU: Reload Value Update on going 231 | * @retval The new state of IWDG_FLAG (SET or RESET). 232 | */ 233 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG) 234 | { 235 | FlagStatus bitstatus = RESET; 236 | /* Check the parameters */ 237 | assert_param(IS_IWDG_FLAG(IWDG_FLAG)); 238 | if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) 239 | { 240 | bitstatus = SET; 241 | } 242 | else 243 | { 244 | bitstatus = RESET; 245 | } 246 | /* Return the flag status */ 247 | return bitstatus; 248 | } 249 | 250 | /** 251 | * @} 252 | */ 253 | 254 | /** 255 | * @} 256 | */ 257 | 258 | /** 259 | * @} 260 | */ 261 | 262 | /** 263 | * @} 264 | */ 265 | 266 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 267 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_syscfg.c 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 08-November-2013 7 | * @brief This file provides firmware functions to manage the SYSCFG peripheral. 8 | * 9 | @verbatim 10 | 11 | =============================================================================== 12 | ##### How to use this driver ##### 13 | =============================================================================== 14 | [..] This driver provides functions for: 15 | 16 | (#) Remapping the memory accessible in the code area using SYSCFG_MemoryRemapConfig() 17 | 18 | (#) Swapping the internal flash Bank1 and Bank2 this features is only visible for 19 | STM32F42xxx/43xxx devices Devices. 20 | 21 | (#) Manage the EXTI lines connection to the GPIOs using SYSCFG_EXTILineConfig() 22 | 23 | (#) Select the ETHERNET media interface (RMII/RII) using SYSCFG_ETH_MediaInterfaceConfig() 24 | 25 | -@- SYSCFG APB clock must be enabled to get write access to SYSCFG registers, 26 | using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); 27 | 28 | @endverbatim 29 | ****************************************************************************** 30 | * @attention 31 | * 32 | *

© COPYRIGHT 2013 STMicroelectronics

33 | * 34 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 35 | * You may not use this file except in compliance with the License. 36 | * You may obtain a copy of the License at: 37 | * 38 | * http://www.st.com/software_license_agreement_liberty_v2 39 | * 40 | * Unless required by applicable law or agreed to in writing, software 41 | * distributed under the License is distributed on an "AS IS" BASIS, 42 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 43 | * See the License for the specific language governing permissions and 44 | * limitations under the License. 45 | * 46 | ****************************************************************************** 47 | */ 48 | 49 | /* Includes ------------------------------------------------------------------*/ 50 | #include "stm32f4xx_syscfg.h" 51 | #include "stm32f4xx_rcc.h" 52 | 53 | /** @addtogroup STM32F4xx_StdPeriph_Driver 54 | * @{ 55 | */ 56 | 57 | /** @defgroup SYSCFG 58 | * @brief SYSCFG driver modules 59 | * @{ 60 | */ 61 | 62 | /* Private typedef -----------------------------------------------------------*/ 63 | /* Private define ------------------------------------------------------------*/ 64 | /* ------------ RCC registers bit address in the alias region ----------- */ 65 | #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE) 66 | /* --- MEMRMP Register ---*/ 67 | /* Alias word address of UFB_MODE bit */ 68 | #define MEMRMP_OFFSET SYSCFG_OFFSET 69 | #define UFB_MODE_BitNumber ((uint8_t)0x8) 70 | #define UFB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32) + (UFB_MODE_BitNumber * 4)) 71 | 72 | 73 | /* --- PMC Register ---*/ 74 | /* Alias word address of MII_RMII_SEL bit */ 75 | #define PMC_OFFSET (SYSCFG_OFFSET + 0x04) 76 | #define MII_RMII_SEL_BitNumber ((uint8_t)0x17) 77 | #define PMC_MII_RMII_SEL_BB (PERIPH_BB_BASE + (PMC_OFFSET * 32) + (MII_RMII_SEL_BitNumber * 4)) 78 | 79 | /* --- CMPCR Register ---*/ 80 | /* Alias word address of CMP_PD bit */ 81 | #define CMPCR_OFFSET (SYSCFG_OFFSET + 0x20) 82 | #define CMP_PD_BitNumber ((uint8_t)0x00) 83 | #define CMPCR_CMP_PD_BB (PERIPH_BB_BASE + (CMPCR_OFFSET * 32) + (CMP_PD_BitNumber * 4)) 84 | 85 | /* Private macro -------------------------------------------------------------*/ 86 | /* Private variables ---------------------------------------------------------*/ 87 | /* Private function prototypes -----------------------------------------------*/ 88 | /* Private functions ---------------------------------------------------------*/ 89 | 90 | /** @defgroup SYSCFG_Private_Functions 91 | * @{ 92 | */ 93 | 94 | /** 95 | * @brief Deinitializes the Alternate Functions (remap and EXTI configuration) 96 | * registers to their default reset values. 97 | * @param None 98 | * @retval None 99 | */ 100 | void SYSCFG_DeInit(void) 101 | { 102 | RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE); 103 | RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, DISABLE); 104 | } 105 | 106 | /** 107 | * @brief Changes the mapping of the specified pin. 108 | * @param SYSCFG_Memory: selects the memory remapping. 109 | * This parameter can be one of the following values: 110 | * @arg SYSCFG_MemoryRemap_Flash: Main Flash memory mapped at 0x00000000 111 | * @arg SYSCFG_MemoryRemap_SystemFlash: System Flash memory mapped at 0x00000000 112 | * @arg SYSCFG_MemoryRemap_FSMC: FSMC (Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000 for STM32F405xx/407xx and STM32F415xx/417xx devices. 113 | * @arg SYSCFG_MemoryRemap_FMC: FMC (Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000 for STM32F42xxx/43xxx devices. 114 | * @arg SYSCFG_MemoryRemap_SRAM: Embedded SRAM (112kB) mapped at 0x00000000 115 | * @arg SYSCFG_MemoryRemap_SDRAM: FMC (External SDRAM) mapped at 0x00000000 for STM32F42xxx/43xxx devices. 116 | * @retval None 117 | */ 118 | void SYSCFG_MemoryRemapConfig(uint8_t SYSCFG_MemoryRemap) 119 | { 120 | /* Check the parameters */ 121 | assert_param(IS_SYSCFG_MEMORY_REMAP_CONFING(SYSCFG_MemoryRemap)); 122 | 123 | SYSCFG->MEMRMP = SYSCFG_MemoryRemap; 124 | } 125 | 126 | /** 127 | * @brief Enables or disables the Interal FLASH Bank Swapping. 128 | * 129 | * @note This function can be used only for STM32F42xxx/43xxx devices. 130 | * 131 | * @param NewState: new state of Interal FLASH Bank swapping. 132 | * This parameter can be one of the following values: 133 | * @arg ENABLE: Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000) 134 | * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000) 135 | * @arg DISABLE:(the default state) Flash Bank1 mapped at 0x08000000 (and aliased @0x0000 0000) 136 | and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000) 137 | * @retval None 138 | */ 139 | void SYSCFG_MemorySwappingBank(FunctionalState NewState) 140 | { 141 | /* Check the parameters */ 142 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 143 | 144 | *(__IO uint32_t *) UFB_MODE_BB = (uint32_t)NewState; 145 | } 146 | 147 | /** 148 | * @brief Selects the GPIO pin used as EXTI Line. 149 | * @param EXTI_PortSourceGPIOx : selects the GPIO port to be used as source for 150 | * EXTI lines where x can be (A..K) for STM32F42xxx/43xxx devices, (A..I) 151 | * for STM32F405xx/407xx and STM32F415xx/417xx devices or (A, B, C, D and H) 152 | * for STM32401xx devices. 153 | * 154 | * @param EXTI_PinSourcex: specifies the EXTI line to be configured. 155 | * This parameter can be EXTI_PinSourcex where x can be (0..15, except 156 | * for EXTI_PortSourceGPIOI x can be (0..11) for STM32F405xx/407xx 157 | * and STM32F405xx/407xx devices and for EXTI_PortSourceGPIOK x can 158 | * be (0..7) for STM32F42xxx/43xxx devices. 159 | * 160 | * @retval None 161 | */ 162 | void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex) 163 | { 164 | uint32_t tmp = 0x00; 165 | 166 | /* Check the parameters */ 167 | assert_param(IS_EXTI_PORT_SOURCE(EXTI_PortSourceGPIOx)); 168 | assert_param(IS_EXTI_PIN_SOURCE(EXTI_PinSourcex)); 169 | 170 | tmp = ((uint32_t)0x0F) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03)); 171 | SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] &= ~tmp; 172 | SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] |= (((uint32_t)EXTI_PortSourceGPIOx) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03))); 173 | } 174 | 175 | /** 176 | * @brief Selects the ETHERNET media interface 177 | * @param SYSCFG_ETH_MediaInterface: specifies the Media Interface mode. 178 | * This parameter can be one of the following values: 179 | * @arg SYSCFG_ETH_MediaInterface_MII: MII mode selected 180 | * @arg SYSCFG_ETH_MediaInterface_RMII: RMII mode selected 181 | * @retval None 182 | */ 183 | void SYSCFG_ETH_MediaInterfaceConfig(uint32_t SYSCFG_ETH_MediaInterface) 184 | { 185 | assert_param(IS_SYSCFG_ETH_MEDIA_INTERFACE(SYSCFG_ETH_MediaInterface)); 186 | /* Configure MII_RMII selection bit */ 187 | *(__IO uint32_t *) PMC_MII_RMII_SEL_BB = SYSCFG_ETH_MediaInterface; 188 | } 189 | 190 | /** 191 | * @brief Enables or disables the I/O Compensation Cell. 192 | * @note The I/O compensation cell can be used only when the device supply 193 | * voltage ranges from 2.4 to 3.6 V. 194 | * @param NewState: new state of the I/O Compensation Cell. 195 | * This parameter can be one of the following values: 196 | * @arg ENABLE: I/O compensation cell enabled 197 | * @arg DISABLE: I/O compensation cell power-down mode 198 | * @retval None 199 | */ 200 | void SYSCFG_CompensationCellCmd(FunctionalState NewState) 201 | { 202 | /* Check the parameters */ 203 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 204 | 205 | *(__IO uint32_t *) CMPCR_CMP_PD_BB = (uint32_t)NewState; 206 | } 207 | 208 | /** 209 | * @brief Checks whether the I/O Compensation Cell ready flag is set or not. 210 | * @param None 211 | * @retval The new state of the I/O Compensation Cell ready flag (SET or RESET) 212 | */ 213 | FlagStatus SYSCFG_GetCompensationCellStatus(void) 214 | { 215 | FlagStatus bitstatus = RESET; 216 | 217 | if ((SYSCFG->CMPCR & SYSCFG_CMPCR_READY ) != (uint32_t)RESET) 218 | { 219 | bitstatus = SET; 220 | } 221 | else 222 | { 223 | bitstatus = RESET; 224 | } 225 | return bitstatus; 226 | } 227 | 228 | /** 229 | * @} 230 | */ 231 | 232 | /** 233 | * @} 234 | */ 235 | 236 | /** 237 | * @} 238 | */ 239 | 240 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 241 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Algorithms/algorithm_ahrs.c: -------------------------------------------------------------------------------- 1 | /*====================================================================================================*/ 2 | /*====================================================================================================*/ 3 | #include "stm32f4_system.h" 4 | #include "algorithm_ahrs.h" 5 | #include "module_imu.h" 6 | #include "algorithm_mathUnit.h" 7 | #include "algorithm_quaternion.h" 8 | /*====================================================================================================*/ 9 | /*====================================================================================================*/ 10 | #define KpDef 2500 11 | #define KiDef 1 12 | 13 | static fpc32 Kp = (2.0f * KpDef) * SampleRate; 14 | static fpc32 Ki = (2.0f * KiDef) * SampleRate; 15 | /*====================================================================================================*/ 16 | /*====================================================================================================*/ 17 | void AHRS_Init( Quaternion *pNumQ, EulerAngle *pAngE ) 18 | { 19 | pNumQ->q0 = 1.0f; 20 | pNumQ->q1 = 0.0f; 21 | pNumQ->q2 = 0.0f; 22 | pNumQ->q3 = 0.0f; 23 | 24 | pAngE->Pitch = 0.0f; 25 | pAngE->Roll = 0.0f; 26 | pAngE->Yaw = 0.0f; 27 | } 28 | /*====================================================================================================*/ 29 | /*====================================================================================================*/ 30 | void AHRS_Update( void ) 31 | { 32 | // fp32 tempX = 0, tempY = 0; 33 | fp32 Normalize; 34 | fp32 gx, gy, gz; 35 | // fp32 hx, hy, hz; 36 | // fp32 wx, wy, wz; 37 | // fp32 bx, bz; 38 | fp32 ErrX, ErrY, ErrZ; 39 | fp32 AccX, AccY, AccZ; 40 | fp32 GyrX, GyrY, GyrZ; 41 | // fp32 MegX, MegY, MegZ; 42 | fp32 /*Mq11, Mq12, */Mq13,/* Mq21, Mq22, */Mq23,/* Mq31, Mq32, */Mq33; 43 | 44 | // static fp32 AngZ_Temp = 0.0f; 45 | static fp32 exInt = 0.0f, eyInt = 0.0f, ezInt = 0.0f; 46 | 47 | // Mq11 = NumQ.q0*NumQ.q0 + NumQ.q1*NumQ.q1 - NumQ.q2*NumQ.q2 - NumQ.q3*NumQ.q3; 48 | // Mq12 = 2.0f*(NumQ.q1*NumQ.q2 + NumQ.q0*NumQ.q3); 49 | Mq13 = 2.0f*(NumQ.q1*NumQ.q3 - NumQ.q0*NumQ.q2); 50 | // Mq21 = 2.0f*(NumQ.q1*NumQ.q2 - NumQ.q0*NumQ.q3); 51 | // Mq22 = NumQ.q0*NumQ.q0 - NumQ.q1*NumQ.q1 + NumQ.q2*NumQ.q2 - NumQ.q3*NumQ.q3; 52 | Mq23 = 2.0f*(NumQ.q0*NumQ.q1 + NumQ.q2*NumQ.q3); 53 | // Mq31 = 2.0f*(NumQ.q0*NumQ.q2 + NumQ.q1*NumQ.q3); 54 | // Mq32 = 2.0f*(NumQ.q2*NumQ.q3 - NumQ.q0*NumQ.q1); 55 | Mq33 = NumQ.q0*NumQ.q0 - NumQ.q1*NumQ.q1 - NumQ.q2*NumQ.q2 + NumQ.q3*NumQ.q3; 56 | 57 | Normalize = invSqrtf(squa(Acc.TrueX) + squa(Acc.TrueY) + squa(Acc.TrueZ)); 58 | AccX = Acc.TrueX*Normalize; 59 | AccY = Acc.TrueY*Normalize; 60 | AccZ = Acc.TrueZ*Normalize; 61 | 62 | // Normalize = invSqrtf(squa(Meg.TrueX) + squa(Meg.TrueY) + squa(Meg.TrueZ)); 63 | // MegX = Meg.TrueX*Normalize; 64 | // MegY = Meg.TrueY*Normalize; 65 | // MegZ = Meg.TrueZ*Normalize; 66 | 67 | gx = Mq13; 68 | gy = Mq23; 69 | gz = Mq33; 70 | 71 | // hx = MegX*Mq11 + MegY*Mq21 + MegZ*Mq31; 72 | // hy = MegX*Mq12 + MegY*Mq22 + MegZ*Mq32; 73 | // hz = MegX*Mq13 + MegY*Mq23 + MegZ*Mq33; 74 | 75 | // bx = sqrtf(squa(hx) + squa(hy)); 76 | // bz = hz; 77 | 78 | // wx = bx*Mq11 + bz*Mq13; 79 | // wy = bx*Mq21 + bz*Mq23; 80 | // wz = bx*Mq31 + bz*Mq33; 81 | 82 | ErrX = (AccY*gz - AccZ*gy)/* + (MegY*wz - MegZ*wy)*/; 83 | ErrY = (AccZ*gx - AccX*gz)/* + (MegZ*wx - MegX*wz)*/; 84 | ErrZ = (AccX*gy - AccY*gx)/* + (MegX*wy - MegY*wx)*/; 85 | 86 | exInt = exInt + ErrX*Ki; 87 | eyInt = eyInt + ErrY*Ki; 88 | ezInt = ezInt + ErrZ*Ki; 89 | 90 | GyrX = toRad(Gyr.TrueX) + Kp*ErrX + exInt; 91 | GyrY = toRad(Gyr.TrueY) + Kp*ErrY + eyInt; 92 | GyrZ = toRad(Gyr.TrueZ) + Kp*ErrZ + ezInt; 93 | 94 | Quaternion_RungeKutta(&NumQ, GyrX, GyrY, GyrZ, SampleRateHelf); 95 | Quaternion_Normalize(&NumQ); 96 | Quaternion_ToAngE(&NumQ, &AngE); 97 | 98 | // tempX = ( Mag.X*arm_cos_f32(Mag.EllipseSita)+Mag.Y*arm_sin_f32(Mag.EllipseSita))/Mag.EllipseB; 99 | // tempY = (-Mag.X*arm_sin_f32(Mag.EllipseSita)+Mag.Y*arm_cos_f32(Mag.EllipseSita))/Mag.EllipseA; 100 | // AngE.Yaw = atan2f(tempX, tempY); 101 | 102 | AngE.Pitch = toDeg(AngE.Pitch); 103 | AngE.Roll = toDeg(AngE.Roll); 104 | // AngE.Yaw = toDeg(AngE.Yaw)+180.0f; 105 | 106 | // /* 互補濾波 Complementary Filter */ 107 | // #define CF_A 0.9f 108 | // #define CF_B 0.1f 109 | // AngZ_Temp = AngZ_Temp + GyrZ*SampleRate; 110 | // AngZ_Temp = CF_A*AngZ_Temp + CF_B*AngE.Yaw; 111 | // if(AngZ_Temp>360.0f) 112 | // AngE.Yaw = AngZ_Temp - 360.0f; 113 | // else if(AngZ_Temp<0.0f) 114 | // AngE.Yaw = AngZ_Temp + 360.0f; 115 | // else 116 | // AngE.Yaw = AngZ_Temp; 117 | } 118 | /*====================================================================================================*/ 119 | /*====================================================================================================*/ 120 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Algorithms/algorithm_ahrs.h: -------------------------------------------------------------------------------- 1 | /* #include "algorithm_ahrs.h" */ 2 | 3 | #ifndef __ALGORITHM_AHRS_H 4 | #define __ALGORITHM_AHRS_H 5 | 6 | #include "stm32f4xx.h" 7 | #include "algorithm_quaternion.h" 8 | /*====================================================================================================*/ 9 | /*====================================================================================================*/ 10 | #define _SampleRateFreg_500Hz_ 11 | 12 | #ifdef _SampleRateFreg_400Hz_ 13 | #define SampleRateFreg ((u16)400) // 400Hz 14 | #define SampleRate ((fp32)0.0025f) // 2.5ms 15 | #define SampleRateHelf ((fp32)0.00125f) // 1.25ms 16 | #endif 17 | 18 | #ifdef _SampleRateFreg_500Hz_ 19 | #define SampleRateFreg ((u16)500) // 500Hz 20 | #define SampleRate ((fp32)0.002f) // 2.0ms 21 | #define SampleRateHelf ((fp32)0.001f) // 1.0ms 22 | #endif 23 | /*====================================================================================================*/ 24 | /*====================================================================================================*/ 25 | void AHRS_Init( Quaternion *pNumQ, EulerAngle *pAngE ); 26 | void AHRS_Update( void ); 27 | /*====================================================================================================*/ 28 | /*====================================================================================================*/ 29 | #endif 30 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Algorithms/algorithm_mathUnit.h: -------------------------------------------------------------------------------- 1 | /* #include "algorithm_mathUnit.h" */ 2 | 3 | #ifndef __ALGORITHM_MATHUNIt_H 4 | #define __ALGORITHM_MATHUNIt_H 5 | 6 | #include "stm32f4xx.h" 7 | #include "arm_math.h" 8 | /*====================================================================================================*/ 9 | /*====================================================================================================*/ 10 | #define invSqrtf( iSq ) (1.0f/sqrtf((float)iSq)) 11 | #define squa( Sq ) (((float)Sq)*((float)Sq)) 12 | #define toRad( Math_D ) ((float)(Math_D)*0.0174532925f) 13 | #define toDeg( Math_R ) ((float)(Math_R)*57.2957795f) 14 | /*====================================================================================================*/ 15 | /*====================================================================================================*/ 16 | 17 | /*====================================================================================================*/ 18 | /*====================================================================================================*/ 19 | #endif 20 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Algorithms/algorithm_moveAve.c: -------------------------------------------------------------------------------- 1 | /*====================================================================================================*/ 2 | /*====================================================================================================*/ 3 | #include "stm32f4_system.h" 4 | #include "algorithm_moveAve.h" 5 | /*====================================================================================================*/ 6 | /*====================================================================================================* 7 | **函數 : MoveAve_SMA 8 | **功能 : Simple Moving Average 9 | **輸入 : NewData, MoveAve_FIFO, SampleLen 10 | **輸出 : AveData 11 | **使用 : MoveAve_SMA(NewData, MoveAve_FIFO, SampleLen); 12 | **====================================================================================================*/ 13 | /*====================================================================================================*/ 14 | s16 MoveAve_SMA( s16 NewData, s16 *MoveAve_FIFO, u8 SampleLen ) 15 | { 16 | u8 i = 0; 17 | s16 AveData = 0; 18 | s32 MoveAve_Sum = 0; 19 | 20 | for(i=0; iKp = 0.0f; 23 | PID->Ki = 0.0f; 24 | PID->Kd = 0.0f; 25 | 26 | PID->Err0 = 0.0f; 27 | PID->Err1 = 0.0f; 28 | PID->Err2 = 0.0f; 29 | PID->SumErr = 0.0f; 30 | PID->ZeroErr = 0.0f; 31 | PID->Output = 0.0f; 32 | PID->KiMax = +400.0f; 33 | PID->KiMin = -400.0f; 34 | PID->OutMax = +800.0f; 35 | PID->OutMin = -800.0f; 36 | } 37 | /*====================================================================================================*/ 38 | /*====================================================================================================* 39 | **函數 : PID_IncCal 40 | **功能 : Calculate Incremental PID 41 | **輸入 : PID, CurrentVal 42 | **輸出 : None 43 | **使用 : PID_IncCal(&PID, CurrentVal) 44 | **====================================================================================================*/ 45 | /*====================================================================================================*/ 46 | fp32 PID_IncCal( PID_ST *PID, fp32 CurrentVal ) 47 | { 48 | fp32 Value_Kp; // 比例 49 | fp32 Value_Ki; // 積分 50 | fp32 Value_Kd; // 微分 51 | 52 | PID->Err0 = PID->Err1; 53 | PID->Err1 = PID->Err2; 54 | PID->Err2 = CurrentVal - PID->ZeroErr; 55 | 56 | Value_Kp = PID->Kp*(PID->Err2 - PID->Err1); 57 | Value_Ki = PID->Ki*PID->Err2; 58 | Value_Kd = PID->Kd*(PID->Err2 - 2.0f*PID->Err1 + PID->Err0); 59 | PID->Output = Value_Kp + Value_Ki + Value_Kd; 60 | 61 | if(PID->Output>PID->OutMax) 62 | PID->Output = PID->OutMax; 63 | if(PID->OutputOutMin) 64 | PID->Output = PID->OutMin; 65 | 66 | return (PID->Output); 67 | } 68 | /*====================================================================================================*/ 69 | /*====================================================================================================* 70 | **函數 : PID_IncCal 71 | **功能 : Calculate Positional PID 72 | **輸入 : PID, CurrentVal 73 | **輸出 : None 74 | **使用 : PID_PosCal(&PID, CurrentVal) 75 | **====================================================================================================*/ 76 | /*====================================================================================================*/ 77 | fp32 PID_PosCal( PID_ST *PID, fp32 CurrentVal ) 78 | { 79 | fp32 Value_Kp; // 比例 80 | fp32 Value_Ki; // 積分 81 | fp32 Value_Kd; // 微分 82 | 83 | PID->Err1 = PID->Err2; 84 | PID->Err2 = CurrentVal - PID->ZeroErr; 85 | 86 | PID->SumErr += PID->Err2; 87 | 88 | Value_Kp = PID->Kp*PID->Err2; 89 | Value_Ki = PID->Ki*PID->SumErr; 90 | Value_Kd = PID->Kd*(PID->Err2 - PID->Err1); 91 | 92 | if(Value_Ki>PID->KiMax) { 93 | PID->SumErr -= PID->Err2; 94 | Value_Ki = PID->KiMax; 95 | } 96 | if(Value_KiKiMin) { 97 | PID->SumErr -= PID->Err2; 98 | Value_Ki = PID->KiMin; 99 | } 100 | 101 | PID->Output = Value_Kp + Value_Ki + Value_Kd; 102 | 103 | if(PID->Output>PID->OutMax) 104 | PID->Output = PID->OutMax; 105 | if(PID->OutputOutMin) 106 | PID->Output = PID->OutMin; 107 | 108 | return (PID->Output); 109 | } 110 | /*====================================================================================================*/ 111 | /*====================================================================================================* 112 | **函數 : PID_AHRS_Cal 113 | **功能 : 114 | **輸入 : PID, Angle, Gyroscope 115 | **輸出 : None 116 | **使用 : PID_AHRS_Cal(&PID, Angle, Gyroscope); 117 | **====================================================================================================*/ 118 | /*====================================================================================================*/ 119 | fp32 PID_AHRS_Cal( PID_ST *PID, fp32 Angle, fp32 Gyroscope ) 120 | { 121 | fp32 Value_Kp; // 比例 122 | fp32 Value_Ki; // 積分 123 | fp32 Value_Kd; // 微分 124 | 125 | PID->Err1 = PID->ZeroErr - Angle; 126 | 127 | PID->SumErr = PID->SumErr + PID->Err1; 128 | 129 | Value_Kp = PID->Kp*PID->Err1; 130 | Value_Ki = PID->Ki*PID->SumErr; 131 | Value_Kd = PID->Kd*Gyroscope; 132 | 133 | if(Value_Ki>PID->KiMax) 134 | Value_Ki = PID->KiMax; 135 | if(Value_KiKiMin) 136 | Value_Ki = PID->KiMin; 137 | 138 | PID->Output = Value_Kp + Value_Ki - Value_Kd; 139 | 140 | if(PID->Output>PID->OutMax) 141 | PID->Output = PID->OutMax; 142 | if(PID->OutputOutMin) 143 | PID->Output = PID->OutMin; 144 | 145 | return (-PID->Output); 146 | } 147 | fp32 PID_AHRS_CalYaw( PID_ST *PID, fp32 Angle, fp32 Gyroscope ) 148 | { 149 | fp32 minErr = 0.0f; 150 | fp32 Value_Kp; // 比例 151 | fp32 Value_Ki; // 積分 152 | fp32 Value_Kd; // 微分 153 | 154 | PID->Err1 = PID->ZeroErr - Angle; 155 | 156 | minErr = fabsf(PID->Err1); 157 | if((minErr>180.0f)&&(PID->Err1<0.0f)) 158 | PID->Err1 = minErr - 360.0f; 159 | else if((minErr>180.0f)&&(PID->Err1>0.0f)) 160 | PID->Err1 = 360.0f - minErr; 161 | else if((minErr<180.0f)&&(PID->Err1<0.0f)) 162 | PID->Err1 = minErr; 163 | else 164 | PID->Err1 = 0.0f - minErr; 165 | 166 | PID->SumErr = PID->SumErr + PID->Err1; 167 | 168 | Value_Kp = PID->Kp*PID->Err1; 169 | Value_Ki = PID->Ki*PID->SumErr; 170 | Value_Kd = PID->Kd*Gyroscope; 171 | 172 | if(Value_Ki>PID->KiMax) 173 | Value_Ki = PID->KiMax; 174 | if(Value_KiKiMin) 175 | Value_Ki = PID->KiMin; 176 | 177 | PID->Output = Value_Kp + Value_Ki - Value_Kd; 178 | 179 | if(PID->Output>PID->OutMax) 180 | PID->Output = PID->OutMax; 181 | if(PID->OutputOutMin) 182 | PID->Output = PID->OutMin; 183 | 184 | return (-PID->Output); 185 | } 186 | /*====================================================================================================*/ 187 | /*====================================================================================================*/ 188 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Algorithms/algorithm_pid.h: -------------------------------------------------------------------------------- 1 | /* #include "algorithm_pid.h" */ 2 | 3 | #ifndef __ALGORITHM_PID_H 4 | #define __ALGORITHM_PID_H 5 | 6 | #include "stm32f4xx.h" 7 | /*====================================================================================================*/ 8 | /*====================================================================================================*/ 9 | typedef struct { 10 | fp32 Kp; 11 | fp32 Ki; 12 | fp32 Kd; 13 | fp32 Err0; 14 | fp32 Err1; 15 | fp32 Err2; 16 | fp32 SumErr; 17 | fp32 ZeroErr; 18 | fp32 Output; 19 | fp32 KiMax; 20 | fp32 KiMin; 21 | fp32 OutMax; 22 | fp32 OutMin; 23 | } PID_ST; 24 | /*====================================================================================================*/ 25 | /*====================================================================================================*/ 26 | void PID_Init( PID_ST *PID ); 27 | fp32 PID_IncCal( PID_ST *PID, fp32 CurrentVal ); 28 | fp32 PID_PosCal( PID_ST *PID, fp32 CurrentVal ); 29 | fp32 PID_AHRS_Cal( PID_ST *PID, fp32 Angle, fp32 Gyroscope ); 30 | fp32 PID_AHRS_CalYaw( PID_ST *PID, fp32 Angle, fp32 Gyroscope ); 31 | /*====================================================================================================*/ 32 | /*====================================================================================================*/ 33 | extern PID_ST PID_Yaw; 34 | extern PID_ST PID_Roll; 35 | extern PID_ST PID_Pitch; 36 | /*====================================================================================================*/ 37 | /*====================================================================================================*/ 38 | #endif 39 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Algorithms/algorithm_quaternion.c: -------------------------------------------------------------------------------- 1 | /*====================================================================================================*/ 2 | /*====================================================================================================*/ 3 | #include "stm32f4_system.h" 4 | #include "algorithm_mathUnit.h" 5 | #include "algorithm_quaternion.h" 6 | /*====================================================================================================*/ 7 | /*====================================================================================================*/ 8 | #define USE_ARM_MATH_LIB 9 | 10 | Quaternion NumQ = {1, 0, 0, 0}; 11 | EulerAngle AngE = {0}; 12 | /*====================================================================================================*/ 13 | /*====================================================================================================* 14 | **函數 : Quaternion_ToNumQ 15 | **功能 : 尤拉角轉四元數 16 | **輸入 : *pNumQ, *pAngE 17 | **輸出 : None 18 | **使用 : Quaternion_ToNumQ(&NumQ, &AngE); 19 | **====================================================================================================*/ 20 | /*====================================================================================================*/ 21 | void Quaternion_ToNumQ( Quaternion *pNumQ, EulerAngle *pAngE ) 22 | { 23 | fp32 halfP = pAngE->Pitch/2.0f; 24 | fp32 halfR = pAngE->Roll/2.0f; 25 | fp32 halfY = pAngE->Yaw/2.0f; 26 | 27 | #ifndef USE_ARM_MATH_LIB 28 | fp32 sinP = sinf(halfP); 29 | fp32 cosP = cosf(halfP); 30 | fp32 sinR = sinf(halfR); 31 | fp32 cosR = cosf(halfR); 32 | fp32 sinY = sinf(halfY); 33 | fp32 cosY = cosf(halfY); 34 | #else 35 | fp32 sinP = arm_sin_f32(halfP); 36 | fp32 cosP = arm_cos_f32(halfP); 37 | fp32 sinR = arm_sin_f32(halfR); 38 | fp32 cosR = arm_cos_f32(halfR); 39 | fp32 sinY = arm_sin_f32(halfY); 40 | fp32 cosY = arm_cos_f32(halfY); 41 | #endif 42 | 43 | pNumQ->q0 = cosY*cosR*cosP + sinY*sinR*sinP; 44 | pNumQ->q1 = cosY*cosR*sinP - sinY*sinR*cosP; 45 | pNumQ->q2 = cosY*sinR*cosP + sinY*cosR*sinP; 46 | pNumQ->q3 = sinY*cosR*cosP - cosY*sinR*sinP; 47 | } 48 | /*====================================================================================================*/ 49 | /*====================================================================================================* 50 | **函數 : Quaternion_ToAngE 51 | **功能 : 四元數轉尤拉角 52 | **輸入 : *pNumQ, *pAngE 53 | **輸出 : None 54 | **使用 : Quaternion_ToAngE(&NumQ, &AngE); 55 | **====================================================================================================*/ 56 | /*====================================================================================================*/ 57 | void Quaternion_ToAngE( Quaternion *pNumQ, EulerAngle *pAngE ) 58 | { 59 | fp32 NumQ_T11 = pNumQ->q0*pNumQ->q0 + pNumQ->q1*pNumQ->q1 - pNumQ->q2*pNumQ->q2 - pNumQ->q3*pNumQ->q3; 60 | fp32 NumQ_T12 = 2.0f*(pNumQ->q0*pNumQ->q3 + pNumQ->q1*pNumQ->q2); 61 | fp32 NumQ_T13 = 2.0f*(pNumQ->q1*pNumQ->q3 - pNumQ->q0*pNumQ->q2); 62 | fp32 NumQ_T23 = 2.0f*(pNumQ->q0*pNumQ->q1 + pNumQ->q2*pNumQ->q3); 63 | fp32 NumQ_T33 = pNumQ->q0*pNumQ->q0 - pNumQ->q1*pNumQ->q1 - pNumQ->q2*pNumQ->q2 + pNumQ->q3*pNumQ->q3; 64 | 65 | pAngE->Pitch = -asinf(NumQ_T13); 66 | pAngE->Roll = atan2f(NumQ_T23, NumQ_T33); 67 | pAngE->Yaw = atan2f(NumQ_T12, NumQ_T11); 68 | } 69 | /*====================================================================================================*/ 70 | /*====================================================================================================* 71 | **函數 : Quaternion_Multiply 72 | **功能 : 四元數乘法 73 | **輸入 : NowQ, OldQ 74 | **輸出 : NewQ 75 | **使用 : NewQ = Quaternion_Multiply(NowQ, OldQ); 76 | **====================================================================================================*/ 77 | /*====================================================================================================*/ 78 | Quaternion Quaternion_Multiply( Quaternion NowQ, Quaternion OldQ ) 79 | { 80 | Quaternion NewQ; 81 | 82 | NewQ.q0 = NowQ.q0*OldQ.q0 - NowQ.q1*OldQ.q1 - NowQ.q2*OldQ.q2 - NowQ.q3*OldQ.q3; 83 | NewQ.q1 = NowQ.q0*OldQ.q1 + NowQ.q1*OldQ.q0 + NowQ.q2*OldQ.q3 - NowQ.q3*OldQ.q2; 84 | NewQ.q2 = NowQ.q0*OldQ.q2 - NowQ.q1*OldQ.q3 + NowQ.q2*OldQ.q0 + NowQ.q3*OldQ.q1; 85 | NewQ.q3 = NowQ.q0*OldQ.q3 + NowQ.q1*OldQ.q2 - NowQ.q2*OldQ.q1 + NowQ.q3*OldQ.q0; 86 | 87 | Quaternion_Normalize(&NewQ); 88 | 89 | return NewQ; 90 | } 91 | /*====================================================================================================*/ 92 | /*====================================================================================================* 93 | **函數 : Quaternion_Normalize 94 | **功能 : 四元數歸一化 95 | **輸入 : *pNumQ 96 | **輸出 : None 97 | **使用 : Quaternion_Normalize(&NewQ); 98 | **====================================================================================================*/ 99 | /*====================================================================================================*/ 100 | void Quaternion_Normalize( Quaternion *pNumQ ) 101 | { 102 | fp32 Normalize = 0.0f; 103 | 104 | Normalize = invSqrtf(squa(pNumQ->q0) + squa(pNumQ->q1) + squa(pNumQ->q2) + squa(pNumQ->q3)); 105 | 106 | pNumQ->q0 = pNumQ->q0 * Normalize; 107 | pNumQ->q1 = pNumQ->q1 * Normalize; 108 | pNumQ->q2 = pNumQ->q2 * Normalize; 109 | pNumQ->q3 = pNumQ->q3 * Normalize; 110 | } 111 | /*====================================================================================================*/ 112 | /*====================================================================================================* 113 | **函數 : Quaternion_RungeKutta 114 | **功能 : 一階龍格-庫塔法, 更新四元數 115 | **輸入 : *pNumQ, GyrX, GyrY, GyrZ, helfTimes 116 | **輸出 : None 117 | **使用 : Quaternion_RungeKutta(&NumQ, GyrX, GyrY, GyrZ, helfT); 118 | **====================================================================================================*/ 119 | /*====================================================================================================*/ 120 | void Quaternion_RungeKutta( Quaternion *pNumQ, fp32 GyrX, fp32 GyrY, fp32 GyrZ, fp32 helfTimes ) 121 | { 122 | fpc32 tmpq0 = pNumQ->q0; 123 | fpc32 tmpq1 = pNumQ->q1; 124 | fpc32 tmpq2 = pNumQ->q2; 125 | fpc32 tmpq3 = pNumQ->q3; 126 | 127 | pNumQ->q0 = pNumQ->q0 + (-tmpq1*GyrX - tmpq2*GyrY - tmpq3*GyrZ) * helfTimes; 128 | pNumQ->q1 = pNumQ->q1 + ( tmpq0*GyrX - tmpq3*GyrY + tmpq2*GyrZ) * helfTimes; 129 | pNumQ->q2 = pNumQ->q2 + ( tmpq3*GyrX + tmpq0*GyrY - tmpq1*GyrZ) * helfTimes; 130 | pNumQ->q3 = pNumQ->q3 + (-tmpq2*GyrX + tmpq1*GyrY + tmpq0*GyrZ) * helfTimes; 131 | } 132 | /*====================================================================================================*/ 133 | /*====================================================================================================*/ 134 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Algorithms/algorithm_quaternion.h: -------------------------------------------------------------------------------- 1 | /* #include "algorithm_quaternion.h" */ 2 | 3 | #ifndef __ALGORITHM_QUATERNION_H 4 | #define __ALGORITHM_QUATERNION_H 5 | 6 | #include "stm32f4xx.h" 7 | /*====================================================================================================*/ 8 | /*====================================================================================================*/ 9 | typedef __IO struct { 10 | fp32 Pitch; 11 | fp32 Roll; 12 | fp32 Yaw; 13 | } EulerAngle; 14 | 15 | typedef __IO struct { 16 | fp32 q0; 17 | fp32 q1; 18 | fp32 q2; 19 | fp32 q3; 20 | } Quaternion; 21 | /*====================================================================================================*/ 22 | /*====================================================================================================*/ 23 | void Quaternion_ToNumQ( Quaternion *pNumQ, EulerAngle *pAngE ); 24 | void Quaternion_ToAngE( Quaternion *pNumQ, EulerAngle *pAngE ); 25 | Quaternion Quaternion_Multiply( Quaternion NowQ, Quaternion OldQ ); 26 | void Quaternion_Normalize( Quaternion *pNumQ ); 27 | void Quaternion_RungeKutta( Quaternion *pNumQ, fp32 GyrX, fp32 GyrY, fp32 GyrZ, fp32 helfTimes ); 28 | /*====================================================================================================*/ 29 | /*====================================================================================================*/ 30 | extern Quaternion NumQ; 31 | extern EulerAngle AngE; 32 | /*====================================================================================================*/ 33 | /*====================================================================================================*/ 34 | #endif 35 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Algorithms/algorithm_string.c: -------------------------------------------------------------------------------- 1 | /*====================================================================================================*/ 2 | /*====================================================================================================*/ 3 | #include "stm32f4_system.h" 4 | #include "algorithm_string.h" 5 | /*====================================================================================================*/ 6 | /*====================================================================================================* 7 | **函數 : Str_NumToChar 8 | **功能 : 數值轉字串 9 | **輸入 : Type, NumLen, *CharData, NumData 10 | **輸出 : None 11 | **使用 : Str_NumToChar(Type_O, 6, TrData, Data) 12 | **====================================================================================================*/ 13 | /*====================================================================================================*/ 14 | void Str_NumToChar( u8 Type, u8 NumLen, u8 *CharData, s32 NumData ) 15 | { 16 | u8 i = 0; 17 | u32 Tmp[48] = {0}; 18 | u32 NumTmp = 1; 19 | 20 | switch(Type) { 21 | 22 | case Type_B: 23 | case Type_O: 24 | case Type_D: 25 | case Type_H: 26 | for(i=0; i9) 33 | CharData[NumLen-i-1] += 55; // 65-10 34 | else 35 | CharData[NumLen-i-1] += 48; 36 | } 37 | CharData[NumLen] = '\0'; 38 | break; 39 | 40 | case Type_I: 41 | if(NumData<0) { 42 | CharData[0] = '-'; 43 | NumData = (~NumData) + 1; 44 | for(i=1; iSR & SPI_I2S_FLAG_TXE) == (u16)RESET); 17 | SPIx->DR = WriteByte; 18 | while((SPIx->SR & SPI_I2S_FLAG_RXNE) == (u16)RESET); 19 | 20 | return SPIx->DR; 21 | } 22 | /*====================================================================================================*/ 23 | /*====================================================================================================*/ 24 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Dirvers/stm32f4_spi.h: -------------------------------------------------------------------------------- 1 | /* #include "stm32f4_spi.h" */ 2 | 3 | #ifndef __STM32F4_SPI_H 4 | #define __STM32F4_SPI_H 5 | 6 | #include "stm32f4xx.h" 7 | /*====================================================================================================*/ 8 | /*====================================================================================================*/ 9 | u8 SPI_RW( SPI_TypeDef* SPIx, u8 WriteByte ); 10 | /*====================================================================================================*/ 11 | /*====================================================================================================*/ 12 | #endif 13 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Dirvers/stm32f4_system.h: -------------------------------------------------------------------------------- 1 | /* #include "stm32f4_system.h" */ 2 | 3 | #ifndef __STM32F4_SYSTEM_H 4 | #define __STM32F4_SYSTEM_H 5 | 6 | #include "stm32f4xx.h" 7 | #include "stm32f4_delay.h" 8 | /*=====================================================================================================*/ 9 | /*=====================================================================================================*/ 10 | #define Bit_Band(Addr, BitNum) ((Addr & 0xF0000000)+0x2000000+((Addr &0xFFFFF)<<5)+(BitNum<<2)) 11 | #define Mem_Addr(Addr) *((vu16 *)(Addr)) 12 | #define Bit_Addr(Addr, BitNum) Mem_Addr(Bit_Band(Addr, BitNum)) 13 | 14 | #define GPIOA_ODR_Addr (GPIOA_BASE+0x14) 15 | #define GPIOB_ODR_Addr (GPIOB_BASE+0x14) 16 | #define GPIOC_ODR_Addr (GPIOC_BASE+0x14) 17 | #define GPIOD_ODR_Addr (GPIOD_BASE+0x14) 18 | #define GPIOE_ODR_Addr (GPIOE_BASE+0x14) 19 | #define GPIOF_ODR_Addr (GPIOF_BASE+0x14) 20 | #define GPIOG_ODR_Addr (GPIOG_BASE+0x14) 21 | #define GPIOA_IDR_Addr (GPIOA_BASE+0x10) 22 | #define GPIOB_IDR_Addr (GPIOB_BASE+0x10) 23 | #define GPIOC_IDR_Addr (GPIOC_BASE+0x10) 24 | #define GPIOD_IDR_Addr (GPIOD_BASE+0x10) 25 | #define GPIOE_IDR_Addr (GPIOE_BASE+0x10) 26 | #define GPIOF_IDR_Addr (GPIOF_BASE+0x10) 27 | #define GPIOG_IDR_Addr (GPIOG_BASE+0x10) 28 | 29 | #define PAO(Pin) Bit_Addr(GPIOA_ODR_Addr, Pin) 30 | #define PAI(Pin) Bit_Addr(GPIOA_IDR_Addr, Pin) 31 | #define PBO(Pin) Bit_Addr(GPIOB_ODR_Addr, Pin) 32 | #define PBI(Pin) Bit_Addr(GPIOB_IDR_Addr, Pin) 33 | #define PCO(Pin) Bit_Addr(GPIOC_ODR_Addr, Pin) 34 | #define PCI(Pin) Bit_Addr(GPIOC_IDR_Addr, Pin) 35 | #define PDO(Pin) Bit_Addr(GPIOD_ODR_Addr, Pin) 36 | #define PDI(Pin) Bit_Addr(GPIOD_IDR_Addr, Pin) 37 | #define PEO(Pin) Bit_Addr(GPIOE_ODR_Addr, Pin) 38 | #define PEI(Pin) Bit_Addr(GPIOE_IDR_Addr, Pin) 39 | #define PFO(Pin) Bit_Addr(GPIOF_ODR_Addr, Pin) 40 | #define PFI(Pin) Bit_Addr(GPIOF_IDR_Addr, Pin) 41 | #define PGO(Pin) Bit_Addr(GPIOG_ODR_Addr, Pin) 42 | #define PGI(Pin) Bit_Addr(GPIOG_IDR_Addr, Pin) 43 | /*=====================================================================================================*/ 44 | /*=====================================================================================================*/ 45 | #define U8_MAX ((u8)255) 46 | #define S8_MAX ((s8)127) 47 | #define S8_MIN ((s8)-128) 48 | #define U16_MAX ((u16)65535u) 49 | #define S16_MAX ((s16)32767) 50 | #define S16_MIN ((s16)-32768) 51 | #define U32_MAX ((u32)4294967295uL) 52 | #define S32_MAX ((s32)2147483647) 53 | #define S32_MIN ((s32)-2147483648) 54 | 55 | #define Byte32(Type, Byte4, Byte3, Byte2, Byte1) ((Type)((((u8)(Byte4))<<24) | (((u8)(Byte3))<<16) | (((u8)(Byte2))<<8) | ((u8)(Byte1)))) 56 | #define Byte16(Type, ByteH, ByteL) ((Type)((((u16)(ByteH))<<8) | ((u16)(ByteL)))) 57 | #define Byte8H(ByteH) ((u8)(((u16)(ByteH))>>8)) 58 | #define Byte8L(ByteL) ((u8)(ByteL)) 59 | 60 | #define NULL 0 61 | /*=====================================================================================================*/ 62 | /*=====================================================================================================*/ 63 | #endif 64 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Dirvers/stm32f4_usart.c: -------------------------------------------------------------------------------- 1 | /*====================================================================================================*/ 2 | /*====================================================================================================*/ 3 | #include "stm32f4_system.h" 4 | #include "stm32f4_usart.h" 5 | /*====================================================================================================*/ 6 | /*====================================================================================================* 7 | **函數 : UART_SendByte 8 | **功能 : 發送 1Byte 資料 9 | **輸入 : USARTx, *SendData 10 | **輸出 : None 11 | **使用 : UART_SendByte(USART1, 'A'); 12 | **====================================================================================================*/ 13 | /*====================================================================================================*/ 14 | void UART_SendByte( USART_TypeDef *USARTx, u8 SendData ) 15 | { 16 | USART_SendData(USARTx, SendData); 17 | while(USART_GetFlagStatus(USARTx, USART_FLAG_TXE) == RESET); 18 | } 19 | /*====================================================================================================*/ 20 | /*====================================================================================================* 21 | **函數 : UART_RecvByte 22 | **功能 : 接收 1Byte 資料 23 | **輸入 : USARTx 24 | **輸出 : RecvByte 25 | **使用 : RecvByte = UART_RecvByte(USART1); 26 | **====================================================================================================*/ 27 | /*====================================================================================================*/ 28 | u8 UART_RecvByte( USART_TypeDef *USARTx ) 29 | { 30 | while(USART_GetFlagStatus(USARTx, USART_FLAG_RXNE) == RESET); 31 | 32 | return USART_ReceiveData(USARTx); 33 | } 34 | /*====================================================================================================*/ 35 | /*====================================================================================================* 36 | **函數 : UART_SendData 37 | **功能 : 發送資料 38 | **輸入 : USARTx, *SendData, DataLen 39 | **輸出 : None 40 | **使用 : UART_SendByte(USART1, SendData, DataLen); 41 | **====================================================================================================*/ 42 | /*====================================================================================================*/ 43 | void UART_SendData( USART_TypeDef *USARTx, u8 *SendData, u16 DataLen ) 44 | { 45 | do { 46 | USART_SendData(USARTx, *SendData); 47 | while(USART_GetFlagStatus(USARTx, USART_FLAG_TXE) == RESET); 48 | SendData++; 49 | DataLen--; 50 | } while(DataLen); 51 | } 52 | /*====================================================================================================*/ 53 | /*====================================================================================================* 54 | **函數 : UART_RecvData 55 | **功能 : 接收資料 56 | **輸入 : USARTx, *RecvData, DataLen 57 | **輸出 : None 58 | **使用 : UART_RecvData(USART1, RecvData, DataLen); 59 | **====================================================================================================*/ 60 | /*====================================================================================================*/ 61 | void UART_RecvData( USART_TypeDef *USARTx, u8 *RecvData, u16 DataLen ) 62 | { 63 | do { 64 | while(USART_GetFlagStatus(USARTx, USART_FLAG_RXNE) == RESET); 65 | *RecvData = USART_ReceiveData(USARTx); 66 | RecvData++; 67 | DataLen--; 68 | } while(DataLen); 69 | } 70 | /*====================================================================================================*/ 71 | /*====================================================================================================*/ 72 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Dirvers/stm32f4_usart.h: -------------------------------------------------------------------------------- 1 | /* #include "stm32f4_usart.h" */ 2 | 3 | #ifndef __STM32F4_USART_H 4 | #define __STM32F4_USART_H 5 | 6 | #include "stm32f4xx.h" 7 | /*====================================================================================================*/ 8 | /*====================================================================================================*/ 9 | void UART_SendByte( USART_TypeDef *USARTx, u8 SendData ); 10 | u8 UART_RecvByte( USART_TypeDef *USARTx ); 11 | void UART_SendData( USART_TypeDef *USARTx, u8 *SendData, u16 DataLen ); 12 | void UART_RecvData( USART_TypeDef *USARTx, u8 *RecvData, u16 DataLen ); 13 | /*====================================================================================================*/ 14 | /*====================================================================================================*/ 15 | #endif 16 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Modules/module_imu.c: -------------------------------------------------------------------------------- 1 | /*====================================================================================================*/ 2 | /*====================================================================================================*/ 3 | #include "stm32f4_system.h" 4 | #include "module_imu.h" 5 | #include "module_mpu9250.h" 6 | //#include "module_ms5611.h" 7 | /*====================================================================================================*/ 8 | /*====================================================================================================*/ 9 | SensorAcc Acc = {0}; 10 | SensorGyr Gyr = {0}; 11 | 12 | #ifdef USE_SENSOR_MAG 13 | SensorMag Mag = {0}; 14 | #endif 15 | 16 | SensorTemp Temp = {0}; 17 | 18 | #ifdef USE_SENSOR_BARO 19 | SensorBaro Baro = {0}; 20 | #endif 21 | /*====================================================================================================*/ 22 | /*====================================================================================================* 23 | **函數 : Sensor_Config 24 | **功能 : Sensor Config 25 | **輸入 : None 26 | **輸出 : None 27 | **使用 : Sensor_Config(); 28 | **====================================================================================================*/ 29 | /*====================================================================================================*/ 30 | void Sensor_Config( void ) 31 | { 32 | GPIO_InitTypeDef GPIO_InitStruct; 33 | 34 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); 35 | 36 | /* INT PA1 */ 37 | GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1; 38 | GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN; 39 | GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; 40 | GPIO_Init(GPIOA, &GPIO_InitStruct); 41 | 42 | MPU9250_Config(); 43 | 44 | #ifdef USE_SENSOR_BARO 45 | MS5611_Config(); 46 | #endif 47 | } 48 | /*====================================================================================================*/ 49 | /*====================================================================================================* 50 | **函數 : Sensor_Init 51 | **功能 : 初始化 Sensor 52 | **輸入 : None 53 | **輸出 : None 54 | **使用 : Sensor_Init(); 55 | **====================================================================================================*/ 56 | /*====================================================================================================*/ 57 | void Sensor_Init( void ) 58 | { 59 | MPU_InitTypeDef MPU_InitStruct; 60 | 61 | Acc.X = 0; 62 | Acc.Y = 0; 63 | Acc.Z = 0; 64 | Acc.OffsetX = 0; 65 | Acc.OffsetY = 0; 66 | Acc.OffsetZ = 0; 67 | Acc.TrueX = 0.0f; 68 | Acc.TrueY = 0.0f; 69 | Acc.TrueZ = 0.0f; 70 | 71 | Gyr.X = 0; 72 | Gyr.Y = 0; 73 | Gyr.Z = 0; 74 | Gyr.OffsetX = 0; 75 | Gyr.OffsetY = 0; 76 | Gyr.OffsetZ = 0; 77 | Gyr.TrueX = 0.0f; 78 | Gyr.TrueY = 0.0f; 79 | Gyr.TrueZ = 0.0f; 80 | 81 | #ifdef USE_SENSOR_MAG 82 | Mag.X = 0; 83 | Mag.Y = 0; 84 | Mag.Z = 0; 85 | Mag.AdjustX = 0; 86 | Mag.AdjustY = 0; 87 | Mag.AdjustZ = 0; 88 | Mag.TrueX = 0.0f; 89 | Mag.TrueY = 0.0f; 90 | Mag.TrueZ = 0.0f; 91 | #endif 92 | 93 | Temp.T = 0; 94 | Temp.OffsetT = TEMP_OFFSET; 95 | Temp.TrueT = 0.0f; 96 | 97 | #ifdef USE_SENSOR_BARO 98 | Baro.Temp = 0.0f; 99 | Baro.Press = 0.0f; 100 | Baro.Height = 0.0f; 101 | #endif 102 | 103 | MPU_InitStruct.MPU_Gyr_FullScale = MPU_GyrFS_2000dps; 104 | MPU_InitStruct.MPU_Gyr_LowPassFilter = MPU_GyrLPS_250Hz; 105 | MPU_InitStruct.MPU_Acc_FullScale = MPU_AccFS_4g; 106 | MPU_InitStruct.MPU_Acc_LowPassFilter = MPU_AccLPS_184Hz; 107 | MPU9250_Init(&MPU_InitStruct); 108 | 109 | #ifdef USE_SENSOR_BARO 110 | MS5611_Init(); 111 | #endif 112 | } 113 | /*====================================================================================================*/ 114 | /*====================================================================================================* 115 | **函數 : Sensor_Read 116 | **功能 : Sensor Read 117 | **輸入 : ReadBuf 118 | **輸出 : None 119 | **使用 : Sensor_Read(SampleRateFreg); 120 | **====================================================================================================*/ 121 | /*====================================================================================================*/ 122 | void Sensor_Read( u16 ReadFreg ) 123 | { 124 | u8 ReadBuf[20] = {0}; 125 | 126 | #ifdef USE_SENSOR_BARO 127 | static s8 ReadCount = 0; 128 | static s32 Baro_Buf[2] = {0}; // 沒加 static 資料會有問題 129 | #endif 130 | 131 | MPU9250_Read(ReadBuf); 132 | 133 | Acc.X = Byte16(s16, ReadBuf[0], ReadBuf[1]); // Acc.X 134 | Acc.Y = Byte16(s16, ReadBuf[2], ReadBuf[3]); // Acc.Y 135 | Acc.Z = Byte16(s16, ReadBuf[4], ReadBuf[5]); // Acc.Z 136 | Gyr.X = Byte16(s16, ReadBuf[8], ReadBuf[9]); // Gyr.X 137 | Gyr.Y = Byte16(s16, ReadBuf[10], ReadBuf[11]); // Gyr.Y 138 | Gyr.Z = Byte16(s16, ReadBuf[12], ReadBuf[13]); // Gyr.Z 139 | #ifdef USE_SENSOR_MAG 140 | Mag.Z = Byte16(s16, ReadBuf[14], ReadBuf[15]); // Mag.X 141 | Mag.Z = Byte16(s16, ReadBuf[16], ReadBuf[17]); // Mag.Y 142 | Mag.Z = Byte16(s16, ReadBuf[18], ReadBuf[19]); // Mag.Z 143 | #endif 144 | Temp.T = Byte16(s16, ReadBuf[6], ReadBuf[7]); // Temp 145 | 146 | #ifdef USE_SENSOR_BARO 147 | if(ReadCount == 0) { 148 | MS5611_Read(Baro_Buf, MS5611_D1_OSR_4096); 149 | Baro.Temp = (fp32)(Baro_Buf[0]*0.01f); // 0.01 degC 150 | Baro.Press = (fp32)(Baro_Buf[1]*0.01f); // 0.01 mbar 151 | Baro.Height = (fp32)((Baro_Buf[1]-101333)*9.5238f); 152 | ReadCount = (u16)(ReadFreg/MS5611_RespFreq_4096)+1; 153 | } 154 | ReadCount--; 155 | #endif 156 | } 157 | /*====================================================================================================*/ 158 | /*====================================================================================================*/ 159 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Modules/module_imu.h: -------------------------------------------------------------------------------- 1 | /* #include "module_imu.h" */ 2 | 3 | #ifndef __MODULE_IMU_H 4 | #define __MODULE_IMU_H 5 | 6 | #include "stm32f4xx.h" 7 | #include "module_mpu9250.h" 8 | //#include "module_ms5611.h" 9 | /*====================================================================================================*/ 10 | /*====================================================================================================*/ 11 | //#define USE_SENSOR_MAG 12 | //#define USE_SENSOR_BARO 13 | 14 | #define ACC_X_OFFSET ((s16)0) 15 | #define ACC_Y_OFFSET ((s16)0) 16 | #define ACC_Z_OFFSET ((s16)8192) 17 | #define GYR_X_OFFSET ((s16)0) 18 | #define GYR_Y_OFFSET ((s16)0) 19 | #define GYR_Z_OFFSET ((s16)0) 20 | #define MAG_X_OFFSET ((s16)0) 21 | #define MAG_Y_OFFSET ((s16)0) 22 | #define MAG_Z_OFFSET ((s16)0) 23 | #define TEMP_OFFSET ((s16)(-12421)) // (340*35)+521 24 | /*====================================================================================================*/ 25 | /*====================================================================================================*/ 26 | typedef __IO struct { 27 | s16 X; 28 | s16 Y; 29 | s16 Z; 30 | s16 OffsetX; 31 | s16 OffsetY; 32 | s16 OffsetZ; 33 | fp32 TrueX; 34 | fp32 TrueY; 35 | fp32 TrueZ; 36 | } SensorAcc; 37 | 38 | typedef __IO struct { 39 | s16 X; 40 | s16 Y; 41 | s16 Z; 42 | s16 OffsetX; 43 | s16 OffsetY; 44 | s16 OffsetZ; 45 | fp32 TrueX; 46 | fp32 TrueY; 47 | fp32 TrueZ; 48 | } SensorGyr; 49 | 50 | #ifdef USE_SENSOR_MAG 51 | typedef __IO struct { 52 | s16 X; 53 | s16 Y; 54 | s16 Z; 55 | u16 AdjustX; 56 | u16 AdjustY; 57 | u16 AdjustZ; 58 | fp32 TrueX; 59 | fp32 TrueY; 60 | fp32 TrueZ; 61 | fp32 EllipseSita; 62 | fp32 EllipseX0; 63 | fp32 EllipseY0; 64 | fp32 EllipseA; 65 | fp32 EllipseB; 66 | } SensorMag; 67 | #endif 68 | 69 | typedef __IO struct { 70 | s16 T; 71 | s16 OffsetT; 72 | fp32 TrueT; 73 | } SensorTemp; 74 | 75 | #ifdef USE_SENSOR_BARO 76 | typedef __IO struct { 77 | fp32 Temp; 78 | fp32 Press; 79 | fp32 Height; 80 | } SensorBaro; 81 | #endif 82 | /*====================================================================================================*/ 83 | /*====================================================================================================*/ 84 | extern SensorAcc Acc; 85 | extern SensorGyr Gyr; 86 | 87 | #ifdef USE_SENSOR_MAG 88 | extern SensorMag Mag; 89 | #endif 90 | 91 | extern SensorTemp Temp; 92 | 93 | #ifdef USE_SENSOR_BARO 94 | extern SensorBaro Baro; 95 | #endif 96 | /*====================================================================================================*/ 97 | /*====================================================================================================*/ 98 | void Sensor_Init( void ); 99 | void Sensor_Config( void ); 100 | void Sensor_Read( u16 ReadFreg ); 101 | /*====================================================================================================*/ 102 | /*====================================================================================================*/ 103 | #endif 104 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Modules/module_nrf24l01.h: -------------------------------------------------------------------------------- 1 | /* #include "module_nrf24l01.h" */ 2 | 3 | #ifndef __MODULE_NRF24L01_H 4 | #define __MODULE_NRF24L01_H 5 | 6 | #include "stm32f4xx.h" 7 | /*====================================================================================================*/ 8 | /*====================================================================================================*/ 9 | #define NRF_PIPE_WIDTH (5) // 發射/接收地址寬度 10 | #define NRF_CHANAL (40) // 頻道選擇 11 | 12 | #define NRF_TX_PL_WIDTH (32) // 發射數據通道有效數據寬度 0~32Byte 13 | #define NRF_RX_PL_WIDTH (32) 14 | 15 | #define NRF_MODE_TXOL (0x00) // Tx Only 16 | #define NRF_MODE_RXOL (0x01) // Rx Only 17 | #define NRF_MODE_FTLR (0x02) // First Tx Last Rx 18 | #define NRF_MODE_FRLT (0x03) // First Rx Last Tx 19 | 20 | #define NRF_RATE_250Kbps ((u8)0x27) // Bit0 Don't Care 21 | #define NRF_RATE_1Mbps ((u8)0x07) // Bit0 Don't Care 22 | #define NRF_RATE_2Mbps ((u8)0x0F) // Bit0 Don't Care 23 | 24 | #define NRF_STA_MAX_RT ((u8)0x10) // Maximum number of TX retransmits interrupt Write 1 to clear bit. 25 | #define NRF_STA_TX_DS ((u8)0x20) // Data Sent TX FIFO interrupt. If AUTO_ACK is activated, this bit is set high only when ACK is received. 26 | #define NRF_STA_RX_DR ((u8)0x40) // Data Ready RX FIFO interrupt. Asserted when new data arrives RX FIFO. 27 | 28 | // nRF24L01P Register 29 | #define NRF_CONFIG ((u8)0x00) 30 | #define NRF_EN_AA ((u8)0x01) 31 | #define NRF_EN_RXADDR ((u8)0x02) 32 | #define NRF_SETUP_AW ((u8)0x03) 33 | #define NRF_SETUP_RETR ((u8)0x04) 34 | #define NRF_RF_CH ((u8)0x05) 35 | #define NRF_RF_SETUP ((u8)0x06) 36 | #define NRF_STATUS ((u8)0x07) 37 | #define NRF_OBSERVE_TX ((u8)0x08) 38 | #define NRF_RPD ((u8)0x09) 39 | #define NRF_RX_ADDR_P0 ((u8)0x0A) 40 | #define NRF_RX_ADDR_P1 ((u8)0x0B) 41 | #define NRF_RX_ADDR_P2 ((u8)0x0C) 42 | #define NRF_RX_ADDR_P3 ((u8)0x0D) 43 | #define NRF_RX_ADDR_P4 ((u8)0x0E) 44 | #define NRF_RX_ADDR_P5 ((u8)0x0F) 45 | #define NRF_TX_ADDR ((u8)0x10) 46 | #define NRF_RX_PW_P0 ((u8)0x11) 47 | #define NRF_RX_PW_P1 ((u8)0x12) 48 | #define NRF_RX_PW_P2 ((u8)0x13) 49 | #define NRF_RX_PW_P3 ((u8)0x14) 50 | #define NRF_RX_PW_P4 ((u8)0x15) 51 | #define NRF_RX_PW_P5 ((u8)0x16) 52 | #define NRF_FIFO_STATUS ((u8)0x17) 53 | #define NRF_DYNPD ((u8)0x1C) 54 | #define NRF_FEATURE ((u8)0x1D) 55 | /*=====================================================================================================*/ 56 | /*=====================================================================================================*/ 57 | void NRF24L01_Config( void ); 58 | void NRF24L01_Init( u8 NRF_INIT_MODE ); 59 | 60 | void NRF_TX_Mode( void ); 61 | void NRF_RX_Mode( void ); 62 | u8 NRF_TxPacket( u8 *TxBuf ); 63 | u8 NRF_RxPacket( u8 *RxBuf ); 64 | extern u8 TxBuf[NRF_TX_PL_WIDTH]; 65 | extern u8 RxBuf[NRF_RX_PL_WIDTH]; 66 | /*====================================================================================================*/ 67 | /*====================================================================================================*/ 68 | #endif 69 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Modules/module_rs232.c: -------------------------------------------------------------------------------- 1 | /*====================================================================================================*/ 2 | /*====================================================================================================*/ 3 | #include "stm32f4_system.h" 4 | #include "stm32f4_usart.h" 5 | #include "module_rs232.h" 6 | #include "algorithm_string.h" 7 | /*====================================================================================================*/ 8 | /*====================================================================================================*/ 9 | #define USARTx USART2 10 | #define USARTx_CLK RCC_APB1Periph_USART2 11 | 12 | #define USARTx_TX_PIN GPIO_Pin_2 13 | #define USARTx_TX_GPIO_PORT GPIOA 14 | #define USARTx_TX_GPIO_CLK RCC_AHB1Periph_GPIOA 15 | #define USARTx_TX_SOURCE GPIO_PinSource2 16 | #define USARTx_TX_AF GPIO_AF_USART2 17 | 18 | #define USARTx_RX_PIN GPIO_Pin_3 19 | #define USARTx_RX_GPIO_PORT GPIOA 20 | #define USARTx_RX_GPIO_CLK RCC_AHB1Periph_GPIOA 21 | #define USARTx_RX_SOURCE GPIO_PinSource3 22 | #define USARTx_RX_AF GPIO_AF_USART2 23 | 24 | #define USARTx_BAUDRATE 9600 25 | #define USARTx_BYTESIZE USART_WordLength_8b 26 | #define USARTx_STOPBITS USART_StopBits_1 27 | #define USARTx_PARITY USART_Parity_No 28 | #define USARTx_HARDWARECTRL USART_HardwareFlowControl_None 29 | /*====================================================================================================*/ 30 | /*====================================================================================================* 31 | **函數 : RS232_Config 32 | **功能 : RS232 配置 33 | **輸入 : None 34 | **輸出 : None 35 | **使用 : RS232_Config(); 36 | **====================================================================================================*/ 37 | /*====================================================================================================*/ 38 | void RS232_Config( void ) 39 | { 40 | GPIO_InitTypeDef GPIO_InitStruct; 41 | USART_InitTypeDef USART_InitStruct; 42 | 43 | /* UART Clk Init *************************************************************/ 44 | RCC_AHB1PeriphClockCmd(USARTx_TX_GPIO_CLK | USARTx_RX_GPIO_CLK, ENABLE); 45 | RCC_APB1PeriphClockCmd(USARTx_CLK, ENABLE); 46 | 47 | GPIO_PinAFConfig(USARTx_TX_GPIO_PORT, USARTx_TX_SOURCE, USARTx_TX_AF); 48 | GPIO_PinAFConfig(USARTx_TX_GPIO_PORT, USARTx_RX_SOURCE, USARTx_RX_AF); 49 | 50 | /* USARTx Tx PA2 */ 51 | GPIO_InitStruct.GPIO_Pin = USARTx_TX_PIN; 52 | GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; 53 | GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; 54 | GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; 55 | GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; 56 | GPIO_Init(USARTx_TX_GPIO_PORT, &GPIO_InitStruct); 57 | /* USARTx Rx PA3 */ 58 | GPIO_InitStruct.GPIO_Pin = USARTx_RX_PIN; 59 | GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; 60 | GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; 61 | GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; 62 | GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; 63 | GPIO_Init(USARTx_RX_GPIO_PORT, &GPIO_InitStruct); 64 | 65 | /* UART Init *****************************************************************/ 66 | USART_InitStruct.USART_BaudRate = USARTx_BAUDRATE; 67 | USART_InitStruct.USART_WordLength = USARTx_BYTESIZE; 68 | USART_InitStruct.USART_StopBits = USARTx_STOPBITS; 69 | USART_InitStruct.USART_Parity = USARTx_PARITY; 70 | USART_InitStruct.USART_HardwareFlowControl = USARTx_HARDWARECTRL; 71 | USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; 72 | USART_Init(USARTx, &USART_InitStruct); 73 | USART_Cmd(USARTx, ENABLE); 74 | 75 | USART_ClearFlag(USARTx, USART_FLAG_TC); 76 | } 77 | /*====================================================================================================*/ 78 | /*====================================================================================================* 79 | **函數 : RS232_SendStr 80 | **功能 : 發送字串 81 | **輸入 : *pWord 82 | **輸出 : None 83 | **使用 : RS232_SendStr((u8*)"Hellow World!"); 84 | **====================================================================================================*/ 85 | /*====================================================================================================*/ 86 | void RS232_SendStr( u8 *pWord ) 87 | { 88 | while(*pWord != '\0') { 89 | UART_SendByte(USARTx, *pWord); 90 | pWord++; 91 | } 92 | } 93 | /*====================================================================================================*/ 94 | /*====================================================================================================* 95 | **函數 : RS232_SendNum 96 | **功能 : 將數值轉字串發送 97 | **輸入 : Type, NumLen, SendData 98 | **輸出 : None 99 | **使用 : RS232_SendNum(Type_O, 6, 1024); 100 | **====================================================================================================*/ 101 | /*====================================================================================================*/ 102 | void RS232_SendNum( u8 Type, u8 NumLen, s32 SendData ) 103 | { 104 | u8 TrData[32] = {0}; 105 | u8 *pWord = TrData; 106 | 107 | Str_NumToChar(Type, NumLen, TrData, SendData); 108 | 109 | while(*pWord != '\0') { 110 | UART_SendByte(USARTx, *pWord); 111 | pWord++; 112 | } 113 | } 114 | /*====================================================================================================*/ 115 | /*====================================================================================================* 116 | **函數 : RS232_SendData 117 | **功能 : 發送資料 118 | **輸入 : *SendData, DataLen 119 | **輸出 : None 120 | **使用 : RS232_SendData(SendData, DataLen); 121 | **====================================================================================================*/ 122 | /*====================================================================================================*/ 123 | void RS232_SendData( u8 *SendData, u16 DataLen ) 124 | { 125 | UART_SendData(USARTx, SendData, DataLen); 126 | } 127 | /*====================================================================================================*/ 128 | /*====================================================================================================* 129 | **函數 : RS232_RecvStr 130 | **功能 : 接收字串 131 | **輸入 : *pWord 132 | **輸出 : None 133 | **使用 : RS232_RecvStr(RecvStirng); 134 | **====================================================================================================*/ 135 | /*====================================================================================================*/ 136 | void RS232_RecvStr( u8 *pWord ) 137 | { 138 | do { 139 | *pWord = UART_RecvByte(USARTx); 140 | pWord++; 141 | } while(*(pWord-1) != '\0'); 142 | *pWord = '\0'; 143 | } 144 | /*====================================================================================================*/ 145 | /*====================================================================================================* 146 | **函數 : RS232_RecvData 147 | **功能 : 接收資料 148 | **輸入 : *RecvData, DataLen 149 | **輸出 : None 150 | **使用 : RS232_RecvData(RecvData, DataLen); 151 | **====================================================================================================*/ 152 | /*====================================================================================================*/ 153 | void RS232_RecvData( u8 *RecvData, u16 DataLen ) 154 | { 155 | UART_RecvData(USARTx, RecvData, DataLen); 156 | } 157 | /*====================================================================================================*/ 158 | /*====================================================================================================* 159 | **函數 : RS232_VisualScope_CRC16 160 | **功能 : VisualScope CRC 161 | **輸入 : *SendData, Len 162 | **輸出 : UART_CRC 163 | **使用 : UART_CRC = RS232_VisualScope_CRC16(SendData, DataLen); 164 | **====================================================================================================*/ 165 | /*====================================================================================================*/ 166 | static u16 RS232_VisualScope_CRC16( u8 *SendData, u8 DataLen ) 167 | { 168 | u16 UART_IX, UART_IY, UART_CRC; 169 | 170 | UART_CRC = 0xffff; 171 | for(UART_IX=0; UART_IX>1)^0xA001; 176 | else 177 | UART_CRC = UART_CRC>>1; 178 | } 179 | } 180 | return(UART_CRC); 181 | } 182 | /*====================================================================================================*/ 183 | /*====================================================================================================* 184 | **函數 : RS232_VisualScope 185 | **功能 : VisualScope 186 | **輸入 : *SendBuf 187 | **輸出 : None 188 | **使用 : RS232_VisualScope(SendBuf); 189 | **====================================================================================================*/ 190 | /*====================================================================================================*/ 191 | void RS232_VisualScope( u8 *SendBuf ) 192 | { 193 | u8 SendCRC[2] = {0}; 194 | u16 UART_CRC; 195 | 196 | UART_CRC = RS232_VisualScope_CRC16(SendBuf, 8); 197 | SendCRC[0] = UART_CRC&0x00ff; 198 | SendCRC[1] = (UART_CRC&0xff00)>>8; 199 | 200 | UART_SendData(USARTx, SendBuf, 8); 201 | UART_SendData(USARTx, SendCRC, 2); 202 | } 203 | /*====================================================================================================*/ 204 | /*====================================================================================================*/ 205 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/Modules/module_rs232.h: -------------------------------------------------------------------------------- 1 | /* #include "module_rs232.h" */ 2 | 3 | #ifndef __MODULE_RS232_H 4 | #define __MODULE_RS232_H 5 | 6 | #include "stm32f4xx.h" 7 | /*====================================================================================================*/ 8 | /*====================================================================================================*/ 9 | void RS232_Config( void ); 10 | void RS232_SendStr( u8 *pWord ); 11 | void RS232_SendNum( u8 Type, u8 NumLen, s32 SendData ); 12 | void RS232_SendData( u8 *SendData, u16 DataLen ); 13 | void RS232_RecvStr( u8 *pWord ); 14 | void RS232_RecvData( u8 *RecvData, u16 DataLen ); 15 | void RS232_VisualScope( u8 *SendBuf ); 16 | /*====================================================================================================*/ 17 | /*====================================================================================================*/ 18 | #endif 19 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/QCopterNano.c: -------------------------------------------------------------------------------- 1 | /*====================================================================================================*/ 2 | /*====================================================================================================*/ 3 | #include "stm32f4_system.h" 4 | #include "stm32f4_usart.h" 5 | #include "QCopterNano.h" 6 | #include "QCopterNano_ctrl.h" 7 | #include "QCopterNano_transport.h" 8 | #include "module_rs232.h" 9 | #include "module_nrf24l01.h" 10 | #include "module_imu.h" 11 | #include "module_mpu9250.h" 12 | #include "algorithm_pid.h" 13 | #include "algorithm_ahrs.h" 14 | #include "algorithm_string.h" 15 | /*====================================================================================================*/ 16 | /*====================================================================================================*/ 17 | FSM_MODE FSM_STATE = FSM_TXRX; 18 | SEN_MODE SEN_STATE = SEN_CORR; 19 | /*====================================================================================================*/ 20 | /*====================================================================================================*/ 21 | void System_Init( void ) 22 | { 23 | SystemInit(); 24 | 25 | GPIO_Config(); 26 | RS232_Config(); 27 | Motor_Config(); 28 | Sensor_Config(); 29 | NRF24L01_Config(); 30 | 31 | LED = 0; 32 | 33 | Sensor_Init(); 34 | NRF24L01_Init(NRF_MODE_FTLR); 35 | 36 | PID_Init(&PID_Yaw); 37 | PID_Init(&PID_Roll); 38 | PID_Init(&PID_Pitch); 39 | 40 | PID_Pitch.Kp = +1.0f; 41 | PID_Pitch.Ki = +0.000f; 42 | PID_Pitch.Kd = +3.0f; 43 | 44 | PID_Roll.Kp = +1.0f; 45 | PID_Roll.Ki = +0.000f; 46 | PID_Roll.Kd = +3.0f; 47 | 48 | PID_Yaw.Kp = +0.0f; 49 | PID_Yaw.Ki = +0.0f; 50 | PID_Yaw.Kd = +0.0f; 51 | 52 | AHRS_Init(&NumQ, &AngE); 53 | 54 | /* Systick Setup */ 55 | if(SysTick_Config((u32)(SystemCoreClock/(float)SampleRateFreg))) 56 | while(1); 57 | 58 | /* Wait Correct */ 59 | while(SEN_STATE != SEN_ALG); 60 | LED = 1; 61 | } 62 | /*====================================================================================================*/ 63 | /*====================================================================================================*/ 64 | int main( void ) 65 | { 66 | u8 Status = 0; 67 | 68 | System_Init(); 69 | Delay_100ms(5); 70 | 71 | /* QCopterNano FSM */ 72 | while(1) { 73 | // LED = !LED; 74 | switch(FSM_STATE) { 75 | 76 | /************************** FSM TXRX ****************************************/ 77 | case FSM_TXRX: 78 | // FSM_TXRX 79 | Transport_Send(TxBuf); 80 | do { 81 | Status = NRF_TxPacket(TxBuf); 82 | } while(Status == NRF_STA_MAX_RT); 83 | NRF_RX_Mode(); 84 | Status = NRF_RxPacket(RxBuf); 85 | if(Status == NRF_STA_RX_DR) { 86 | Transport_Recv(RxBuf); 87 | } 88 | // FSM_TXRX End 89 | FSM_STATE = FSM_CTRL; 90 | break; 91 | 92 | /************************** FSM CTRL ****************************************/ 93 | case FSM_CTRL: 94 | // FSM_CTRL 95 | Ctrl_BasicThr(); 96 | // FSM_CTRL End 97 | FSM_STATE = FSM_UART; 98 | break; 99 | 100 | /************************** FSM UART ****************************************/ 101 | case FSM_UART: 102 | // FSM_UART 103 | RS232_VisualScope(TxBuf+20); 104 | // FSM_UART End 105 | FSM_STATE = FSM_DATA; 106 | break; 107 | 108 | /************************** FSM DATA ****************************************/ 109 | case FSM_DATA: 110 | // FSM_DATA 111 | 112 | // FSM_DATA End 113 | FSM_STATE = FSM_TXRX; 114 | break; 115 | 116 | /************************** FSM Err *****************************************/ 117 | default: 118 | LED = 1; 119 | while(1) { 120 | LED = !LED; 121 | Delay_100ms(10); 122 | } 123 | } 124 | } 125 | } 126 | /*====================================================================================================*/ 127 | /*====================================================================================================*/ 128 | void GPIO_Config( void ) 129 | { 130 | GPIO_InitTypeDef GPIO_InitStruct; 131 | 132 | /* LED Clk Init *************************************************************/ 133 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); 134 | 135 | /* LED PC13 */ 136 | GPIO_InitStruct.GPIO_Pin = GPIO_Pin_13; 137 | GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; 138 | GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; 139 | GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; 140 | GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; 141 | GPIO_Init(GPIOC, &GPIO_InitStruct); 142 | 143 | LED = 1; 144 | } 145 | /*====================================================================================================*/ 146 | /*====================================================================================================*/ 147 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/QCopterNano.h: -------------------------------------------------------------------------------- 1 | /* #include "experiment_stm32f4.h" */ 2 | 3 | #ifndef __EXPERIMENT_STM32F4_H 4 | #define __EXPERIMENT_STM32F4_H 5 | 6 | #include "stm32f4xx.h" 7 | /*====================================================================================================*/ 8 | /*====================================================================================================*/ 9 | #define LED PCO(13) 10 | /*====================================================================================================*/ 11 | /*====================================================================================================*/ 12 | typedef __IO enum { 13 | FSM__OUT_L = 0, 14 | FSM_TXRX, 15 | FSM_CTRL, 16 | FSM_UART, 17 | FSM_DATA, 18 | FSM_OUT_R 19 | } FSM_MODE; 20 | 21 | typedef __IO enum { 22 | SEN__OUT_L = 0, 23 | SEN_CORR, 24 | SEN_GYR, 25 | SEN_ACC, 26 | SEN_MAG, 27 | SEN_NUMQ, 28 | SEN_ALG, 29 | SEN_OUT_R 30 | } SEN_MODE; 31 | /*====================================================================================================*/ 32 | /*====================================================================================================*/ 33 | void GPIO_Config( void ); 34 | /*====================================================================================================*/ 35 | /*====================================================================================================*/ 36 | extern FSM_MODE FSM_STATE; 37 | extern SEN_MODE SEN_STATE; 38 | /*====================================================================================================*/ 39 | /*====================================================================================================*/ 40 | #endif 41 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/QCopterNano_ctrl.c: -------------------------------------------------------------------------------- 1 | /*====================================================================================================*/ 2 | /*====================================================================================================*/ 3 | #include "stm32f4_system.h" 4 | #include "QCopterNano_ctrl.h" 5 | #include "QCopterNano_transport.h" 6 | /*====================================================================================================*/ 7 | /*====================================================================================================*/ 8 | #define PWM1 TIM4->CCR4 9 | #define PWM2 TIM4->CCR1 10 | #define PWM3 TIM4->CCR2 11 | #define PWM4 TIM4->CCR3 12 | /*====================================================================================================*/ 13 | /*====================================================================================================*/ 14 | u16 BasicThr = 0; // 0 ~ 10000 對應到 0.00% ~ 100.00% 15 | /*=====================================================================================================*/ 16 | /*=====================================================================================================* 17 | **函數 : Motor_Config 18 | **功能 : 配置馬達 19 | **輸入 : None 20 | **輸出 : None 21 | **使用 : Motor_Config(); 22 | **=====================================================================================================*/ 23 | /*=====================================================================================================*/ 24 | void Motor_Config( void ) 25 | { 26 | GPIO_InitTypeDef GPIO_InitStruct; 27 | TIM_TimeBaseInitTypeDef TIM_TimeBaseStruct; 28 | TIM_OCInitTypeDef TIM_OCInitStruct; 29 | 30 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); 31 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE); 32 | 33 | GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_TIM4); 34 | GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_TIM4); 35 | GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_TIM4); 36 | GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_TIM4); 37 | 38 | /* TIM4 PWM1 PB6 */ /* TIM4 PWM2 PB7 */ /* TIM4 PWM3 PB8 */ /* TIM4 PWM4 PB9 */ 39 | GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9; 40 | GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; 41 | GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; 42 | GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; 43 | GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; 44 | GPIO_Init(GPIOB, &GPIO_InitStruct); 45 | 46 | TIM_DeInit(TIM4); 47 | 48 | /************************** PWM Output **************************************/ 49 | /* TIM4 Time Base */ 50 | TIM_TimeBaseStruct.TIM_Period = (u16)(MOTOR_PWM_RANGE-1); // Period = 11.9us => Freq = 400Hz 51 | TIM_TimeBaseStruct.TIM_Prescaler = (u16)(21-1); // fCK_PSC = APB1*2 = 42*2 = 84, fCK_PSC /21 = 4M ( 0.25us ) 52 | TIM_TimeBaseStruct.TIM_ClockDivision = TIM_CKD_DIV1; 53 | TIM_TimeBaseStruct.TIM_CounterMode = TIM_CounterMode_Up; // Count Up 54 | TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStruct); 55 | TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStruct); 56 | 57 | /* TIM4 OC */ 58 | TIM_OCInitStruct.TIM_OCMode = TIM_OCMode_PWM1; // Set PWM1 Mode 59 | TIM_OCInitStruct.TIM_OutputState = TIM_OutputState_Enable; // Enable OC 60 | TIM_OCInitStruct.TIM_Pulse = MOTOR_PWM_MIN; // Set Pulse 61 | TIM_OCInitStruct.TIM_OCPolarity = TIM_OCPolarity_High; // when Count < PWM_MOTOR_MIN => High 62 | TIM_OC1Init(TIM4, &TIM_OCInitStruct); // Init TIM4 OC1 63 | TIM_OC2Init(TIM4, &TIM_OCInitStruct); // Init TIM4 OC2 64 | TIM_OC3Init(TIM4, &TIM_OCInitStruct); // Init TIM4 OC3 65 | TIM_OC4Init(TIM4, &TIM_OCInitStruct); // Init TIM4 OC4 66 | TIM_OC1PreloadConfig(TIM4, TIM_OCPreload_Enable); // Enable TIM4 OC1 Preload 67 | TIM_OC2PreloadConfig(TIM4, TIM_OCPreload_Enable); // Enable TIM4 OC2 Preload 68 | TIM_OC3PreloadConfig(TIM4, TIM_OCPreload_Enable); // Enable TIM4 OC3 Preload 69 | TIM_OC4PreloadConfig(TIM4, TIM_OCPreload_Enable); // Enable TIM4 OC4 Preload 70 | 71 | TIM4->CCR1 = MOTOR_PWM_MIN; 72 | TIM4->CCR2 = MOTOR_PWM_MIN; 73 | TIM4->CCR3 = MOTOR_PWM_MIN; 74 | TIM4->CCR4 = MOTOR_PWM_MIN; 75 | 76 | /* Enable */ 77 | TIM_ARRPreloadConfig(TIM4, ENABLE); // Enable TIM4 ARR Preload 78 | TIM_Cmd(TIM4, ENABLE); // Start TIM4 79 | } 80 | /*=====================================================================================================*/ 81 | /*=====================================================================================================* 82 | **函數 : Ctrl_MotorPWM 83 | **功能 : 馬達脈波控制 84 | **輸入 : MOTOR_1, MOTOR_2, MOTOR_3, MOTOR_4 85 | **輸出 : None 86 | **使用 : Ctrl_MotorPWM(MOTOR[0], MOTOR[1], MOTOR[2], MOTOR[3]); 87 | **=====================================================================================================*/ 88 | /*=====================================================================================================*/ 89 | void Ctrl_MotorPWM( s16 MOTOR_1, s16 MOTOR_2, s16 MOTOR_3, s16 MOTOR_4 ) 90 | { 91 | if(MOTOR_1>MOTOR_PWM_MAX) MOTOR_1 = MOTOR_PWM_MAX; 92 | else if(MOTOR_1MOTOR_PWM_MAX) MOTOR_2 = MOTOR_PWM_MAX; 94 | else if(MOTOR_2MOTOR_PWM_MAX) MOTOR_3 = MOTOR_PWM_MAX; 96 | else if(MOTOR_3MOTOR_PWM_MAX) MOTOR_4 = MOTOR_PWM_MAX; 98 | else if(MOTOR_4MOTOR_THR_MAX) MOTOR_1 = MOTOR_THR_MAX; 117 | else if(MOTOR_1<(MOTOR_THR_MIN+500)) MOTOR_1 = MOTOR_THR_MIN; 118 | if(MOTOR_2>MOTOR_THR_MAX) MOTOR_2 = MOTOR_THR_MAX; 119 | else if(MOTOR_2<(MOTOR_THR_MIN+500)) MOTOR_2 = MOTOR_THR_MIN; 120 | if(MOTOR_3>MOTOR_THR_MAX) MOTOR_3 = MOTOR_THR_MAX; 121 | else if(MOTOR_3<(MOTOR_THR_MIN+500)) MOTOR_3 = MOTOR_THR_MIN; 122 | if(MOTOR_4>MOTOR_THR_MAX) MOTOR_4 = MOTOR_THR_MAX; 123 | else if(MOTOR_4<(MOTOR_THR_MIN+500)) MOTOR_4 = MOTOR_THR_MIN; 124 | 125 | PWM1 = (u16)(MOTOR_1>>2); 126 | PWM2 = (u16)(MOTOR_2>>2); 127 | PWM3 = (u16)(MOTOR_3>>2); 128 | PWM4 = (u16)(MOTOR_4>>2); 129 | } 130 | /*=====================================================================================================*/ 131 | /*=====================================================================================================* 132 | **函數 : CTRL_SERVO 133 | **功能 : 伺服馬達控制 134 | **輸入 : SevroA, SevroB 135 | **輸出 : None 136 | **使用 : CTRL_SERVO( SevroA, SevroB ); 137 | **=====================================================================================================*/ 138 | /*=====================================================================================================*/ 139 | //void CTRL_SERVO( void ) 140 | //{ 141 | 142 | //} 143 | /*=====================================================================================================*/ 144 | /*=====================================================================================================* 145 | **函數 : Ctrl_BasicThr 146 | **功能 : 飛行器基本油門控制 147 | **輸入 : None 148 | **輸出 : None 149 | **使用 : Ctrl_BasicThr(); 150 | **=====================================================================================================*/ 151 | /*=====================================================================================================*/ 152 | void Ctrl_BasicThr( void ) 153 | { 154 | s16 TempThr = 0; 155 | static s16 TempThrB = 0; 156 | 157 | // 粗調油門 158 | if(KEY_LP == 1) { 159 | TempThrB = (s16)EXP_THR_B; 160 | if(TempThrB>MOTOR_THR_MAX) 161 | TempThrB = MOTOR_THR_MAX; 162 | if(TempThrBMOTOR_THR_MAX) 169 | TempThr = MOTOR_THR_MAX; 170 | if(TempThr>1); 35 | RF_RecvData.KeyR[1].KeyRead = (u8)(RecvBuf[5]&0x01); 36 | RF_RecvData.KeyR[1].PressTime = (u8)(RecvBuf[5]>>1); 37 | RF_RecvData.KeyR[2].KeyRead = (u8)(RecvBuf[6]&0x01); 38 | RF_RecvData.KeyR[2].PressTime = (u8)(RecvBuf[6]>>1); 39 | 40 | RF_RecvData.KeyL[0].KeyRead = (u8)(RecvBuf[7]&0x01); 41 | RF_RecvData.KeyL[0].PressTime = (u8)(RecvBuf[7]>>1); 42 | RF_RecvData.KeyL[1].KeyRead = (u8)(RecvBuf[8]&0x01); 43 | RF_RecvData.KeyL[1].PressTime = (u8)(RecvBuf[8]>>1); 44 | RF_RecvData.KeyL[2].KeyRead = (u8)(RecvBuf[9]&0x01); 45 | RF_RecvData.KeyL[2].PressTime = (u8)(RecvBuf[9]>>1); 46 | 47 | RF_RecvData.KeyP[0].KeyRead = (u8)(RecvBuf[10]&0x01); 48 | RF_RecvData.KeyP[0].PressTime = (u8)(RecvBuf[10]>>1); 49 | RF_RecvData.KeyP[1].KeyRead = (u8)(RecvBuf[11]&0x01); 50 | RF_RecvData.KeyP[1].PressTime = (u8)(RecvBuf[11]>>1); 51 | RF_RecvData.KeyP[2].KeyRead = (u8)(RecvBuf[12]&0x01); 52 | RF_RecvData.KeyP[2].PressTime = (u8)(RecvBuf[12]>>1); 53 | 54 | RF_RecvData.KeyS[0].KeyRead = (u8)(RecvBuf[13]&0x01); 55 | RF_RecvData.KeyS[0].PressTime = (u8)(RecvBuf[13]>>1); 56 | RF_RecvData.KeyS[1].KeyRead = (u8)(RecvBuf[14]&0x01); 57 | RF_RecvData.KeyS[1].PressTime = (u8)(RecvBuf[14]>>1); 58 | RF_RecvData.KeyS[2].KeyRead = (u8)(RecvBuf[15]&0x01); 59 | RF_RecvData.KeyS[2].PressTime = (u8)(RecvBuf[15]>>1); 60 | 61 | RF_RecvData.Ctrl.ThrB = (s16)(Byte16(u16, RecvBuf[16], RecvBuf[17])); 62 | RF_RecvData.Ctrl.ThrS = (s16)(Byte16(u16, RecvBuf[18], RecvBuf[19])); 63 | RF_RecvData.Ctrl.Pitch = (s16)(Byte16(u16, RecvBuf[20], RecvBuf[21])); 64 | RF_RecvData.Ctrl.Roll = (s16)(Byte16(u16, RecvBuf[22], RecvBuf[23])); 65 | RF_RecvData.Ctrl.Yaw = (s16)(Byte16(u16, RecvBuf[24], RecvBuf[25])); 66 | RF_RecvData.Ctrl.Corr = (s16)(Byte16(u16, RecvBuf[26], RecvBuf[27])); 67 | 68 | RF_RecvData.Cmd = (u8)(RecvBuf[28]); 69 | RF_RecvData.Data[0] = (u8)(RecvBuf[29]); 70 | RF_RecvData.Data[1] = (u8)(RecvBuf[30]); 71 | RF_RecvData.Data[2] = (u8)(RecvBuf[31]); 72 | } 73 | /*=====================================================================================================*/ 74 | /*=====================================================================================================* 75 | **函數 : Transport_Send 76 | **功能 : 紀錄發送資料 77 | **輸入 : SendBuf 78 | **輸出 : None 79 | **使用 : Transport_Send(TxBuf); 80 | **=====================================================================================================*/ 81 | /*=====================================================================================================*/ 82 | void Transport_Send( u8* SendBuf ) 83 | { 84 | s16 TMP_BUF[16] = {0}; 85 | 86 | // TMP_BUF[0] = (s16)(Acc.X); // 1 mg/LSB 87 | // TMP_BUF[1] = (s16)(Acc.Y); // 1 mg/LSB 88 | // TMP_BUF[2] = (s16)(Acc.Z); // 1 mg/LSB 89 | // TMP_BUF[3] = (s16)(Gyr.X); // 10 mdps/LSB 90 | // TMP_BUF[4] = (s16)(Gyr.Y); // 10 mdps/LSB 91 | // TMP_BUF[5] = (s16)(Gyr.Z); // 10 mdps/LSB 92 | TMP_BUF[0] = (s16)(Acc.TrueX*1000); // 1 mg/LSB 93 | TMP_BUF[1] = (s16)(Acc.TrueY*1000); // 1 mg/LSB 94 | TMP_BUF[2] = (s16)(Acc.TrueZ*1000); // 1 mg/LSB 95 | TMP_BUF[3] = (s16)(Gyr.TrueX*10); // 10 mdps/LSB 96 | TMP_BUF[4] = (s16)(Gyr.TrueY*10); // 10 mdps/LSB 97 | TMP_BUF[5] = (s16)(Gyr.TrueZ*10); // 10 mdps/LSB 98 | // TMP_BUF[6] = (s16)(PID_Pitch.Kp); 99 | // TMP_BUF[7] = (s16)(PID_Pitch.Ki); 100 | // TMP_BUF[8] = (s16)(PID_Pitch.Kd); 101 | TMP_BUF[6] = (s16)(PID_Pitch.Kp*1000); 102 | TMP_BUF[7] = (s16)(PID_Pitch.Ki*1000); 103 | TMP_BUF[8] = (s16)(PID_Pitch.Kd*1000); 104 | TMP_BUF[9] = (s16)(AngE.Pitch*100); 105 | TMP_BUF[10] = (s16)(AngE.Roll*100); 106 | TMP_BUF[11] = (s16)(AngE.Yaw*10); 107 | TMP_BUF[12] = (s16)(BasicThr); 108 | TMP_BUF[13] = (s16)(Time_Sec); 109 | TMP_BUF[14] = (s16)(Time_Min); 110 | 111 | SendBuf[0] = (u8)(0x01); 112 | SendBuf[1] = (u8)(0x02); 113 | SendBuf[2] = (u8)Byte8L(TMP_BUF[0]); 114 | SendBuf[3] = (u8)Byte8H(TMP_BUF[0]); 115 | SendBuf[4] = (u8)Byte8L(TMP_BUF[1]); 116 | SendBuf[5] = (u8)Byte8H(TMP_BUF[1]); 117 | SendBuf[6] = (u8)Byte8L(TMP_BUF[2]); 118 | SendBuf[7] = (u8)Byte8H(TMP_BUF[2]); 119 | SendBuf[8] = (u8)Byte8L(TMP_BUF[3]); 120 | SendBuf[9] = (u8)Byte8H(TMP_BUF[3]); 121 | SendBuf[10] = (u8)Byte8L(TMP_BUF[4]); 122 | SendBuf[11] = (u8)Byte8H(TMP_BUF[4]); 123 | SendBuf[12] = (u8)Byte8L(TMP_BUF[5]); 124 | SendBuf[13] = (u8)Byte8H(TMP_BUF[5]); 125 | SendBuf[14] = (u8)Byte8L(TMP_BUF[6]); 126 | SendBuf[15] = (u8)Byte8H(TMP_BUF[6]); 127 | SendBuf[16] = (u8)Byte8L(TMP_BUF[7]); 128 | SendBuf[17] = (u8)Byte8H(TMP_BUF[7]); 129 | SendBuf[18] = (u8)Byte8L(TMP_BUF[8]); 130 | SendBuf[19] = (u8)Byte8H(TMP_BUF[8]); 131 | SendBuf[20] = (u8)Byte8L(TMP_BUF[9]); 132 | SendBuf[21] = (u8)Byte8H(TMP_BUF[9]); 133 | SendBuf[22] = (u8)Byte8L(TMP_BUF[10]); 134 | SendBuf[23] = (u8)Byte8H(TMP_BUF[10]); 135 | SendBuf[24] = (u8)Byte8L(TMP_BUF[11]); 136 | SendBuf[25] = (u8)Byte8H(TMP_BUF[11]); 137 | SendBuf[26] = (u8)Byte8L(TMP_BUF[12]); 138 | SendBuf[27] = (u8)Byte8H(TMP_BUF[12]); 139 | SendBuf[28] = (u8)(0); 140 | SendBuf[29] = (u8)(0); 141 | SendBuf[30] = (u8)(TMP_BUF[13]); 142 | SendBuf[31] = (u8)(TMP_BUF[14]); 143 | } 144 | /*=====================================================================================================*/ 145 | /*=====================================================================================================*/ 146 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/QCopterNano_transport.h: -------------------------------------------------------------------------------- 1 | /* #include "QCopterNano_transport.h" */ 2 | 3 | #ifndef __QCOPTERNANO_TRANSPORT_H 4 | #define __QCOPTERNANO_TRANSPORT_H 5 | 6 | #include "stm32f4xx.h" 7 | /*=====================================================================================================*/ 8 | /*=====================================================================================================*/ 9 | #define KEY_RP (RF_RecvData.KeyR[0].KeyRead) 10 | #define KEY_RR (RF_RecvData.KeyR[1].KeyRead) 11 | #define KEY_RL (RF_RecvData.KeyR[2].KeyRead) 12 | #define KEY_LP (RF_RecvData.KeyL[0].KeyRead) 13 | #define KEY_LR (RF_RecvData.KeyL[1].KeyRead) 14 | #define KEY_LL (RF_RecvData.KeyL[2].KeyRead) 15 | #define KEY_PP (RF_RecvData.KeyP[0].KeyRead) 16 | #define KEY_PR (RF_RecvData.KeyP[1].KeyRead) 17 | #define KEY_PL (RF_RecvData.KeyP[2].KeyRead) 18 | #define KEY_S1 (RF_RecvData.KeyS[0].KeyRead) 19 | #define KEY_S2 (RF_RecvData.KeyS[1].KeyRead) 20 | #define KEY_S3 (RF_RecvData.KeyS[2].KeyRead) 21 | 22 | #define KEY_RP_T (RF_RecvData.KeyR[0].PressTime) 23 | #define KEY_RR_T (RF_RecvData.KeyR[1].PressTime) 24 | #define KEY_RL_T (RF_RecvData.KeyR[2].PressTime) 25 | #define KEY_LP_T (RF_RecvData.KeyL[0].PressTime) 26 | #define KEY_LR_T (RF_RecvData.KeyL[1].PressTime) 27 | #define KEY_LL_T (RF_RecvData.KeyL[2].PressTime) 28 | #define KEY_PP_T (RF_RecvData.KeyP[0].PressTime) 29 | #define KEY_PR_T (RF_RecvData.KeyP[1].PressTime) 30 | #define KEY_PL_T (RF_RecvData.KeyP[2].PressTime) 31 | #define KEY_S1_T (RF_RecvData.KeyS[0].PressTime) 32 | #define KEY_S2_T (RF_RecvData.KeyS[1].PressTime) 33 | #define KEY_S3_T (RF_RecvData.KeyS[2].PressTime) 34 | 35 | #define EXP_THR_B (RF_RecvData.Ctrl.ThrB) 36 | #define EXP_THR_S (RF_RecvData.Ctrl.ThrS) 37 | #define EXP_PITCH (RF_RecvData.Ctrl.Pitch) 38 | #define EXP_ROLL (RF_RecvData.Ctrl.Roll) 39 | #define EXP_YAW (RF_RecvData.Ctrl.Yaw) 40 | /*=====================================================================================================*/ 41 | /*=====================================================================================================*/ 42 | typedef __IO struct { 43 | u8 Packet; // Byt[00:00] Packet ***** 44 | struct { // Byt[01:03] Time ******* 45 | u8 Min; // [01:01] Time_Min 46 | u8 Sec; // [02:02] Time_Sec 47 | u8 Cnt; // [03:03] Time_Cnt 48 | } Time; 49 | struct { // Byt[04:06] KeyR ******* 50 | u8 KeyRead; // [04:04] KeyRP Bit[7:1] PressTime Bit[0:0] KeyRead 51 | u8 PressTime; // [05:05] KeyRR Bit[7:1] PressTime Bit[0:0] KeyRead 52 | } KeyR[3]; // [06:06] KeyRL Bit[7:1] PressTime Bit[0:0] KeyRead 53 | struct { // Byt[07:09] KeyL ******* 54 | u8 KeyRead; // [07:07] KeyLP Bit[7:1] PressTime Bit[0:0] KeyRead 55 | u8 PressTime; // [08:08] KeyLR Bit[7:1] PressTime Bit[0:0] KeyRead 56 | } KeyL[3]; // [09:09] KeyLL Bit[7:1] PressTime Bit[0:0] KeyRead 57 | struct { // Byt[10:12] KeyP ******* 58 | u8 KeyRead; // [10:10] KeyPP Bit[7:1] PressTime Bit[0:0] KeyRead 59 | u8 PressTime; // [11:11] KeyPR Bit[7:1] PressTime Bit[0:0] KeyRead 60 | } KeyP[3]; // [12:12] KeyPL Bit[7:1] PressTime Bit[0:0] KeyRead 61 | struct { // Byt[13:15] KeyS ******* 62 | u8 KeyRead; // [13:13] KeyS1 Bit[7:1] PressTime Bit[0:0] KeyRead 63 | u8 PressTime; // [14:14] KeyS2 Bit[7:1] PressTime Bit[0:0] KeyRead 64 | } KeyS[3]; // [15:15] KeyS3 Bit[7:1] PressTime Bit[0:0] KeyRead 65 | struct { // Byt[16:27] Ctrl ******* 66 | s16 ThrB; // [16:17] ThrB [16] ThrB_H [17] ThrB_L 67 | s16 ThrS; // [18:19] ThrS [18] ThrS_H [19] ThrS_L 68 | s16 Pitch; // [20:21] Pitch [20] Pitch_H [21] Pitch_L 69 | s16 Roll; // [22:23] Roll [22] Roll_H [23] Roll_L 70 | s16 Yaw; // [24:25] Yaw [24] Yaw_H [25] Yaw_L 71 | s16 Corr; // [26:27] Corr [26] Corr_H [27] Corr_L 72 | } Ctrl; 73 | u8 Cmd; // Byt[28:28] Cmd ******** 74 | u8 Data[3]; // Byt[29:31] Data ******* 75 | } TR_RECV_DATA; 76 | /*=====================================================================================================*/ 77 | /*=====================================================================================================*/ 78 | void Transport_Recv( u8* RecvBuf ); 79 | void Transport_Send( u8* SendBuf ); 80 | /*=====================================================================================================*/ 81 | /*=====================================================================================================*/ 82 | extern TR_RECV_DATA RF_RecvData; 83 | /*=====================================================================================================*/ 84 | /*=====================================================================================================*/ 85 | #endif 86 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/Program/stm32f4xx_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_conf.h 4 | * @author MCD Application Team 5 | * @version V1.3.0 6 | * @date 13-November-2013 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32F4xx_CONF_H 30 | #define __STM32F4xx_CONF_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | /* Uncomment the line below to enable peripheral header file inclusion */ 34 | //#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 35 | //#include "stm32f4xx_adc.h" 36 | //#include "stm32f4xx_can.h" 37 | //#include "stm32f4xx_crc.h" 38 | //#include "stm32f4xx_cryp.h" 39 | //#include "stm32f4xx_dbgmcu.h" 40 | //#include "stm32f4xx_dac.h" 41 | //#include "stm32f4xx_dcmi.h" 42 | //#include "stm32f4xx_dma.h" 43 | //#include "stm32f4xx_dma2d.h" 44 | //#include "stm32f4xx_exti.h" 45 | //#include "stm32f4xx_flash.h" 46 | //#include "stm32f4xx_fmc.h" 47 | #include "stm32f4xx_gpio.h" 48 | //#include "stm32f4xx_hash.h" 49 | //#include "stm32f4xx_i2c.h" 50 | //#include "stm32f4xx_iwdg.h" 51 | //#include "stm32f4xx_ltdc.h" 52 | //#include "stm32f4xx_pwr.h" 53 | #include "stm32f4xx_rcc.h" 54 | //#include "stm32f4xx_rng.h" 55 | //#include "stm32f4xx_rtc.h" 56 | //#include "stm32f4xx_sai.h" 57 | //#include "stm32f4xx_sdio.h" 58 | #include "stm32f4xx_spi.h" 59 | //#include "stm32f4xx_syscfg.h" 60 | #include "stm32f4xx_tim.h" 61 | #include "stm32f4xx_usart.h" 62 | //#include "stm32f4xx_wwdg.h" 63 | 64 | /* Exported macro ------------------------------------------------------------*/ 65 | #ifdef USE_FULL_ASSERT 66 | 67 | /** 68 | * @brief The assert_param macro is used for function's parameters check. 69 | * @param expr: If expr is false, it calls assert_failed function 70 | * which reports the name of the source file and the source 71 | * line number of the call that failed. 72 | * If expr is true, it returns no value. 73 | * @retval None 74 | */ 75 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 76 | /* Exported functions ------------------------------------------------------- */ 77 | void assert_failed(uint8_t* file, uint32_t line); 78 | #else 79 | #define assert_param(expr) ((void)0) 80 | #endif /* USE_FULL_ASSERT */ 81 | 82 | #endif /* __STM32F4xx_CONF_H */ 83 | 84 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 85 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/ProjectIMU/ClearFile.bat: -------------------------------------------------------------------------------- 1 | del *.bak /s 2 | del *.ddk /s 3 | del *.edk /s 4 | del *.lst /s 5 | del *.lnp /s 6 | del *.mpf /s 7 | del *.mpj /s 8 | del *.obj /s 9 | del *.omf /s 10 | del *.opt /s 11 | del *.plg /s 12 | del *.rpt /s 13 | del *.tmp /s 14 | del *.__i /s 15 | del *.crf /s 16 | del *.o /s 17 | del *.d /s 18 | del *.axf /s 19 | del *.tra /s 20 | del *.dep /s 21 | del JLinkLog.txt /s 22 | 23 | del *.iex /s 24 | del *.htm /s 25 | del *.sct /s 26 | del *.hex /s 27 | del *.map /s 28 | del JLinkSettings.ini /s 29 | exit 30 | -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/VisualScope/VisualScope.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitSprout/QCopterNano/926637209d0051d8d4bd4299ed4504e62b30c40f/Software/QCopterNano_FlightControl/VisualScope/VisualScope.exe -------------------------------------------------------------------------------- /Software/QCopterNano_FlightControl/VisualScope/config.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitSprout/QCopterNano/926637209d0051d8d4bd4299ed4504e62b30c40f/Software/QCopterNano_FlightControl/VisualScope/config.dat --------------------------------------------------------------------------------