Galactic Explorer 6 hónapja
szülő
commit
7855a43239

+ 0 - 52
Core - 副本/Inc/adc.h

@@ -1,52 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    adc.h
-  * @brief   This file contains all the function prototypes for
-  *          the adc.c file
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __ADC_H__
-#define __ADC_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-extern ADC_HandleTypeDef hadc1;
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-void MX_ADC1_Init(void);
-
-/* USER CODE BEGIN Prototypes */
-
-/* USER CODE END Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __ADC_H__ */
-

+ 0 - 49
Core - 副本/Inc/gpio.h

@@ -1,49 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    gpio.h
-  * @brief   This file contains all the function prototypes for
-  *          the gpio.c file
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __GPIO_H__
-#define __GPIO_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-void MX_GPIO_Init(void);
-
-/* USER CODE BEGIN Prototypes */
-
-/* USER CODE END Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-#endif /*__ GPIO_H__ */
-

+ 0 - 58
Core - 副本/Inc/i2c.h

@@ -1,58 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    i2c.h
-  * @brief   This file contains all the function prototypes for
-  *          the i2c.c file
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __I2C_H__
-#define __I2C_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-extern I2C_HandleTypeDef hi2c1;
-
-extern I2C_HandleTypeDef hi2c2;
-
-extern I2C_HandleTypeDef hi2c3;
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-void MX_I2C1_Init(void);
-void MX_I2C2_Init(void);
-void MX_I2C3_Init(void);
-
-/* USER CODE BEGIN Prototypes */
-
-/* USER CODE END Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __I2C_H__ */
-

+ 0 - 74
Core - 副本/Inc/main.h

@@ -1,74 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file           : main.h
-  * @brief          : Header for main.c file.
-  *                   This file contains the common defines of the application.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-	
-extern int a;
-extern int b;
-extern int c;
-extern int t;
-/* USER CODE END Header */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __MAIN_H
-#define __MAIN_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32h7xx_hal.h"
-
-/* Private includes ----------------------------------------------------------*/
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-/* Exported types ------------------------------------------------------------*/
-/* USER CODE BEGIN ET */
-
-/* USER CODE END ET */
-
-/* Exported constants --------------------------------------------------------*/
-/* USER CODE BEGIN EC */
-
-/* USER CODE END EC */
-
-/* Exported macro ------------------------------------------------------------*/
-/* USER CODE BEGIN EM */
-
-/* USER CODE END EM */
-
-/* Exported functions prototypes ---------------------------------------------*/
-void Error_Handler(void);
-
-/* USER CODE BEGIN EFP */
-
-/* USER CODE END EFP */
-
-/* Private defines -----------------------------------------------------------*/
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MAIN_H */

+ 0 - 52
Core - 副本/Inc/quadspi.h

@@ -1,52 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    quadspi.h
-  * @brief   This file contains all the function prototypes for
-  *          the quadspi.c file
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __QUADSPI_H__
-#define __QUADSPI_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-extern QSPI_HandleTypeDef hqspi;
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-void MX_QUADSPI_Init(void);
-
-/* USER CODE BEGIN Prototypes */
-
-/* USER CODE END Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __QUADSPI_H__ */
-

+ 0 - 515
Core - 副本/Inc/stm32h7xx_hal_conf.h

@@ -1,515 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    stm32h7xx_hal_conf.h
-  * @author  MCD Application Team
-  * @brief   HAL configuration file.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2017 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef STM32H7xx_HAL_CONF_H
-#define STM32H7xx_HAL_CONF_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-
-/* ########################## Module Selection ############################## */
-/**
-  * @brief This is the list of modules to be used in the HAL driver
-  */
-#define HAL_MODULE_ENABLED
-
-  #define HAL_ADC_MODULE_ENABLED
-/* #define HAL_FDCAN_MODULE_ENABLED   */
-/* #define HAL_FMAC_MODULE_ENABLED   */
-/* #define HAL_CEC_MODULE_ENABLED   */
-/* #define HAL_COMP_MODULE_ENABLED   */
-/* #define HAL_CORDIC_MODULE_ENABLED   */
-/* #define HAL_CRC_MODULE_ENABLED   */
-/* #define HAL_CRYP_MODULE_ENABLED   */
-/* #define HAL_DAC_MODULE_ENABLED   */
-/* #define HAL_DCMI_MODULE_ENABLED   */
-/* #define HAL_DMA2D_MODULE_ENABLED   */
-/* #define HAL_ETH_MODULE_ENABLED   */
-/* #define HAL_ETH_LEGACY_MODULE_ENABLED   */
-/* #define HAL_NAND_MODULE_ENABLED   */
-/* #define HAL_NOR_MODULE_ENABLED   */
-/* #define HAL_OTFDEC_MODULE_ENABLED   */
-/* #define HAL_SRAM_MODULE_ENABLED   */
-/* #define HAL_SDRAM_MODULE_ENABLED   */
-/* #define HAL_HASH_MODULE_ENABLED   */
-/* #define HAL_HRTIM_MODULE_ENABLED   */
-/* #define HAL_HSEM_MODULE_ENABLED   */
-/* #define HAL_GFXMMU_MODULE_ENABLED   */
-/* #define HAL_JPEG_MODULE_ENABLED   */
-/* #define HAL_OPAMP_MODULE_ENABLED   */
-/* #define HAL_OSPI_MODULE_ENABLED   */
-/* #define HAL_OSPI_MODULE_ENABLED   */
-/* #define HAL_I2S_MODULE_ENABLED   */
-/* #define HAL_SMBUS_MODULE_ENABLED   */
-/* #define HAL_IWDG_MODULE_ENABLED   */
-/* #define HAL_LPTIM_MODULE_ENABLED   */
-/* #define HAL_LTDC_MODULE_ENABLED   */
-#define HAL_QSPI_MODULE_ENABLED
-/* #define HAL_RAMECC_MODULE_ENABLED   */
-/* #define HAL_RNG_MODULE_ENABLED   */
-/* #define HAL_RTC_MODULE_ENABLED   */
-/* #define HAL_SAI_MODULE_ENABLED   */
-/* #define HAL_SD_MODULE_ENABLED   */
-/* #define HAL_MMC_MODULE_ENABLED   */
-/* #define HAL_SPDIFRX_MODULE_ENABLED   */
-/* #define HAL_SPI_MODULE_ENABLED   */
-/* #define HAL_SWPMI_MODULE_ENABLED   */
-#define HAL_TIM_MODULE_ENABLED
-#define HAL_UART_MODULE_ENABLED
-/* #define HAL_USART_MODULE_ENABLED   */
-/* #define HAL_IRDA_MODULE_ENABLED   */
-/* #define HAL_SMARTCARD_MODULE_ENABLED   */
-/* #define HAL_WWDG_MODULE_ENABLED   */
-/* #define HAL_PCD_MODULE_ENABLED   */
-/* #define HAL_HCD_MODULE_ENABLED   */
-/* #define HAL_DFSDM_MODULE_ENABLED   */
-/* #define HAL_DSI_MODULE_ENABLED   */
-/* #define HAL_JPEG_MODULE_ENABLED   */
-/* #define HAL_MDIOS_MODULE_ENABLED   */
-/* #define HAL_PSSI_MODULE_ENABLED   */
-/* #define HAL_DTS_MODULE_ENABLED   */
-#define HAL_GPIO_MODULE_ENABLED
-#define HAL_DMA_MODULE_ENABLED
-#define HAL_MDMA_MODULE_ENABLED
-#define HAL_RCC_MODULE_ENABLED
-#define HAL_FLASH_MODULE_ENABLED
-#define HAL_EXTI_MODULE_ENABLED
-#define HAL_PWR_MODULE_ENABLED
-#define HAL_I2C_MODULE_ENABLED
-#define HAL_CORTEX_MODULE_ENABLED
-#define HAL_HSEM_MODULE_ENABLED
-
-/* ########################## Oscillator Values adaptation ####################*/
-/**
-  * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
-  *        This value is used by the RCC HAL module to compute the system frequency
-  *        (when HSE is used as system clock source, directly or through the PLL).
-  */
-#if !defined  (HSE_VALUE)
-#define HSE_VALUE    (25000000UL) /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */
-#endif /* HSE_VALUE */
-
-#if !defined  (HSE_STARTUP_TIMEOUT)
-  #define HSE_STARTUP_TIMEOUT    (100UL)   /*!< Time out for HSE start up, in ms */
-#endif /* HSE_STARTUP_TIMEOUT */
-
-/**
-  * @brief Internal  oscillator (CSI) default value.
-  *        This value is the default CSI value after Reset.
-  */
-#if !defined  (CSI_VALUE)
-  #define CSI_VALUE    (4000000UL) /*!< Value of the Internal oscillator in Hz*/
-#endif /* CSI_VALUE */
-
-/**
-  * @brief Internal High Speed oscillator (HSI) value.
-  *        This value is used by the RCC HAL module to compute the system frequency
-  *        (when HSI is used as system clock source, directly or through the PLL).
-  */
-#if !defined  (HSI_VALUE)
-  #define HSI_VALUE    (64000000UL) /*!< Value of the Internal oscillator in Hz*/
-#endif /* HSI_VALUE */
-
-/**
-  * @brief External Low Speed oscillator (LSE) value.
-  *        This value is used by the UART, RTC HAL module to compute the system frequency
-  */
-#if !defined  (LSE_VALUE)
-  #define LSE_VALUE    (32768UL) /*!< Value of the External oscillator in Hz*/
-#endif /* LSE_VALUE */
-
-#if !defined  (LSE_STARTUP_TIMEOUT)
-  #define LSE_STARTUP_TIMEOUT    (5000UL)   /*!< Time out for LSE start up, in ms */
-#endif /* LSE_STARTUP_TIMEOUT */
-
-#if !defined  (LSI_VALUE)
-  #define LSI_VALUE  (32000UL)              /*!< LSI Typical Value in Hz*/
-#endif /* LSI_VALUE */                      /*!< Value of the Internal Low Speed oscillator in Hz
-                                              The real value may vary depending on the variations
-                                              in voltage and temperature.*/
-
-/**
-  * @brief External clock source for I2S peripheral
-  *        This value is used by the I2S HAL module to compute the I2S clock source
-  *        frequency, this source is inserted directly through I2S_CKIN pad.
-  */
-#if !defined  (EXTERNAL_CLOCK_VALUE)
-  #define EXTERNAL_CLOCK_VALUE    12288000UL /*!< Value of the External clock in Hz*/
-#endif /* EXTERNAL_CLOCK_VALUE */
-
-/* Tip: To avoid modifying this file each time you need to use different HSE,
-   ===  you can define the HSE value in your toolchain compiler preprocessor. */
-
-/* ########################### System Configuration ######################### */
-/**
-  * @brief This is the HAL system configuration section
-  */
-#define  VDD_VALUE                    (3300UL) /*!< Value of VDD in mv */
-#define  TICK_INT_PRIORITY            (15UL) /*!< tick interrupt priority */
-#define  USE_RTOS                     0
-#define  USE_SD_TRANSCEIVER           0U               /*!< use uSD Transceiver */
-#define  USE_SPI_CRC	              0U               /*!< use CRC in SPI */
-
-#define  USE_HAL_ADC_REGISTER_CALLBACKS     0U /* ADC register callback disabled     */
-#define  USE_HAL_CEC_REGISTER_CALLBACKS     0U /* CEC register callback disabled     */
-#define  USE_HAL_COMP_REGISTER_CALLBACKS    0U /* COMP register callback disabled    */
-#define  USE_HAL_CORDIC_REGISTER_CALLBACKS  0U /* CORDIC register callback disabled  */
-#define  USE_HAL_CRYP_REGISTER_CALLBACKS    0U /* CRYP register callback disabled    */
-#define  USE_HAL_DAC_REGISTER_CALLBACKS     0U /* DAC register callback disabled     */
-#define  USE_HAL_DCMI_REGISTER_CALLBACKS    0U /* DCMI register callback disabled    */
-#define  USE_HAL_DFSDM_REGISTER_CALLBACKS   0U /* DFSDM register callback disabled   */
-#define  USE_HAL_DMA2D_REGISTER_CALLBACKS   0U /* DMA2D register callback disabled   */
-#define  USE_HAL_DSI_REGISTER_CALLBACKS     0U /* DSI register callback disabled     */
-#define  USE_HAL_DTS_REGISTER_CALLBACKS     0U /* DTS register callback disabled     */
-#define  USE_HAL_ETH_REGISTER_CALLBACKS     0U /* ETH register callback disabled     */
-#define  USE_HAL_FDCAN_REGISTER_CALLBACKS   0U /* FDCAN register callback disabled   */
-#define  USE_HAL_FMAC_REGISTER_CALLBACKS    0U /* FMAC register callback disabled  */
-#define  USE_HAL_NAND_REGISTER_CALLBACKS    0U /* NAND register callback disabled    */
-#define  USE_HAL_NOR_REGISTER_CALLBACKS     0U /* NOR register callback disabled     */
-#define  USE_HAL_SDRAM_REGISTER_CALLBACKS   0U /* SDRAM register callback disabled   */
-#define  USE_HAL_SRAM_REGISTER_CALLBACKS    0U /* SRAM register callback disabled    */
-#define  USE_HAL_HASH_REGISTER_CALLBACKS    0U /* HASH register callback disabled    */
-#define  USE_HAL_HCD_REGISTER_CALLBACKS     0U /* HCD register callback disabled     */
-#define  USE_HAL_GFXMMU_REGISTER_CALLBACKS  0U /* GFXMMU register callback disabled  */
-#define  USE_HAL_HRTIM_REGISTER_CALLBACKS   0U /* HRTIM register callback disabled   */
-#define  USE_HAL_I2C_REGISTER_CALLBACKS     0U /* I2C register callback disabled     */
-#define  USE_HAL_I2S_REGISTER_CALLBACKS     0U /* I2S register callback disabled     */
-#define  USE_HAL_IRDA_REGISTER_CALLBACKS    0U /* IRDA register callback disabled    */
-#define  USE_HAL_JPEG_REGISTER_CALLBACKS    0U /* JPEG register callback disabled    */
-#define  USE_HAL_LPTIM_REGISTER_CALLBACKS   0U /* LPTIM register callback disabled   */
-#define  USE_HAL_LTDC_REGISTER_CALLBACKS    0U /* LTDC register callback disabled    */
-#define  USE_HAL_MDIOS_REGISTER_CALLBACKS   0U /* MDIO register callback disabled    */
-#define  USE_HAL_MMC_REGISTER_CALLBACKS     0U /* MMC register callback disabled     */
-#define  USE_HAL_OPAMP_REGISTER_CALLBACKS   0U /* MDIO register callback disabled    */
-#define  USE_HAL_OSPI_REGISTER_CALLBACKS    0U /* OSPI register callback disabled    */
-#define  USE_HAL_OTFDEC_REGISTER_CALLBACKS  0U /* OTFDEC register callback disabled  */
-#define  USE_HAL_PCD_REGISTER_CALLBACKS     0U /* PCD register callback disabled     */
-#define  USE_HAL_QSPI_REGISTER_CALLBACKS    0U /* QSPI register callback disabled    */
-#define  USE_HAL_RNG_REGISTER_CALLBACKS     0U /* RNG register callback disabled     */
-#define  USE_HAL_RTC_REGISTER_CALLBACKS     0U /* RTC register callback disabled     */
-#define  USE_HAL_SAI_REGISTER_CALLBACKS     0U /* SAI register callback disabled     */
-#define  USE_HAL_SD_REGISTER_CALLBACKS      0U /* SD register callback disabled      */
-#define  USE_HAL_SMARTCARD_REGISTER_CALLBACKS  0U /* SMARTCARD register callback disabled */
-#define  USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
-#define  USE_HAL_SMBUS_REGISTER_CALLBACKS   0U /* SMBUS register callback disabled   */
-#define  USE_HAL_SPI_REGISTER_CALLBACKS     0U /* SPI register callback disabled     */
-#define  USE_HAL_SWPMI_REGISTER_CALLBACKS   0U /* SWPMI register callback disabled   */
-#define  USE_HAL_TIM_REGISTER_CALLBACKS     0U /* TIM register callback disabled     */
-#define  USE_HAL_UART_REGISTER_CALLBACKS    0U /* UART register callback disabled    */
-#define  USE_HAL_USART_REGISTER_CALLBACKS   0U /* USART register callback disabled   */
-#define  USE_HAL_WWDG_REGISTER_CALLBACKS    0U /* WWDG register callback disabled    */
-
-/* ########################### Ethernet Configuration ######################### */
-#define ETH_TX_DESC_CNT         4U  /* number of Ethernet Tx DMA descriptors */
-#define ETH_RX_DESC_CNT         4U  /* number of Ethernet Rx DMA descriptors */
-
-#define ETH_MAC_ADDR0    (0x02UL)
-#define ETH_MAC_ADDR1    (0x00UL)
-#define ETH_MAC_ADDR2    (0x00UL)
-#define ETH_MAC_ADDR3    (0x00UL)
-#define ETH_MAC_ADDR4    (0x00UL)
-#define ETH_MAC_ADDR5    (0x00UL)
-
-/* ########################## Assert Selection ############################## */
-/**
-  * @brief Uncomment the line below to expanse the "assert_param" macro in the
-  *        HAL drivers code
-  */
-/* #define USE_FULL_ASSERT    1U */
-
-/* Includes ------------------------------------------------------------------*/
-/**
-  * @brief Include module's header file
-  */
-
-#ifdef HAL_RCC_MODULE_ENABLED
-  #include "stm32h7xx_hal_rcc.h"
-#endif /* HAL_RCC_MODULE_ENABLED */
-
-#ifdef HAL_GPIO_MODULE_ENABLED
-  #include "stm32h7xx_hal_gpio.h"
-#endif /* HAL_GPIO_MODULE_ENABLED */
-
-#ifdef HAL_DMA_MODULE_ENABLED
-  #include "stm32h7xx_hal_dma.h"
-#endif /* HAL_DMA_MODULE_ENABLED */
-
-#ifdef HAL_MDMA_MODULE_ENABLED
- #include "stm32h7xx_hal_mdma.h"
-#endif /* HAL_MDMA_MODULE_ENABLED */
-
-#ifdef HAL_HASH_MODULE_ENABLED
-  #include "stm32h7xx_hal_hash.h"
-#endif /* HAL_HASH_MODULE_ENABLED */
-
-#ifdef HAL_DCMI_MODULE_ENABLED
-  #include "stm32h7xx_hal_dcmi.h"
-#endif /* HAL_DCMI_MODULE_ENABLED */
-
-#ifdef HAL_DMA2D_MODULE_ENABLED
-  #include "stm32h7xx_hal_dma2d.h"
-#endif /* HAL_DMA2D_MODULE_ENABLED */
-
-#ifdef HAL_DSI_MODULE_ENABLED
-  #include "stm32h7xx_hal_dsi.h"
-#endif /* HAL_DSI_MODULE_ENABLED */
-
-#ifdef HAL_DFSDM_MODULE_ENABLED
-  #include "stm32h7xx_hal_dfsdm.h"
-#endif /* HAL_DFSDM_MODULE_ENABLED */
-
-#ifdef HAL_DTS_MODULE_ENABLED
- #include "stm32h7xx_hal_dts.h"
-#endif /* HAL_DTS_MODULE_ENABLED */
-
-#ifdef HAL_ETH_MODULE_ENABLED
-  #include "stm32h7xx_hal_eth.h"
-#endif /* HAL_ETH_MODULE_ENABLED */
-
-#ifdef HAL_ETH_LEGACY_MODULE_ENABLED
-  #include "stm32h7xx_hal_eth_legacy.h"
-#endif /* HAL_ETH_LEGACY_MODULE_ENABLED */
-
-#ifdef HAL_EXTI_MODULE_ENABLED
-  #include "stm32h7xx_hal_exti.h"
-#endif /* HAL_EXTI_MODULE_ENABLED */
-
-#ifdef HAL_CORTEX_MODULE_ENABLED
-  #include "stm32h7xx_hal_cortex.h"
-#endif /* HAL_CORTEX_MODULE_ENABLED */
-
-#ifdef HAL_ADC_MODULE_ENABLED
-  #include "stm32h7xx_hal_adc.h"
-#endif /* HAL_ADC_MODULE_ENABLED */
-
-#ifdef HAL_FDCAN_MODULE_ENABLED
-  #include "stm32h7xx_hal_fdcan.h"
-#endif /* HAL_FDCAN_MODULE_ENABLED */
-
-#ifdef HAL_CEC_MODULE_ENABLED
-  #include "stm32h7xx_hal_cec.h"
-#endif /* HAL_CEC_MODULE_ENABLED */
-
-#ifdef HAL_COMP_MODULE_ENABLED
-  #include "stm32h7xx_hal_comp.h"
-#endif /* HAL_COMP_MODULE_ENABLED */
-
-#ifdef HAL_CORDIC_MODULE_ENABLED
-  #include "stm32h7xx_hal_cordic.h"
-#endif /* HAL_CORDIC_MODULE_ENABLED */
-
-#ifdef HAL_CRC_MODULE_ENABLED
-  #include "stm32h7xx_hal_crc.h"
-#endif /* HAL_CRC_MODULE_ENABLED */
-
-#ifdef HAL_CRYP_MODULE_ENABLED
-  #include "stm32h7xx_hal_cryp.h"
-#endif /* HAL_CRYP_MODULE_ENABLED */
-
-#ifdef HAL_DAC_MODULE_ENABLED
-  #include "stm32h7xx_hal_dac.h"
-#endif /* HAL_DAC_MODULE_ENABLED */
-
-#ifdef HAL_FLASH_MODULE_ENABLED
-  #include "stm32h7xx_hal_flash.h"
-#endif /* HAL_FLASH_MODULE_ENABLED */
-
-#ifdef HAL_GFXMMU_MODULE_ENABLED
-  #include "stm32h7xx_hal_gfxmmu.h"
-#endif /* HAL_GFXMMU_MODULE_ENABLED */
-
-#ifdef HAL_FMAC_MODULE_ENABLED
-  #include "stm32h7xx_hal_fmac.h"
-#endif /* HAL_FMAC_MODULE_ENABLED */
-
-#ifdef HAL_HRTIM_MODULE_ENABLED
-  #include "stm32h7xx_hal_hrtim.h"
-#endif /* HAL_HRTIM_MODULE_ENABLED */
-
-#ifdef HAL_HSEM_MODULE_ENABLED
-  #include "stm32h7xx_hal_hsem.h"
-#endif /* HAL_HSEM_MODULE_ENABLED */
-
-#ifdef HAL_SRAM_MODULE_ENABLED
-  #include "stm32h7xx_hal_sram.h"
-#endif /* HAL_SRAM_MODULE_ENABLED */
-
-#ifdef HAL_NOR_MODULE_ENABLED
-  #include "stm32h7xx_hal_nor.h"
-#endif /* HAL_NOR_MODULE_ENABLED */
-
-#ifdef HAL_NAND_MODULE_ENABLED
-  #include "stm32h7xx_hal_nand.h"
-#endif /* HAL_NAND_MODULE_ENABLED */
-
-#ifdef HAL_I2C_MODULE_ENABLED
- #include "stm32h7xx_hal_i2c.h"
-#endif /* HAL_I2C_MODULE_ENABLED */
-
-#ifdef HAL_I2S_MODULE_ENABLED
- #include "stm32h7xx_hal_i2s.h"
-#endif /* HAL_I2S_MODULE_ENABLED */
-
-#ifdef HAL_IWDG_MODULE_ENABLED
- #include "stm32h7xx_hal_iwdg.h"
-#endif /* HAL_IWDG_MODULE_ENABLED */
-
-#ifdef HAL_JPEG_MODULE_ENABLED
- #include "stm32h7xx_hal_jpeg.h"
-#endif /* HAL_JPEG_MODULE_ENABLED */
-
-#ifdef HAL_MDIOS_MODULE_ENABLED
- #include "stm32h7xx_hal_mdios.h"
-#endif /* HAL_MDIOS_MODULE_ENABLED */
-
-#ifdef HAL_MMC_MODULE_ENABLED
- #include "stm32h7xx_hal_mmc.h"
-#endif /* HAL_MMC_MODULE_ENABLED */
-
-#ifdef HAL_LPTIM_MODULE_ENABLED
-#include "stm32h7xx_hal_lptim.h"
-#endif /* HAL_LPTIM_MODULE_ENABLED */
-
-#ifdef HAL_LTDC_MODULE_ENABLED
-#include "stm32h7xx_hal_ltdc.h"
-#endif /* HAL_LTDC_MODULE_ENABLED */
-
-#ifdef HAL_OPAMP_MODULE_ENABLED
-#include "stm32h7xx_hal_opamp.h"
-#endif /* HAL_OPAMP_MODULE_ENABLED */
-
-#ifdef HAL_OSPI_MODULE_ENABLED
- #include "stm32h7xx_hal_ospi.h"
-#endif /* HAL_OSPI_MODULE_ENABLED */
-
-#ifdef HAL_OTFDEC_MODULE_ENABLED
-#include "stm32h7xx_hal_otfdec.h"
-#endif /* HAL_OTFDEC_MODULE_ENABLED */
-
-#ifdef HAL_PSSI_MODULE_ENABLED
- #include "stm32h7xx_hal_pssi.h"
-#endif /* HAL_PSSI_MODULE_ENABLED */
-
-#ifdef HAL_PWR_MODULE_ENABLED
- #include "stm32h7xx_hal_pwr.h"
-#endif /* HAL_PWR_MODULE_ENABLED */
-
-#ifdef HAL_QSPI_MODULE_ENABLED
- #include "stm32h7xx_hal_qspi.h"
-#endif /* HAL_QSPI_MODULE_ENABLED */
-
-#ifdef HAL_RAMECC_MODULE_ENABLED
- #include "stm32h7xx_hal_ramecc.h"
-#endif /* HAL_RAMECC_MODULE_ENABLED */
-
-#ifdef HAL_RNG_MODULE_ENABLED
- #include "stm32h7xx_hal_rng.h"
-#endif /* HAL_RNG_MODULE_ENABLED */
-
-#ifdef HAL_RTC_MODULE_ENABLED
- #include "stm32h7xx_hal_rtc.h"
-#endif /* HAL_RTC_MODULE_ENABLED */
-
-#ifdef HAL_SAI_MODULE_ENABLED
- #include "stm32h7xx_hal_sai.h"
-#endif /* HAL_SAI_MODULE_ENABLED */
-
-#ifdef HAL_SD_MODULE_ENABLED
- #include "stm32h7xx_hal_sd.h"
-#endif /* HAL_SD_MODULE_ENABLED */
-
-#ifdef HAL_SDRAM_MODULE_ENABLED
- #include "stm32h7xx_hal_sdram.h"
-#endif /* HAL_SDRAM_MODULE_ENABLED */
-
-#ifdef HAL_SPI_MODULE_ENABLED
- #include "stm32h7xx_hal_spi.h"
-#endif /* HAL_SPI_MODULE_ENABLED */
-
-#ifdef HAL_SPDIFRX_MODULE_ENABLED
- #include "stm32h7xx_hal_spdifrx.h"
-#endif /* HAL_SPDIFRX_MODULE_ENABLED */
-
-#ifdef HAL_SWPMI_MODULE_ENABLED
- #include "stm32h7xx_hal_swpmi.h"
-#endif /* HAL_SWPMI_MODULE_ENABLED */
-
-#ifdef HAL_TIM_MODULE_ENABLED
- #include "stm32h7xx_hal_tim.h"
-#endif /* HAL_TIM_MODULE_ENABLED */
-
-#ifdef HAL_UART_MODULE_ENABLED
- #include "stm32h7xx_hal_uart.h"
-#endif /* HAL_UART_MODULE_ENABLED */
-
-#ifdef HAL_USART_MODULE_ENABLED
- #include "stm32h7xx_hal_usart.h"
-#endif /* HAL_USART_MODULE_ENABLED */
-
-#ifdef HAL_IRDA_MODULE_ENABLED
- #include "stm32h7xx_hal_irda.h"
-#endif /* HAL_IRDA_MODULE_ENABLED */
-
-#ifdef HAL_SMARTCARD_MODULE_ENABLED
- #include "stm32h7xx_hal_smartcard.h"
-#endif /* HAL_SMARTCARD_MODULE_ENABLED */
-
-#ifdef HAL_SMBUS_MODULE_ENABLED
- #include "stm32h7xx_hal_smbus.h"
-#endif /* HAL_SMBUS_MODULE_ENABLED */
-
-#ifdef HAL_WWDG_MODULE_ENABLED
- #include "stm32h7xx_hal_wwdg.h"
-#endif /* HAL_WWDG_MODULE_ENABLED */
-
-#ifdef HAL_PCD_MODULE_ENABLED
- #include "stm32h7xx_hal_pcd.h"
-#endif /* HAL_PCD_MODULE_ENABLED */
-
-#ifdef HAL_HCD_MODULE_ENABLED
- #include "stm32h7xx_hal_hcd.h"
-#endif /* HAL_HCD_MODULE_ENABLED */
-
-/* Exported macro ------------------------------------------------------------*/
-#ifdef  USE_FULL_ASSERT
-/**
-  * @brief  The assert_param macro is used for function's parameters check.
-  * @param  expr: If expr is false, it calls assert_failed function
-  *         which reports the name of the source file and the source
-  *         line number of the call that failed.
-  *         If expr is true, it returns no value.
-  * @retval None
-  */
-  #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
-/* Exported functions ------------------------------------------------------- */
-  void assert_failed(uint8_t *file, uint32_t line);
-#else
-  #define assert_param(expr) ((void)0U)
-#endif /* USE_FULL_ASSERT */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* STM32H7xx_HAL_CONF_H */

+ 0 - 66
Core - 副本/Inc/stm32h7xx_it.h

@@ -1,66 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    stm32h7xx_it.h
-  * @brief   This file contains the headers of the interrupt handlers.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
- ******************************************************************************
-  */
-/* USER CODE END Header */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STM32H7xx_IT_H
-#define __STM32H7xx_IT_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Private includes ----------------------------------------------------------*/
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-/* Exported types ------------------------------------------------------------*/
-/* USER CODE BEGIN ET */
-
-/* USER CODE END ET */
-
-/* Exported constants --------------------------------------------------------*/
-/* USER CODE BEGIN EC */
-
-/* USER CODE END EC */
-
-/* Exported macro ------------------------------------------------------------*/
-/* USER CODE BEGIN EM */
-
-/* USER CODE END EM */
-
-/* Exported functions prototypes ---------------------------------------------*/
-void NMI_Handler(void);
-void HardFault_Handler(void);
-void MemManage_Handler(void);
-void BusFault_Handler(void);
-void UsageFault_Handler(void);
-void SVC_Handler(void);
-void DebugMon_Handler(void);
-void PendSV_Handler(void);
-void SysTick_Handler(void);
-/* USER CODE BEGIN EFP */
-
-/* USER CODE END EFP */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __STM32H7xx_IT_H */

+ 0 - 60
Core - 副本/Inc/tim.h

@@ -1,60 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    tim.h
-  * @brief   This file contains all the function prototypes for
-  *          the tim.c file
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __TIM_H__
-#define __TIM_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-extern TIM_HandleTypeDef htim1;
-
-extern TIM_HandleTypeDef htim3;
-
-extern TIM_HandleTypeDef htim4;
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-void MX_TIM1_Init(void);
-void MX_TIM3_Init(void);
-void MX_TIM4_Init(void);
-
-void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
-
-/* USER CODE BEGIN Prototypes */
-
-/* USER CODE END Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TIM_H__ */
-

+ 0 - 52
Core - 副本/Inc/usart.h

@@ -1,52 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    usart.h
-  * @brief   This file contains all the function prototypes for
-  *          the usart.c file
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USART_H__
-#define __USART_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-extern UART_HandleTypeDef huart2;
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-void MX_USART2_UART_Init(void);
-
-/* USER CODE BEGIN Prototypes */
-
-/* USER CODE END Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __USART_H__ */
-

+ 0 - 177
Core - 副本/Src/adc.c

@@ -1,177 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    adc.c
-  * @brief   This file provides code for the configuration
-  *          of the ADC instances.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "adc.h"
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-ADC_HandleTypeDef hadc1;
-
-/* ADC1 init function */
-void MX_ADC1_Init(void)
-{
-
-  /* USER CODE BEGIN ADC1_Init 0 */
-
-  /* USER CODE END ADC1_Init 0 */
-
-  ADC_MultiModeTypeDef multimode = {0};
-  ADC_ChannelConfTypeDef sConfig = {0};
-
-  /* USER CODE BEGIN ADC1_Init 1 */
-
-  /* USER CODE END ADC1_Init 1 */
-
-  /** Common config
-  */
-  hadc1.Instance = ADC1;
-  hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
-  hadc1.Init.Resolution = ADC_RESOLUTION_16B;
-  hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
-  hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
-  hadc1.Init.LowPowerAutoWait = DISABLE;
-  hadc1.Init.ContinuousConvMode = DISABLE;
-  hadc1.Init.NbrOfConversion = 1;
-  hadc1.Init.DiscontinuousConvMode = DISABLE;
-  hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
-  hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
-  hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
-  hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
-  hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
-  hadc1.Init.OversamplingMode = DISABLE;
-  if (HAL_ADC_Init(&hadc1) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** Configure the ADC multi-mode
-  */
-  multimode.Mode = ADC_MODE_INDEPENDENT;
-  if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** Configure Regular Channel
-  */
-  sConfig.Channel = ADC_CHANNEL_3;
-  sConfig.Rank = ADC_REGULAR_RANK_1;
-  sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
-  sConfig.SingleDiff = ADC_DIFFERENTIAL_ENDED;
-  sConfig.OffsetNumber = ADC_OFFSET_NONE;
-  sConfig.Offset = 0;
-  sConfig.OffsetSignedSaturation = DISABLE;
-  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  /* USER CODE BEGIN ADC1_Init 2 */
-
-  /* USER CODE END ADC1_Init 2 */
-
-}
-
-void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
-{
-
-  GPIO_InitTypeDef GPIO_InitStruct = {0};
-  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
-  if(adcHandle->Instance==ADC1)
-  {
-  /* USER CODE BEGIN ADC1_MspInit 0 */
-
-  /* USER CODE END ADC1_MspInit 0 */
-
-  /** Initializes the peripherals clock
-  */
-    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC;
-    PeriphClkInitStruct.PLL2.PLL2M = 4;
-    PeriphClkInitStruct.PLL2.PLL2N = 9;
-    PeriphClkInitStruct.PLL2.PLL2P = 2;
-    PeriphClkInitStruct.PLL2.PLL2Q = 2;
-    PeriphClkInitStruct.PLL2.PLL2R = 2;
-    PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3;
-    PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM;
-    PeriphClkInitStruct.PLL2.PLL2FRACN = 3072;
-    PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2;
-    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
-    {
-      Error_Handler();
-    }
-
-    /* ADC1 clock enable */
-    __HAL_RCC_ADC12_CLK_ENABLE();
-
-    __HAL_RCC_GPIOA_CLK_ENABLE();
-    __HAL_RCC_GPIOC_CLK_ENABLE();
-    /**ADC1 GPIO Configuration
-    PA6     ------> ADC1_INP3
-    PA7     ------> ADC1_INN3
-    PC4     ------> ADC1_INP4
-    PC5     ------> ADC1_INN4
-    */
-    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
-    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
-    GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
-    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
-  /* USER CODE BEGIN ADC1_MspInit 1 */
-
-  /* USER CODE END ADC1_MspInit 1 */
-  }
-}
-
-void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
-{
-
-  if(adcHandle->Instance==ADC1)
-  {
-  /* USER CODE BEGIN ADC1_MspDeInit 0 */
-
-  /* USER CODE END ADC1_MspDeInit 0 */
-    /* Peripheral clock disable */
-    __HAL_RCC_ADC12_CLK_DISABLE();
-
-    /**ADC1 GPIO Configuration
-    PA6     ------> ADC1_INP3
-    PA7     ------> ADC1_INN3
-    PC4     ------> ADC1_INP4
-    PC5     ------> ADC1_INN4
-    */
-    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_6|GPIO_PIN_7);
-
-    HAL_GPIO_DeInit(GPIOC, GPIO_PIN_4|GPIO_PIN_5);
-
-  /* USER CODE BEGIN ADC1_MspDeInit 1 */
-
-  /* USER CODE END ADC1_MspDeInit 1 */
-  }
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */

+ 0 - 80
Core - 副本/Src/gpio.c

@@ -1,80 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    gpio.c
-  * @brief   This file provides code for the configuration
-  *          of all used GPIO pins.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-
-/* Includes ------------------------------------------------------------------*/
-#include "gpio.h"
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-/*----------------------------------------------------------------------------*/
-/* Configure GPIO                                                             */
-/*----------------------------------------------------------------------------*/
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */
-
-/** Configure pins
-     PC14-OSC32_IN (OSC32_IN)   ------> RCC_OSC32_IN
-     PC15-OSC32_OUT (OSC32_OUT)   ------> RCC_OSC32_OUT
-     PH0-OSC_IN (PH0)   ------> RCC_OSC_IN
-     PH1-OSC_OUT (PH1)   ------> RCC_OSC_OUT
-     PA13 (JTMS/SWDIO)   ------> DEBUG_JTMS-SWDIO
-     PA14 (JTCK/SWCLK)   ------> DEBUG_JTCK-SWCLK
-*/
-void MX_GPIO_Init(void)
-{
-
-  GPIO_InitTypeDef GPIO_InitStruct = {0};
-
-  /* GPIO Ports Clock Enable */
-  __HAL_RCC_GPIOE_CLK_ENABLE();
-  __HAL_RCC_GPIOC_CLK_ENABLE();
-  __HAL_RCC_GPIOH_CLK_ENABLE();
-  __HAL_RCC_GPIOA_CLK_ENABLE();
-  __HAL_RCC_GPIOB_CLK_ENABLE();
-  __HAL_RCC_GPIOD_CLK_ENABLE();
-
-  /*Configure GPIO pin Output Level */
-  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|GPIO_PIN_1, GPIO_PIN_RESET);
-
-  /*Configure GPIO pin Output Level */
-  HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3, GPIO_PIN_RESET);
-
-  /*Configure GPIO pins : PC13 PC1 */
-  GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_1;
-  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
-  GPIO_InitStruct.Pull = GPIO_NOPULL;
-  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
-  /*Configure GPIO pin : PA3 */
-  GPIO_InitStruct.Pin = GPIO_PIN_3;
-  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
-  GPIO_InitStruct.Pull = GPIO_NOPULL;
-  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
-}
-
-/* USER CODE BEGIN 2 */
-
-/* USER CODE END 2 */

+ 0 - 354
Core - 副本/Src/i2c.c

@@ -1,354 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    i2c.c
-  * @brief   This file provides code for the configuration
-  *          of the I2C instances.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "i2c.h"
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-I2C_HandleTypeDef hi2c1;
-I2C_HandleTypeDef hi2c2;
-I2C_HandleTypeDef hi2c3;
-
-/* I2C1 init function */
-void MX_I2C1_Init(void)
-{
-
-  /* USER CODE BEGIN I2C1_Init 0 */
-
-  /* USER CODE END I2C1_Init 0 */
-
-  /* USER CODE BEGIN I2C1_Init 1 */
-
-  /* USER CODE END I2C1_Init 1 */
-  hi2c1.Instance = I2C1;
-  hi2c1.Init.Timing = 0x00401242;
-  hi2c1.Init.OwnAddress1 = 0;
-  hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
-  hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
-  hi2c1.Init.OwnAddress2 = 0;
-  hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
-  hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
-  hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
-  if (HAL_I2C_Init(&hi2c1) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** Configure Analogue filter
-  */
-  if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** Configure Digital filter
-  */
-  if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** I2C Enable Fast Mode Plus
-  */
-  HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C1);
-  /* USER CODE BEGIN I2C1_Init 2 */
-
-  /* USER CODE END I2C1_Init 2 */
-
-}
-/* I2C2 init function */
-void MX_I2C2_Init(void)
-{
-
-  /* USER CODE BEGIN I2C2_Init 0 */
-
-  /* USER CODE END I2C2_Init 0 */
-
-  /* USER CODE BEGIN I2C2_Init 1 */
-
-  /* USER CODE END I2C2_Init 1 */
-  hi2c2.Instance = I2C2;
-  hi2c2.Init.Timing = 0x00401242;
-  hi2c2.Init.OwnAddress1 = 0;
-  hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
-  hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
-  hi2c2.Init.OwnAddress2 = 0;
-  hi2c2.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
-  hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
-  hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
-  if (HAL_I2C_Init(&hi2c2) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** Configure Analogue filter
-  */
-  if (HAL_I2CEx_ConfigAnalogFilter(&hi2c2, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** Configure Digital filter
-  */
-  if (HAL_I2CEx_ConfigDigitalFilter(&hi2c2, 0) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** I2C Enable Fast Mode Plus
-  */
-  HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C2);
-  /* USER CODE BEGIN I2C2_Init 2 */
-
-  /* USER CODE END I2C2_Init 2 */
-
-}
-/* I2C3 init function */
-void MX_I2C3_Init(void)
-{
-
-  /* USER CODE BEGIN I2C3_Init 0 */
-
-  /* USER CODE END I2C3_Init 0 */
-
-  /* USER CODE BEGIN I2C3_Init 1 */
-
-  /* USER CODE END I2C3_Init 1 */
-  hi2c3.Instance = I2C3;
-  hi2c3.Init.Timing = 0x00401242;
-  hi2c3.Init.OwnAddress1 = 0;
-  hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
-  hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
-  hi2c3.Init.OwnAddress2 = 0;
-  hi2c3.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
-  hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
-  hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
-  if (HAL_I2C_Init(&hi2c3) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** Configure Analogue filter
-  */
-  if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** Configure Digital filter
-  */
-  if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** I2C Enable Fast Mode Plus
-  */
-  HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C3);
-  /* USER CODE BEGIN I2C3_Init 2 */
-
-  /* USER CODE END I2C3_Init 2 */
-
-}
-
-void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
-{
-
-  GPIO_InitTypeDef GPIO_InitStruct = {0};
-  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
-  if(i2cHandle->Instance==I2C1)
-  {
-  /* USER CODE BEGIN I2C1_MspInit 0 */
-
-  /* USER CODE END I2C1_MspInit 0 */
-
-  /** Initializes the peripherals clock
-  */
-    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C1;
-    PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1;
-    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
-    {
-      Error_Handler();
-    }
-
-    __HAL_RCC_GPIOB_CLK_ENABLE();
-    /**I2C1 GPIO Configuration
-    PB7     ------> I2C1_SDA
-    PB8     ------> I2C1_SCL
-    */
-    GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
-    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
-    /* I2C1 clock enable */
-    __HAL_RCC_I2C1_CLK_ENABLE();
-  /* USER CODE BEGIN I2C1_MspInit 1 */
-
-  /* USER CODE END I2C1_MspInit 1 */
-  }
-  else if(i2cHandle->Instance==I2C2)
-  {
-  /* USER CODE BEGIN I2C2_MspInit 0 */
-
-  /* USER CODE END I2C2_MspInit 0 */
-
-  /** Initializes the peripherals clock
-  */
-    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C2;
-    PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1;
-    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
-    {
-      Error_Handler();
-    }
-
-    __HAL_RCC_GPIOB_CLK_ENABLE();
-    /**I2C2 GPIO Configuration
-    PB10     ------> I2C2_SCL
-    PB11     ------> I2C2_SDA
-    */
-    GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF4_I2C2;
-    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
-    /* I2C2 clock enable */
-    __HAL_RCC_I2C2_CLK_ENABLE();
-  /* USER CODE BEGIN I2C2_MspInit 1 */
-
-  /* USER CODE END I2C2_MspInit 1 */
-  }
-  else if(i2cHandle->Instance==I2C3)
-  {
-  /* USER CODE BEGIN I2C3_MspInit 0 */
-
-  /* USER CODE END I2C3_MspInit 0 */
-
-  /** Initializes the peripherals clock
-  */
-    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C3;
-    PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1;
-    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
-    {
-      Error_Handler();
-    }
-
-    __HAL_RCC_GPIOC_CLK_ENABLE();
-    __HAL_RCC_GPIOA_CLK_ENABLE();
-    /**I2C3 GPIO Configuration
-    PC9     ------> I2C3_SDA
-    PA8     ------> I2C3_SCL
-    */
-    GPIO_InitStruct.Pin = GPIO_PIN_9;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF4_I2C3;
-    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
-    GPIO_InitStruct.Pin = GPIO_PIN_8;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF4_I2C3;
-    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
-    /* I2C3 clock enable */
-    __HAL_RCC_I2C3_CLK_ENABLE();
-  /* USER CODE BEGIN I2C3_MspInit 1 */
-
-  /* USER CODE END I2C3_MspInit 1 */
-  }
-}
-
-void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle)
-{
-
-  if(i2cHandle->Instance==I2C1)
-  {
-  /* USER CODE BEGIN I2C1_MspDeInit 0 */
-
-  /* USER CODE END I2C1_MspDeInit 0 */
-    /* Peripheral clock disable */
-    __HAL_RCC_I2C1_CLK_DISABLE();
-
-    /**I2C1 GPIO Configuration
-    PB7     ------> I2C1_SDA
-    PB8     ------> I2C1_SCL
-    */
-    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);
-
-    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8);
-
-  /* USER CODE BEGIN I2C1_MspDeInit 1 */
-
-  /* USER CODE END I2C1_MspDeInit 1 */
-  }
-  else if(i2cHandle->Instance==I2C2)
-  {
-  /* USER CODE BEGIN I2C2_MspDeInit 0 */
-
-  /* USER CODE END I2C2_MspDeInit 0 */
-    /* Peripheral clock disable */
-    __HAL_RCC_I2C2_CLK_DISABLE();
-
-    /**I2C2 GPIO Configuration
-    PB10     ------> I2C2_SCL
-    PB11     ------> I2C2_SDA
-    */
-    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10);
-
-    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_11);
-
-  /* USER CODE BEGIN I2C2_MspDeInit 1 */
-
-  /* USER CODE END I2C2_MspDeInit 1 */
-  }
-  else if(i2cHandle->Instance==I2C3)
-  {
-  /* USER CODE BEGIN I2C3_MspDeInit 0 */
-
-  /* USER CODE END I2C3_MspDeInit 0 */
-    /* Peripheral clock disable */
-    __HAL_RCC_I2C3_CLK_DISABLE();
-
-    /**I2C3 GPIO Configuration
-    PC9     ------> I2C3_SDA
-    PA8     ------> I2C3_SCL
-    */
-    HAL_GPIO_DeInit(GPIOC, GPIO_PIN_9);
-
-    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8);
-
-  /* USER CODE BEGIN I2C3_MspDeInit 1 */
-
-  /* USER CODE END I2C3_MspDeInit 1 */
-  }
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */

+ 0 - 386
Core - 副本/Src/main.c

@@ -1,386 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file           : main.c
- * @brief          : Main program body
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2024 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-#include "adc.h"
-#include "i2c.h"
-#include "quadspi.h"
-#include "tim.h"
-#include "usart.h"
-#include "gpio.h"
-
-/* Private includes ----------------------------------------------------------*/
-/* USER CODE BEGIN Includes */
-#include "MPU6050.h"
-
-#include <stdio.h>
-/* USER CODE END Includes */
-
-/* Private typedef -----------------------------------------------------------*/
-/* USER CODE BEGIN PTD */
-
-/* USER CODE END PTD */
-
-/* Private define ------------------------------------------------------------*/
-/* USER CODE BEGIN PD */
-
-/* USER CODE END PD */
-
-/* Private macro -------------------------------------------------------------*/
-/* USER CODE BEGIN PM */
-
-/* USER CODE END PM */
-
-/* Private variables ---------------------------------------------------------*/
-
-/* USER CODE BEGIN PV */
-
-
- int a=0x68;
- int b=0xD1;
- int c=0xD0;
-int t = 1;
-//int a = 0x69;
-//int b = 0xD3;
-//int c = 0xD2;
-/* USER CODE END PV */
-
-/* Private function prototypes -----------------------------------------------*/
-void SystemClock_Config(void);
-/* USER CODE BEGIN PFP */
-
-/* USER CODE END PFP */
-
-/* Private user code ---------------------------------------------------------*/
-/* USER CODE BEGIN 0 */
-
-int fputc(int ch, FILE *f)
-{
-  HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, 0xffff); // �����ض���
-  return ch;
-}
-
-int fgetc(FILE *f)
-{
-  uint8_t ch = 0;
-  HAL_UART_Receive(&huart2, &ch, 1, 0xffff); // �����ض���
-  return ch;
-}
-
-/* USER CODE END 0 */
-
-/**
-  * @brief  The application entry point.
-  * @retval int
-  */
-int main(void)
-{
-  /* USER CODE BEGIN 1 */
-
-  /* USER CODE END 1 */
-
-  /* MCU Configuration--------------------------------------------------------*/
-
-  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
-  HAL_Init();
-
-  /* USER CODE BEGIN Init */
-
-  /* USER CODE END Init */
-
-  /* Configure the system clock */
-  SystemClock_Config();
-
-  /* USER CODE BEGIN SysInit */
-
-  /* USER CODE END SysInit */
-
-  /* Initialize all configured peripherals */
-  MX_GPIO_Init();
-  MX_ADC1_Init();
-  MX_I2C1_Init();
-  MX_QUADSPI_Init();
-  MX_TIM1_Init();
-  MX_TIM3_Init();
-  MX_TIM4_Init();
-  MX_USART2_UART_Init();
-  MX_I2C2_Init();
-  MX_I2C3_Init();
-  /* USER CODE BEGIN 2 */
-				a=0x69;
-    		b=0xD3;
-    		c=0XD2;
-    		t=1;
-				DMP_Init();
-				a=0x68;
-    		b=0xD1;
-    		c=0XD0;
-    		t=1;
-				DMP_Init();
-				a=0x68;
-    		b=0xD1;
-    		c=0XD0;
-    		t=2;
-				DMP_Init();
-				a=0x69;
-    		b=0xD3;
-    		c=0XD2;
-    		t=2;
-				DMP_Init();
-				a=0x69;
-    		b=0xD3;
-    		c=0XD2;
-    		t=3;
-				DMP_Init();
-				a=0x68;
-    		b=0xD1;
-    		c=0XD0;
-    		t=3;
-				DMP_Init();
-
-  HAL_QSPI_Init(&hqspi);
-  int g = 1;
-  float Pitch1, Roll1, Yaw1;
-  float Pitch2, Roll2, Yaw2;
-	float Pitch3, Roll3, Yaw3;
-	float Pitch4, Roll4, Yaw4;
-  float Pitch5, Roll5, Yaw5;
-	float Pitch6, Roll6, Yaw6;
-  /* USER CODE END 2 */
-
-  /* Infinite loop */
-  /* USER CODE BEGIN WHILE */
-  while (1)
-  {
-
-		
-		//测试
-//			a=0x68;
-//			b=0xD1;
-//			c=0XD0;
-				a=0x69;
-    		b=0xD3;
-    		c=0XD2;
-    		t=3;
-    
-    
-    uint8_t ret = Read_DMP(&Pitch1, &Roll1, &Yaw1);
-		a=0x68;
-    		b=0xD1;
-    		c=0XD0;
-    		t=1;
-    
-    
-    uint8_t ret1 = Read_DMP(&Pitch2, &Roll2, &Yaw2);
-    printf("%f,%f,%f,%f,%f,%f\r\n",Pitch1,Roll1,Yaw1,Pitch2,Roll2,Yaw2);
-		
-		
-//		
-//		
-//  	if(g==1){ //15
-//    		
-//			
-//			a=0x69;
-//    		b=0xD3;
-//    		c=0XD2;
-//    		t=1;
-//    
-//    // char buff[100]={0};
-//       	  uint8_t ret = Read_DMP(&Pitch1, &Roll1, &Yaw1);
-//    ////printf("%d,%f,%f,%f\r\n", g,Pitch1, Roll1, Yaw1);
-//    ////printf("com:imu:%d:ang:%f:%f:%f\r\n", g,Pitch1, Roll1, Yaw1);
-//    ////		sprintf(buff,"16:%f,%f,%f\r\n", Pitch, Roll, Yaw);
-//    ////		HAL_QSPI_Transmit(&hqspi, buff, 100);
-//    		g=2;
-//    	}
-//     else if(g==2){  //18
-//    			 a=0x68;
-//			b=0xD1;
-//			c=0XD0;
-//			t=1;
-//	
-
-//    // float Pitch2, Roll2, Yaw2;
-
-//      	  uint8_t ret = Read_DMP(&Pitch2, &Roll2, &Yaw2);
-//			
-//    // printf("com:imu:%d:ang:%f:%f:%f\r\n", g,Pitch2, Roll2, Yaw2);
-//    	g=3;
-//    }
-//     else if(g==3){ //16
-//    		
-//		
-//		    a=0x68;
-//    		b=0xD1;
-//    		c=0XD0;
-//    		t=2;
-//    // float Pitch, Roll, Yaw;
-
-//      	  uint8_t ret = Read_DMP(&Pitch3, &Roll3, &Yaw3);
-//			 //printf("%f,%f,%f,%f,%f,%f,%f,%f,%f\r\n",Pitch1, Roll1, Yaw1,Pitch2, Roll2, Yaw2,Pitch3, Roll3, Yaw3);
-//    // printf("com:imu:%d:ang:%f:%f:%f\r\n", g,Pitch3, Roll3, Yaw3);
-//    		g=4;
-//    	}
-
-//     else if(g==4){ //13
-//    a = 0x69;
-//    b = 0xD3;
-//    c = 0XD2;
-//    t = 2;
-
-
-//   uint8_t ret = Read_DMP(&Pitch4, &Roll4, &Yaw4);
-//			//printf("%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\r\n",Pitch1, Roll1, Yaw1,Pitch2, Roll2, Yaw2,Pitch3, Roll3, Yaw3,Pitch4, Roll4, Yaw4,Pitch5, Roll5, Yaw5,Pitch6, Roll6, Yaw6);
-//		 //printf("%d,%f,%f,%f\r\n", g, Pitch4, Roll4, Yaw4);
-//    ////printf("com:imu:%d:ang:%f:%f:%f\r\n", g,Pitch4, Roll4, Yaw4);
-//    		g=5;
-//    	}
-//    	else if(g==5){ //17
-//    		a=0x68;
-//    		b=0xD1;
-//    		c=0XD0;
-//    		t=3;
-//    ////float Pitch5, Roll5, Yaw5;
-
-//      	  uint8_t ret = Read_DMP(&Pitch5, &Roll5, &Yaw5);
-//    ////		printf("%d,%f,%f,%f\r\n", g,Pitch5, Roll5, Yaw5);
-//    //printf("com:imu:%d:ang:%f:%f:%f\r\n", g,Pitch5, Roll5, Yaw5);
-//    		g=6;
-//    	}
-//    	else if(g==6){ //14
-//    		a=0x69;
-//    		b=0xD3;
-//    		c=0XD2;
-//    	t=3;
-//     
-//      uint8_t ret = Read_DMP(&Pitch6, &Roll6, &Yaw6);
-//    		//printf("%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\r\n",Pitch1, Roll1, Yaw1,Pitch2, Roll2, Yaw2,Pitch3, Roll3, Yaw3,Pitch4, Roll4, Yaw4,Pitch5, Roll5, Yaw5,Pitch6, Roll6, Yaw6);
-//      	 
-//     //printf("com:imu:%d:ang:%f:%f:%f\r\n", g,Pitch, Roll, Yaw);
-//    		g=1;
-//    	}
-    //
-	//printf("%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\r\n",Pitch1, Roll1, Yaw1,Pitch2, Roll2, Yaw2,Pitch3, Roll3, Yaw3,Pitch4, Roll4, Yaw4,Pitch5, Roll5, Yaw5,Pitch6, Roll6, Yaw6);
-    //		HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);
-    //		HAL_Delay(10);
-    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 1);
-    //		HAL_Delay(10);
-    //
-
-    /* USER CODE END WHILE */
-
-    /* USER CODE BEGIN 3 */
-  }
-  /* USER CODE END 3 */
-}
-
-/**
-  * @brief System Clock Configuration
-  * @retval None
-  */
-void SystemClock_Config(void)
-{
-  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
-  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
-
-  /** Supply configuration update enable
-  */
-  HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
-
-  /** Configure the main internal regulator output voltage
-  */
-  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
-
-  while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
-
-  /** Initializes the RCC Oscillators according to the specified parameters
-  * in the RCC_OscInitTypeDef structure.
-  */
-  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
-  RCC_OscInitStruct.HSIState = RCC_HSI_DIV1;
-  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
-  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
-  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
-  RCC_OscInitStruct.PLL.PLLM = 4;
-  RCC_OscInitStruct.PLL.PLLN = 50;
-  RCC_OscInitStruct.PLL.PLLP = 2;
-  RCC_OscInitStruct.PLL.PLLQ = 2;
-  RCC_OscInitStruct.PLL.PLLR = 2;
-  RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
-  RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
-  RCC_OscInitStruct.PLL.PLLFRACN = 0;
-  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
-  {
-    Error_Handler();
-  }
-
-  /** Initializes the CPU, AHB and APB buses clocks
-  */
-  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
-                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
-                              |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
-  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
-  RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
-  RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
-  RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
-  RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
-  RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
-  RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
-
-  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
-  {
-    Error_Handler();
-  }
-}
-
-/* USER CODE BEGIN 4 */
-
-/* USER CODE END 4 */
-
-/**
-  * @brief  This function is executed in case of error occurrence.
-  * @retval None
-  */
-void Error_Handler(void)
-{
-  /* USER CODE BEGIN Error_Handler_Debug */
-  /* User can add his own implementation to report the HAL error return state */
-  __disable_irq();
-  while (1)
-  {
-  }
-  /* USER CODE END Error_Handler_Debug */
-}
-
-#ifdef  USE_FULL_ASSERT
-/**
-  * @brief  Reports the name of the source file and the source line number
-  *         where the assert_param error has occurred.
-  * @param  file: pointer to the source file name
-  * @param  line: assert_param error line source number
-  * @retval None
-  */
-void assert_failed(uint8_t *file, uint32_t line)
-{
-  /* USER CODE BEGIN 6 */
-  /* User can add his own implementation to report the file name and line number,
-     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
-  /* USER CODE END 6 */
-}
-#endif /* USE_FULL_ASSERT */

+ 0 - 180
Core - 副本/Src/quadspi.c

@@ -1,180 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    quadspi.c
-  * @brief   This file provides code for the configuration
-  *          of the QUADSPI instances.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "quadspi.h"
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-QSPI_HandleTypeDef hqspi;
-
-/* QUADSPI init function */
-void MX_QUADSPI_Init(void)
-{
-
-  /* USER CODE BEGIN QUADSPI_Init 0 */
-
-  /* USER CODE END QUADSPI_Init 0 */
-
-  /* USER CODE BEGIN QUADSPI_Init 1 */
-
-  /* USER CODE END QUADSPI_Init 1 */
-  hqspi.Instance = QUADSPI;
-  hqspi.Init.ClockPrescaler = 255;
-  hqspi.Init.FifoThreshold = 1;
-  hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE;
-  hqspi.Init.FlashSize = 1;
-  hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE;
-  hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;
-  hqspi.Init.FlashID = QSPI_FLASH_ID_1;
-  hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;
-  if (HAL_QSPI_Init(&hqspi) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  /* USER CODE BEGIN QUADSPI_Init 2 */
-
-  /* USER CODE END QUADSPI_Init 2 */
-
-}
-
-void HAL_QSPI_MspInit(QSPI_HandleTypeDef* qspiHandle)
-{
-
-  GPIO_InitTypeDef GPIO_InitStruct = {0};
-  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
-  if(qspiHandle->Instance==QUADSPI)
-  {
-  /* USER CODE BEGIN QUADSPI_MspInit 0 */
-
-  /* USER CODE END QUADSPI_MspInit 0 */
-
-  /** Initializes the peripherals clock
-  */
-    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_QSPI;
-    PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK;
-    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
-    {
-      Error_Handler();
-    }
-
-    /* QUADSPI clock enable */
-    __HAL_RCC_QSPI_CLK_ENABLE();
-
-    __HAL_RCC_GPIOE_CLK_ENABLE();
-    __HAL_RCC_GPIOA_CLK_ENABLE();
-    __HAL_RCC_GPIOB_CLK_ENABLE();
-    __HAL_RCC_GPIOD_CLK_ENABLE();
-    __HAL_RCC_GPIOC_CLK_ENABLE();
-    /**QUADSPI GPIO Configuration
-    PE2     ------> QUADSPI_BK1_IO2
-    PA1     ------> QUADSPI_BK1_IO3
-    PB2     ------> QUADSPI_CLK
-    PD11     ------> QUADSPI_BK1_IO0
-    PC10     ------> QUADSPI_BK1_IO1
-    PB6     ------> QUADSPI_BK1_NCS
-    */
-    GPIO_InitStruct.Pin = GPIO_PIN_2;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
-    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
-
-    GPIO_InitStruct.Pin = GPIO_PIN_1;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
-    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
-    GPIO_InitStruct.Pin = GPIO_PIN_2;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
-    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
-    GPIO_InitStruct.Pin = GPIO_PIN_11;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
-    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
-
-    GPIO_InitStruct.Pin = GPIO_PIN_10;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
-    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
-    GPIO_InitStruct.Pin = GPIO_PIN_6;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;
-    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
-  /* USER CODE BEGIN QUADSPI_MspInit 1 */
-
-  /* USER CODE END QUADSPI_MspInit 1 */
-  }
-}
-
-void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* qspiHandle)
-{
-
-  if(qspiHandle->Instance==QUADSPI)
-  {
-  /* USER CODE BEGIN QUADSPI_MspDeInit 0 */
-
-  /* USER CODE END QUADSPI_MspDeInit 0 */
-    /* Peripheral clock disable */
-    __HAL_RCC_QSPI_CLK_DISABLE();
-
-    /**QUADSPI GPIO Configuration
-    PE2     ------> QUADSPI_BK1_IO2
-    PA1     ------> QUADSPI_BK1_IO3
-    PB2     ------> QUADSPI_CLK
-    PD11     ------> QUADSPI_BK1_IO0
-    PC10     ------> QUADSPI_BK1_IO1
-    PB6     ------> QUADSPI_BK1_NCS
-    */
-    HAL_GPIO_DeInit(GPIOE, GPIO_PIN_2);
-
-    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1);
-
-    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_2|GPIO_PIN_6);
-
-    HAL_GPIO_DeInit(GPIOD, GPIO_PIN_11);
-
-    HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10);
-
-  /* USER CODE BEGIN QUADSPI_MspDeInit 1 */
-
-  /* USER CODE END QUADSPI_MspDeInit 1 */
-  }
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */

+ 0 - 81
Core - 副本/Src/stm32h7xx_hal_msp.c

@@ -1,81 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file         stm32h7xx_hal_msp.c
-  * @brief        This file provides code for the MSP Initialization
-  *               and de-Initialization codes.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-/* Private typedef -----------------------------------------------------------*/
-/* USER CODE BEGIN TD */
-
-/* USER CODE END TD */
-
-/* Private define ------------------------------------------------------------*/
-/* USER CODE BEGIN Define */
-
-/* USER CODE END Define */
-
-/* Private macro -------------------------------------------------------------*/
-/* USER CODE BEGIN Macro */
-
-/* USER CODE END Macro */
-
-/* Private variables ---------------------------------------------------------*/
-/* USER CODE BEGIN PV */
-
-/* USER CODE END PV */
-
-/* Private function prototypes -----------------------------------------------*/
-/* USER CODE BEGIN PFP */
-
-/* USER CODE END PFP */
-
-/* External functions --------------------------------------------------------*/
-/* USER CODE BEGIN ExternalFunctions */
-
-/* USER CODE END ExternalFunctions */
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-/**
-  * Initializes the Global MSP.
-  */
-void HAL_MspInit(void)
-{
-  /* USER CODE BEGIN MspInit 0 */
-
-  /* USER CODE END MspInit 0 */
-
-  __HAL_RCC_SYSCFG_CLK_ENABLE();
-
-  /* System interrupt init*/
-
-  /* USER CODE BEGIN MspInit 1 */
-
-  /* USER CODE END MspInit 1 */
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */

+ 0 - 203
Core - 副本/Src/stm32h7xx_it.c

@@ -1,203 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    stm32h7xx_it.c
-  * @brief   Interrupt Service Routines.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-#include "stm32h7xx_it.h"
-/* Private includes ----------------------------------------------------------*/
-/* USER CODE BEGIN Includes */
-/* USER CODE END Includes */
-
-/* Private typedef -----------------------------------------------------------*/
-/* USER CODE BEGIN TD */
-
-/* USER CODE END TD */
-
-/* Private define ------------------------------------------------------------*/
-/* USER CODE BEGIN PD */
-
-/* USER CODE END PD */
-
-/* Private macro -------------------------------------------------------------*/
-/* USER CODE BEGIN PM */
-
-/* USER CODE END PM */
-
-/* Private variables ---------------------------------------------------------*/
-/* USER CODE BEGIN PV */
-
-/* USER CODE END PV */
-
-/* Private function prototypes -----------------------------------------------*/
-/* USER CODE BEGIN PFP */
-
-/* USER CODE END PFP */
-
-/* Private user code ---------------------------------------------------------*/
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-/* External variables --------------------------------------------------------*/
-
-/* USER CODE BEGIN EV */
-
-/* USER CODE END EV */
-
-/******************************************************************************/
-/*           Cortex Processor Interruption and Exception Handlers          */
-/******************************************************************************/
-/**
-  * @brief This function handles Non maskable interrupt.
-  */
-void NMI_Handler(void)
-{
-  /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
-
-  /* USER CODE END NonMaskableInt_IRQn 0 */
-  /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
-   while (1)
-  {
-  }
-  /* USER CODE END NonMaskableInt_IRQn 1 */
-}
-
-/**
-  * @brief This function handles Hard fault interrupt.
-  */
-void HardFault_Handler(void)
-{
-  /* USER CODE BEGIN HardFault_IRQn 0 */
-
-  /* USER CODE END HardFault_IRQn 0 */
-  while (1)
-  {
-    /* USER CODE BEGIN W1_HardFault_IRQn 0 */
-    /* USER CODE END W1_HardFault_IRQn 0 */
-  }
-}
-
-/**
-  * @brief This function handles Memory management fault.
-  */
-void MemManage_Handler(void)
-{
-  /* USER CODE BEGIN MemoryManagement_IRQn 0 */
-
-  /* USER CODE END MemoryManagement_IRQn 0 */
-  while (1)
-  {
-    /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
-    /* USER CODE END W1_MemoryManagement_IRQn 0 */
-  }
-}
-
-/**
-  * @brief This function handles Pre-fetch fault, memory access fault.
-  */
-void BusFault_Handler(void)
-{
-  /* USER CODE BEGIN BusFault_IRQn 0 */
-
-  /* USER CODE END BusFault_IRQn 0 */
-  while (1)
-  {
-    /* USER CODE BEGIN W1_BusFault_IRQn 0 */
-    /* USER CODE END W1_BusFault_IRQn 0 */
-  }
-}
-
-/**
-  * @brief This function handles Undefined instruction or illegal state.
-  */
-void UsageFault_Handler(void)
-{
-  /* USER CODE BEGIN UsageFault_IRQn 0 */
-
-  /* USER CODE END UsageFault_IRQn 0 */
-  while (1)
-  {
-    /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
-    /* USER CODE END W1_UsageFault_IRQn 0 */
-  }
-}
-
-/**
-  * @brief This function handles System service call via SWI instruction.
-  */
-void SVC_Handler(void)
-{
-  /* USER CODE BEGIN SVCall_IRQn 0 */
-
-  /* USER CODE END SVCall_IRQn 0 */
-  /* USER CODE BEGIN SVCall_IRQn 1 */
-
-  /* USER CODE END SVCall_IRQn 1 */
-}
-
-/**
-  * @brief This function handles Debug monitor.
-  */
-void DebugMon_Handler(void)
-{
-  /* USER CODE BEGIN DebugMonitor_IRQn 0 */
-
-  /* USER CODE END DebugMonitor_IRQn 0 */
-  /* USER CODE BEGIN DebugMonitor_IRQn 1 */
-
-  /* USER CODE END DebugMonitor_IRQn 1 */
-}
-
-/**
-  * @brief This function handles Pendable request for system service.
-  */
-void PendSV_Handler(void)
-{
-  /* USER CODE BEGIN PendSV_IRQn 0 */
-
-  /* USER CODE END PendSV_IRQn 0 */
-  /* USER CODE BEGIN PendSV_IRQn 1 */
-
-  /* USER CODE END PendSV_IRQn 1 */
-}
-
-/**
-  * @brief This function handles System tick timer.
-  */
-void SysTick_Handler(void)
-{
-  /* USER CODE BEGIN SysTick_IRQn 0 */
-
-  /* USER CODE END SysTick_IRQn 0 */
-  HAL_IncTick();
-  /* USER CODE BEGIN SysTick_IRQn 1 */
-
-  /* USER CODE END SysTick_IRQn 1 */
-}
-
-/******************************************************************************/
-/* STM32H7xx Peripheral Interrupt Handlers                                    */
-/* Add here the Interrupt Handlers for the used peripherals.                  */
-/* For the available peripheral interrupt handler names,                      */
-/* please refer to the startup file (startup_stm32h7xx.s).                    */
-/******************************************************************************/
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */

+ 0 - 450
Core - 副本/Src/system_stm32h7xx.c

@@ -1,450 +0,0 @@
-/**
-  ******************************************************************************
-  * @file    system_stm32h7xx.c
-  * @author  MCD Application Team
-  * @brief   CMSIS Cortex-Mx Device Peripheral Access Layer System Source File.
-  *
-  *   This file provides two functions and one global variable to be called from
-  *   user application:
-  *      - SystemInit(): This function is called at startup just after reset and
-  *                      before branch to main program. This call is made inside
-  *                      the "startup_stm32h7xx.s" file.
-  *
-  *      - SystemCoreClock variable: Contains the core clock, it can be used
-  *                                  by the user application to setup the SysTick
-  *                                  timer or configure other parameters.
-  *
-  *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
-  *                                 be called whenever the core clock is changed
-  *                                 during program execution.
-  *
-  *
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2017 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-
-/** @addtogroup CMSIS
-  * @{
-  */
-
-/** @addtogroup stm32h7xx_system
-  * @{
-  */
-
-/** @addtogroup STM32H7xx_System_Private_Includes
-  * @{
-  */
-
-#include "stm32h7xx.h"
-#include <math.h>
-
-#if !defined  (HSE_VALUE)
-#define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
-#endif /* HSE_VALUE */
-
-#if !defined  (CSI_VALUE)
-  #define CSI_VALUE    ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
-#endif /* CSI_VALUE */
-
-#if !defined  (HSI_VALUE)
-  #define HSI_VALUE    ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
-#endif /* HSI_VALUE */
-
-
-/**
-  * @}
-  */
-
-/** @addtogroup STM32H7xx_System_Private_TypesDefinitions
-  * @{
-  */
-
-/**
-  * @}
-  */
-
-/** @addtogroup STM32H7xx_System_Private_Defines
-  * @{
-  */
-
-/************************* Miscellaneous Configuration ************************/
-/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */
-/* #define DATA_IN_D2_SRAM */
-
-/* Note: Following vector table addresses must be defined in line with linker
-         configuration. */
-/*!< Uncomment the following line if you need to relocate the vector table
-     anywhere in FLASH BANK1 or AXI SRAM, else the vector table is kept at the automatic
-     remap of boot address selected */
-/* #define USER_VECT_TAB_ADDRESS */
-
-#if defined(USER_VECT_TAB_ADDRESS)
-#if defined(DUAL_CORE) && defined(CORE_CM4)
-/*!< Uncomment the following line if you need to relocate your vector Table
-     in D2 AXI SRAM else user remap will be done in FLASH BANK2. */
-/* #define VECT_TAB_SRAM */
-#if defined(VECT_TAB_SRAM)
-#define VECT_TAB_BASE_ADDRESS   D2_AXISRAM_BASE   /*!< Vector Table base address field.
-                                                       This value must be a multiple of 0x400. */
-#define VECT_TAB_OFFSET         0x00000000U       /*!< Vector Table base offset field.
-                                                       This value must be a multiple of 0x400. */
-#else
-#define VECT_TAB_BASE_ADDRESS   FLASH_BANK2_BASE  /*!< Vector Table base address field.
-                                                       This value must be a multiple of 0x400. */
-#define VECT_TAB_OFFSET         0x00000000U       /*!< Vector Table base offset field.
-                                                       This value must be a multiple of 0x400. */
-#endif /* VECT_TAB_SRAM */
-#else
-/*!< Uncomment the following line if you need to relocate your vector Table
-     in D1 AXI SRAM else user remap will be done in FLASH BANK1. */
-/* #define VECT_TAB_SRAM */
-#if defined(VECT_TAB_SRAM)
-#define VECT_TAB_BASE_ADDRESS   D1_AXISRAM_BASE   /*!< Vector Table base address field.
-                                                       This value must be a multiple of 0x400. */
-#define VECT_TAB_OFFSET         0x00000000U       /*!< Vector Table base offset field.
-                                                       This value must be a multiple of 0x400. */
-#else
-#define VECT_TAB_BASE_ADDRESS   FLASH_BANK1_BASE  /*!< Vector Table base address field.
-                                                       This value must be a multiple of 0x400. */
-#define VECT_TAB_OFFSET         0x00000000U       /*!< Vector Table base offset field.
-                                                       This value must be a multiple of 0x400. */
-#endif /* VECT_TAB_SRAM */
-#endif /* DUAL_CORE && CORE_CM4 */
-#endif /* USER_VECT_TAB_ADDRESS */
-/******************************************************************************/
-
-/**
-  * @}
-  */
-
-/** @addtogroup STM32H7xx_System_Private_Macros
-  * @{
-  */
-
-/**
-  * @}
-  */
-
-/** @addtogroup STM32H7xx_System_Private_Variables
-  * @{
-  */
-  /* This variable is updated in three ways:
-      1) by calling CMSIS function SystemCoreClockUpdate()
-      2) by calling HAL API function HAL_RCC_GetHCLKFreq()
-      3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
-         Note: If you use this function to configure the system clock; then there
-               is no need to call the 2 first functions listed above, since SystemCoreClock
-               variable is updated automatically.
-  */
-  uint32_t SystemCoreClock = 64000000;
-  uint32_t SystemD2Clock = 64000000;
-  const  uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
-
-/**
-  * @}
-  */
-
-/** @addtogroup STM32H7xx_System_Private_FunctionPrototypes
-  * @{
-  */
-
-/**
-  * @}
-  */
-
-/** @addtogroup STM32H7xx_System_Private_Functions
-  * @{
-  */
-
-/**
-  * @brief  Setup the microcontroller system
-  *         Initialize the FPU setting and  vector table location
-  *         configuration.
-  * @param  None
-  * @retval None
-  */
-void SystemInit (void)
-{
-#if defined (DATA_IN_D2_SRAM)
- __IO uint32_t tmpreg;
-#endif /* DATA_IN_D2_SRAM */
-
-  /* FPU settings ------------------------------------------------------------*/
-  #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
-    SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2)));  /* set CP10 and CP11 Full Access */
-  #endif
-  /* Reset the RCC clock configuration to the default reset state ------------*/
-
-   /* Increasing the CPU frequency */
-  if(FLASH_LATENCY_DEFAULT  > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
-  {
-    /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
-    MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
-  }
-
-  /* Set HSION bit */
-  RCC->CR |= RCC_CR_HSION;
-
-  /* Reset CFGR register */
-  RCC->CFGR = 0x00000000;
-
-  /* Reset HSEON, HSECSSON, CSION, HSI48ON, CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */
-  RCC->CR &= 0xEAF6ED7FU;
-
-   /* Decreasing the number of wait states because of lower CPU frequency */
-  if(FLASH_LATENCY_DEFAULT  < (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
-  {
-    /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
-    MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
-  }
-
-#if defined(D3_SRAM_BASE)
-  /* Reset D1CFGR register */
-  RCC->D1CFGR = 0x00000000;
-
-  /* Reset D2CFGR register */
-  RCC->D2CFGR = 0x00000000;
-
-  /* Reset D3CFGR register */
-  RCC->D3CFGR = 0x00000000;
-#else
-  /* Reset CDCFGR1 register */
-  RCC->CDCFGR1 = 0x00000000;
-
-  /* Reset CDCFGR2 register */
-  RCC->CDCFGR2 = 0x00000000;
-
-  /* Reset SRDCFGR register */
-  RCC->SRDCFGR = 0x00000000;
-#endif
-  /* Reset PLLCKSELR register */
-  RCC->PLLCKSELR = 0x02020200;
-
-  /* Reset PLLCFGR register */
-  RCC->PLLCFGR = 0x01FF0000;
-  /* Reset PLL1DIVR register */
-  RCC->PLL1DIVR = 0x01010280;
-  /* Reset PLL1FRACR register */
-  RCC->PLL1FRACR = 0x00000000;
-
-  /* Reset PLL2DIVR register */
-  RCC->PLL2DIVR = 0x01010280;
-
-  /* Reset PLL2FRACR register */
-
-  RCC->PLL2FRACR = 0x00000000;
-  /* Reset PLL3DIVR register */
-  RCC->PLL3DIVR = 0x01010280;
-
-  /* Reset PLL3FRACR register */
-  RCC->PLL3FRACR = 0x00000000;
-
-  /* Reset HSEBYP bit */
-  RCC->CR &= 0xFFFBFFFFU;
-
-  /* Disable all interrupts */
-  RCC->CIER = 0x00000000;
-
-#if (STM32H7_DEV_ID == 0x450UL)
-  /* dual core CM7 or single core line */
-  if((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U)
-  {
-    /* if stm32h7 revY*/
-    /* Change  the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */
-    *((__IO uint32_t*)0x51008108) = 0x000000001U;
-  }
-#endif /* STM32H7_DEV_ID */
-
-#if defined(DATA_IN_D2_SRAM)
-  /* in case of initialized data in D2 SRAM (AHB SRAM), enable the D2 SRAM clock (AHB SRAM clock) */
-#if defined(RCC_AHB2ENR_D2SRAM3EN)
-  RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN);
-#elif defined(RCC_AHB2ENR_D2SRAM2EN)
-  RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN);
-#else
-  RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN);
-#endif /* RCC_AHB2ENR_D2SRAM3EN */
-
-  tmpreg = RCC->AHB2ENR;
-  (void) tmpreg;
-#endif /* DATA_IN_D2_SRAM */
-
-#if defined(DUAL_CORE) && defined(CORE_CM4)
-  /* Configure the Vector Table location add offset address for cortex-M4 ------------------*/
-#if defined(USER_VECT_TAB_ADDRESS)
-  SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal D2 AXI-RAM or in Internal FLASH */
-#endif /* USER_VECT_TAB_ADDRESS */
-
-#else
-  /*
-   * Disable the FMC bank1 (enabled after reset).
-   * This, prevents CPU speculation access on this bank which blocks the use of FMC during
-   * 24us. During this time the others FMC master (such as LTDC) cannot use it!
-   */
-  FMC_Bank1_R->BTCR[0] = 0x000030D2;
-
-  /* Configure the Vector Table location -------------------------------------*/
-#if defined(USER_VECT_TAB_ADDRESS)
-  SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal D1 AXI-RAM or in Internal FLASH */
-#endif /* USER_VECT_TAB_ADDRESS */
-
-#endif /*DUAL_CORE && CORE_CM4*/
-}
-
-/**
-   * @brief  Update SystemCoreClock variable according to Clock Register Values.
-  *         The SystemCoreClock variable contains the core clock , it can
-  *         be used by the user application to setup the SysTick timer or configure
-  *         other parameters.
-  *
-  * @note   Each time the core clock changes, this function must be called
-  *         to update SystemCoreClock variable value. Otherwise, any configuration
-  *         based on this variable will be incorrect.
-  *
-  * @note   - The system frequency computed by this function is not the real
-  *           frequency in the chip. It is calculated based on the predefined
-  *           constant and the selected clock source:
-  *
-  *           - If SYSCLK source is CSI, SystemCoreClock will contain the CSI_VALUE(*)
-  *           - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**)
-  *           - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***)
-  *           - If SYSCLK source is PLL, SystemCoreClock will contain the CSI_VALUE(*),
-  *             HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors.
-  *
-  *         (*) CSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value
-  *             4 MHz) but the real value may vary depending on the variations
-  *             in voltage and temperature.
-  *         (**) HSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value
-  *             64 MHz) but the real value may vary depending on the variations
-  *             in voltage and temperature.
-  *
-  *         (***)HSE_VALUE is a constant defined in stm32h7xx_hal.h file (default value
-  *              25 MHz), user has to ensure that HSE_VALUE is same as the real
-  *              frequency of the crystal used. Otherwise, this function may
-  *              have wrong result.
-  *
-  *         - The result of this function could be not correct when using fractional
-  *           value for HSE crystal.
-  * @param  None
-  * @retval None
-  */
-void SystemCoreClockUpdate (void)
-{
-  uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp;
-  uint32_t common_system_clock;
-  float_t fracn1, pllvco;
-
-
-  /* Get SYSCLK source -------------------------------------------------------*/
-
-  switch (RCC->CFGR & RCC_CFGR_SWS)
-  {
-  case RCC_CFGR_SWS_HSI:  /* HSI used as system clock source */
-    common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
-    break;
-
-  case RCC_CFGR_SWS_CSI:  /* CSI used as system clock  source */
-    common_system_clock = CSI_VALUE;
-    break;
-
-  case RCC_CFGR_SWS_HSE:  /* HSE used as system clock  source */
-    common_system_clock = HSE_VALUE;
-    break;
-
-  case RCC_CFGR_SWS_PLL1:  /* PLL1 used as system clock  source */
-
-    /* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN
-    SYSCLK = PLL_VCO / PLLR
-    */
-    pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC);
-    pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4)  ;
-    pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos);
-    fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3));
-
-    if (pllm != 0U)
-    {
-      switch (pllsource)
-      {
-        case RCC_PLLCKSELR_PLLSRC_HSI:  /* HSI used as PLL clock source */
-
-        hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ;
-        pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
-
-        break;
-
-        case RCC_PLLCKSELR_PLLSRC_CSI:  /* CSI used as PLL clock source */
-          pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
-        break;
-
-        case RCC_PLLCKSELR_PLLSRC_HSE:  /* HSE used as PLL clock source */
-          pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
-        break;
-
-      default:
-          hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ;
-          pllvco = ((float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
-        break;
-      }
-      pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ;
-      common_system_clock =  (uint32_t)(float_t)(pllvco/(float_t)pllp);
-    }
-    else
-    {
-      common_system_clock = 0U;
-    }
-    break;
-
-  default:
-    common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
-    break;
-  }
-
-  /* Compute SystemClock frequency --------------------------------------------------*/
-#if defined (RCC_D1CFGR_D1CPRE)
-  tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos];
-
-  /* common_system_clock frequency : CM7 CPU frequency  */
-  common_system_clock >>= tmp;
-
-  /* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency  */
-  SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU));
-
-#else
-  tmp = D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos];
-
-  /* common_system_clock frequency : CM7 CPU frequency  */
-  common_system_clock >>= tmp;
-
-  /* SystemD2Clock frequency : AXI and AHBs Clock frequency  */
-  SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU));
-
-#endif
-
-#if defined(DUAL_CORE) && defined(CORE_CM4)
-  SystemCoreClock = SystemD2Clock;
-#else
-  SystemCoreClock = common_system_clock;
-#endif /* DUAL_CORE && CORE_CM4 */
-}
-
-
-/**
-  * @}
-  */
-
-/**
-  * @}
-  */
-
-/**
-  * @}
-  */

+ 0 - 356
Core - 副本/Src/tim.c

@@ -1,356 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    tim.c
-  * @brief   This file provides code for the configuration
-  *          of the TIM instances.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "tim.h"
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-TIM_HandleTypeDef htim1;
-TIM_HandleTypeDef htim3;
-TIM_HandleTypeDef htim4;
-
-/* TIM1 init function */
-void MX_TIM1_Init(void)
-{
-
-  /* USER CODE BEGIN TIM1_Init 0 */
-
-  /* USER CODE END TIM1_Init 0 */
-
-  TIM_MasterConfigTypeDef sMasterConfig = {0};
-  TIM_OC_InitTypeDef sConfigOC = {0};
-  TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
-
-  /* USER CODE BEGIN TIM1_Init 1 */
-
-  /* USER CODE END TIM1_Init 1 */
-  htim1.Instance = TIM1;
-  htim1.Init.Prescaler = 0;
-  htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
-  htim1.Init.Period = 65535;
-  htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
-  htim1.Init.RepetitionCounter = 0;
-  htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
-  if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
-  sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
-  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
-  if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  sConfigOC.OCMode = TIM_OCMODE_PWM1;
-  sConfigOC.Pulse = 0;
-  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
-  sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
-  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
-  sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
-  sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
-  if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
-  sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
-  sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
-  sBreakDeadTimeConfig.DeadTime = 0;
-  sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
-  sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
-  sBreakDeadTimeConfig.BreakFilter = 0;
-  sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
-  sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
-  sBreakDeadTimeConfig.Break2Filter = 0;
-  sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
-  if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  /* USER CODE BEGIN TIM1_Init 2 */
-
-  /* USER CODE END TIM1_Init 2 */
-  HAL_TIM_MspPostInit(&htim1);
-
-}
-/* TIM3 init function */
-void MX_TIM3_Init(void)
-{
-
-  /* USER CODE BEGIN TIM3_Init 0 */
-
-  /* USER CODE END TIM3_Init 0 */
-
-  TIM_MasterConfigTypeDef sMasterConfig = {0};
-  TIM_OC_InitTypeDef sConfigOC = {0};
-
-  /* USER CODE BEGIN TIM3_Init 1 */
-
-  /* USER CODE END TIM3_Init 1 */
-  htim3.Instance = TIM3;
-  htim3.Init.Prescaler = 0;
-  htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
-  htim3.Init.Period = 65535;
-  htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
-  htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
-  if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
-  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
-  if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  sConfigOC.OCMode = TIM_OCMODE_PWM1;
-  sConfigOC.Pulse = 0;
-  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
-  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
-  if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  /* USER CODE BEGIN TIM3_Init 2 */
-
-  /* USER CODE END TIM3_Init 2 */
-  HAL_TIM_MspPostInit(&htim3);
-
-}
-/* TIM4 init function */
-void MX_TIM4_Init(void)
-{
-
-  /* USER CODE BEGIN TIM4_Init 0 */
-
-  /* USER CODE END TIM4_Init 0 */
-
-  TIM_MasterConfigTypeDef sMasterConfig = {0};
-  TIM_OC_InitTypeDef sConfigOC = {0};
-
-  /* USER CODE BEGIN TIM4_Init 1 */
-
-  /* USER CODE END TIM4_Init 1 */
-  htim4.Instance = TIM4;
-  htim4.Init.Prescaler = 0;
-  htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
-  htim4.Init.Period = 65535;
-  htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
-  htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
-  if (HAL_TIM_PWM_Init(&htim4) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
-  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
-  if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  sConfigOC.OCMode = TIM_OCMODE_PWM1;
-  sConfigOC.Pulse = 0;
-  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
-  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
-  if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  /* USER CODE BEGIN TIM4_Init 2 */
-
-  /* USER CODE END TIM4_Init 2 */
-  HAL_TIM_MspPostInit(&htim4);
-
-}
-
-void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* tim_pwmHandle)
-{
-
-  if(tim_pwmHandle->Instance==TIM1)
-  {
-  /* USER CODE BEGIN TIM1_MspInit 0 */
-
-  /* USER CODE END TIM1_MspInit 0 */
-    /* TIM1 clock enable */
-    __HAL_RCC_TIM1_CLK_ENABLE();
-  /* USER CODE BEGIN TIM1_MspInit 1 */
-
-  /* USER CODE END TIM1_MspInit 1 */
-  }
-  else if(tim_pwmHandle->Instance==TIM3)
-  {
-  /* USER CODE BEGIN TIM3_MspInit 0 */
-
-  /* USER CODE END TIM3_MspInit 0 */
-    /* TIM3 clock enable */
-    __HAL_RCC_TIM3_CLK_ENABLE();
-  /* USER CODE BEGIN TIM3_MspInit 1 */
-
-  /* USER CODE END TIM3_MspInit 1 */
-  }
-  else if(tim_pwmHandle->Instance==TIM4)
-  {
-  /* USER CODE BEGIN TIM4_MspInit 0 */
-
-  /* USER CODE END TIM4_MspInit 0 */
-    /* TIM4 clock enable */
-    __HAL_RCC_TIM4_CLK_ENABLE();
-  /* USER CODE BEGIN TIM4_MspInit 1 */
-
-  /* USER CODE END TIM4_MspInit 1 */
-  }
-}
-void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
-{
-
-  GPIO_InitTypeDef GPIO_InitStruct = {0};
-  if(timHandle->Instance==TIM1)
-  {
-  /* USER CODE BEGIN TIM1_MspPostInit 0 */
-
-  /* USER CODE END TIM1_MspPostInit 0 */
-    __HAL_RCC_GPIOE_CLK_ENABLE();
-    /**TIM1 GPIO Configuration
-    PE9     ------> TIM1_CH1
-    PE11     ------> TIM1_CH2
-    PE13     ------> TIM1_CH3
-    PE14     ------> TIM1_CH4
-    */
-    GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_13|GPIO_PIN_14;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
-    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
-
-  /* USER CODE BEGIN TIM1_MspPostInit 1 */
-
-  /* USER CODE END TIM1_MspPostInit 1 */
-  }
-  else if(timHandle->Instance==TIM3)
-  {
-  /* USER CODE BEGIN TIM3_MspPostInit 0 */
-
-  /* USER CODE END TIM3_MspPostInit 0 */
-
-    __HAL_RCC_GPIOC_CLK_ENABLE();
-    /**TIM3 GPIO Configuration
-    PC6     ------> TIM3_CH1
-    PC7     ------> TIM3_CH2
-    */
-    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
-    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
-  /* USER CODE BEGIN TIM3_MspPostInit 1 */
-
-  /* USER CODE END TIM3_MspPostInit 1 */
-  }
-  else if(timHandle->Instance==TIM4)
-  {
-  /* USER CODE BEGIN TIM4_MspPostInit 0 */
-
-  /* USER CODE END TIM4_MspPostInit 0 */
-
-    __HAL_RCC_GPIOD_CLK_ENABLE();
-    /**TIM4 GPIO Configuration
-    PD12     ------> TIM4_CH1
-    PD13     ------> TIM4_CH2
-    */
-    GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF2_TIM4;
-    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
-
-  /* USER CODE BEGIN TIM4_MspPostInit 1 */
-
-  /* USER CODE END TIM4_MspPostInit 1 */
-  }
-
-}
-
-void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* tim_pwmHandle)
-{
-
-  if(tim_pwmHandle->Instance==TIM1)
-  {
-  /* USER CODE BEGIN TIM1_MspDeInit 0 */
-
-  /* USER CODE END TIM1_MspDeInit 0 */
-    /* Peripheral clock disable */
-    __HAL_RCC_TIM1_CLK_DISABLE();
-  /* USER CODE BEGIN TIM1_MspDeInit 1 */
-
-  /* USER CODE END TIM1_MspDeInit 1 */
-  }
-  else if(tim_pwmHandle->Instance==TIM3)
-  {
-  /* USER CODE BEGIN TIM3_MspDeInit 0 */
-
-  /* USER CODE END TIM3_MspDeInit 0 */
-    /* Peripheral clock disable */
-    __HAL_RCC_TIM3_CLK_DISABLE();
-  /* USER CODE BEGIN TIM3_MspDeInit 1 */
-
-  /* USER CODE END TIM3_MspDeInit 1 */
-  }
-  else if(tim_pwmHandle->Instance==TIM4)
-  {
-  /* USER CODE BEGIN TIM4_MspDeInit 0 */
-
-  /* USER CODE END TIM4_MspDeInit 0 */
-    /* Peripheral clock disable */
-    __HAL_RCC_TIM4_CLK_DISABLE();
-  /* USER CODE BEGIN TIM4_MspDeInit 1 */
-
-  /* USER CODE END TIM4_MspDeInit 1 */
-  }
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */

+ 0 - 140
Core - 副本/Src/usart.c

@@ -1,140 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
-  ******************************************************************************
-  * @file    usart.c
-  * @brief   This file provides code for the configuration
-  *          of the USART instances.
-  ******************************************************************************
-  * @attention
-  *
-  * Copyright (c) 2024 STMicroelectronics.
-  * All rights reserved.
-  *
-  * This software is licensed under terms that can be found in the LICENSE file
-  * in the root directory of this software component.
-  * If no LICENSE file comes with this software, it is provided AS-IS.
-  *
-  ******************************************************************************
-  */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "usart.h"
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-UART_HandleTypeDef huart2;
-
-/* USART2 init function */
-
-void MX_USART2_UART_Init(void)
-{
-
-  /* USER CODE BEGIN USART2_Init 0 */
-
-  /* USER CODE END USART2_Init 0 */
-
-  /* USER CODE BEGIN USART2_Init 1 */
-
-  /* USER CODE END USART2_Init 1 */
-  huart2.Instance = USART2;
-  huart2.Init.BaudRate = 115200;
-  huart2.Init.WordLength = UART_WORDLENGTH_8B;
-  huart2.Init.StopBits = UART_STOPBITS_1;
-  huart2.Init.Parity = UART_PARITY_NONE;
-  huart2.Init.Mode = UART_MODE_TX_RX;
-  huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
-  huart2.Init.OverSampling = UART_OVERSAMPLING_16;
-  huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
-  huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1;
-  huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
-  if (HAL_UART_Init(&huart2) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  if (HAL_UARTEx_SetTxFifoThreshold(&huart2, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  if (HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  if (HAL_UARTEx_DisableFifoMode(&huart2) != HAL_OK)
-  {
-    Error_Handler();
-  }
-  /* USER CODE BEGIN USART2_Init 2 */
-
-  /* USER CODE END USART2_Init 2 */
-
-}
-
-void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
-{
-
-  GPIO_InitTypeDef GPIO_InitStruct = {0};
-  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
-  if(uartHandle->Instance==USART2)
-  {
-  /* USER CODE BEGIN USART2_MspInit 0 */
-
-  /* USER CODE END USART2_MspInit 0 */
-
-  /** Initializes the peripherals clock
-  */
-    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART2;
-    PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1;
-    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
-    {
-      Error_Handler();
-    }
-
-    /* USART2 clock enable */
-    __HAL_RCC_USART2_CLK_ENABLE();
-
-    __HAL_RCC_GPIOD_CLK_ENABLE();
-    /**USART2 GPIO Configuration
-    PD5     ------> USART2_TX
-    PD6     ------> USART2_RX
-    */
-    GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6;
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-    GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
-    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
-
-  /* USER CODE BEGIN USART2_MspInit 1 */
-
-  /* USER CODE END USART2_MspInit 1 */
-  }
-}
-
-void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
-{
-
-  if(uartHandle->Instance==USART2)
-  {
-  /* USER CODE BEGIN USART2_MspDeInit 0 */
-
-  /* USER CODE END USART2_MspDeInit 0 */
-    /* Peripheral clock disable */
-    __HAL_RCC_USART2_CLK_DISABLE();
-
-    /**USART2 GPIO Configuration
-    PD5     ------> USART2_TX
-    PD6     ------> USART2_RX
-    */
-    HAL_GPIO_DeInit(GPIOD, GPIO_PIN_5|GPIO_PIN_6);
-
-  /* USER CODE BEGIN USART2_MspDeInit 1 */
-
-  /* USER CODE END USART2_MspDeInit 1 */
-  }
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */

+ 0 - 710
Core - 副本/imu/MPU6050.c

@@ -1,710 +0,0 @@
-/*
- * MPU6050.c
- *
- *  Created on: Oct 26, 2021
- *      Author: Administrator
- */
-
-#include "MPU6050.h"
-#include "main.h"
-#include <stdio.h>
-
-extern int t;
-extern int a;
-extern int b;
-extern int c;
-
-//void addr_check_point(u8 addr){
-//    if (addr != 0x69)
-//    {
-//        printf("checkpoint error addr");
-//    }
-//}
-
-//void common_check_point(u8 value){
-//printf("<checkpoint> value => %x\n", value);
-//}
-
-
-u8 IIC_Write_Byte(u8 reg, u8 value)
-{
-
-	
-
-    return IIC_Write_Len(a, reg, 1, &value);
-}
-
-
-u8 IIC_Read_Byte(u8 reg)
-{
-    u8 value = 0;
-
-
-  	IIC_Read_Len(a, reg, 1, &value);
-
-    return value;
-}
-
-
-
-
-u8 IIC_Write_Len1(u8 addr, u8 reg, u8 len, u8 *buf)
-{
-	
-	addr=a;
-	addr = (addr << 1) | 0;
-
-        u8 data[10] = {0};
-        data[0] = reg;
-        for (int i = 0; i < len; i++)
-        {
-            data[1 + i] = buf[i];
-        }
-
-        if (HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)addr, (uint8_t *)data, len + 1, 10000) != HAL_OK
-        ||HAL_I2C_Master_Transmit(&hi2c2, (uint16_t)addr, (uint8_t *)data, len + 1, 10000) != HAL_OK
-        ||HAL_I2C_Master_Transmit(&hi2c3, (uint16_t)addr, (uint8_t *)data, len + 1, 10000) != HAL_OK)
-        {
-            printf("++write len byte fail\r\n");
-            return 1;
-					
-        }
-	return 0;
-}
-// IIC连续写
-u8 IIC_Write_Len(u8 addr, u8 reg, u8 len, u8 *buf)
-{
-	
-	addr=a;
-  		
-
-    if (t == 1)
-    {
-        addr = (addr << 1) | 0;
-
-        u8 data[10] = {0};
-        data[0] = reg;
-        for (int i = 0; i < len; i++)
-        {
-            data[1 + i] = buf[i];
-        }
-
-        if (HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)addr, (uint8_t *)data, len + 1, 10000) != HAL_OK)
-        {
-            printf("++write len byte fail\r\n");
-            return 1;
-        }
-    }
-    else if (t == 2)
-    {
-        addr = (addr << 1) | 0;
-
-        u8 data[10] = {0};
-        data[0] = reg;
-        for (int i = 0; i < len; i++)
-        {
-            data[1 + i] = buf[i];
-        }
-
-        if (HAL_I2C_Master_Transmit(&hi2c2, (uint16_t)addr, (uint8_t *)data, len + 1, 10000) != HAL_OK)
-        {
-            printf("++write len byte fail\r\n");
-            return 1;
-        }
-    }
-    else if (t == 3)
-    {
-        addr = (addr << 1) | 0;
-
-        u8 data[10] = {0};
-        data[0] = reg;
-        for (int i = 0; i < len; i++)
-        {
-            data[1 + i] = buf[i];
-        }
-
-        if (HAL_I2C_Master_Transmit(&hi2c3, (uint16_t)addr, (uint8_t *)data, len + 1, 10000) != HAL_OK)
-        {
-            printf("++write len byte fail\r\n");
-            return 1;
-        }
-    }
-    return 0;
-}
-
-u8 IIC_Read_Len1(u8 addr, u8 reg, u8 len, u8 *buf)
-{addr=a;
-	u8 tmp = (addr << 1) | 0;
-        if (HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)tmp, (uint8_t *)&reg, 1, 10000) != HAL_OK
-        ||HAL_I2C_Master_Transmit(&hi2c2, (uint16_t)tmp, (uint8_t *)&reg, 1, 10000) != HAL_OK
-        ||HAL_I2C_Master_Transmit(&hi2c3, (uint16_t)tmp, (uint8_t *)&reg, 1, 10000) != HAL_OK)
-        {
-            printf("++write byte fail\r\n");
-            return 1;
-				
-			  
-				//	return addr_test;
-        }
-
-        tmp = (addr << 1) | 1;
-        if (HAL_I2C_Master_Receive(&hi2c1, (uint16_t)tmp, (uint8_t *)buf, len, 10000) != HAL_OK
-        ||HAL_I2C_Master_Receive(&hi2c2, (uint16_t)tmp, (uint8_t *)buf, len, 10000) != HAL_OK
-        ||HAL_I2C_Master_Receive(&hi2c3, (uint16_t)tmp, (uint8_t *)buf, len, 10000) != HAL_OK)
-        {
-					
-            printf("--read byte fail\r\n");
-				
-			  
-        }
-	
-}
-
-// IIC连续读
-u8 IIC_Read_Len(u8 addr, u8 reg, u8 len, u8 *buf)
-{
-	
-	addr=a;
-
-
-    if (t == 1)
-    {
-        u8 tmp = (addr << 1) | 0;
-        if (HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)tmp, (uint8_t *)&reg, 1, 10000) != HAL_OK)
-        {
-            printf("++write byte fail\r\n");
-            return 1;
-				//	return addr_test;
-        }
-
-        tmp = (addr << 1) | 1;
-        if (HAL_I2C_Master_Receive(&hi2c1, (uint16_t)tmp, (uint8_t *)buf, len, 10000) != HAL_OK)
-        {
-            printf("--read byte fail\r\n");
-        }
-    }
-    else if (t == 2)
-    {
-        u8 tmp = (addr << 1) | 0;
-        if (HAL_I2C_Master_Transmit(&hi2c2, (uint16_t)tmp, (uint8_t *)&reg, 1, 10000) != HAL_OK)
-        {
-            printf("++write byte fail\r\n");
-            return 1;
-				//	return addr_test;
-        }
-
-        tmp = (addr << 1) | 1;
-        if (HAL_I2C_Master_Receive(&hi2c2, (uint16_t)tmp, (uint8_t *)buf, len, 10000) != HAL_OK)
-        {
-            printf("--read byte fail\r\n");
-        }
-    }
-    else if (t == 3)
-    {
-        u8 tmp = (addr << 1) | 0;
-        if (HAL_I2C_Master_Transmit(&hi2c3, (uint16_t)tmp, (uint8_t *)&reg, 1, 10000) != HAL_OK)
-        {
-            printf("++write byte fail\r\n");
-             return 1;
-				//	return addr_test;
-        }
-
-        tmp = (addr << 1) | 1;
-        if (HAL_I2C_Master_Receive(&hi2c3, (uint16_t)tmp, (uint8_t *)buf, len, 10000) != HAL_OK)
-        {
-            printf("--read byte fail\r\n");
-        }
-    }
-		
-	//	return -1;
-}
-
-// 初始化MPU6050
-// 返回值: 0,成功
-//         其他,错误代码
-u8 MPU_Init(void)
-{
-    u8 res = 0;
-
-    IIC_Write_Byte(MPU_PWR_MGMT1_REG, 0X80); // 复位MPU6050
-
-    HAL_Delay(100);
-
-    IIC_Write_Byte(MPU_PWR_MGMT1_REG, 0X00); // 唤醒MPU6050
-
-    MPU_Set_Gyro_Fsr(3);                     // 陀螺仪传感器,±2000dps
-    MPU_Set_Accel_Fsr(0);                    // 加速度传感器 ±2g
-    MPU_Set_Rate(50);                        // 设置采样率50HZ
-    IIC_Write_Byte(MPU_INT_EN_REG, 0X00);    // 关闭所有中断
-    IIC_Write_Byte(MPU_USER_CTRL_REG, 0X00); // I2C主模式关闭
-    IIC_Write_Byte(MPU_FIFO_EN_REG, 0X00);   // 关闭FIFO
-    IIC_Write_Byte(MPU_INTBP_CFG_REG, 0X80); // INT引脚低电平有效
-
-    res = IIC_Read_Byte(MPU_DEVICE_ID_REG);
-
-    printf("the addr is:%d\r\n", res);
-
-    //    if(res==a)//器件ID正确
-    //    {
-    IIC_Write_Byte(MPU_PWR_MGMT1_REG, 0X01); // 设置CLKSEL,PLL X 轴为参考
-    IIC_Write_Byte(MPU_PWR_MGMT2_REG, 0X00); // 加速度陀螺仪都工作
-    MPU_Set_Rate(50);                        // 设置采样率为50HZ
-    //    }
-    //    else
-    //    {
-    //    	return 1;
-    //    }
-
-    return 0;
-}
-
-// 设置MPU6050陀螺仪传感器满量程范围
-// fsr:0,±250dps;1,±500dps;2,±1000dps;3,±2000dps
-// 返回值:0,设置成功
-//     其他,设置失败
-u8 MPU_Set_Gyro_Fsr(u8 fsr)
-{
-    return IIC_Write_Byte(MPU_GYRO_CFG_REG, fsr << 3); // 设置陀螺仪满量程范围
-}
-
-// 设置MPU6050加速度传感器满量程范围
-// fsr:0,±2g;1,±4g;2,±8g;3,±16g
-// 返回值:0,设置成功
-//     其他,设置失败
-u8 MPU_Set_Accel_Fsr(u8 fsr)
-{
-    return IIC_Write_Byte(MPU_ACCEL_CFG_REG, fsr << 3); // 设置加速度传感器满量程范围
-}
-
-// 设置MPU6050的数字低通滤波器
-// lpf:数字低通滤波频率(Hz)
-// 返回值:0,设置成功
-//     其他,设置失败
-u8 MPU_Set_LPF(u16 lpf)
-{
-    u8 data = 0;
-    if (lpf >= 188)
-        data = 1;
-    else if (lpf >= 98)
-        data = 2;
-    else if (lpf >= 42)
-        data = 2;
-    else if (lpf >= 42)
-        data = 3;
-    else if (lpf >= 20)
-        data = 4;
-    else if (lpf >= 10)
-        data = 5;
-    else
-        data = 6;
-    return IIC_Write_Byte(MPU_CFG_REG, data); // 设置数字低通滤波器
-}
-
-// 设置MPU6050的采样率(假定Fs=1KHz)
-// rate:4~1000(Hz)
-// 返回值:0,设置成功
-//     其他,设置失败
-u8 MPU_Set_Rate(u16 rate)
-{
-    u8 data;
-    if (rate > 1000)
-        rate = 1000;
-    if (rate < 4)
-        rate = 4;
-    data = 1000 / rate - 1;
-    data = IIC_Write_Byte(MPU_SAMPLE_RATE_REG, data); // 设置数字低通滤波器
-    return MPU_Set_LPF(rate / 2);                     // 自动设置LPF为采样率的一半
-}
-
-// 得到温度值
-// 返回值:温度值(扩大了100倍)
-short MPU_Get_Temperature(void)
-{
-    u8 buf[2];
-    short raw;
-    float temp;
-    IIC_Read_Len(a, MPU_TEMP_OUTH_REG, 2, buf);
-    raw = ((u16)buf[0] << 8) | buf[1];
-    temp = 36.53 + ((double)raw) / 340;
-
-    return temp * 100;
-    ;
-}
-
-// 得到陀螺仪值(原始值)
-// gx,gy,gz:陀螺仪x,y,z轴的原始读数(带符号)
-// 返回值:0,成功
-//  其他,错误代码
-u8 MPU_Get_Gyroscope(short *gx, short *gy, short *gz)
-{
-    u8 buf[6], res;
-    res = IIC_Read_Len(a, MPU_GYRO_XOUTH_REG, 6, buf);
-    if (res == 0)
-    {
-        *gx = ((u16)buf[0] << 8) | buf[1];
-        *gy = ((u16)buf[2] << 8) | buf[3];
-        *gz = ((u16)buf[4] << 8) | buf[5];
-    }
-    return res;
-}
-
-// 得到加速度值(原始值)
-// ax,ay,az:陀螺仪x,y,z轴的原始读数(带符号)
-// 返回值:0,成功
-//     其他,错误代码
-u8 MPU_Get_Accelerometer(short *ax, short *ay, short *az)
-{
-    u8 buf[6], res;
-    res = IIC_Read_Len(a, MPU_ACCEL_XOUTH_REG, 6, buf);
-    if (res == 0)
-    {
-        *ax = ((u16)buf[0] << 8) | buf[1];
-        *ay = ((u16)buf[2] << 8) | buf[3];
-        *az = ((u16)buf[4] << 8) | buf[5];
-    }
-    return res;
-    ;
-}
-
-/*--------------------以下为使用板载固件DMP的相关代码,这个融合得到的姿态角效果很好*/
-
-/**
- * @brief  获取当前毫秒值
- * @param  存储最新毫秒值的变量
- * @retval 无
- */
-int get_tick_count(unsigned long *count)
-{
-    count[0] = HAL_GetTick();
-    return 0;
-}
-
-#include "inv_mpu.h"
-#include "inv_mpu_dmp_motion_driver.h"
-
-/* Data requested by client. */
-#define PRINT_ACCEL (0x01)
-#define PRINT_GYRO (0x02)
-#define PRINT_QUAT (0x04)
-
-#define ACCEL_ON (0x01)
-#define GYRO_ON (0x02)
-
-#define MOTION (0)
-#define NO_MOTION (1)
-
-/* Starting sampling rate. */ // 100
-#define DEFAULT_MPU_HZ (50)
-
-struct rx_s
-{
-    unsigned char header[3];
-    unsigned char cmd;
-};
-struct hal_s
-{
-    unsigned char sensors;
-    unsigned char dmp_on;
-    unsigned char wait_for_tap;
-    volatile unsigned char new_gyro;
-    unsigned short report;
-    unsigned short dmp_features;
-    unsigned char motion_int_mode;
-    struct rx_s rx;
-};
-static struct hal_s hal = {0};
-
-/* USB RX binary semaphore. Actually, it's just a flag. Not included in struct
- * because it's declared extern elsewhere.
- */
-volatile unsigned char rx_new;
-
-/* The sensors can be mounted onto the board in any orientation. The mounting
- * matrix seen below tells the MPL how to rotate the raw data from thei
- * driver(s).
- * TODO: The following matrices refer to the configuration on an internal test
- * board at Invensense. If needed, please modify the matrices to match the
- * chip-to-body matrix for your particular set up.
- */
-static signed char gyro_orientation[9] = {-1, 0, 0,
-                                          0, -1, 0,
-                                          0, 0, 1};
-
-/* Every time new gyro data is available, this function is called in an
- * ISR context. In this example, it sets a flag protecting the FIFO read
- * function.
- */
-static void gyro_data_ready_cb(void)
-{
-    hal.new_gyro = 1;
-}
-
-enum packet_type_e
-{
-    PACKET_TYPE_ACCEL,
-    PACKET_TYPE_GYRO,
-    PACKET_TYPE_QUAT,
-    PACKET_TYPE_TAP,
-    PACKET_TYPE_ANDROID_ORIENT,
-    PACKET_TYPE_PEDO,
-    PACKET_TYPE_MISC
-};
-
-#define BYTE u_char
-/* Send data to the Python client application.
- * Data is formatted as follows:
- * packet[0]    = $
- * packet[1]    = packet type (see packet_type_e)
- * packet[2+]   = data
- */
-void send_packet(char packet_type, void *data)
-{
-
-#define MAX_BUF_LENGTH (18)
-    char buf[MAX_BUF_LENGTH], length;
-
-    memset(buf, 0, MAX_BUF_LENGTH);
-    buf[0] = '$';
-    buf[1] = packet_type;
-
-    if (packet_type == PACKET_TYPE_ACCEL || packet_type == PACKET_TYPE_GYRO)
-    {
-        short *sdata = (short *)data;
-        buf[2] = (char)(sdata[0] >> 8);
-        buf[3] = (char)sdata[0];
-        buf[4] = (char)(sdata[1] >> 8);
-        buf[5] = (char)sdata[1];
-        buf[6] = (char)(sdata[2] >> 8);
-        buf[7] = (char)sdata[2];
-        length = 8;
-    }
-    else if (packet_type == PACKET_TYPE_QUAT)
-    {
-        long *ldata = (long *)data;
-        buf[2] = (char)(ldata[0] >> 24);
-        buf[3] = (char)(ldata[0] >> 16);
-        buf[4] = (char)(ldata[0] >> 8);
-        buf[5] = (char)ldata[0];
-        buf[6] = (char)(ldata[1] >> 24);
-        buf[7] = (char)(ldata[1] >> 16);
-        buf[8] = (char)(ldata[1] >> 8);
-        buf[9] = (char)ldata[1];
-        buf[10] = (char)(ldata[2] >> 24);
-        buf[11] = (char)(ldata[2] >> 16);
-        buf[12] = (char)(ldata[2] >> 8);
-        buf[13] = (char)ldata[2];
-        buf[14] = (char)(ldata[3] >> 24);
-        buf[15] = (char)(ldata[3] >> 16);
-        buf[16] = (char)(ldata[3] >> 8);
-        buf[17] = (char)ldata[3];
-        length = 18;
-    }
-    else if (packet_type == PACKET_TYPE_TAP)
-    {
-        buf[2] = ((char *)data)[0];
-        buf[3] = ((char *)data)[1];
-        length = 4;
-    }
-    else if (packet_type == PACKET_TYPE_ANDROID_ORIENT)
-    {
-        buf[2] = ((char *)data)[0];
-        length = 3;
-    }
-    else if (packet_type == PACKET_TYPE_PEDO)
-    {
-        long *ldata = (long *)data;
-        buf[2] = (char)(ldata[0] >> 24);
-        buf[3] = (char)(ldata[0] >> 16);
-        buf[4] = (char)(ldata[0] >> 8);
-        buf[5] = (char)ldata[0];
-        buf[6] = (char)(ldata[1] >> 24);
-        buf[7] = (char)(ldata[1] >> 16);
-        buf[8] = (char)(ldata[1] >> 8);
-        buf[9] = (char)ldata[1];
-        length = 10;
-    }
-    else if (packet_type == PACKET_TYPE_MISC)
-    {
-        buf[2] = ((char *)data)[0];
-        buf[3] = ((char *)data)[1];
-        buf[4] = ((char *)data)[2];
-        buf[5] = ((char *)data)[3];
-        length = 6;
-    }
-
-    //    cdcSendDataWaitTilDone((BYTE*)buf, length, CDC0_INTFNUM, 100);
-}
-
-/* These next two functions converts the orientation matrix (see
- * gyro_orientation) to a scalar representation for use by the DMP.
- * NOTE: These functions are borrowed from Invensense's MPL.
- */
-static inline unsigned short inv_row_2_scale(const signed char *row)
-{
-    unsigned short b;
-
-    if (row[0] > 0)
-        b = 0;
-    else if (row[0] < 0)
-        b = 4;
-    else if (row[1] > 0)
-        b = 1;
-    else if (row[1] < 0)
-        b = 5;
-    else if (row[2] > 0)
-        b = 2;
-    else if (row[2] < 0)
-        b = 6;
-    else
-        b = 7; // error
-    return b;
-}
-static inline unsigned short inv_orientation_matrix_to_scalar(
-    const signed char *mtx)
-{
-    unsigned short scalar;
-
-    /*
-       XYZ  010_001_000 Identity Matrix
-       XZY  001_010_000
-       YXZ  010_000_001
-       YZX  000_010_001
-       ZXY  001_000_010
-       ZYX  000_001_010
-     */
-
-    scalar = inv_row_2_scale(mtx);
-    scalar |= inv_row_2_scale(mtx + 3) << 3;
-    scalar |= inv_row_2_scale(mtx + 6) << 6;
-
-    return scalar;
-}
-
-static inline void run_self_test(void)
-{
-    int result;
-    char test_packet[4] = {0};
-    long gyro[3], accel[3];
-
-    result = mpu_run_self_test(gyro, accel);
-    if (result == 0x7)
-    {
-        /* Test passed. We can trust the gyro data here, so let's push it down
-         * to the DMP.
-         */
-        float sens;
-        unsigned short accel_sens;
-        mpu_get_gyro_sens(&sens);
-        gyro[0] = (long)(gyro[0] * sens);
-        gyro[1] = (long)(gyro[1] * sens);
-        gyro[2] = (long)(gyro[2] * sens);
-        dmp_set_gyro_bias(gyro);
-        mpu_get_accel_sens(&accel_sens);
-        accel[0] *= accel_sens;
-        accel[1] *= accel_sens;
-        accel[2] *= accel_sens;
-        dmp_set_accel_bias(accel);
-    }
-
-    /* Report results. */
-    test_packet[0] = 't';
-    test_packet[1] = result;
-    send_packet(PACKET_TYPE_MISC, test_packet);
-}
-
-#define INT_EXIT_LPM0 12
-
-void DMP_Init(void)
-{
-      	        printf("checkpoint Func DMP_Init\n");
-struct int_param_s int_param;
-
-    /* Set up gyro.
-     * Every function preceded by mpu_ is a driver function and can be found
-     * in inv_mpu.h.
-     */
-    int_param.cb = gyro_data_ready_cb;
-    int_param.pin = 16;
-    int_param.lp_exit = INT_EXIT_LPM0;
-    int_param.active_low = 1;
-
-    int result = mpu_init(&int_param);
-
-    printf("mpu_init, %d\r\n", result);
-
-    if (result == 0) // mpu初始化
-    {
-  if (!mpu_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL)) // 设置需要的传感器
-            printf("mpu_set_sensor complete ......\r\n");
-
-        if (!mpu_configure_fifo(INV_XYZ_GYRO | INV_XYZ_ACCEL)) // 设置fifo
-            printf("mpu_configure_fifo complete ......\r\n");
-
-        if (!mpu_set_sample_rate(DEFAULT_MPU_HZ)) // 设置采集样率
-            printf("mpu_set_sample_rate complete ......\r\n");
-
-        unsigned short gyro_rate = 0, gyro_fsr = 0;
-        unsigned char accel_fsr = 0;
-
-        mpu_get_sample_rate(&gyro_rate);
-        mpu_get_gyro_fsr(&gyro_fsr);
-        mpu_get_accel_fsr(&accel_fsr);
-
-        printf("gyro_rate %d, gyro_fsr %d, accel_fsr %d\r\n", gyro_rate, gyro_fsr, accel_fsr);
-
-        if (!dmp_load_motion_driver_firmware()) // 加载dmp固件
-            printf("dmp_load_motion_driver_firmware complete ......\r\n");
-
-        if (!dmp_set_orientation(inv_orientation_matrix_to_scalar(gyro_orientation)))
-            printf("dmp_set_orientation complete ......\r\n"); // 设置陀螺仪方向
-
-        if (!dmp_enable_feature(DMP_FEATURE_6X_LP_QUAT | DMP_FEATURE_TAP |
-                                DMP_FEATURE_ANDROID_ORIENT | DMP_FEATURE_SEND_RAW_ACCEL | DMP_FEATURE_SEND_CAL_GYRO |
-                                DMP_FEATURE_GYRO_CAL))
-            printf("dmp_enable_feature complete ......\r\n");
-
-        if (!dmp_set_fifo_rate(DEFAULT_MPU_HZ)) // 设置速率
-            printf("dmp_set_fifo_rate complete ......\r\n");
-
-        run_self_test(); // 自检(非必要)
-
-        if (!mpu_set_dmp_state(1)) // 使能
-            printf("mpu_set_dmp_state complete ......\r\n");
-    }
-}
-
-#define q30 1073741824.0
-
-uint8_t Read_DMP(float *Pitch, float *Roll, float *Yaw)
-{
-
-    short gyro[3], accel[3], sensors;
-    float q0 = 1.0f, q1 = 0.0f, q2 = 0.0f, q3 = 0.0f;
-    unsigned long sensor_timestamp;
-    unsigned char more;
-    long quat[4];
-
-    int ret = dmp_read_fifo(gyro, accel, quat, &sensor_timestamp, &sensors, &more);
-
-    //	printf("dmp_read_fifo, %d\r\n", ret);
-
-    if (ret)
-    {
-        return 1;
-    }
-
-    if (sensors & INV_WXYZ_QUAT)
-    {
-        q0 = quat[0] / q30;
-        q1 = quat[1] / q30;
-        q2 = quat[2] / q30;
-        q3 = quat[3] / q30;
-        *Pitch = (float)asin(-2 * q1 * q3 + 2 * q0 * q2) * 57.3;
-        *Roll = (float)atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2 * q2 + 1) * 57.3; // roll
-        *Yaw = (float)atan2(2 * (q1 * q2 + q0 * q3), q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3) * 57.3;
-        return 0;
-    }
-    else
-    {
-        return 2;
-    }
-}

+ 0 - 124
Core - 副本/imu/MPU6050.h

@@ -1,124 +0,0 @@
-/*
- * MPU6050.h
- *
- *  Created on: Oct 26, 2021
- *      Author: Administrator
- */
-
-#ifndef INC_MPU6050_H_
-#define INC_MPU6050_H_
-
-#include "i2c.h"
-#include "inv_mpu.h"
-#include "main.h"
-
-extern int a;
-extern int b;
-extern int c;
-
-// #define MPU_ACCEL_OFFS_REG		0X06	//accel_offs寄存器,可读取版本号,寄存器手册未提到
-// #define MPU_PROD_ID_REG			0X0C	//prod id寄存器,在寄存器手册未提到
-#define MPU_SELF_TESTX_REG 0X0D   // 自检寄存器X
-#define MPU_SELF_TESTY_REG 0X0E   // 自检寄存器Y
-#define MPU_SELF_TESTZ_REG 0X0F   // 自检寄存器Z
-#define MPU_SELF_TESTA_REG 0X10   // 自检寄存器A
-#define MPU_SAMPLE_RATE_REG 0X19  // 采样频率分频器
-#define MPU_CFG_REG 0X1A          // 配置寄存器
-#define MPU_GYRO_CFG_REG 0X1B     // 陀螺仪配置寄存器
-#define MPU_ACCEL_CFG_REG 0X1C    // 加速度计配置寄存器
-#define MPU_MOTION_DET_REG 0X1F   // 运动检测阀值设置寄存器
-#define MPU_FIFO_EN_REG 0X23      // FIFO使能寄存器
-#define MPU_I2CMST_CTRL_REG 0X24  // IIC主机控制寄存器
-#define MPU_I2CSLV0_ADDR_REG 0X25 // IIC从机0器件地址寄存器
-#define MPU_I2CSLV0_REG 0X26      // IIC从机0数据地址寄存器
-#define MPU_I2CSLV0_CTRL_REG 0X27 // IIC从机0控制寄存器
-#define MPU_I2CSLV1_ADDR_REG 0X28 // IIC从机1器件地址寄存器
-#define MPU_I2CSLV1_REG 0X29      // IIC从机1数据地址寄存器
-#define MPU_I2CSLV1_CTRL_REG 0X2A // IIC从机1控制寄存器
-#define MPU_I2CSLV2_ADDR_REG 0X2B // IIC从机2器件地址寄存器
-#define MPU_I2CSLV2_REG 0X2C      // IIC从机2数据地址寄存器
-#define MPU_I2CSLV2_CTRL_REG 0X2D // IIC从机2控制寄存器
-#define MPU_I2CSLV3_ADDR_REG 0X2E // IIC从机3器件地址寄存器
-#define MPU_I2CSLV3_REG 0X2F      // IIC从机3数据地址寄存器
-#define MPU_I2CSLV3_CTRL_REG 0X30 // IIC从机3控制寄存器
-#define MPU_I2CSLV4_ADDR_REG 0X31 // IIC从机4器件地址寄存器
-#define MPU_I2CSLV4_REG 0X32      // IIC从机4数据地址寄存器
-#define MPU_I2CSLV4_DO_REG 0X33   // IIC从机4写数据寄存器
-#define MPU_I2CSLV4_CTRL_REG 0X34 // IIC从机4控制寄存器
-#define MPU_I2CSLV4_DI_REG 0X35   // IIC从机4读数据寄存器
-
-#define MPU_I2CMST_STA_REG 0X36 // IIC主机状态寄存器
-#define MPU_INTBP_CFG_REG 0X37  // 中断/旁路设置寄存器
-#define MPU_INT_EN_REG 0X38     // 中断使能寄存器
-#define MPU_INT_STA_REG 0X3A    // 中断状态寄存器
-
-#define MPU_ACCEL_XOUTH_REG 0X3B // 加速度值,X轴高8位寄存器
-#define MPU_ACCEL_XOUTL_REG 0X3C // 加速度值,X轴低8位寄存器
-#define MPU_ACCEL_YOUTH_REG 0X3D // 加速度值,Y轴高8位寄存器
-#define MPU_ACCEL_YOUTL_REG 0X3E // 加速度值,Y轴低8位寄存器
-#define MPU_ACCEL_ZOUTH_REG 0X3F // 加速度值,Z轴高8位寄存器
-#define MPU_ACCEL_ZOUTL_REG 0X40 // 加速度值,Z轴低8位寄存器
-
-#define MPU_TEMP_OUTH_REG 0X41 // 温度值高八位寄存器
-#define MPU_TEMP_OUTL_REG 0X42 // 温度值低8位寄存器
-
-#define MPU_GYRO_XOUTH_REG 0X43 // 陀螺仪值,X轴高8位寄存器
-#define MPU_GYRO_XOUTL_REG 0X44 // 陀螺仪值,X轴低8位寄存器
-#define MPU_GYRO_YOUTH_REG 0X45 // 陀螺仪值,Y轴高8位寄存器
-#define MPU_GYRO_YOUTL_REG 0X46 // 陀螺仪值,Y轴低8位寄存器
-#define MPU_GYRO_ZOUTH_REG 0X47 // 陀螺仪值,Z轴高8位寄存器
-#define MPU_GYRO_ZOUTL_REG 0X48 // 陀螺仪值,Z轴低8位寄存器
-
-#define MPU_I2CSLV0_DO_REG 0X63 // IIC从机0数据寄存器
-#define MPU_I2CSLV1_DO_REG 0X64 // IIC从机1数据寄存器
-#define MPU_I2CSLV2_DO_REG 0X65 // IIC从机2数据寄存器
-#define MPU_I2CSLV3_DO_REG 0X66 // IIC从机3数据寄存器
-
-#define MPU_I2CMST_DELAY_REG 0X67 // IIC主机延时管理寄存器
-#define MPU_SIGPATH_RST_REG 0X68  // 信号通道复位寄存器
-#define MPU_MDETECT_CTRL_REG 0X69 // 运动检测控制寄存器
-#define MPU_USER_CTRL_REG 0X6A    // 用户控制寄存器
-#define MPU_PWR_MGMT1_REG 0X6B    // 电源管理寄存器1
-#define MPU_PWR_MGMT2_REG 0X6C    // 电源管理寄存器2
-#define MPU_FIFO_CNTH_REG 0X72    // FIFO计数寄存器高八位
-#define MPU_FIFO_CNTL_REG 0X73    // FIFO计数寄存器低八位
-#define MPU_FIFO_RW_REG 0X74      // FIFO读写寄存器
-#define MPU_DEVICE_ID_REG 0X75    // 器件ID寄存器
-
-// 如果AD0脚接地,IIC地址为0X68(不包含最低位).
-// 如果接V3.3,则IIC地址为0X69(不包含最低位).
-
-// 因为模块AD0默认接GND,所以转为读写地址后,为0XD1和0XD0(如果接VCC,则为0XD3和0XD2)
-// #define MPU_ADDR		a
-// #define MPU_READ    b
-// #define MPU_WRITE   c
-
-#define u8 uint8_t
-#define u16 uint16_t
-
-u8 MPU_Init(void);                                  // 初始化MPU6050
-u8 IIC_Write_Len(u8 addr, u8 reg, u8 len, u8 *buf); // IIC连续写
-u8 IIC_Read_Len(u8 addr, u8 reg, u8 len, u8 *buf);  // IIC连续读
-u8 IIC_Write_Byte(u8 reg, u8 data);                 // IIC写一个字节
-u8 IIC_Read_Byte(u8 reg);                           // IIC读一个字节
-
-u8 IIC_Write_Len1(u8 addr, u8 reg, u8 len, u8 *buf);
-u8 IIC_Read_Len1(u8 addr, u8 reg, u8 len, u8 *buf);
-
-
-u8 MPU_Set_Gyro_Fsr(u8 fsr);
-u8 MPU_Set_Accel_Fsr(u8 fsr);
-u8 MPU_Set_LPF(u16 lpf);
-u8 MPU_Set_Rate(u16 rate);
-u8 MPU_Set_Fifo(u8 sens);
-
-short MPU_Get_Temperature(void);
-u8 MPU_Get_Gyroscope(short *gx, short *gy, short *gz);
-u8 MPU_Get_Accelerometer(short *ax, short *ay, short *az);
-
-//----------------------DMP-------------------------------
-void DMP_Init(void);
-uint8_t Read_DMP(float *Pitch, float *Roll, float *Yaw);
-int get_tick_count(unsigned long *count);
-
-#endif /* INC_MPU6050_H_ */

+ 0 - 494
Core - 副本/imu/dmpKey.h

@@ -1,494 +0,0 @@
-/*
- $License:
-    Copyright (C) 2011 InvenSense Corporation, All Rights Reserved.
- $
- */
-#ifndef DMPKEY_H__
-#define DMPKEY_H__
-
-#define KEY_CFG_25                  (0)
-#define KEY_CFG_24                  (KEY_CFG_25 + 1)
-#define KEY_CFG_26                  (KEY_CFG_24 + 1)
-#define KEY_CFG_27                  (KEY_CFG_26 + 1)
-#define KEY_CFG_21                  (KEY_CFG_27 + 1)
-#define KEY_CFG_20                  (KEY_CFG_21 + 1)
-#define KEY_CFG_TAP4                (KEY_CFG_20 + 1)
-#define KEY_CFG_TAP5                (KEY_CFG_TAP4 + 1)
-#define KEY_CFG_TAP6                (KEY_CFG_TAP5 + 1)
-#define KEY_CFG_TAP7                (KEY_CFG_TAP6 + 1)
-#define KEY_CFG_TAP0                (KEY_CFG_TAP7 + 1)
-#define KEY_CFG_TAP1                (KEY_CFG_TAP0 + 1)
-#define KEY_CFG_TAP2                (KEY_CFG_TAP1 + 1)
-#define KEY_CFG_TAP3                (KEY_CFG_TAP2 + 1)
-#define KEY_CFG_TAP_QUANTIZE        (KEY_CFG_TAP3 + 1)
-#define KEY_CFG_TAP_JERK            (KEY_CFG_TAP_QUANTIZE + 1)
-#define KEY_CFG_DR_INT              (KEY_CFG_TAP_JERK + 1)
-#define KEY_CFG_AUTH                (KEY_CFG_DR_INT + 1)
-#define KEY_CFG_TAP_SAVE_ACCB       (KEY_CFG_AUTH + 1)
-#define KEY_CFG_TAP_CLEAR_STICKY    (KEY_CFG_TAP_SAVE_ACCB + 1)
-#define KEY_CFG_FIFO_ON_EVENT       (KEY_CFG_TAP_CLEAR_STICKY + 1)
-#define KEY_FCFG_ACCEL_INPUT        (KEY_CFG_FIFO_ON_EVENT + 1)
-#define KEY_FCFG_ACCEL_INIT         (KEY_FCFG_ACCEL_INPUT + 1)
-#define KEY_CFG_23                  (KEY_FCFG_ACCEL_INIT + 1)
-#define KEY_FCFG_1                  (KEY_CFG_23 + 1)
-#define KEY_FCFG_3                  (KEY_FCFG_1 + 1)
-#define KEY_FCFG_2                  (KEY_FCFG_3 + 1)
-#define KEY_CFG_3D                  (KEY_FCFG_2 + 1)
-#define KEY_CFG_3B                  (KEY_CFG_3D + 1)
-#define KEY_CFG_3C                  (KEY_CFG_3B + 1)
-#define KEY_FCFG_5                  (KEY_CFG_3C + 1)
-#define KEY_FCFG_4                  (KEY_FCFG_5 + 1)
-#define KEY_FCFG_7                  (KEY_FCFG_4 + 1)
-#define KEY_FCFG_FSCALE             (KEY_FCFG_7 + 1)
-#define KEY_FCFG_AZ                 (KEY_FCFG_FSCALE + 1)
-#define KEY_FCFG_6                  (KEY_FCFG_AZ + 1)
-#define KEY_FCFG_LSB4               (KEY_FCFG_6 + 1)
-#define KEY_CFG_12                  (KEY_FCFG_LSB4 + 1)
-#define KEY_CFG_14                  (KEY_CFG_12 + 1)
-#define KEY_CFG_15                  (KEY_CFG_14 + 1)
-#define KEY_CFG_16                  (KEY_CFG_15 + 1)
-#define KEY_CFG_18                  (KEY_CFG_16 + 1)
-#define KEY_CFG_6                   (KEY_CFG_18 + 1)
-#define KEY_CFG_7                   (KEY_CFG_6 + 1)
-#define KEY_CFG_4                   (KEY_CFG_7 + 1)
-#define KEY_CFG_5                   (KEY_CFG_4 + 1)
-#define KEY_CFG_2                   (KEY_CFG_5 + 1)
-#define KEY_CFG_3                   (KEY_CFG_2 + 1)
-#define KEY_CFG_1                   (KEY_CFG_3 + 1)
-#define KEY_CFG_EXTERNAL            (KEY_CFG_1 + 1)
-#define KEY_CFG_8                   (KEY_CFG_EXTERNAL + 1)
-#define KEY_CFG_9                   (KEY_CFG_8 + 1)
-#define KEY_CFG_ORIENT_3            (KEY_CFG_9 + 1)
-#define KEY_CFG_ORIENT_2            (KEY_CFG_ORIENT_3 + 1)
-#define KEY_CFG_ORIENT_1            (KEY_CFG_ORIENT_2 + 1)
-#define KEY_CFG_GYRO_SOURCE         (KEY_CFG_ORIENT_1 + 1)
-#define KEY_CFG_ORIENT_IRQ_1        (KEY_CFG_GYRO_SOURCE + 1)
-#define KEY_CFG_ORIENT_IRQ_2        (KEY_CFG_ORIENT_IRQ_1 + 1)
-#define KEY_CFG_ORIENT_IRQ_3        (KEY_CFG_ORIENT_IRQ_2 + 1)
-#define KEY_FCFG_MAG_VAL            (KEY_CFG_ORIENT_IRQ_3 + 1)
-#define KEY_FCFG_MAG_MOV            (KEY_FCFG_MAG_VAL + 1)
-#define KEY_CFG_LP_QUAT             (KEY_FCFG_MAG_MOV + 1)
-
-/* MPU6050 keys */
-#define KEY_CFG_ACCEL_FILTER        (KEY_CFG_LP_QUAT + 1)
-#define KEY_CFG_MOTION_BIAS         (KEY_CFG_ACCEL_FILTER + 1)
-#define KEY_TEMPLABEL               (KEY_CFG_MOTION_BIAS + 1)
-
-#define KEY_D_0_22                  (KEY_TEMPLABEL + 1)
-#define KEY_D_0_24                  (KEY_D_0_22 + 1)
-#define KEY_D_0_36                  (KEY_D_0_24 + 1)
-#define KEY_D_0_52                  (KEY_D_0_36 + 1)
-#define KEY_D_0_96                  (KEY_D_0_52 + 1)
-#define KEY_D_0_104                 (KEY_D_0_96 + 1)
-#define KEY_D_0_108                 (KEY_D_0_104 + 1)
-#define KEY_D_0_163                 (KEY_D_0_108 + 1)
-#define KEY_D_0_188                 (KEY_D_0_163 + 1)
-#define KEY_D_0_192                 (KEY_D_0_188 + 1)
-#define KEY_D_0_224                 (KEY_D_0_192 + 1)
-#define KEY_D_0_228                 (KEY_D_0_224 + 1)
-#define KEY_D_0_232                 (KEY_D_0_228 + 1)
-#define KEY_D_0_236                 (KEY_D_0_232 + 1)
-
-#define KEY_DMP_PREVPTAT            (KEY_D_0_236 + 1)
-#define KEY_D_1_2                   (KEY_DMP_PREVPTAT + 1)
-#define KEY_D_1_4                   (KEY_D_1_2 + 1)
-#define KEY_D_1_8                   (KEY_D_1_4 + 1)
-#define KEY_D_1_10                  (KEY_D_1_8 + 1)
-#define KEY_D_1_24                  (KEY_D_1_10 + 1)
-#define KEY_D_1_28                  (KEY_D_1_24 + 1)
-#define KEY_D_1_36                  (KEY_D_1_28 + 1)
-#define KEY_D_1_40                  (KEY_D_1_36 + 1)
-#define KEY_D_1_44                  (KEY_D_1_40 + 1)
-#define KEY_D_1_72                  (KEY_D_1_44 + 1)
-#define KEY_D_1_74                  (KEY_D_1_72 + 1)
-#define KEY_D_1_79                  (KEY_D_1_74 + 1)
-#define KEY_D_1_88                  (KEY_D_1_79 + 1)
-#define KEY_D_1_90                  (KEY_D_1_88 + 1)
-#define KEY_D_1_92                  (KEY_D_1_90 + 1)
-#define KEY_D_1_96                  (KEY_D_1_92 + 1)
-#define KEY_D_1_98                  (KEY_D_1_96 + 1)
-#define KEY_D_1_100                 (KEY_D_1_98 + 1)
-#define KEY_D_1_106                 (KEY_D_1_100 + 1)
-#define KEY_D_1_108                 (KEY_D_1_106 + 1)
-#define KEY_D_1_112                 (KEY_D_1_108 + 1)
-#define KEY_D_1_128                 (KEY_D_1_112 + 1)
-#define KEY_D_1_152                 (KEY_D_1_128 + 1)
-#define KEY_D_1_160                 (KEY_D_1_152 + 1)
-#define KEY_D_1_168                 (KEY_D_1_160 + 1)
-#define KEY_D_1_175                 (KEY_D_1_168 + 1)
-#define KEY_D_1_176                 (KEY_D_1_175 + 1)
-#define KEY_D_1_178                 (KEY_D_1_176 + 1)
-#define KEY_D_1_179                 (KEY_D_1_178 + 1)
-#define KEY_D_1_218                 (KEY_D_1_179 + 1)
-#define KEY_D_1_232                 (KEY_D_1_218 + 1)
-#define KEY_D_1_236                 (KEY_D_1_232 + 1)
-#define KEY_D_1_240                 (KEY_D_1_236 + 1)
-#define KEY_D_1_244                 (KEY_D_1_240 + 1)
-#define KEY_D_1_250                 (KEY_D_1_244 + 1)
-#define KEY_D_1_252                 (KEY_D_1_250 + 1)
-#define KEY_D_2_12                  (KEY_D_1_252 + 1)
-#define KEY_D_2_96                  (KEY_D_2_12 + 1)
-#define KEY_D_2_108                 (KEY_D_2_96 + 1)
-#define KEY_D_2_208                 (KEY_D_2_108 + 1)
-#define KEY_FLICK_MSG               (KEY_D_2_208 + 1)
-#define KEY_FLICK_COUNTER           (KEY_FLICK_MSG + 1)
-#define KEY_FLICK_LOWER             (KEY_FLICK_COUNTER + 1)
-#define KEY_CFG_FLICK_IN            (KEY_FLICK_LOWER + 1)
-#define KEY_FLICK_UPPER             (KEY_CFG_FLICK_IN + 1)
-#define KEY_CGNOTICE_INTR           (KEY_FLICK_UPPER + 1)
-#define KEY_D_2_224                 (KEY_CGNOTICE_INTR + 1)
-#define KEY_D_2_244                 (KEY_D_2_224 + 1)
-#define KEY_D_2_248                 (KEY_D_2_244 + 1)
-#define KEY_D_2_252                 (KEY_D_2_248 + 1)
-
-#define KEY_D_GYRO_BIAS_X               (KEY_D_2_252 + 1)
-#define KEY_D_GYRO_BIAS_Y               (KEY_D_GYRO_BIAS_X + 1)
-#define KEY_D_GYRO_BIAS_Z               (KEY_D_GYRO_BIAS_Y + 1)
-#define KEY_D_ACC_BIAS_X                (KEY_D_GYRO_BIAS_Z + 1)
-#define KEY_D_ACC_BIAS_Y                (KEY_D_ACC_BIAS_X + 1)
-#define KEY_D_ACC_BIAS_Z                (KEY_D_ACC_BIAS_Y + 1)
-#define KEY_D_GYRO_ENABLE               (KEY_D_ACC_BIAS_Z + 1)
-#define KEY_D_ACCEL_ENABLE              (KEY_D_GYRO_ENABLE + 1)
-#define KEY_D_QUAT_ENABLE               (KEY_D_ACCEL_ENABLE +1)
-#define KEY_D_OUTPUT_ENABLE             (KEY_D_QUAT_ENABLE + 1)
-#define KEY_D_CR_TIME_G                 (KEY_D_OUTPUT_ENABLE + 1)
-#define KEY_D_CR_TIME_A                 (KEY_D_CR_TIME_G + 1)
-#define KEY_D_CR_TIME_Q                 (KEY_D_CR_TIME_A + 1)
-#define KEY_D_CS_TAX                    (KEY_D_CR_TIME_Q + 1)
-#define KEY_D_CS_TAY                    (KEY_D_CS_TAX + 1)
-#define KEY_D_CS_TAZ                    (KEY_D_CS_TAY + 1)
-#define KEY_D_CS_TGX                    (KEY_D_CS_TAZ + 1)
-#define KEY_D_CS_TGY                    (KEY_D_CS_TGX + 1)
-#define KEY_D_CS_TGZ                    (KEY_D_CS_TGY + 1)
-#define KEY_D_CS_TQ0                    (KEY_D_CS_TGZ + 1)
-#define KEY_D_CS_TQ1                    (KEY_D_CS_TQ0 + 1)
-#define KEY_D_CS_TQ2                    (KEY_D_CS_TQ1 + 1)
-#define KEY_D_CS_TQ3                    (KEY_D_CS_TQ2 + 1)
-
-/* Compass keys */
-#define KEY_CPASS_BIAS_X            (KEY_D_CS_TQ3 + 1)
-#define KEY_CPASS_BIAS_Y            (KEY_CPASS_BIAS_X + 1)
-#define KEY_CPASS_BIAS_Z            (KEY_CPASS_BIAS_Y + 1)
-#define KEY_CPASS_MTX_00            (KEY_CPASS_BIAS_Z + 1)
-#define KEY_CPASS_MTX_01            (KEY_CPASS_MTX_00 + 1)
-#define KEY_CPASS_MTX_02            (KEY_CPASS_MTX_01 + 1)
-#define KEY_CPASS_MTX_10            (KEY_CPASS_MTX_02 + 1)
-#define KEY_CPASS_MTX_11            (KEY_CPASS_MTX_10 + 1)
-#define KEY_CPASS_MTX_12            (KEY_CPASS_MTX_11 + 1)
-#define KEY_CPASS_MTX_20            (KEY_CPASS_MTX_12 + 1)
-#define KEY_CPASS_MTX_21            (KEY_CPASS_MTX_20 + 1)
-#define KEY_CPASS_MTX_22            (KEY_CPASS_MTX_21 + 1)
-
-/* Gesture Keys */
-#define KEY_DMP_TAPW_MIN            (KEY_CPASS_MTX_22 + 1)
-#define KEY_DMP_TAP_THR_X           (KEY_DMP_TAPW_MIN + 1)
-#define KEY_DMP_TAP_THR_Y           (KEY_DMP_TAP_THR_X + 1)
-#define KEY_DMP_TAP_THR_Z           (KEY_DMP_TAP_THR_Y + 1)
-#define KEY_DMP_SH_TH_Y             (KEY_DMP_TAP_THR_Z + 1)
-#define KEY_DMP_SH_TH_X             (KEY_DMP_SH_TH_Y + 1)
-#define KEY_DMP_SH_TH_Z             (KEY_DMP_SH_TH_X + 1)
-#define KEY_DMP_ORIENT              (KEY_DMP_SH_TH_Z + 1)
-#define KEY_D_ACT0                  (KEY_DMP_ORIENT + 1)
-#define KEY_D_ACSX                  (KEY_D_ACT0 + 1)
-#define KEY_D_ACSY                  (KEY_D_ACSX + 1)
-#define KEY_D_ACSZ                  (KEY_D_ACSY + 1)
-
-#define KEY_X_GRT_Y_TMP             (KEY_D_ACSZ + 1)
-#define KEY_SKIP_X_GRT_Y_TMP        (KEY_X_GRT_Y_TMP + 1)
-#define KEY_SKIP_END_COMPARE        (KEY_SKIP_X_GRT_Y_TMP + 1)
-#define KEY_END_COMPARE_Y_X_TMP2    (KEY_SKIP_END_COMPARE + 1)       
-#define KEY_CFG_ANDROID_ORIENT_INT  (KEY_END_COMPARE_Y_X_TMP2 + 1)
-#define KEY_NO_ORIENT_INTERRUPT     (KEY_CFG_ANDROID_ORIENT_INT + 1)
-#define KEY_END_COMPARE_Y_X_TMP     (KEY_NO_ORIENT_INTERRUPT + 1)
-#define KEY_END_ORIENT_1            (KEY_END_COMPARE_Y_X_TMP + 1)
-#define KEY_END_COMPARE_Y_X         (KEY_END_ORIENT_1 + 1) 
-#define KEY_END_ORIENT              (KEY_END_COMPARE_Y_X + 1)
-#define KEY_X_GRT_Y                 (KEY_END_ORIENT + 1)
-#define KEY_NOT_TIME_MINUS_1        (KEY_X_GRT_Y + 1)       
-#define KEY_END_COMPARE_Y_X_TMP3    (KEY_NOT_TIME_MINUS_1 + 1) 
-#define KEY_X_GRT_Y_TMP2            (KEY_END_COMPARE_Y_X_TMP3 + 1)
-
-/* Authenticate Keys */
-#define KEY_D_AUTH_OUT              (KEY_X_GRT_Y_TMP2 + 1)
-#define KEY_D_AUTH_IN               (KEY_D_AUTH_OUT + 1)
-#define KEY_D_AUTH_A                (KEY_D_AUTH_IN + 1)
-#define KEY_D_AUTH_B                (KEY_D_AUTH_A + 1)
-
-/* Pedometer standalone only keys */
-#define KEY_D_PEDSTD_BP_B           (KEY_D_AUTH_B + 1)
-#define KEY_D_PEDSTD_HP_A           (KEY_D_PEDSTD_BP_B + 1)
-#define KEY_D_PEDSTD_HP_B           (KEY_D_PEDSTD_HP_A + 1)
-#define KEY_D_PEDSTD_BP_A4          (KEY_D_PEDSTD_HP_B + 1)
-#define KEY_D_PEDSTD_BP_A3          (KEY_D_PEDSTD_BP_A4 + 1)
-#define KEY_D_PEDSTD_BP_A2          (KEY_D_PEDSTD_BP_A3 + 1)
-#define KEY_D_PEDSTD_BP_A1          (KEY_D_PEDSTD_BP_A2 + 1)
-#define KEY_D_PEDSTD_INT_THRSH      (KEY_D_PEDSTD_BP_A1 + 1)
-#define KEY_D_PEDSTD_CLIP           (KEY_D_PEDSTD_INT_THRSH + 1)
-#define KEY_D_PEDSTD_SB             (KEY_D_PEDSTD_CLIP + 1)
-#define KEY_D_PEDSTD_SB_TIME        (KEY_D_PEDSTD_SB + 1)
-#define KEY_D_PEDSTD_PEAKTHRSH      (KEY_D_PEDSTD_SB_TIME + 1)
-#define KEY_D_PEDSTD_TIML           (KEY_D_PEDSTD_PEAKTHRSH + 1)
-#define KEY_D_PEDSTD_TIMH           (KEY_D_PEDSTD_TIML + 1)
-#define KEY_D_PEDSTD_PEAK           (KEY_D_PEDSTD_TIMH + 1)
-#define KEY_D_PEDSTD_TIMECTR        (KEY_D_PEDSTD_PEAK + 1)
-#define KEY_D_PEDSTD_STEPCTR        (KEY_D_PEDSTD_TIMECTR + 1)
-#define KEY_D_PEDSTD_WALKTIME       (KEY_D_PEDSTD_STEPCTR + 1)
-#define KEY_D_PEDSTD_DECI           (KEY_D_PEDSTD_WALKTIME + 1)
-
-/*Host Based No Motion*/
-#define KEY_D_HOST_NO_MOT           (KEY_D_PEDSTD_DECI + 1)
-
-/* EIS keys */
-#define KEY_P_EIS_FIFO_FOOTER       (KEY_D_HOST_NO_MOT + 1)
-#define KEY_P_EIS_FIFO_YSHIFT       (KEY_P_EIS_FIFO_FOOTER + 1)
-#define KEY_P_EIS_DATA_RATE         (KEY_P_EIS_FIFO_YSHIFT + 1)
-#define KEY_P_EIS_FIFO_XSHIFT       (KEY_P_EIS_DATA_RATE + 1)
-#define KEY_P_EIS_FIFO_SYNC         (KEY_P_EIS_FIFO_XSHIFT + 1)
-#define KEY_P_EIS_FIFO_ZSHIFT       (KEY_P_EIS_FIFO_SYNC + 1)
-#define KEY_P_EIS_FIFO_READY        (KEY_P_EIS_FIFO_ZSHIFT + 1)
-#define KEY_DMP_FOOTER              (KEY_P_EIS_FIFO_READY + 1)
-#define KEY_DMP_INTX_HC             (KEY_DMP_FOOTER + 1)
-#define KEY_DMP_INTX_PH             (KEY_DMP_INTX_HC + 1)
-#define KEY_DMP_INTX_SH             (KEY_DMP_INTX_PH + 1)
-#define KEY_DMP_AINV_SH             (KEY_DMP_INTX_SH + 1)
-#define KEY_DMP_A_INV_XH            (KEY_DMP_AINV_SH + 1)
-#define KEY_DMP_AINV_PH             (KEY_DMP_A_INV_XH + 1)
-#define KEY_DMP_CTHX_H              (KEY_DMP_AINV_PH + 1)
-#define KEY_DMP_CTHY_H              (KEY_DMP_CTHX_H + 1)
-#define KEY_DMP_CTHZ_H              (KEY_DMP_CTHY_H + 1)
-#define KEY_DMP_NCTHX_H             (KEY_DMP_CTHZ_H + 1)
-#define KEY_DMP_NCTHY_H             (KEY_DMP_NCTHX_H + 1)
-#define KEY_DMP_NCTHZ_H             (KEY_DMP_NCTHY_H + 1)
-#define KEY_DMP_CTSQ_XH             (KEY_DMP_NCTHZ_H + 1)
-#define KEY_DMP_CTSQ_YH             (KEY_DMP_CTSQ_XH + 1)
-#define KEY_DMP_CTSQ_ZH             (KEY_DMP_CTSQ_YH + 1)
-#define KEY_DMP_INTX_H              (KEY_DMP_CTSQ_ZH + 1)
-#define KEY_DMP_INTY_H              (KEY_DMP_INTX_H + 1)
-#define KEY_DMP_INTZ_H              (KEY_DMP_INTY_H + 1)
-//#define KEY_DMP_HPX_H               (KEY_DMP_INTZ_H + 1)
-//#define KEY_DMP_HPY_H               (KEY_DMP_HPX_H + 1)
-//#define KEY_DMP_HPZ_H               (KEY_DMP_HPY_H + 1)
-
-/* Stream keys */
-#define KEY_STREAM_P_GYRO_Z         (KEY_DMP_INTZ_H + 1)
-#define KEY_STREAM_P_GYRO_Y         (KEY_STREAM_P_GYRO_Z + 1)
-#define KEY_STREAM_P_GYRO_X         (KEY_STREAM_P_GYRO_Y + 1)
-#define KEY_STREAM_P_TEMP           (KEY_STREAM_P_GYRO_X + 1)
-#define KEY_STREAM_P_AUX_Y          (KEY_STREAM_P_TEMP + 1)
-#define KEY_STREAM_P_AUX_X          (KEY_STREAM_P_AUX_Y + 1)
-#define KEY_STREAM_P_AUX_Z          (KEY_STREAM_P_AUX_X + 1)
-#define KEY_STREAM_P_ACCEL_Y        (KEY_STREAM_P_AUX_Z + 1)
-#define KEY_STREAM_P_ACCEL_X        (KEY_STREAM_P_ACCEL_Y + 1)
-#define KEY_STREAM_P_FOOTER         (KEY_STREAM_P_ACCEL_X + 1)
-#define KEY_STREAM_P_ACCEL_Z        (KEY_STREAM_P_FOOTER + 1)
-
-#define NUM_KEYS                    (KEY_STREAM_P_ACCEL_Z + 1)
-
-typedef struct {
-    unsigned short key;
-    unsigned short addr;
-} tKeyLabel;
-
-#define DINA0A 0x0a
-#define DINA22 0x22
-#define DINA42 0x42
-#define DINA5A 0x5a
-
-#define DINA06 0x06
-#define DINA0E 0x0e
-#define DINA16 0x16
-#define DINA1E 0x1e
-#define DINA26 0x26
-#define DINA2E 0x2e
-#define DINA36 0x36
-#define DINA3E 0x3e
-#define DINA46 0x46
-#define DINA4E 0x4e
-#define DINA56 0x56
-#define DINA5E 0x5e
-#define DINA66 0x66
-#define DINA6E 0x6e
-#define DINA76 0x76
-#define DINA7E 0x7e
-
-#define DINA00 0x00
-#define DINA08 0x08
-#define DINA10 0x10
-#define DINA18 0x18
-#define DINA20 0x20
-#define DINA28 0x28
-#define DINA30 0x30
-#define DINA38 0x38
-#define DINA40 0x40
-#define DINA48 0x48
-#define DINA50 0x50
-#define DINA58 0x58
-#define DINA60 0x60
-#define DINA68 0x68
-#define DINA70 0x70
-#define DINA78 0x78
-
-#define DINA04 0x04
-#define DINA0C 0x0c
-#define DINA14 0x14
-#define DINA1C 0x1C
-#define DINA24 0x24
-#define DINA2C 0x2c
-#define DINA34 0x34
-#define DINA3C 0x3c
-#define DINA44 0x44
-#define DINA4C 0x4c
-#define DINA54 0x54
-#define DINA5C 0x5c
-#define DINA64 0x64
-#define DINA6C 0x6c
-#define DINA74 0x74
-#define DINA7C 0x7c
-
-#define DINA01 0x01
-#define DINA09 0x09
-#define DINA11 0x11
-#define DINA19 0x19
-#define DINA21 0x21
-#define DINA29 0x29
-#define DINA31 0x31
-#define DINA39 0x39
-#define DINA41 0x41
-#define DINA49 0x49
-#define DINA51 0x51
-#define DINA59 0x59
-#define DINA61 0x61
-#define DINA69 0x69
-#define DINA71 0x71
-#define DINA79 0x79
-
-#define DINA25 0x25
-#define DINA2D 0x2d
-#define DINA35 0x35
-#define DINA3D 0x3d
-#define DINA4D 0x4d
-#define DINA55 0x55
-#define DINA5D 0x5D
-#define DINA6D 0x6d
-#define DINA75 0x75
-#define DINA7D 0x7d
-
-#define DINADC 0xdc
-#define DINAF2 0xf2
-#define DINAAB 0xab
-#define DINAAA 0xaa
-#define DINAF1 0xf1
-#define DINADF 0xdf
-#define DINADA 0xda
-#define DINAB1 0xb1
-#define DINAB9 0xb9
-#define DINAF3 0xf3
-#define DINA8B 0x8b
-#define DINAA3 0xa3
-#define DINA91 0x91
-#define DINAB6 0xb6
-#define DINAB4 0xb4
-
-
-#define DINC00 0x00
-#define DINC01 0x01
-#define DINC02 0x02
-#define DINC03 0x03
-#define DINC08 0x08
-#define DINC09 0x09
-#define DINC0A 0x0a
-#define DINC0B 0x0b
-#define DINC10 0x10
-#define DINC11 0x11
-#define DINC12 0x12
-#define DINC13 0x13
-#define DINC18 0x18
-#define DINC19 0x19
-#define DINC1A 0x1a
-#define DINC1B 0x1b
-
-#define DINC20 0x20
-#define DINC21 0x21
-#define DINC22 0x22
-#define DINC23 0x23
-#define DINC28 0x28
-#define DINC29 0x29
-#define DINC2A 0x2a
-#define DINC2B 0x2b
-#define DINC30 0x30
-#define DINC31 0x31
-#define DINC32 0x32
-#define DINC33 0x33
-#define DINC38 0x38
-#define DINC39 0x39
-#define DINC3A 0x3a
-#define DINC3B 0x3b
-
-#define DINC40 0x40
-#define DINC41 0x41
-#define DINC42 0x42
-#define DINC43 0x43
-#define DINC48 0x48
-#define DINC49 0x49
-#define DINC4A 0x4a
-#define DINC4B 0x4b
-#define DINC50 0x50
-#define DINC51 0x51
-#define DINC52 0x52
-#define DINC53 0x53
-#define DINC58 0x58
-#define DINC59 0x59
-#define DINC5A 0x5a
-#define DINC5B 0x5b
-
-#define DINC60 0x60
-#define DINC61 0x61
-#define DINC62 0x62
-#define DINC63 0x63
-#define DINC68 0x68
-#define DINC69 0x69
-#define DINC6A 0x6a
-#define DINC6B 0x6b
-#define DINC70 0x70
-#define DINC71 0x71
-#define DINC72 0x72
-#define DINC73 0x73
-#define DINC78 0x78
-#define DINC79 0x79
-#define DINC7A 0x7a
-#define DINC7B 0x7b
-
-#define DIND40 0x40
-
-
-#define DINA80 0x80
-#define DINA90 0x90
-#define DINAA0 0xa0
-#define DINAC9 0xc9
-#define DINACB 0xcb
-#define DINACD 0xcd
-#define DINACF 0xcf
-#define DINAC8 0xc8
-#define DINACA 0xca
-#define DINACC 0xcc
-#define DINACE 0xce
-#define DINAD8 0xd8
-#define DINADD 0xdd
-#define DINAF8 0xf0
-#define DINAFE 0xfe
-
-#define DINBF8 0xf8
-#define DINAC0 0xb0
-#define DINAC1 0xb1
-#define DINAC2 0xb4
-#define DINAC3 0xb5
-#define DINAC4 0xb8
-#define DINAC5 0xb9
-#define DINBC0 0xc0
-#define DINBC2 0xc2
-#define DINBC4 0xc4
-#define DINBC6 0xc6
-
-
-
-#endif // DMPKEY_H__

+ 0 - 264
Core - 副本/imu/dmpmap.h

@@ -1,264 +0,0 @@
-/*
- $License:
-    Copyright (C) 2011 InvenSense Corporation, All Rights Reserved.
- $
- */
-#ifndef DMPMAP_H
-#define DMPMAP_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define DMP_PTAT    0
-#define DMP_XGYR    2
-#define DMP_YGYR    4
-#define DMP_ZGYR    6
-#define DMP_XACC    8
-#define DMP_YACC    10
-#define DMP_ZACC    12
-#define DMP_ADC1    14
-#define DMP_ADC2    16
-#define DMP_ADC3    18
-#define DMP_BIASUNC    20
-#define DMP_FIFORT    22
-#define DMP_INVGSFH    24
-#define DMP_INVGSFL    26
-#define DMP_1H    28
-#define DMP_1L    30
-#define DMP_BLPFSTCH    32
-#define DMP_BLPFSTCL    34
-#define DMP_BLPFSXH    36
-#define DMP_BLPFSXL    38
-#define DMP_BLPFSYH    40
-#define DMP_BLPFSYL    42
-#define DMP_BLPFSZH    44
-#define DMP_BLPFSZL    46
-#define DMP_BLPFMTC    48
-#define DMP_SMC    50
-#define DMP_BLPFMXH    52
-#define DMP_BLPFMXL    54
-#define DMP_BLPFMYH    56
-#define DMP_BLPFMYL    58
-#define DMP_BLPFMZH    60
-#define DMP_BLPFMZL    62
-#define DMP_BLPFC    64
-#define DMP_SMCTH    66
-#define DMP_0H2    68
-#define DMP_0L2    70
-#define DMP_BERR2H    72
-#define DMP_BERR2L    74
-#define DMP_BERR2NH    76
-#define DMP_SMCINC    78
-#define DMP_ANGVBXH    80
-#define DMP_ANGVBXL    82
-#define DMP_ANGVBYH    84
-#define DMP_ANGVBYL    86
-#define DMP_ANGVBZH    88
-#define DMP_ANGVBZL    90
-#define DMP_BERR1H    92
-#define DMP_BERR1L    94
-#define DMP_ATCH    96
-#define DMP_BIASUNCSF    98
-#define DMP_ACT2H    100
-#define DMP_ACT2L    102
-#define DMP_GSFH    104
-#define DMP_GSFL    106
-#define DMP_GH    108
-#define DMP_GL    110
-#define DMP_0_5H    112
-#define DMP_0_5L    114
-#define DMP_0_0H    116
-#define DMP_0_0L    118
-#define DMP_1_0H    120
-#define DMP_1_0L    122
-#define DMP_1_5H    124
-#define DMP_1_5L    126
-#define DMP_TMP1AH    128
-#define DMP_TMP1AL    130
-#define DMP_TMP2AH    132
-#define DMP_TMP2AL    134
-#define DMP_TMP3AH    136
-#define DMP_TMP3AL    138
-#define DMP_TMP4AH    140
-#define DMP_TMP4AL    142
-#define DMP_XACCW    144
-#define DMP_TMP5    146
-#define DMP_XACCB    148
-#define DMP_TMP8    150
-#define DMP_YACCB    152
-#define DMP_TMP9    154
-#define DMP_ZACCB    156
-#define DMP_TMP10    158
-#define DMP_DZH    160
-#define DMP_DZL    162
-#define DMP_XGCH    164
-#define DMP_XGCL    166
-#define DMP_YGCH    168
-#define DMP_YGCL    170
-#define DMP_ZGCH    172
-#define DMP_ZGCL    174
-#define DMP_YACCW    176
-#define DMP_TMP7    178
-#define DMP_AFB1H    180
-#define DMP_AFB1L    182
-#define DMP_AFB2H    184
-#define DMP_AFB2L    186
-#define DMP_MAGFBH    188
-#define DMP_MAGFBL    190
-#define DMP_QT1H    192
-#define DMP_QT1L    194
-#define DMP_QT2H    196
-#define DMP_QT2L    198
-#define DMP_QT3H    200
-#define DMP_QT3L    202
-#define DMP_QT4H    204
-#define DMP_QT4L    206
-#define DMP_CTRL1H    208
-#define DMP_CTRL1L    210
-#define DMP_CTRL2H    212
-#define DMP_CTRL2L    214
-#define DMP_CTRL3H    216
-#define DMP_CTRL3L    218
-#define DMP_CTRL4H    220
-#define DMP_CTRL4L    222
-#define DMP_CTRLS1    224
-#define DMP_CTRLSF1    226
-#define DMP_CTRLS2    228
-#define DMP_CTRLSF2    230
-#define DMP_CTRLS3    232
-#define DMP_CTRLSFNLL    234
-#define DMP_CTRLS4    236
-#define DMP_CTRLSFNL2    238
-#define DMP_CTRLSFNL    240
-#define DMP_TMP30    242
-#define DMP_CTRLSFJT    244
-#define DMP_TMP31    246
-#define DMP_TMP11    248
-#define DMP_CTRLSF2_2    250
-#define DMP_TMP12    252
-#define DMP_CTRLSF1_2    254
-#define DMP_PREVPTAT    256
-#define DMP_ACCZB    258
-#define DMP_ACCXB    264
-#define DMP_ACCYB    266
-#define DMP_1HB    272
-#define DMP_1LB    274
-#define DMP_0H    276
-#define DMP_0L    278
-#define DMP_ASR22H    280
-#define DMP_ASR22L    282
-#define DMP_ASR6H    284
-#define DMP_ASR6L    286
-#define DMP_TMP13    288
-#define DMP_TMP14    290
-#define DMP_FINTXH    292
-#define DMP_FINTXL    294
-#define DMP_FINTYH    296
-#define DMP_FINTYL    298
-#define DMP_FINTZH    300
-#define DMP_FINTZL    302
-#define DMP_TMP1BH    304
-#define DMP_TMP1BL    306
-#define DMP_TMP2BH    308
-#define DMP_TMP2BL    310
-#define DMP_TMP3BH    312
-#define DMP_TMP3BL    314
-#define DMP_TMP4BH    316
-#define DMP_TMP4BL    318
-#define DMP_STXG    320
-#define DMP_ZCTXG    322
-#define DMP_STYG    324
-#define DMP_ZCTYG    326
-#define DMP_STZG    328
-#define DMP_ZCTZG    330
-#define DMP_CTRLSFJT2    332
-#define DMP_CTRLSFJTCNT    334
-#define DMP_PVXG    336
-#define DMP_TMP15    338
-#define DMP_PVYG    340
-#define DMP_TMP16    342
-#define DMP_PVZG    344
-#define DMP_TMP17    346
-#define DMP_MNMFLAGH    352
-#define DMP_MNMFLAGL    354
-#define DMP_MNMTMH    356
-#define DMP_MNMTML    358
-#define DMP_MNMTMTHRH    360
-#define DMP_MNMTMTHRL    362
-#define DMP_MNMTHRH    364
-#define DMP_MNMTHRL    366
-#define DMP_ACCQD4H    368
-#define DMP_ACCQD4L    370
-#define DMP_ACCQD5H    372
-#define DMP_ACCQD5L    374
-#define DMP_ACCQD6H    376
-#define DMP_ACCQD6L    378
-#define DMP_ACCQD7H    380
-#define DMP_ACCQD7L    382
-#define DMP_ACCQD0H    384
-#define DMP_ACCQD0L    386
-#define DMP_ACCQD1H    388
-#define DMP_ACCQD1L    390
-#define DMP_ACCQD2H    392
-#define DMP_ACCQD2L    394
-#define DMP_ACCQD3H    396
-#define DMP_ACCQD3L    398
-#define DMP_XN2H    400
-#define DMP_XN2L    402
-#define DMP_XN1H    404
-#define DMP_XN1L    406
-#define DMP_YN2H    408
-#define DMP_YN2L    410
-#define DMP_YN1H    412
-#define DMP_YN1L    414
-#define DMP_YH    416
-#define DMP_YL    418
-#define DMP_B0H    420
-#define DMP_B0L    422
-#define DMP_A1H    424
-#define DMP_A1L    426
-#define DMP_A2H    428
-#define DMP_A2L    430
-#define DMP_SEM1    432
-#define DMP_FIFOCNT    434
-#define DMP_SH_TH_X    436
-#define DMP_PACKET    438
-#define DMP_SH_TH_Y    440
-#define DMP_FOOTER    442
-#define DMP_SH_TH_Z    444
-#define DMP_TEMP29    448
-#define DMP_TEMP30    450
-#define DMP_XACCB_PRE    452
-#define DMP_XACCB_PREL    454
-#define DMP_YACCB_PRE    456
-#define DMP_YACCB_PREL    458
-#define DMP_ZACCB_PRE    460
-#define DMP_ZACCB_PREL    462
-#define DMP_TMP22    464
-#define DMP_TAP_TIMER    466
-#define DMP_TAP_THX    468
-#define DMP_TAP_THY    472
-#define DMP_TAP_THZ    476
-#define DMP_TAPW_MIN    478
-#define DMP_TMP25    480
-#define DMP_TMP26    482
-#define DMP_TMP27    484
-#define DMP_TMP28    486
-#define DMP_ORIENT    488
-#define DMP_THRSH    490
-#define DMP_ENDIANH    492
-#define DMP_ENDIANL    494
-#define DMP_BLPFNMTCH    496
-#define DMP_BLPFNMTCL    498
-#define DMP_BLPFNMXH    500
-#define DMP_BLPFNMXL    502
-#define DMP_BLPFNMYH    504
-#define DMP_BLPFNMYL    506
-#define DMP_BLPFNMZH    508
-#define DMP_BLPFNMZL    510
-#ifdef __cplusplus
-}
-#endif
-#endif // DMPMAP_H

+ 0 - 2921
Core - 副本/imu/inv_mpu.c

@@ -1,2921 +0,0 @@
-/*
- $License:
-    Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved.
-    See included License.txt for License information.
- $
- */
-/**
- *  @addtogroup  DRIVERS Sensor Driver Layer
- *  @brief       Hardware drivers to communicate with sensors via I2C.
- *
- *  @{
- *      @file       inv_mpu.c
- *      @brief      An I2C-based driver for Invensense gyroscopes.
- *      @details    This driver currently works for the following devices:
- *                  MPU6050
- *                  MPU6500
- *                  MPU9150 (or MPU6050 w/ AK8975 on the auxiliary bus)
- *                  MPU9250 (or MPU6500 w/ AK8963 on the auxiliary bus)
- */
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include "inv_mpu.h"
-
-#include "MPU6050.h"
-int a1 = 0x68, b1 = 0x69;
-
-/* The following functions must be defined for this platform:
- * i2c_write(unsigned char slave_addr, unsigned char reg_addr,
- *      unsigned char length, unsigned char const *data)
- * i2c_read(unsigned char slave_addr, unsigned char reg_addr,
- *      unsigned char length, unsigned char *data)
- * delay_ms(unsigned long num_ms)
- * get_ms(unsigned long *count)
- * reg_int_cb(void (*cb)(void), unsigned char port, unsigned char pin)
- * labs(long x)
- * fabsf(float x)
- * min(int a, int b)
- */
-#if defined MOTION_DRIVER_TARGET_MSP430
-#include "msp430.h"
-#include "msp430_i2c.h"
-#include "msp430_clock.h"
-#include "msp430_interrupt.h"
-#define i2c_write msp430_i2c_write
-#define i2c_read msp430_i2c_read
-#define delay_ms msp430_delay_ms
-#define get_ms msp430_get_clock_ms
-static inline int reg_int_cb(struct int_param_s *int_param)
-{
-    return msp430_reg_int_cb(int_param->cb, int_param->pin, int_param->lp_exit,
-                             int_param->active_low);
-}
-#define log_i(...) \
-    do             \
-    {              \
-    } while (0)
-#define log_e(...) \
-    do             \
-    {              \
-    } while (0)
-/* labs is already defined by TI's toolchain. */
-/* fabs is for doubles. fabsf is for floats. */
-#define fabs fabsf
-#define min(a, b) ((a < b) ? a : b)
-#elif defined EMPL_TARGET_MSP430
-#include "msp430.h"
-#include "msp430_i2c.h"
-#include "msp430_clock.h"
-#include "msp430_interrupt.h"
-#include "log.h"
-#define i2c_write msp430_i2c_write
-#define i2c_read msp430_i2c_read
-#define delay_ms msp430_delay_ms
-#define get_ms msp430_get_clock_ms
-static inline int reg_int_cb(struct int_param_s *int_param)
-{
-    return msp430_reg_int_cb(int_param->cb, int_param->pin, int_param->lp_exit,
-                             int_param->active_low);
-}
-#define log_i MPL_LOGI
-#define log_e MPL_LOGE
-/* labs is already defined by TI's toolchain. */
-/* fabs is for doubles. fabsf is for floats. */
-#define fabs fabsf
-#define min(a, b) ((a < b) ? a : b)
-#elif defined EMPL_TARGET_UC3L0
-/* Instead of using the standard TWI driver from the ASF library, we're using
- * a TWI driver that follows the slave address + register address convention.
- */
-#include "twi.h"
-#include "delay.h"
-#include "sysclk.h"
-#include "log.h"
-#include "sensors_xplained.h"
-#include "uc3l0_clock.h"
-#define i2c_write(a, b, c, d) twi_write(a, b, d, c)
-#define i2c_read(a, b, c, d) twi_read(a, b, d, c)
-/* delay_ms is a function already defined in ASF. */
-#define get_ms uc3l0_get_clock_ms
-static inline int reg_int_cb(struct int_param_s *int_param)
-{
-    sensor_board_irq_connect(int_param->pin, int_param->cb, int_param->arg);
-    return 0;
-}
-#define log_i MPL_LOGI
-#define log_e MPL_LOGE
-/* UC3 is a 32-bit processor, so abs and labs are equivalent. */
-#define labs abs
-#define fabs(x) (((x) > 0) ? (x) : -(x))
-#elif defined MOTION_DRIVER_TARGET_STM32
-
-/* The following functions must be defined for this platform:
- * i2c_write(unsigned char slave_addr, unsigned char reg_addr,
- *      unsigned char length, unsigned char const *data)
- * i2c_read(unsigned char slave_addr, unsigned char reg_addr,
- *      unsigned char length, unsigned char *data)
- * delay_ms(unsigned long num_ms)
- * get_ms(unsigned long *count)
- * reg_int_cb(void (*cb)(void), unsigned char port, unsigned char pin)
- * labs(long x)
- * fabsf(float x)
- * min(int a, int b)
- */
-#define i2c_write1 IIC_Write_Len1
-#define i2c_read1 IIC_Read_Len1
-#define i2c_write IIC_Write_Len
-#define i2c_read IIC_Read_Len
-#define delay_ms HAL_Delay
-#define get_ms get_tick_count
-// static inline int reg_int_cb(struct int_param_s *int_param)
-//{
-////    return msp430_reg_int_cb(int_param->cb, int_param->pin, int_param->lp_exit,
-////        int_param->active_low);
-//}
-// #define log_i(...)     do {} while (0)
-// #define log_e(...)     do {} while (0)
-
-#define log_i printf
-#define log_e printf
-
-/* labs is already defined by TI's toolchain. */
-/* fabs is for doubles. fabsf is for floats. */
-#define fabs fabsf
-#define min(a, b) ((a < b) ? a : b)
-
-#else
-#error Gyro driver is missing the system layer implementations.
-#endif
-
-#if !defined MPU6050 && !defined MPU9150 && !defined MPU6500 && !defined MPU9250
-#error Which gyro are you using? Define MPUxxxx in your compiler options.
-#endif
-
-/* Time for some messy macro work. =]
- * #define MPU9150
- * is equivalent to..
- * #define MPU6050
- * #define AK8975_SECONDARY
- *
- * #define MPU9250
- * is equivalent to..
- * #define MPU6500
- * #define AK8963_SECONDARY
- */
-#if defined MPU9150
-#ifndef MPU6050
-#define MPU6050
-#endif /* #ifndef MPU6050 */
-#if defined AK8963_SECONDARY
-#error "MPU9150 and AK8963_SECONDARY cannot both be defined."
-#elif !defined AK8975_SECONDARY /* #if defined AK8963_SECONDARY */
-#define AK8975_SECONDARY
-#endif                /* #if defined AK8963_SECONDARY */
-#elif defined MPU9250 /* #if defined MPU9150 */
-#ifndef MPU6500
-#define MPU6500
-#endif /* #ifndef MPU6500 */
-#if defined AK8975_SECONDARY
-#error "MPU9250 and AK8975_SECONDARY cannot both be defined."
-#elif !defined AK8963_SECONDARY /* #if defined AK8975_SECONDARY */
-#define AK8963_SECONDARY
-#endif /* #if defined AK8975_SECONDARY */
-#endif /* #if defined MPU9150 */
-
-#if defined AK8975_SECONDARY || defined AK8963_SECONDARY
-#define AK89xx_SECONDARY
-#else
-/* #warning "No compass = less profit for Invensense. Lame." */
-#endif
-
-static int set_int_enable(unsigned char enable);
-
-/* Hardware registers needed by driver. */
-struct gyro_reg_s
-{
-    unsigned char who_am_i;
-    unsigned char rate_div;
-    unsigned char lpf;
-    unsigned char prod_id;
-    unsigned char user_ctrl;
-    unsigned char fifo_en;
-    unsigned char gyro_cfg;
-    unsigned char accel_cfg;
-    unsigned char accel_cfg2;
-    unsigned char lp_accel_odr;
-    unsigned char motion_thr;
-    unsigned char motion_dur;
-    unsigned char fifo_count_h;
-    unsigned char fifo_r_w;
-    unsigned char raw_gyro;
-    unsigned char raw_accel;
-    unsigned char temp;
-    unsigned char int_enable;
-    unsigned char dmp_int_status;
-    unsigned char int_status;
-    unsigned char accel_intel;
-    unsigned char pwr_mgmt_1;
-    unsigned char pwr_mgmt_2;
-    unsigned char int_pin_cfg;
-    unsigned char mem_r_w;
-    unsigned char accel_offs;
-    unsigned char i2c_mst;
-    unsigned char bank_sel;
-    unsigned char mem_start_addr;
-    unsigned char prgm_start_h;
-#if defined AK89xx_SECONDARY
-    unsigned char s0_addr;
-    unsigned char s0_reg;
-    unsigned char s0_ctrl;
-    unsigned char s1_addr;
-    unsigned char s1_reg;
-    unsigned char s1_ctrl;
-    unsigned char s4_ctrl;
-    unsigned char s0_do;
-    unsigned char s1_do;
-    unsigned char i2c_delay_ctrl;
-    unsigned char raw_compass;
-    /* The I2C_MST_VDDIO bit is in this register. */
-    unsigned char yg_offs_tc;
-#endif
-};
-
-/* Information specific to a particular device. */
-struct hw_s
-{
-    unsigned char addr;
-    unsigned short max_fifo;
-    unsigned char num_reg;
-    unsigned short temp_sens;
-    short temp_offset;
-    unsigned short bank_size;
-#if defined AK89xx_SECONDARY
-    unsigned short compass_fsr;
-#endif
-};
-
-/* When entering motion interrupt mode, the driver keeps track of the
- * previous state so that it can be restored at a later time.
- * TODO: This is tacky. Fix it.
- */
-struct motion_int_cache_s
-{
-    unsigned short gyro_fsr;
-    unsigned char accel_fsr;
-    unsigned short lpf;
-    unsigned short sample_rate;
-    unsigned char sensors_on;
-    unsigned char fifo_sensors;
-    unsigned char dmp_on;
-};
-
-/* Cached chip configuration data.
- * TODO: A lot of these can be handled with a bitmask.
- */
-struct chip_cfg_s
-{
-    /* Matches gyro_cfg >> 3 & 0x03 */
-    unsigned char gyro_fsr;
-    /* Matches accel_cfg >> 3 & 0x03 */
-    unsigned char accel_fsr;
-    /* Enabled sensors. Uses same masks as fifo_en, NOT pwr_mgmt_2. */
-    unsigned char sensors;
-    /* Matches config register. */
-    unsigned char lpf;
-    unsigned char clk_src;
-    /* Sample rate, NOT rate divider. */
-    unsigned short sample_rate;
-    /* Matches fifo_en register. */
-    unsigned char fifo_enable;
-    /* Matches int enable register. */
-    unsigned char int_enable;
-    /* 1 if devices on auxiliary I2C bus appear on the primary. */
-    unsigned char bypass_mode;
-    /* 1 if half-sensitivity.
-     * NOTE: This doesn't belong here, but everything else in hw_s is const,
-     * and this allows us to save some precious RAM.
-     */
-    unsigned char accel_half;
-    /* 1 if device in low-power accel-only mode. */
-    unsigned char lp_accel_mode;
-    /* 1 if interrupts are only triggered on motion events. */
-    unsigned char int_motion_only;
-    struct motion_int_cache_s cache;
-    /* 1 for active low interrupts. */
-    unsigned char active_low_int;
-    /* 1 for latched interrupts. */
-    unsigned char latched_int;
-    /* 1 if DMP is enabled. */
-    unsigned char dmp_on;
-    /* Ensures that DMP will only be loaded once. */
-    unsigned char dmp_loaded;
-    /* Sampling rate used when DMP is enabled. */
-    unsigned short dmp_sample_rate;
-#ifdef AK89xx_SECONDARY
-    /* Compass sample rate. */
-    unsigned short compass_sample_rate;
-    unsigned char compass_addr;
-    short mag_sens_adj[3];
-#endif
-};
-
-/* Information for self-test. */
-struct test_s
-{
-    unsigned long gyro_sens;
-    unsigned long accel_sens;
-    unsigned char reg_rate_div;
-    unsigned char reg_lpf;
-    unsigned char reg_gyro_fsr;
-    unsigned char reg_accel_fsr;
-    unsigned short wait_ms;
-    unsigned char packet_thresh;
-    float min_dps;
-    float max_dps;
-    float max_gyro_var;
-    float min_g;
-    float max_g;
-    float max_accel_var;
-};
-
-/* Gyro driver state variables. */
-struct gyro_state_s
-{
-    const struct gyro_reg_s *reg;
-    const struct hw_s *hw;
-    struct chip_cfg_s chip_cfg;
-    const struct test_s *test;
-};
-
-/* Filter configurations. */
-enum lpf_e
-{
-    INV_FILTER_256HZ_NOLPF2 = 0,
-    INV_FILTER_188HZ,
-    INV_FILTER_98HZ,
-    INV_FILTER_42HZ,
-    INV_FILTER_20HZ,
-    INV_FILTER_10HZ,
-    INV_FILTER_5HZ,
-    INV_FILTER_2100HZ_NOLPF,
-    NUM_FILTER
-};
-
-/* Full scale ranges. */
-enum gyro_fsr_e
-{
-    INV_FSR_250DPS = 0,
-    INV_FSR_500DPS,
-    INV_FSR_1000DPS,
-    INV_FSR_2000DPS,
-    NUM_GYRO_FSR
-};
-
-/* Full scale ranges. */
-enum accel_fsr_e
-{
-    INV_FSR_2G = 0,
-    INV_FSR_4G,
-    INV_FSR_8G,
-    INV_FSR_16G,
-    NUM_ACCEL_FSR
-};
-
-/* Clock sources. */
-enum clock_sel_e
-{
-    INV_CLK_INTERNAL = 0,
-    INV_CLK_PLL,
-    NUM_CLK
-};
-
-/* Low-power accel wakeup rates. */
-enum lp_accel_rate_e
-{
-#if defined MPU6050
-    INV_LPA_1_25HZ,
-    INV_LPA_5HZ,
-    INV_LPA_20HZ,
-    INV_LPA_40HZ
-#elif defined MPU6500
-    INV_LPA_0_3125HZ,
-    INV_LPA_0_625HZ,
-    INV_LPA_1_25HZ,
-    INV_LPA_2_5HZ,
-    INV_LPA_5HZ,
-    INV_LPA_10HZ,
-    INV_LPA_20HZ,
-    INV_LPA_40HZ,
-    INV_LPA_80HZ,
-    INV_LPA_160HZ,
-    INV_LPA_320HZ,
-    INV_LPA_640HZ
-#endif
-};
-
-#define BIT_I2C_MST_VDDIO (0x80)
-#define BIT_FIFO_EN (0x40)
-#define BIT_DMP_EN (0x80)
-#define BIT_FIFO_RST (0x04)
-#define BIT_DMP_RST (0x08)
-#define BIT_FIFO_OVERFLOW (0x10)
-#define BIT_DATA_RDY_EN (0x01)
-#define BIT_DMP_INT_EN (0x02)
-#define BIT_MOT_INT_EN (0x40)
-#define BITS_FSR (0x18)
-#define BITS_LPF (0x07)
-#define BITS_HPF (0x07)
-#define BITS_CLK (0x07)
-#define BIT_FIFO_SIZE_1024 (0x40)
-#define BIT_FIFO_SIZE_2048 (0x80)
-#define BIT_FIFO_SIZE_4096 (0xC0)
-#define BIT_RESET (0x80)
-#define BIT_SLEEP (0x40)
-#define BIT_S0_DELAY_EN (0x01)
-#define BIT_S2_DELAY_EN (0x04)
-#define BITS_SLAVE_LENGTH (0x0F)
-#define BIT_SLAVE_BYTE_SW (0x40)
-#define BIT_SLAVE_GROUP (0x10)
-#define BIT_SLAVE_EN (0x80)
-#define BIT_I2C_READ (0x80)
-#define BITS_I2C_MASTER_DLY (0x1F)
-#define BIT_AUX_IF_EN (0x20)
-#define BIT_ACTL (0x80)
-#define BIT_LATCH_EN (0x20)
-#define BIT_ANY_RD_CLR (0x10)
-#define BIT_BYPASS_EN (0x02)
-#define BITS_WOM_EN (0xC0)
-#define BIT_LPA_CYCLE (0x20)
-#define BIT_STBY_XA (0x20)
-#define BIT_STBY_YA (0x10)
-#define BIT_STBY_ZA (0x08)
-#define BIT_STBY_XG (0x04)
-#define BIT_STBY_YG (0x02)
-#define BIT_STBY_ZG (0x01)
-#define BIT_STBY_XYZA (BIT_STBY_XA | BIT_STBY_YA | BIT_STBY_ZA)
-#define BIT_STBY_XYZG (BIT_STBY_XG | BIT_STBY_YG | BIT_STBY_ZG)
-
-#if defined AK8975_SECONDARY
-#define SUPPORTS_AK89xx_HIGH_SENS (0x00)
-#define AK89xx_FSR (9830)
-#elif defined AK8963_SECONDARY
-#define SUPPORTS_AK89xx_HIGH_SENS (0x10)
-#define AK89xx_FSR (4915)
-#endif
-
-#ifdef AK89xx_SECONDARY
-#define AKM_REG_WHOAMI (0x00)
-
-#define AKM_REG_ST1 (0x02)
-#define AKM_REG_HXL (0x03)
-#define AKM_REG_ST2 (0x09)
-
-#define AKM_REG_CNTL (0x0A)
-#define AKM_REG_ASTC (0x0C)
-#define AKM_REG_ASAX (0x10)
-#define AKM_REG_ASAY (0x11)
-#define AKM_REG_ASAZ (0x12)
-
-#define AKM_DATA_READY (0x01)
-#define AKM_DATA_OVERRUN (0x02)
-#define AKM_OVERFLOW (0x80)
-#define AKM_DATA_ERROR (0x40)
-
-#define AKM_BIT_SELF_TEST (0x40)
-
-#define AKM_POWER_DOWN (0x00 | SUPPORTS_AK89xx_HIGH_SENS)
-#define AKM_SINGLE_MEASUREMENT (0x01 | SUPPORTS_AK89xx_HIGH_SENS)
-#define AKM_FUSE_ROM_ACCESS (0x0F | SUPPORTS_AK89xx_HIGH_SENS)
-#define AKM_MODE_SELF_TEST (0x08 | SUPPORTS_AK89xx_HIGH_SENS)
-
-#define AKM_WHOAMI (0x48)
-#endif
-
-#if defined MPU6050
-const struct gyro_reg_s reg = {
-    .who_am_i = 0x75,
-    .rate_div = 0x19,
-    .lpf = 0x1A,
-    .prod_id = 0x0C,
-    .user_ctrl = 0x6A,
-    .fifo_en = 0x23,
-    .gyro_cfg = 0x1B,
-    .accel_cfg = 0x1C,
-    .motion_thr = 0x1F,
-    .motion_dur = 0x20,
-    .fifo_count_h = 0x72,
-    .fifo_r_w = 0x74,
-    .raw_gyro = 0x43,
-    .raw_accel = 0x3B,
-    .temp = 0x41,
-    .int_enable = 0x38,
-    .dmp_int_status = 0x39,
-    .int_status = 0x3A,
-    .pwr_mgmt_1 = 0x6B,
-    .pwr_mgmt_2 = 0x6C,
-    .int_pin_cfg = 0x37,
-    .mem_r_w = 0x6F,
-    .accel_offs = 0x06,
-    .i2c_mst = 0x24,
-    .bank_sel = 0x6D,
-    .mem_start_addr = 0x6E,
-    .prgm_start_h = 0x70
-#ifdef AK89xx_SECONDARY
-    ,
-    .raw_compass = 0x49,
-    .yg_offs_tc = 0x01,
-    .s0_addr = 0x25,
-    .s0_reg = 0x26,
-    .s0_ctrl = 0x27,
-    .s1_addr = 0x28,
-    .s1_reg = 0x29,
-    .s1_ctrl = 0x2A,
-    .s4_ctrl = 0x34,
-    .s0_do = 0x63,
-    .s1_do = 0x64,
-    .i2c_delay_ctrl = 0x67
-#endif
-};
-const struct hw_s hw = {
-    .addr = 0x68,
-    .max_fifo = 1024,
-    .num_reg = 118,
-    .temp_sens = 340,
-    .temp_offset = -521,
-    .bank_size = 256
-#if defined AK89xx_SECONDARY
-    ,
-    .compass_fsr = AK89xx_FSR
-#endif
-};
-
-const struct test_s test = {
-    .gyro_sens = 32768 / 250,
-    .accel_sens = 32768 / 16,
-    .reg_rate_div = 0,     /* 1kHz. */
-    .reg_lpf = 1,          /* 188Hz. */
-    .reg_gyro_fsr = 0,     /* 250dps. */
-    .reg_accel_fsr = 0x18, /* 16g. */
-    .wait_ms = 50,
-    .packet_thresh = 5, /* 5% */
-    .min_dps = 10.f,
-    .max_dps = 105.f,
-    .max_gyro_var = 0.14f,
-    .min_g = 0.3f,
-    .max_g = 0.95f,
-    .max_accel_var = 0.14f};
-
-static struct gyro_state_s st = {
-    .reg = &reg,
-    .hw = &hw,
-    .test = &test};
-#elif defined MPU6500
-const struct gyro_reg_s reg = {
-    .who_am_i = 0x75,
-    .rate_div = 0x19,
-    .lpf = 0x1A,
-    .prod_id = 0x0C,
-    .user_ctrl = 0x6A,
-    .fifo_en = 0x23,
-    .gyro_cfg = 0x1B,
-    .accel_cfg = 0x1C,
-    .accel_cfg2 = 0x1D,
-    .lp_accel_odr = 0x1E,
-    .motion_thr = 0x1F,
-    .motion_dur = 0x20,
-    .fifo_count_h = 0x72,
-    .fifo_r_w = 0x74,
-    .raw_gyro = 0x43,
-    .raw_accel = 0x3B,
-    .temp = 0x41,
-    .int_enable = 0x38,
-    .dmp_int_status = 0x39,
-    .int_status = 0x3A,
-    .accel_intel = 0x69,
-    .pwr_mgmt_1 = 0x6B,
-    .pwr_mgmt_2 = 0x6C,
-    .int_pin_cfg = 0x37,
-    .mem_r_w = 0x6F,
-    .accel_offs = 0x77,
-    .i2c_mst = 0x24,
-    .bank_sel = 0x6D,
-    .mem_start_addr = 0x6E,
-    .prgm_start_h = 0x70
-#ifdef AK89xx_SECONDARY
-    ,
-    .raw_compass = 0x49,
-    .s0_addr = 0x25,
-    .s0_reg = 0x26,
-    .s0_ctrl = 0x27,
-    .s1_addr = 0x28,
-    .s1_reg = 0x29,
-    .s1_ctrl = 0x2A,
-    .s4_ctrl = 0x34,
-    .s0_do = 0x63,
-    .s1_do = 0x64,
-    .i2c_delay_ctrl = 0x67
-#endif
-};
-const struct hw_s hw = {
-    .addr = 0x68,
-    .max_fifo = 1024,
-    .num_reg = 128,
-    .temp_sens = 321,
-    .temp_offset = 0,
-    .bank_size = 256
-#if defined AK89xx_SECONDARY
-    ,
-    .compass_fsr = AK89xx_FSR
-#endif
-};
-
-const struct test_s test = {
-    .gyro_sens = 32768 / 250,
-    .accel_sens = 32768 / 16,
-    .reg_rate_div = 0,     /* 1kHz. */
-    .reg_lpf = 1,          /* 188Hz. */
-    .reg_gyro_fsr = 0,     /* 250dps. */
-    .reg_accel_fsr = 0x18, /* 16g. */
-    .wait_ms = 50,
-    .packet_thresh = 5, /* 5% */
-    .min_dps = 10.f,
-    .max_dps = 105.f,
-    .max_gyro_var = 0.14f,
-    .min_g = 0.3f,
-    .max_g = 0.95f,
-    .max_accel_var = 0.14f};
-
-static struct gyro_state_s st = {
-    .reg = &reg,
-    .hw = &hw,
-    .test = &test};
-#endif
-
-#define MAX_PACKET_LENGTH (12)
-
-#ifdef AK89xx_SECONDARY
-static int setup_compass(void);
-#define MAX_COMPASS_SAMPLE_RATE (100)
-#endif
-
-/**
- *  @brief      Enable/disable data ready interrupt.
- *  If the DMP is on, the DMP interrupt is enabled. Otherwise, the data ready
- *  interrupt is used.
- *  @param[in]  enable      1 to enable interrupt.
- *  @return     0 if successful.
- */
-static int set_int_enable(unsigned char enable)
-{
-    unsigned char tmp;
-
-    if (st.chip_cfg.dmp_on)
-    {
-        if (enable)
-            tmp = BIT_DMP_INT_EN;
-        else
-            tmp = 0x00;
-        if (i2c_write(a1, st.reg->int_enable, 1, &tmp) && i2c_write(b1, st.reg->int_enable, 1, &tmp))
-            return -1;
-        st.chip_cfg.int_enable = tmp;
-    }
-    else
-    {
-        if (!st.chip_cfg.sensors)
-            return -1;
-        if (enable && st.chip_cfg.int_enable)
-            return 0;
-        if (enable)
-            tmp = BIT_DATA_RDY_EN;
-        else
-            tmp = 0x00;
-        if (i2c_write(a1, st.reg->int_enable, 1, &tmp) && i2c_write(b1, st.reg->int_enable, 1, &tmp))
-            return -1;
-        st.chip_cfg.int_enable = tmp;
-    }
-    return 0;
-}
-
-/**
- *  @brief      Register dump for testing.
- *  @return     0 if successful.
- */
-int mpu_reg_dump(void)
-{
-    unsigned char ii;
-    unsigned char data;
-
-    for (ii = 0; ii < st.hw->num_reg; ii++)
-    {
-        if (ii == st.reg->fifo_r_w || ii == st.reg->mem_r_w)
-            continue;
-        if (i2c_read(a1, ii, 1, &data) && i2c_write(b1, ii, 1, &data))
-            return -1;
-        log_i("%#5x: %#5x\r\n", ii, data);
-    }
-    return 0;
-}
-
-/**
- *  @brief      Read from a single register.
- *  NOTE: The memory and FIFO read/write registers cannot be accessed.
- *  @param[in]  reg     Register address.
- *  @param[out] data    Register data.
- *  @return     0 if successful.
- */
-int mpu_read_reg(unsigned char reg, unsigned char *data)
-{
-    if (reg == st.reg->fifo_r_w || reg == st.reg->mem_r_w)
-        return -1;
-    if (reg >= st.hw->num_reg)
-        return -1;
-    return i2c_read(a, reg, 1, data);
-}
-
-/**
- *  @brief      Initialize hardware.
- *  Initial configuration:\n
- *  Gyro FSR: +/- 2000DPS\n
- *  Accel FSR +/- 2G\n
- *  DLPF: 42Hz\n
- *  FIFO rate: 50Hz\n
- *  Clock source: Gyro PLL\n
- *  FIFO: Disabled.\n
- *  Data ready interrupt: Disabled, active low, unlatched.
- *  @param[in]  int_param   Platform-specific parameters to interrupt API.
- *  @return     0 if successful.
- */
-int mpu_init(struct int_param_s *int_param)
-{
-    unsigned char data[6], rev;
-
-    /* Reset device. */
-    data[0] = BIT_RESET;
-    if (i2c_write1(a1, st.reg->pwr_mgmt_1, 1, data) && i2c_write1(b1, st.reg->pwr_mgmt_1, 1, data))
-        return -1;
-    delay_ms(100);
-
-    /* Wake up chip. */
-    data[0] = 0x00;
-    if (i2c_write1(a1, st.reg->pwr_mgmt_1, 1, data) && i2c_write1(b1, st.reg->pwr_mgmt_1, 1, data))
-        return -1;
-
-#if defined MPU6050
-    /* Check product revision. */
-    if (i2c_read1(a1, st.reg->pwr_mgmt_1, 1, data) && i2c_read1(b1, st.reg->pwr_mgmt_1, 1, data))
-        return -1;
-    rev = ((data[5] & 0x01) << 2) | ((data[3] & 0x01) << 1) |
-          (data[1] & 0x01);
-
-    if (rev)
-    {
-        /* Congrats, these parts are better. */
-        if (rev == 1)
-            st.chip_cfg.accel_half = 1;
-        else if (rev == 2)
-            st.chip_cfg.accel_half = 0;
-        else
-        {
-            log_e("Unsupported software product rev %d.\n", rev);
-            return -1;
-        }
-    }
-    else
-    {
-        if (i2c_read1(a1, st.reg->prod_id, 1, data) && i2c_read1(b1, st.reg->prod_id, 1, data))
-            return -1;
-        rev = data[0] & 0x0F;
-        if (!rev)
-        {
-            log_e("Product ID read as 0 indicates device is either "
-                  "incompatible or an MPU3050.\n");
-            return -1;
-        }
-        else if (rev == 4)
-        {
-            log_i("Half sensitivity part found.\n");
-            st.chip_cfg.accel_half = 1;
-        }
-        else
-            st.chip_cfg.accel_half = 0;
-    }
-#elif defined MPU6500
-#define MPU6500_MEM_REV_ADDR (0x17)
-    if (mpu_read_mem(MPU6500_MEM_REV_ADDR, 1, &rev))
-        return -1;
-    if (rev == 0x1)
-        st.chip_cfg.accel_half = 0;
-    else
-    {
-        log_e("Unsupported software product rev %d.\n", rev);
-        return -1;
-    }
-
-    /* MPU6500 shares 4kB of memory between the DMP and the FIFO. Since the
-     * first 3kB are needed by the DMP, we'll use the last 1kB for the FIFO.
-     */
-    data[0] = BIT_FIFO_SIZE_1024 | 0x8;
-    if (i2c_write(a, st.reg->accel_cfg2, 1, data))
-        return -1;
-#endif
-
-    /* Set to invalid values to ensure no I2C writes are skipped. */
-    st.chip_cfg.sensors = 0xFF;
-    st.chip_cfg.gyro_fsr = 0xFF;
-    st.chip_cfg.accel_fsr = 0xFF;
-    st.chip_cfg.lpf = 0xFF;
-    st.chip_cfg.sample_rate = 0xFFFF;
-    st.chip_cfg.fifo_enable = 0xFF;
-    st.chip_cfg.bypass_mode = 0xFF;
-#ifdef AK89xx_SECONDARY
-    st.chip_cfg.compass_sample_rate = 0xFFFF;
-#endif
-    /* mpu_set_sensors always preserves this setting. */
-    st.chip_cfg.clk_src = INV_CLK_PLL;
-    /* Handled in next call to mpu_set_bypass. */
-    st.chip_cfg.active_low_int = 1;
-    st.chip_cfg.latched_int = 0;
-    st.chip_cfg.int_motion_only = 0;
-    st.chip_cfg.lp_accel_mode = 0;
-    memset(&st.chip_cfg.cache, 0, sizeof(st.chip_cfg.cache));
-    st.chip_cfg.dmp_on = 0;
-    st.chip_cfg.dmp_loaded = 0;
-    st.chip_cfg.dmp_sample_rate = 0;
-
-    if (mpu_set_gyro_fsr(2000))
-        return -1;
-    if (mpu_set_accel_fsr(2))
-        return -1;
-    if (mpu_set_lpf(42))
-        return -1;
-    if (mpu_set_sample_rate(50))
-        return -1;
-    if (mpu_configure_fifo(0))
-        return -1;
-
-#ifndef MOTION_DRIVER_TARGET_STM32
-    if (int_param)
-        reg_int_cb(int_param);
-#endif
-
-#ifdef AK89xx_SECONDARY
-    setup_compass();
-    if (mpu_set_compass_sample_rate(10))
-        return -1;
-#else
-    /* Already disabled by setup_compass. */
-    if (mpu_set_bypass(0))
-        return -1;
-#endif
-
-    mpu_set_sensors(0);
-    return 0;
-}
-
-/**
- *  @brief      Enter low-power accel-only mode.
- *  In low-power accel mode, the chip goes to sleep and only wakes up to sample
- *  the accelerometer at one of the following frequencies:
- *  \n MPU6050: 1.25Hz, 5Hz, 20Hz, 40Hz
- *  \n MPU6500: 1.25Hz, 2.5Hz, 5Hz, 10Hz, 20Hz, 40Hz, 80Hz, 160Hz, 320Hz, 640Hz
- *  \n If the requested rate is not one listed above, the device will be set to
- *  the next highest rate. Requesting a rate above the maximum supported
- *  frequency will result in an error.
- *  \n To select a fractional wake-up frequency, round down the value passed to
- *  @e rate.
- *  @param[in]  rate        Minimum sampling rate, or zero to disable LP
- *                          accel mode.
- *  @return     0 if successful.
- */
-int mpu_lp_accel_mode(unsigned char rate)
-{
-    unsigned char tmp[2];
-
-    if (rate > 40)
-        return -1;
-
-    if (!rate)
-    {
-        mpu_set_int_latched(0);
-        tmp[0] = 0;
-        tmp[1] = BIT_STBY_XYZG;
-        if (i2c_write1(a1, st.reg->pwr_mgmt_1, 2, tmp) && i2c_write1(b1, st.reg->pwr_mgmt_1, 2, tmp))
-            return -1;
-        st.chip_cfg.lp_accel_mode = 0;
-        return 0;
-    }
-    /* For LP accel, we automatically configure the hardware to produce latched
-     * interrupts. In LP accel mode, the hardware cycles into sleep mode before
-     * it gets a chance to deassert the interrupt pin; therefore, we shift this
-     * responsibility over to the MCU.
-     *
-     * Any register read will clear the interrupt.
-     */
-    mpu_set_int_latched(1);
-#if defined MPU6050
-    tmp[0] = BIT_LPA_CYCLE;
-    if (rate == 1)
-    {
-        tmp[1] = INV_LPA_1_25HZ;
-        mpu_set_lpf(5);
-    }
-    else if (rate <= 5)
-    {
-        tmp[1] = INV_LPA_5HZ;
-        mpu_set_lpf(5);
-    }
-    else if (rate <= 20)
-    {
-        tmp[1] = INV_LPA_20HZ;
-        mpu_set_lpf(10);
-    }
-    else
-    {
-        tmp[1] = INV_LPA_40HZ;
-        mpu_set_lpf(20);
-    }
-    tmp[1] = (tmp[1] << 6) | BIT_STBY_XYZG;
-    if (i2c_write(a1, st.reg->pwr_mgmt_1, 2, tmp) && i2c_write(b1, st.reg->pwr_mgmt_1, 2, tmp))
-        return -1;
-#elif defined MPU6500
-    /* Set wake frequency. */
-    if (rate == 1)
-        tmp[0] = INV_LPA_1_25HZ;
-    else if (rate == 2)
-        tmp[0] = INV_LPA_2_5HZ;
-    else if (rate <= 5)
-        tmp[0] = INV_LPA_5HZ;
-    else if (rate <= 10)
-        tmp[0] = INV_LPA_10HZ;
-    else if (rate <= 20)
-        tmp[0] = INV_LPA_20HZ;
-    else if (rate <= 40)
-        tmp[0] = INV_LPA_40HZ;
-    else if (rate <= 80)
-        tmp[0] = INV_LPA_80HZ;
-    else if (rate <= 160)
-        tmp[0] = INV_LPA_160HZ;
-    else if (rate <= 320)
-        tmp[0] = INV_LPA_320HZ;
-    else
-        tmp[0] = INV_LPA_640HZ;
-    if (i2c_write(a, st.reg->lp_accel_odr, 1, tmp))
-        return -1;
-    tmp[0] = BIT_LPA_CYCLE;
-    if (i2c_write(a, st.reg->pwr_mgmt_1, 1, tmp))
-        return -1;
-#endif
-    st.chip_cfg.sensors = INV_XYZ_ACCEL;
-    st.chip_cfg.clk_src = 0;
-    st.chip_cfg.lp_accel_mode = 1;
-    mpu_configure_fifo(0);
-
-    return 0;
-}
-
-/**
- *  @brief      Read raw gyro data directly from the registers.
- *  @param[out] data        Raw data in hardware units.
- *  @param[out] timestamp   Timestamp in milliseconds. Null if not needed.
- *  @return     0 if successful.
- */
-int mpu_get_gyro_reg(short *data, unsigned long *timestamp)
-{
-    unsigned char tmp[6];
-
-    if (!(st.chip_cfg.sensors & INV_XYZ_GYRO))
-        return -1;
-
-    if (i2c_read(a1, st.reg->raw_gyro, 6, tmp) && i2c_read(b1, st.reg->raw_gyro, 6, tmp))
-        return -1;
-    data[0] = (tmp[0] << 8) | tmp[1];
-    data[1] = (tmp[2] << 8) | tmp[3];
-    data[2] = (tmp[4] << 8) | tmp[5];
-    if (timestamp)
-        get_ms(timestamp);
-    return 0;
-}
-
-/**
- *  @brief      Read raw accel data directly from the registers.
- *  @param[out] data        Raw data in hardware units.
- *  @param[out] timestamp   Timestamp in milliseconds. Null if not needed.
- *  @return     0 if successful.
- */
-int mpu_get_accel_reg(short *data, unsigned long *timestamp)
-{
-    unsigned char tmp[6];
-
-    if (!(st.chip_cfg.sensors & INV_XYZ_ACCEL))
-        return -1;
-
-    if (i2c_read(a1, st.reg->raw_accel, 6, tmp) && i2c_read(b1, st.reg->raw_accel, 6, tmp))
-        return -1;
-    data[0] = (tmp[0] << 8) | tmp[1];
-    data[1] = (tmp[2] << 8) | tmp[3];
-    data[2] = (tmp[4] << 8) | tmp[5];
-    if (timestamp)
-        get_ms(timestamp);
-    return 0;
-}
-
-/**
- *  @brief      Read temperature data directly from the registers.
- *  @param[out] data        Data in q16 format.
- *  @param[out] timestamp   Timestamp in milliseconds. Null if not needed.
- *  @return     0 if successful.
- */
-int mpu_get_temperature(long *data, unsigned long *timestamp)
-{
-    unsigned char tmp[2];
-    short raw;
-
-    if (!(st.chip_cfg.sensors))
-        return -1;
-
-    if (i2c_read(a1, st.reg->temp, 2, tmp) && i2c_read(b1, st.reg->temp, 2, tmp))
-        return -1;
-    raw = (tmp[0] << 8) | tmp[1];
-    if (timestamp)
-        get_ms(timestamp);
-
-    data[0] = (long)((35 + ((raw - (float)st.hw->temp_offset) / st.hw->temp_sens)) * 65536L);
-    return 0;
-}
-
-/**
- *  @brief      Push biases to the accel bias registers.
- *  This function expects biases relative to the current sensor output, and
- *  these biases will be added to the factory-supplied values.
- *  @param[in]  accel_bias  New biases.
- *  @return     0 if successful.
- */
-int mpu_set_accel_bias(const long *accel_bias)
-{
-    unsigned char data[6];
-    short accel_hw[3];
-    short got_accel[3];
-    short fg[3];
-
-    if (!accel_bias)
-        return -1;
-    if (!accel_bias[0] && !accel_bias[1] && !accel_bias[2])
-        return 0;
-
-    if (i2c_read(a1, 3, 3, data) && i2c_read(b1, 3, 3, data))
-        return -1;
-    fg[0] = ((data[0] >> 4) + 8) & 0xf;
-    fg[1] = ((data[1] >> 4) + 8) & 0xf;
-    fg[2] = ((data[2] >> 4) + 8) & 0xf;
-
-    accel_hw[0] = (short)(accel_bias[0] * 2 / (64 + fg[0]));
-    accel_hw[1] = (short)(accel_bias[1] * 2 / (64 + fg[1]));
-    accel_hw[2] = (short)(accel_bias[2] * 2 / (64 + fg[2]));
-
-    if (i2c_read(a1, 0x06, 6, data) && i2c_read(b1, 0x06, 6, data))
-        return -1;
-
-    got_accel[0] = ((short)data[0] << 8) | data[1];
-    got_accel[1] = ((short)data[2] << 8) | data[3];
-    got_accel[2] = ((short)data[4] << 8) | data[5];
-
-    accel_hw[0] += got_accel[0];
-    accel_hw[1] += got_accel[1];
-    accel_hw[2] += got_accel[2];
-
-    data[0] = (accel_hw[0] >> 8) & 0xff;
-    data[1] = (accel_hw[0]) & 0xff;
-    data[2] = (accel_hw[1] >> 8) & 0xff;
-    data[3] = (accel_hw[1]) & 0xff;
-    data[4] = (accel_hw[2] >> 8) & 0xff;
-    data[5] = (accel_hw[2]) & 0xff;
-
-    if (i2c_write(a1, 0x06, 6, data) && i2c_write(b1, 0x06, 6, data))
-        return -1;
-    return 0;
-}
-
-/**
- *  @brief  Reset FIFO read/write pointers.
- *  @return 0 if successful.
- */
-int mpu_reset_fifo(void)
-{
-    unsigned char data;
-
-    if (!(st.chip_cfg.sensors))
-        return -1;
-
-    data = 0;
-    if (i2c_write(a1, st.reg->int_enable, 1, &data) && i2c_write(b1, st.reg->int_enable, 1, &data))
-        return -1;
-    if (i2c_write(a1, st.reg->fifo_en, 1, &data) && i2c_write(b1, st.reg->fifo_en, 1, &data))
-        return -1;
-    if (i2c_write(a1, st.reg->user_ctrl, 1, &data) && i2c_write(b1, st.reg->user_ctrl, 1, &data))
-        return -1;
-
-    if (st.chip_cfg.dmp_on)
-    {
-        data = BIT_FIFO_RST | BIT_DMP_RST;
-        if (i2c_write(a1, st.reg->user_ctrl, 1, &data) && i2c_write(b1, st.reg->user_ctrl, 1, &data))
-            return -1;
-        delay_ms(50);
-        data = BIT_DMP_EN | BIT_FIFO_EN;
-        if (st.chip_cfg.sensors & INV_XYZ_COMPASS)
-            data |= BIT_AUX_IF_EN;
-        if (i2c_write(a1, st.reg->user_ctrl, 1, &data) && i2c_write(b1, st.reg->user_ctrl, 1, &data))
-            return -1;
-        if (st.chip_cfg.int_enable)
-            data = BIT_DMP_INT_EN;
-        else
-            data = 0;
-        if (i2c_write(a1, st.reg->int_enable, 1, &data) && i2c_write(b1, st.reg->int_enable, 1, &data))
-            return -1;
-        data = 0;
-        if (i2c_write(a1, st.reg->fifo_en, 1, &data) && i2c_write(b1, st.reg->fifo_en, 1, &data))
-            return -1;
-    }
-    else
-    {
-        data = BIT_FIFO_RST;
-        if (i2c_write(a1, st.reg->user_ctrl, 1, &data) && i2c_write(b1, st.reg->user_ctrl, 1, &data))
-            return -1;
-        if (st.chip_cfg.bypass_mode || !(st.chip_cfg.sensors & INV_XYZ_COMPASS))
-            data = BIT_FIFO_EN;
-        else
-            data = BIT_FIFO_EN | BIT_AUX_IF_EN;
-        if (i2c_write(a1, st.reg->user_ctrl, 1, &data) && i2c_write(b1, st.reg->user_ctrl, 1, &data))
-            return -1;
-        delay_ms(50);
-        if (st.chip_cfg.int_enable)
-            data = BIT_DATA_RDY_EN;
-        else
-            data = 0;
-        if (i2c_write(a1, st.reg->int_enable, 1, &data) && i2c_write(b1, st.reg->int_enable, 1, &data))
-            return -1;
-        if (i2c_write(a1, st.reg->fifo_en, 1, &st.chip_cfg.fifo_enable) && i2c_write(b1, st.reg->fifo_en, 1, &st.chip_cfg.fifo_enable))
-            return -1;
-    }
-    return 0;
-}
-
-/**
- *  @brief      Get the gyro full-scale range.
- *  @param[out] fsr Current full-scale range.
- *  @return     0 if successful.
- */
-int mpu_get_gyro_fsr(unsigned short *fsr)
-{
-    switch (st.chip_cfg.gyro_fsr)
-    {
-    case INV_FSR_250DPS:
-        fsr[0] = 250;
-        break;
-    case INV_FSR_500DPS:
-        fsr[0] = 500;
-        break;
-    case INV_FSR_1000DPS:
-        fsr[0] = 1000;
-        break;
-    case INV_FSR_2000DPS:
-        fsr[0] = 2000;
-        break;
-    default:
-        fsr[0] = 0;
-        break;
-    }
-    return 0;
-}
-
-/**
- *  @brief      Set the gyro full-scale range.
- *  @param[in]  fsr Desired full-scale range.
- *  @return     0 if successful.
- */
-int mpu_set_gyro_fsr(unsigned short fsr)
-{
-    unsigned char data;
-
-    if (!(st.chip_cfg.sensors))
-        return -1;
-
-    switch (fsr)
-    {
-    case 250:
-        data = INV_FSR_250DPS << 3;
-        break;
-    case 500:
-        data = INV_FSR_500DPS << 3;
-        break;
-    case 1000:
-        data = INV_FSR_1000DPS << 3;
-        break;
-    case 2000:
-        data = INV_FSR_2000DPS << 3;
-        break;
-    default:
-        return -1;
-    }
-
-    if (st.chip_cfg.gyro_fsr == (data >> 3))
-        return 0;
-    if (i2c_write(a1, st.reg->gyro_cfg, 1, &data) && i2c_write(b1, st.reg->gyro_cfg, 1, &data))
-        return -1;
-    st.chip_cfg.gyro_fsr = data >> 3;
-    return 0;
-}
-
-/**
- *  @brief      Get the accel full-scale range.
- *  @param[out] fsr Current full-scale range.
- *  @return     0 if successful.
- */
-int mpu_get_accel_fsr(unsigned char *fsr)
-{
-    switch (st.chip_cfg.accel_fsr)
-    {
-    case INV_FSR_2G:
-        fsr[0] = 2;
-        break;
-    case INV_FSR_4G:
-        fsr[0] = 4;
-        break;
-    case INV_FSR_8G:
-        fsr[0] = 8;
-        break;
-    case INV_FSR_16G:
-        fsr[0] = 16;
-        break;
-    default:
-        return -1;
-    }
-    if (st.chip_cfg.accel_half)
-        fsr[0] <<= 1;
-    return 0;
-}
-
-/**
- *  @brief      Set the accel full-scale range.
- *  @param[in]  fsr Desired full-scale range.
- *  @return     0 if successful.
- */
-int mpu_set_accel_fsr(unsigned char fsr)
-{
-    unsigned char data;
-
-    if (!(st.chip_cfg.sensors))
-        return -1;
-
-    switch (fsr)
-    {
-    case 2:
-        data = INV_FSR_2G << 3;
-        break;
-    case 4:
-        data = INV_FSR_4G << 3;
-        break;
-    case 8:
-        data = INV_FSR_8G << 3;
-        break;
-    case 16:
-        data = INV_FSR_16G << 3;
-        break;
-    default:
-        return -1;
-    }
-
-    if (st.chip_cfg.accel_fsr == (data >> 3))
-        return 0;
-    if (i2c_write(a1, st.reg->accel_cfg, 1, &data) && i2c_write(b1, st.reg->accel_cfg, 1, &data))
-        return -1;
-    st.chip_cfg.accel_fsr = data >> 3;
-    return 0;
-}
-
-/**
- *  @brief      Get the current DLPF setting.
- *  @param[out] lpf Current LPF setting.
- *  0 if successful.
- */
-int mpu_get_lpf(unsigned short *lpf)
-{
-    switch (st.chip_cfg.lpf)
-    {
-    case INV_FILTER_188HZ:
-        lpf[0] = 188;
-        break;
-    case INV_FILTER_98HZ:
-        lpf[0] = 98;
-        break;
-    case INV_FILTER_42HZ:
-        lpf[0] = 42;
-        break;
-    case INV_FILTER_20HZ:
-        lpf[0] = 20;
-        break;
-    case INV_FILTER_10HZ:
-        lpf[0] = 10;
-        break;
-    case INV_FILTER_5HZ:
-        lpf[0] = 5;
-        break;
-    case INV_FILTER_256HZ_NOLPF2:
-    case INV_FILTER_2100HZ_NOLPF:
-    default:
-        lpf[0] = 0;
-        break;
-    }
-    return 0;
-}
-
-/**
- *  @brief      Set digital low pass filter.
- *  The following LPF settings are supported: 188, 98, 42, 20, 10, 5.
- *  @param[in]  lpf Desired LPF setting.
- *  @return     0 if successful.
- */
-int mpu_set_lpf(unsigned short lpf)
-{
-    unsigned char data;
-
-    if (!(st.chip_cfg.sensors))
-        return -1;
-
-    if (lpf >= 188)
-        data = INV_FILTER_188HZ;
-    else if (lpf >= 98)
-        data = INV_FILTER_98HZ;
-    else if (lpf >= 42)
-        data = INV_FILTER_42HZ;
-    else if (lpf >= 20)
-        data = INV_FILTER_20HZ;
-    else if (lpf >= 10)
-        data = INV_FILTER_10HZ;
-    else
-        data = INV_FILTER_5HZ;
-
-    if (st.chip_cfg.lpf == data)
-        return 0;
-    if (i2c_write1(a1, st.reg->lpf, 1, &data) && i2c_write1(b1, st.reg->lpf, 1, &data))
-        return -1;
-    st.chip_cfg.lpf = data;
-    return 0;
-}
-
-/**
- *  @brief      Get sampling rate.
- *  @param[out] rate    Current sampling rate (Hz).
- *  @return     0 if successful.
- */
-int mpu_get_sample_rate(unsigned short *rate)
-{
-    if (st.chip_cfg.dmp_on)
-        return -1;
-    else
-        rate[0] = st.chip_cfg.sample_rate;
-
-    return 0;
-}
-
-/**
- *  @brief      Set sampling rate.
- *  Sampling rate must be between 4Hz and 1kHz.
- *  @param[in]  rate    Desired sampling rate (Hz).
- *  @return     0 if successful.
- */
-int mpu_set_sample_rate(unsigned short rate)
-{
-    unsigned char data;
-
-    if (!(st.chip_cfg.sensors))
-        return -1;
-
-    if (st.chip_cfg.dmp_on)
-        return -1;
-    else
-    {
-        if (st.chip_cfg.lp_accel_mode)
-        {
-            if (rate && (rate <= 40))
-            {
-                /* Just stay in low-power accel mode. */
-                mpu_lp_accel_mode(rate);
-                return 0;
-            }
-            /* Requested rate exceeds the allowed frequencies in LP accel mode,
-             * switch back to full-power mode.
-             */
-            mpu_lp_accel_mode(0);
-        }
-        if (rate < 4)
-            rate = 4;
-        else if (rate > 1000)
-            rate = 1000;
-
-        data = 1000 / rate - 1;
-        if (i2c_write(a1, st.reg->rate_div, 1, &data) && i2c_write(b1, st.reg->rate_div, 1, &data))
-            return -1;
-
-        st.chip_cfg.sample_rate = 1000 / (1 + data);
-
-#ifdef AK89xx_SECONDARY
-        mpu_set_compass_sample_rate(min(st.chip_cfg.compass_sample_rate, MAX_COMPASS_SAMPLE_RATE));
-#endif
-
-        /* Automatically set LPF to 1/2 sampling rate. */
-        mpu_set_lpf(st.chip_cfg.sample_rate >> 1);
-        return 0;
-    }
-}
-
-/**
- *  @brief      Get compass sampling rate.
- *  @param[out] rate    Current compass sampling rate (Hz).
- *  @return     0 if successful.
- */
-int mpu_get_compass_sample_rate(unsigned short *rate)
-{
-#ifdef AK89xx_SECONDARY
-    rate[0] = st.chip_cfg.compass_sample_rate;
-    return 0;
-#else
-    rate[0] = 0;
-    return -1;
-#endif
-}
-
-/**
- *  @brief      Set compass sampling rate.
- *  The compass on the auxiliary I2C bus is read by the MPU hardware at a
- *  maximum of 100Hz. The actual rate can be set to a fraction of the gyro
- *  sampling rate.
- *
- *  \n WARNING: The new rate may be different than what was requested. Call
- *  mpu_get_compass_sample_rate to check the actual setting.
- *  @param[in]  rate    Desired compass sampling rate (Hz).
- *  @return     0 if successful.
- */
-int mpu_set_compass_sample_rate(unsigned short rate)
-{
-#ifdef AK89xx_SECONDARY
-    unsigned char div;
-    if (!rate || rate > st.chip_cfg.sample_rate || rate > MAX_COMPASS_SAMPLE_RATE)
-        return -1;
-
-    div = st.chip_cfg.sample_rate / rate - 1;
-    if (i2c_write(a, st.reg->s4_ctrl, 1, &div))
-        return -1;
-    st.chip_cfg.compass_sample_rate = st.chip_cfg.sample_rate / (div + 1);
-    return 0;
-#else
-    return -1;
-#endif
-}
-
-/**
- *  @brief      Get gyro sensitivity scale factor.
- *  @param[out] sens    Conversion from hardware units to dps.
- *  @return     0 if successful.
- */
-int mpu_get_gyro_sens(float *sens)
-{
-    switch (st.chip_cfg.gyro_fsr)
-    {
-    case INV_FSR_250DPS:
-        sens[0] = 131.f;
-        break;
-    case INV_FSR_500DPS:
-        sens[0] = 65.5f;
-        break;
-    case INV_FSR_1000DPS:
-        sens[0] = 32.8f;
-        break;
-    case INV_FSR_2000DPS:
-        sens[0] = 16.4f;
-        break;
-    default:
-        return -1;
-    }
-    return 0;
-}
-
-/**
- *  @brief      Get accel sensitivity scale factor.
- *  @param[out] sens    Conversion from hardware units to g's.
- *  @return     0 if successful.
- */
-int mpu_get_accel_sens(unsigned short *sens)
-{
-    switch (st.chip_cfg.accel_fsr)
-    {
-    case INV_FSR_2G:
-        sens[0] = 16384;
-        break;
-    case INV_FSR_4G:
-        sens[0] = 8092;
-        break;
-    case INV_FSR_8G:
-        sens[0] = 4096;
-        break;
-    case INV_FSR_16G:
-        sens[0] = 2048;
-        break;
-    default:
-        return -1;
-    }
-    if (st.chip_cfg.accel_half)
-        sens[0] >>= 1;
-    return 0;
-}
-
-/**
- *  @brief      Get current FIFO configuration.
- *  @e sensors can contain a combination of the following flags:
- *  \n INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO
- *  \n INV_XYZ_GYRO
- *  \n INV_XYZ_ACCEL
- *  @param[out] sensors Mask of sensors in FIFO.
- *  @return     0 if successful.
- */
-int mpu_get_fifo_config(unsigned char *sensors)
-{
-    sensors[0] = st.chip_cfg.fifo_enable;
-    return 0;
-}
-
-/**
- *  @brief      Select which sensors are pushed to FIFO.
- *  @e sensors can contain a combination of the following flags:
- *  \n INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO
- *  \n INV_XYZ_GYRO
- *  \n INV_XYZ_ACCEL
- *  @param[in]  sensors Mask of sensors to push to FIFO.
- *  @return     0 if successful.
- */
-int mpu_configure_fifo(unsigned char sensors)
-{
-    unsigned char prev;
-    int result = 0;
-
-    /* Compass data isn't going into the FIFO. Stop trying. */
-    sensors &= ~INV_XYZ_COMPASS;
-
-    if (st.chip_cfg.dmp_on)
-        return 0;
-    else
-    {
-        if (!(st.chip_cfg.sensors))
-            return -1;
-        prev = st.chip_cfg.fifo_enable;
-        st.chip_cfg.fifo_enable = sensors & st.chip_cfg.sensors;
-        if (st.chip_cfg.fifo_enable != sensors)
-            /* You're not getting what you asked for. Some sensors are
-             * asleep.
-             */
-            result = -1;
-        else
-            result = 0;
-        if (sensors || st.chip_cfg.lp_accel_mode)
-            set_int_enable(1);
-        else
-            set_int_enable(0);
-        if (sensors)
-        {
-            if (mpu_reset_fifo())
-            {
-                st.chip_cfg.fifo_enable = prev;
-                return -1;
-            }
-        }
-    }
-
-    return result;
-}
-
-/**
- *  @brief      Get current power state.
- *  @param[in]  power_on    1 if turned on, 0 if suspended.
- *  @return     0 if successful.
- */
-int mpu_get_power_state(unsigned char *power_on)
-{
-    if (st.chip_cfg.sensors)
-        power_on[0] = 1;
-    else
-        power_on[0] = 0;
-    return 0;
-}
-
-/**
- *  @brief      Turn specific sensors on/off.
- *  @e sensors can contain a combination of the following flags:
- *  \n INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO
- *  \n INV_XYZ_GYRO
- *  \n INV_XYZ_ACCEL
- *  \n INV_XYZ_COMPASS
- *  @param[in]  sensors    Mask of sensors to wake.
- *  @return     0 if successful.
- */
-int mpu_set_sensors(unsigned char sensors)
-{
-    unsigned char data;
-#ifdef AK89xx_SECONDARY
-    unsigned char user_ctrl;
-#endif
-
-    if (sensors & INV_XYZ_GYRO)
-        data = INV_CLK_PLL;
-    else if (sensors)
-        data = 0;
-    else
-        data = BIT_SLEEP;
-    if (i2c_write1(a1, st.reg->pwr_mgmt_1, 1, &data) && i2c_write1(b1, st.reg->pwr_mgmt_1, 1, &data))
-    {
-        st.chip_cfg.sensors = 0;
-        return -1;
-    }
-    st.chip_cfg.clk_src = data & ~BIT_SLEEP;
-
-    data = 0;
-    if (!(sensors & INV_X_GYRO))
-        data |= BIT_STBY_XG;
-    if (!(sensors & INV_Y_GYRO))
-        data |= BIT_STBY_YG;
-    if (!(sensors & INV_Z_GYRO))
-        data |= BIT_STBY_ZG;
-    if (!(sensors & INV_XYZ_ACCEL))
-        data |= BIT_STBY_XYZA;
-    if (i2c_write1(a1, st.reg->pwr_mgmt_2, 1, &data) && i2c_write1(b1, st.reg->pwr_mgmt_2, 1, &data))
-    {
-        st.chip_cfg.sensors = 0;
-        return -1;
-    }
-
-    if (sensors && (sensors != INV_XYZ_ACCEL))
-        /* Latched interrupts only used in LP accel mode. */
-        mpu_set_int_latched(0);
-
-#ifdef AK89xx_SECONDARY
-#ifdef AK89xx_BYPASS
-    if (sensors & INV_XYZ_COMPASS)
-        mpu_set_bypass(1);
-    else
-        mpu_set_bypass(0);
-#else
-    if (i2c_read(a, st.reg->user_ctrl, 1, &user_ctrl))
-        return -1;
-    /* Handle AKM power management. */
-    if (sensors & INV_XYZ_COMPASS)
-    {
-        data = AKM_SINGLE_MEASUREMENT;
-        user_ctrl |= BIT_AUX_IF_EN;
-    }
-    else
-    {
-        data = AKM_POWER_DOWN;
-        user_ctrl &= ~BIT_AUX_IF_EN;
-    }
-    if (st.chip_cfg.dmp_on)
-        user_ctrl |= BIT_DMP_EN;
-    else
-        user_ctrl &= ~BIT_DMP_EN;
-    if (i2c_write(a, st.reg->s1_do, 1, &data))
-        return -1;
-    /* Enable/disable I2C master mode. */
-    if (i2c_write(a, st.reg->user_ctrl, 1, &user_ctrl))
-        return -1;
-#endif
-#endif
-
-    st.chip_cfg.sensors = sensors;
-    st.chip_cfg.lp_accel_mode = 0;
-    delay_ms(50);
-    return 0;
-}
-
-/**
- *  @brief      Read the MPU interrupt status registers.
- *  @param[out] status  Mask of interrupt bits.
- *  @return     0 if successful.
- */
-int mpu_get_int_status(short *status)
-{
-    unsigned char tmp[2];
-    if (!st.chip_cfg.sensors)
-        return -1;
-    if (i2c_read(a1, st.reg->dmp_int_status, 2, tmp) && i2c_read(b1, st.reg->dmp_int_status, 2, tmp))
-        return -1;
-    status[0] = (tmp[0] << 8) | tmp[1];
-    return 0;
-}
-
-/**
- *  @brief      Get one packet from the FIFO.
- *  If @e sensors does not contain a particular sensor, disregard the data
- *  returned to that pointer.
- *  \n @e sensors can contain a combination of the following flags:
- *  \n INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO
- *  \n INV_XYZ_GYRO
- *  \n INV_XYZ_ACCEL
- *  \n If the FIFO has no new data, @e sensors will be zero.
- *  \n If the FIFO is disabled, @e sensors will be zero and this function will
- *  return a non-zero error code.
- *  @param[out] gyro        Gyro data in hardware units.
- *  @param[out] accel       Accel data in hardware units.
- *  @param[out] timestamp   Timestamp in milliseconds.
- *  @param[out] sensors     Mask of sensors read from FIFO.
- *  @param[out] more        Number of remaining packets.
- *  @return     0 if successful.
- */
-int mpu_read_fifo(short *gyro, short *accel, unsigned long *timestamp,
-                  unsigned char *sensors, unsigned char *more)
-{
-    /* Assumes maximum packet size is gyro (6) + accel (6). */
-    unsigned char data[MAX_PACKET_LENGTH];
-    unsigned char packet_size = 0;
-    unsigned short fifo_count, index = 0;
-
-    if (st.chip_cfg.dmp_on)
-        return -1;
-
-    sensors[0] = 0;
-    if (!st.chip_cfg.sensors)
-        return -1;
-    if (!st.chip_cfg.fifo_enable)
-        return -1;
-
-    if (st.chip_cfg.fifo_enable & INV_X_GYRO)
-        packet_size += 2;
-    if (st.chip_cfg.fifo_enable & INV_Y_GYRO)
-        packet_size += 2;
-    if (st.chip_cfg.fifo_enable & INV_Z_GYRO)
-        packet_size += 2;
-    if (st.chip_cfg.fifo_enable & INV_XYZ_ACCEL)
-        packet_size += 6;
-
-    if (i2c_read(a1, st.reg->fifo_count_h, 2, data) && i2c_read(b1, st.reg->fifo_count_h, 2, data))
-        return -1;
-    fifo_count = (data[0] << 8) | data[1];
-    if (fifo_count < packet_size)
-        return 0;
-    //    log_i("FIFO count: %hd\n", fifo_count);
-    if (fifo_count > (st.hw->max_fifo >> 1))
-    {
-        /* FIFO is 50% full, better check overflow bit. */
-        if (i2c_read(a1, st.reg->int_status, 1, data) && i2c_read(b1, st.reg->int_status, 1, data))
-            return -1;
-        if (data[0] & BIT_FIFO_OVERFLOW)
-        {
-            mpu_reset_fifo();
-            return -2;
-        }
-    }
-    get_ms((unsigned long *)timestamp);
-
-    if (i2c_read(a1, st.reg->fifo_r_w, packet_size, data) && i2c_read(b1, st.reg->fifo_r_w, packet_size, data))
-        return -1;
-    more[0] = fifo_count / packet_size - 1;
-    sensors[0] = 0;
-
-    if ((index != packet_size) && st.chip_cfg.fifo_enable & INV_XYZ_ACCEL)
-    {
-        accel[0] = (data[index + 0] << 8) | data[index + 1];
-        accel[1] = (data[index + 2] << 8) | data[index + 3];
-        accel[2] = (data[index + 4] << 8) | data[index + 5];
-        sensors[0] |= INV_XYZ_ACCEL;
-        index += 6;
-    }
-    if ((index != packet_size) && st.chip_cfg.fifo_enable & INV_X_GYRO)
-    {
-        gyro[0] = (data[index + 0] << 8) | data[index + 1];
-        sensors[0] |= INV_X_GYRO;
-        index += 2;
-    }
-    if ((index != packet_size) && st.chip_cfg.fifo_enable & INV_Y_GYRO)
-    {
-        gyro[1] = (data[index + 0] << 8) | data[index + 1];
-        sensors[0] |= INV_Y_GYRO;
-        index += 2;
-    }
-    if ((index != packet_size) && st.chip_cfg.fifo_enable & INV_Z_GYRO)
-    {
-        gyro[2] = (data[index + 0] << 8) | data[index + 1];
-        sensors[0] |= INV_Z_GYRO;
-        index += 2;
-    }
-
-    return 0;
-}
-
-/**
- *  @brief      Get one unparsed packet from the FIFO.
- *  This function should be used if the packet is to be parsed elsewhere.
- *  @param[in]  length  Length of one FIFO packet.
- *  @param[in]  data    FIFO packet.
- *  @param[in]  more    Number of remaining packets.
- */
-int mpu_read_fifo_stream(unsigned short length, unsigned char *data,
-                         unsigned char *more)
-{
-    unsigned char tmp[2];
-    unsigned short fifo_count;
-
-    //    printf("addr %d, dmp_on %d, sensors %d\r\n", a, st.chip_cfg.dmp_on, st.chip_cfg.sensors);
-
-    if (!st.chip_cfg.dmp_on)
-        return -1;
-    if (!st.chip_cfg.sensors)
-        return -1;
-
-    //    printf("----1\r\n");
-
-    if (i2c_read(a1, st.reg->fifo_count_h, 2, tmp) && i2c_read(b1, st.reg->fifo_count_h, 2, tmp))
-        return -1;
-
-    //    printf("----2\r\n");
-
-    fifo_count = (tmp[0] << 8) | tmp[1];
-    if (fifo_count < length)
-    {
-        more[0] = 0;
-        return -1;
-    }
-
-    //    printf("----3\r\n");
-    if (fifo_count > (st.hw->max_fifo >> 1))
-    {
-
-        //        printf("----3.1\r\n");
-        /* FIFO is 50% full, better check overflow bit. */
-        if (i2c_read(a1, st.reg->int_status, 1, tmp) && i2c_read(b1, st.reg->int_status, 1, tmp))
-            return -1;
-
-        //        printf("----3.2\r\n");
-        if (tmp[0] & BIT_FIFO_OVERFLOW)
-        {
-            mpu_reset_fifo();
-            return -2;
-        }
-    }
-
-    //    printf("----4\r\n");
-    if (i2c_read(a1, st.reg->fifo_r_w, length, data) && i2c_read(b1, st.reg->fifo_r_w, length, data))
-        return -1;
-
-    more[0] = fifo_count / length - 1;
-    return 0;
-}
-
-/**
- *  @brief      Set device to bypass mode.
- *  @param[in]  bypass_on   1 to enable bypass mode.
- *  @return     0 if successful.
- */
-int mpu_set_bypass(unsigned char bypass_on)
-{
-    unsigned char tmp;
-
-    if (st.chip_cfg.bypass_mode == bypass_on)
-        return 0;
-
-    if (bypass_on)
-    {
-        if (i2c_read(a1, st.reg->user_ctrl, 1, &tmp) && i2c_read(b1, st.reg->user_ctrl, 1, &tmp))
-            return -1;
-        tmp &= ~BIT_AUX_IF_EN;
-        if (i2c_write(a1, st.reg->user_ctrl, 1, &tmp) && i2c_write(b1, st.reg->user_ctrl, 1, &tmp))
-            return -1;
-        delay_ms(3);
-        tmp = BIT_BYPASS_EN;
-        if (st.chip_cfg.active_low_int)
-            tmp |= BIT_ACTL;
-        if (st.chip_cfg.latched_int)
-            tmp |= BIT_LATCH_EN | BIT_ANY_RD_CLR;
-        if (i2c_write(a1, st.reg->int_pin_cfg, 1, &tmp) && i2c_write(b1, st.reg->int_pin_cfg, 1, &tmp))
-            return -1;
-    }
-    else
-    {
-        /* Enable I2C master mode if compass is being used. */
-        if (i2c_read(a1, st.reg->user_ctrl, 1, &tmp) && i2c_read(b1, st.reg->user_ctrl, 1, &tmp))
-            return -1;
-        if (st.chip_cfg.sensors & INV_XYZ_COMPASS)
-            tmp |= BIT_AUX_IF_EN;
-        else
-            tmp &= ~BIT_AUX_IF_EN;
-        if (i2c_write(a1, st.reg->user_ctrl, 1, &tmp) && i2c_write(b1, st.reg->user_ctrl, 1, &tmp))
-            return -1;
-        delay_ms(3);
-        if (st.chip_cfg.active_low_int)
-            tmp = BIT_ACTL;
-        else
-            tmp = 0;
-        if (st.chip_cfg.latched_int)
-            tmp |= BIT_LATCH_EN | BIT_ANY_RD_CLR;
-        if (i2c_write(a1, st.reg->int_pin_cfg, 1, &tmp) && i2c_write(b1, st.reg->int_pin_cfg, 1, &tmp))
-            return -1;
-    }
-    st.chip_cfg.bypass_mode = bypass_on;
-    return 0;
-}
-
-/**
- *  @brief      Set interrupt level.
- *  @param[in]  active_low  1 for active low, 0 for active high.
- *  @return     0 if successful.
- */
-int mpu_set_int_level(unsigned char active_low)
-{
-    st.chip_cfg.active_low_int = active_low;
-    return 0;
-}
-
-/**
- *  @brief      Enable latched interrupts.
- *  Any MPU register will clear the interrupt.
- *  @param[in]  enable  1 to enable, 0 to disable.
- *  @return     0 if successful.
- */
-int mpu_set_int_latched(unsigned char enable)
-{
-    unsigned char tmp;
-    if (st.chip_cfg.latched_int == enable)
-        return 0;
-
-    if (enable)
-        tmp = BIT_LATCH_EN | BIT_ANY_RD_CLR;
-    else
-        tmp = 0;
-    if (st.chip_cfg.bypass_mode)
-        tmp |= BIT_BYPASS_EN;
-    if (st.chip_cfg.active_low_int)
-        tmp |= BIT_ACTL;
-    if (i2c_write1(a1, st.reg->int_pin_cfg, 1, &tmp) && i2c_write1(b1, st.reg->int_pin_cfg, 1, &tmp))
-        return -1;
-    st.chip_cfg.latched_int = enable;
-    return 0;
-}
-
-#ifdef MPU6050
-static int get_accel_prod_shift(float *st_shift)
-{
-    unsigned char tmp[4], shift_code[3], ii;
-
-    if (i2c_read(a1, 0x0D, 4, tmp) && i2c_read(b1, 0x0D, 4, tmp))
-        return 0x07;
-
-    shift_code[0] = ((tmp[0] & 0xE0) >> 3) | ((tmp[3] & 0x30) >> 4);
-    shift_code[1] = ((tmp[1] & 0xE0) >> 3) | ((tmp[3] & 0x0C) >> 2);
-    shift_code[2] = ((tmp[2] & 0xE0) >> 3) | (tmp[3] & 0x03);
-    for (ii = 0; ii < 3; ii++)
-    {
-        if (!shift_code[ii])
-        {
-            st_shift[ii] = 0.f;
-            continue;
-        }
-        /* Equivalent to..
-         * st_shift[ii] = 0.34f * powf(0.92f/0.34f, (shift_code[ii]-1) / 30.f)
-         */
-        st_shift[ii] = 0.34f;
-        while (--shift_code[ii])
-            st_shift[ii] *= 1.034f;
-    }
-    return 0;
-}
-
-static int accel_self_test(long *bias_regular, long *bias_st)
-{
-    int jj, result = 0;
-    float st_shift[3], st_shift_cust, st_shift_var;
-
-    get_accel_prod_shift(st_shift);
-    for (jj = 0; jj < 3; jj++)
-    {
-        st_shift_cust = labs(bias_regular[jj] - bias_st[jj]) / 65536.f;
-        if (st_shift[jj])
-        {
-            st_shift_var = st_shift_cust / st_shift[jj] - 1.f;
-            if (fabs(st_shift_var) > test.max_accel_var)
-                result |= 1 << jj;
-        }
-        else if ((st_shift_cust < test.min_g) ||
-                 (st_shift_cust > test.max_g))
-            result |= 1 << jj;
-    }
-
-    return result;
-}
-
-static int gyro_self_test(long *bias_regular, long *bias_st)
-{
-    int jj, result = 0;
-    unsigned char tmp[3];
-    float st_shift, st_shift_cust, st_shift_var;
-
-    if (i2c_read(a1, 0x0D, 3, tmp) && i2c_read(b1, 0x0D, 3, tmp))
-        return 0x07;
-
-    tmp[0] &= 0x1F;
-    tmp[1] &= 0x1F;
-    tmp[2] &= 0x1F;
-
-    for (jj = 0; jj < 3; jj++)
-    {
-        st_shift_cust = labs(bias_regular[jj] - bias_st[jj]) / 65536.f;
-        if (tmp[jj])
-        {
-            st_shift = 3275.f / test.gyro_sens;
-            while (--tmp[jj])
-                st_shift *= 1.046f;
-            st_shift_var = st_shift_cust / st_shift - 1.f;
-            if (fabs(st_shift_var) > test.max_gyro_var)
-                result |= 1 << jj;
-        }
-        else if ((st_shift_cust < test.min_dps) ||
-                 (st_shift_cust > test.max_dps))
-            result |= 1 << jj;
-    }
-    return result;
-}
-
-#ifdef AK89xx_SECONDARY
-static int compass_self_test(void)
-{
-    unsigned char tmp[6];
-    unsigned char tries = 10;
-    int result = 0x07;
-    short data;
-
-    mpu_set_bypass(1);
-
-    tmp[0] = AKM_POWER_DOWN;
-    if (i2c_write(st.chip_cfg.compass_addr, AKM_REG_CNTL, 1, tmp))
-        return 0x07;
-    tmp[0] = AKM_BIT_SELF_TEST;
-    if (i2c_write(st.chip_cfg.compass_addr, AKM_REG_ASTC, 1, tmp))
-        goto AKM_restore;
-    tmp[0] = AKM_MODE_SELF_TEST;
-    if (i2c_write(st.chip_cfg.compass_addr, AKM_REG_CNTL, 1, tmp))
-        goto AKM_restore;
-
-    do
-    {
-        delay_ms(10);
-        if (i2c_read(st.chip_cfg.compass_addr, AKM_REG_ST1, 1, tmp))
-            goto AKM_restore;
-        if (tmp[0] & AKM_DATA_READY)
-            break;
-    } while (tries--);
-    if (!(tmp[0] & AKM_DATA_READY))
-        goto AKM_restore;
-
-    if (i2c_read(st.chip_cfg.compass_addr, AKM_REG_HXL, 6, tmp))
-        goto AKM_restore;
-
-    result = 0;
-    data = (short)(tmp[1] << 8) | tmp[0];
-    if ((data > 100) || (data < -100))
-        result |= 0x01;
-    data = (short)(tmp[3] << 8) | tmp[2];
-    if ((data > 100) || (data < -100))
-        result |= 0x02;
-    data = (short)(tmp[5] << 8) | tmp[4];
-    if ((data > -300) || (data < -1000))
-        result |= 0x04;
-
-AKM_restore:
-    tmp[0] = 0 | SUPPORTS_AK89xx_HIGH_SENS;
-    i2c_write(st.chip_cfg.compass_addr, AKM_REG_ASTC, 1, tmp);
-    tmp[0] = SUPPORTS_AK89xx_HIGH_SENS;
-    i2c_write(st.chip_cfg.compass_addr, AKM_REG_CNTL, 1, tmp);
-    mpu_set_bypass(0);
-    return result;
-}
-#endif
-#endif
-
-static int get_st_biases(long *gyro, long *accel, unsigned char hw_test)
-{
-    unsigned char data[MAX_PACKET_LENGTH];
-    unsigned char packet_count, ii;
-    unsigned short fifo_count;
-
-    data[0] = 0x01;
-    data[1] = 0;
-    if (i2c_write(a1, st.reg->pwr_mgmt_1, 2, data) && i2c_write(b1, st.reg->pwr_mgmt_1, 2, data))
-        return -1;
-    delay_ms(200);
-    data[0] = 0;
-    if (i2c_write(a1, st.reg->int_enable, 1, data) && i2c_write(b1, st.reg->int_enable, 1, data))
-        return -1;
-    if (i2c_write(a1, st.reg->fifo_en, 1, data) && i2c_write(b1, st.reg->fifo_en, 1, data))
-        return -1;
-    if (i2c_write(a1, st.reg->pwr_mgmt_1, 1, data) && i2c_write(b1, st.reg->pwr_mgmt_1, 1, data))
-        return -1;
-    if (i2c_write(a1, st.reg->i2c_mst, 1, data) && i2c_write(b1, st.reg->i2c_mst, 1, data))
-        return -1;
-    if (i2c_write(a1, st.reg->user_ctrl, 1, data) && i2c_write(b1, st.reg->user_ctrl, 1, data))
-        return -1;
-    data[0] = BIT_FIFO_RST | BIT_DMP_RST;
-    if (i2c_write(a1, st.reg->user_ctrl, 1, data) && i2c_write(b1, st.reg->user_ctrl, 1, data))
-        return -1;
-    delay_ms(15);
-    data[0] = st.test->reg_lpf;
-    if (i2c_write(a1, st.reg->lpf, 1, data) && i2c_write(b1, st.reg->lpf, 1, data))
-        return -1;
-    data[0] = st.test->reg_rate_div;
-    if (i2c_write(a1, st.reg->rate_div, 1, data) && i2c_write(b1, st.reg->rate_div, 1, data))
-        return -1;
-    if (hw_test)
-        data[0] = st.test->reg_gyro_fsr | 0xE0;
-    else
-        data[0] = st.test->reg_gyro_fsr;
-    if (i2c_write(a1, st.reg->gyro_cfg, 1, data) && i2c_write(b1, st.reg->gyro_cfg, 1, data))
-        return -1;
-
-    if (hw_test)
-        data[0] = st.test->reg_accel_fsr | 0xE0;
-    else
-        data[0] = test.reg_accel_fsr;
-    if (i2c_write(a1, st.reg->accel_cfg, 1, data) && i2c_write(b1, st.reg->accel_cfg, 1, data))
-        return -1;
-    if (hw_test)
-        delay_ms(200);
-
-    /* Fill FIFO for test.wait_ms milliseconds. */
-    data[0] = BIT_FIFO_EN;
-    if (i2c_write(a1, st.reg->user_ctrl, 1, data) && i2c_write(b1, st.reg->user_ctrl, 1, data))
-        return -1;
-
-    data[0] = INV_XYZ_GYRO | INV_XYZ_ACCEL;
-    if (i2c_write(a1, st.reg->fifo_en, 1, data) && i2c_write(b1, st.reg->fifo_en, 1, data))
-        return -1;
-    delay_ms(test.wait_ms);
-    data[0] = 0;
-    if (i2c_write(a1, st.reg->fifo_en, 1, data) && i2c_write(b1, st.reg->fifo_en, 1, data))
-        return -1;
-
-    if (i2c_read(a1, st.reg->fifo_count_h, 2, data) && i2c_write(b1, st.reg->fifo_count_h, 2, data))
-        return -1;
-
-    fifo_count = (data[0] << 8) | data[1];
-    packet_count = fifo_count / MAX_PACKET_LENGTH;
-    gyro[0] = gyro[1] = gyro[2] = 0;
-    accel[0] = accel[1] = accel[2] = 0;
-
-    for (ii = 0; ii < packet_count; ii++)
-    {
-        short accel_cur[3], gyro_cur[3];
-        if (i2c_read(a1, st.reg->fifo_r_w, MAX_PACKET_LENGTH, data) && i2c_read(b1, st.reg->fifo_r_w, MAX_PACKET_LENGTH, data))
-            return -1;
-        accel_cur[0] = ((short)data[0] << 8) | data[1];
-        accel_cur[1] = ((short)data[2] << 8) | data[3];
-        accel_cur[2] = ((short)data[4] << 8) | data[5];
-        accel[0] += (long)accel_cur[0];
-        accel[1] += (long)accel_cur[1];
-        accel[2] += (long)accel_cur[2];
-        gyro_cur[0] = (((short)data[6] << 8) | data[7]);
-        gyro_cur[1] = (((short)data[8] << 8) | data[9]);
-        gyro_cur[2] = (((short)data[10] << 8) | data[11]);
-        gyro[0] += (long)gyro_cur[0];
-        gyro[1] += (long)gyro_cur[1];
-        gyro[2] += (long)gyro_cur[2];
-    }
-#ifdef EMPL_NO_64BIT
-    gyro[0] = (long)(((float)gyro[0] * 65536.f) / test.gyro_sens / packet_count);
-    gyro[1] = (long)(((float)gyro[1] * 65536.f) / test.gyro_sens / packet_count);
-    gyro[2] = (long)(((float)gyro[2] * 65536.f) / test.gyro_sens / packet_count);
-    if (has_accel)
-    {
-        accel[0] = (long)(((float)accel[0] * 65536.f) / test.accel_sens /
-                          packet_count);
-        accel[1] = (long)(((float)accel[1] * 65536.f) / test.accel_sens /
-                          packet_count);
-        accel[2] = (long)(((float)accel[2] * 65536.f) / test.accel_sens /
-                          packet_count);
-        /* Don't remove gravity! */
-        accel[2] -= 65536L;
-    }
-#else
-    gyro[0] = (long)(((long long)gyro[0] << 16) / test.gyro_sens / packet_count);
-    gyro[1] = (long)(((long long)gyro[1] << 16) / test.gyro_sens / packet_count);
-    gyro[2] = (long)(((long long)gyro[2] << 16) / test.gyro_sens / packet_count);
-    accel[0] = (long)(((long long)accel[0] << 16) / test.accel_sens /
-                      packet_count);
-    accel[1] = (long)(((long long)accel[1] << 16) / test.accel_sens /
-                      packet_count);
-    accel[2] = (long)(((long long)accel[2] << 16) / test.accel_sens /
-                      packet_count);
-    /* Don't remove gravity! */
-    if (accel[2] > 0L)
-        accel[2] -= 65536L;
-    else
-        accel[2] += 65536L;
-#endif
-
-    return 0;
-}
-
-/**
- *  @brief      Trigger gyro/accel/compass self-test.
- *  On success/error, the self-test returns a mask representing the sensor(s)
- *  that failed. For each bit, a one (1) represents a "pass" case; conversely,
- *  a zero (0) indicates a failure.
- *
- *  \n The mask is defined as follows:
- *  \n Bit 0:   Gyro.
- *  \n Bit 1:   Accel.
- *  \n Bit 2:   Compass.
- *
- *  \n Currently, the hardware self-test is unsupported for MPU6500. However,
- *  this function can still be used to obtain the accel and gyro biases.
- *
- *  \n This function must be called with the device either face-up or face-down
- *  (z-axis is parallel to gravity).
- *  @param[out] gyro        Gyro biases in q16 format.
- *  @param[out] accel       Accel biases (if applicable) in q16 format.
- *  @return     Result mask (see above).
- */
-int mpu_run_self_test(long *gyro, long *accel)
-{
-#ifdef MPU6050
-    const unsigned char tries = 2;
-    long gyro_st[3], accel_st[3];
-    unsigned char accel_result, gyro_result;
-#ifdef AK89xx_SECONDARY
-    unsigned char compass_result;
-#endif
-    int ii;
-#endif
-    int result;
-    unsigned char accel_fsr, fifo_sensors, sensors_on;
-    unsigned short gyro_fsr, sample_rate, lpf;
-    unsigned char dmp_was_on;
-
-    if (st.chip_cfg.dmp_on)
-    {
-        mpu_set_dmp_state(0);
-        dmp_was_on = 1;
-    }
-    else
-        dmp_was_on = 0;
-
-    /* Get initial settings. */
-    mpu_get_gyro_fsr(&gyro_fsr);
-    mpu_get_accel_fsr(&accel_fsr);
-    mpu_get_lpf(&lpf);
-    mpu_get_sample_rate(&sample_rate);
-    sensors_on = st.chip_cfg.sensors;
-    mpu_get_fifo_config(&fifo_sensors);
-
-    /* For older chips, the self-test will be different. */
-#if defined MPU6050
-    for (ii = 0; ii < tries; ii++)
-        if (!get_st_biases(gyro, accel, 0))
-            break;
-    if (ii == tries)
-    {
-        /* If we reach this point, we most likely encountered an I2C error.
-         * We'll just report an error for all three sensors.
-         */
-        result = 0;
-        goto restore;
-    }
-    for (ii = 0; ii < tries; ii++)
-        if (!get_st_biases(gyro_st, accel_st, 1))
-            break;
-    if (ii == tries)
-    {
-        /* Again, probably an I2C error. */
-        result = 0;
-        goto restore;
-    }
-    accel_result = accel_self_test(accel, accel_st);
-    gyro_result = gyro_self_test(gyro, gyro_st);
-
-    result = 0;
-    if (!gyro_result)
-        result |= 0x01;
-    if (!accel_result)
-        result |= 0x02;
-
-#ifdef AK89xx_SECONDARY
-    compass_result = compass_self_test();
-    if (!compass_result)
-        result |= 0x04;
-#endif
-restore:
-#elif defined MPU6500
-    /* For now, this function will return a "pass" result for all three sensors
-     * for compatibility with current test applications.
-     */
-    get_st_biases(gyro, accel, 0);
-    result = 0x7;
-#endif
-    /* Set to invalid values to ensure no I2C writes are skipped. */
-    st.chip_cfg.gyro_fsr = 0xFF;
-    st.chip_cfg.accel_fsr = 0xFF;
-    st.chip_cfg.lpf = 0xFF;
-    st.chip_cfg.sample_rate = 0xFFFF;
-    st.chip_cfg.sensors = 0xFF;
-    st.chip_cfg.fifo_enable = 0xFF;
-    st.chip_cfg.clk_src = INV_CLK_PLL;
-    mpu_set_gyro_fsr(gyro_fsr);
-    mpu_set_accel_fsr(accel_fsr);
-    mpu_set_lpf(lpf);
-    mpu_set_sample_rate(sample_rate);
-    mpu_set_sensors(sensors_on);
-    mpu_configure_fifo(fifo_sensors);
-
-    if (dmp_was_on)
-        mpu_set_dmp_state(1);
-
-    return result;
-}
-
-/**
- *  @brief      Write to the DMP memory.
- *  This function prevents I2C writes past the bank boundaries. The DMP memory
- *  is only accessible when the chip is awake.
- *  @param[in]  mem_addr    Memory location (bank << 8 | start address)
- *  @param[in]  length      Number of bytes to write.
- *  @param[in]  data        Bytes to write to memory.
- *  @return     0 if successful.
- */
-int mpu_write_mem(unsigned short mem_addr, unsigned short length,
-                  unsigned char *data)
-{
-    unsigned char tmp[2];
-
-    if (!data)
-        return -1;
-    if (!st.chip_cfg.sensors)
-        return -1;
-
-    tmp[0] = (unsigned char)(mem_addr >> 8);
-    tmp[1] = (unsigned char)(mem_addr & 0xFF);
-
-    /* Check bank boundaries. */
-    if (tmp[1] + length > st.hw->bank_size)
-        return -1;
-
-    if (i2c_write(a1, st.reg->bank_sel, 2, tmp) && i2c_write(b1, st.reg->bank_sel, 2, tmp))
-        return -1;
-    if (i2c_write(a1, st.reg->mem_r_w, length, data) && i2c_write(b1, st.reg->bank_sel, length, tmp))
-        return -1;
-    return 0;
-}
-
-int mpu_write_mem1(unsigned short mem_addr, unsigned short length,
-                  unsigned char *data)
-{
-    unsigned char tmp[2];
-
-    if (!data)
-        return -1;
-    if (!st.chip_cfg.sensors)
-        return -1;
-
-    tmp[0] = (unsigned char)(mem_addr >> 8);
-    tmp[1] = (unsigned char)(mem_addr & 0xFF);
-
-    /* Check bank boundaries. */
-    if (tmp[1] + length > st.hw->bank_size)
-        return -1;
-
-    if (i2c_write1(a1, st.reg->bank_sel, 2, tmp) && i2c_write1(b1, st.reg->bank_sel, 2, tmp))
-        return -1;
-    if (i2c_write1(a1, st.reg->mem_r_w, length, data) && i2c_write1(b1, st.reg->bank_sel, length, tmp))
-        return -1;
-    return 0;
-}
-/**
- *  @brief      Read from the DMP memory.
- *  This function prevents I2C reads past the bank boundaries. The DMP memory
- *  is only accessible when the chip is awake.
- *  @param[in]  mem_addr    Memory location (bank << 8 | start address)
- *  @param[in]  length      Number of bytes to read.
- *  @param[out] data        Bytes read from memory.
- *  @return     0 if successful.
- */
-int mpu_read_mem(unsigned short mem_addr, unsigned short length,
-                 unsigned char *data)
-{
-    unsigned char tmp[2];
-
-    if (!data)
-        return -1;
-    if (!st.chip_cfg.sensors)
-        return -1;
-
-    tmp[0] = (unsigned char)(mem_addr >> 8);
-    tmp[1] = (unsigned char)(mem_addr & 0xFF);
-
-    /* Check bank boundaries. */
-    if (tmp[1] + length > st.hw->bank_size)
-        return -1;
-
-    if (i2c_write(a1, st.reg->bank_sel, 2, tmp) && i2c_write(b1, st.reg->bank_sel, 2, tmp))
-        return -1;
-    if (i2c_read(a1, st.reg->mem_r_w, length, data) && i2c_write(b1, st.reg->mem_r_w, length, tmp))
-        return -1;
-    return 0;
-}
-
-int mpu_read_mem1(unsigned short mem_addr, unsigned short length,
-                 unsigned char *data)
-{
-    unsigned char tmp[2];
-
-    if (!data)
-        return -1;
-    if (!st.chip_cfg.sensors)
-        return -1;
-
-    tmp[0] = (unsigned char)(mem_addr >> 8);
-    tmp[1] = (unsigned char)(mem_addr & 0xFF);
-
-    /* Check bank boundaries. */
-    if (tmp[1] + length > st.hw->bank_size)
-        return -1;
-
-    if (i2c_write1(a1, st.reg->bank_sel, 2, tmp) && i2c_write1(b1, st.reg->bank_sel, 2, tmp))
-        return -1;
-    if (i2c_read1(a1, st.reg->mem_r_w, length, data) && i2c_write1(b1, st.reg->mem_r_w, length, tmp))
-        return -1;
-    return 0;
-}
-
-/**
- *  @brief      Load and verify DMP image.
- *  @param[in]  length      Length of DMP image.
- *  @param[in]  firmware    DMP code.
- *  @param[in]  start_addr  Starting address of DMP code memory.
- *  @param[in]  sample_rate Fixed sampling rate used when DMP is enabled.
- *  @return     0 if successful.
- */
-int mpu_load_firmware(unsigned short length, const unsigned char *firmware,
-                      unsigned short start_addr, unsigned short sample_rate)
-{
-    unsigned short ii;
-    unsigned short this_write;
-    /* Must divide evenly into st.hw->bank_size to avoid bank crossings. */
-#define LOAD_CHUNK (16)
-    unsigned char cur[LOAD_CHUNK], tmp[2];
-
-    if (st.chip_cfg.dmp_loaded)
-        /* DMP should only be loaded once. */
-        return -1;
-
-    if (!firmware)
-        return -1;
-    for (ii = 0; ii < length; ii += this_write)
-    {
-        this_write = min(LOAD_CHUNK, length - ii);
-        if (mpu_write_mem1(ii, this_write, (unsigned char *)&firmware[ii]))
-            return -1;
-        if (mpu_read_mem1(ii, this_write, cur))
-            return -1;
-        if (memcmp(firmware + ii, cur, this_write))
-            return -2;
-    }
-
-    /* Set program start address. */
-    tmp[0] = start_addr >> 8;
-    tmp[1] = start_addr & 0xFF;
-    if (i2c_write(a1, st.reg->prgm_start_h, 2, tmp) && i2c_write(b1, st.reg->prgm_start_h, 2, tmp))
-        return -1;
-
-    st.chip_cfg.dmp_loaded = 1;
-    st.chip_cfg.dmp_sample_rate = sample_rate;
-    return 0;
-}
-
-/**
- *  @brief      Enable/disable DMP support.
- *  @param[in]  enable  1 to turn on the DMP.
- *  @return     0 if successful.
- */
-int mpu_set_dmp_state(unsigned char enable)
-{
-    unsigned char tmp;
-    if (st.chip_cfg.dmp_on == enable)
-        return 0;
-
-    if (enable)
-    {
-        if (!st.chip_cfg.dmp_loaded)
-            return -1;
-        /* Disable data ready interrupt. */
-        set_int_enable(0);
-        /* Disable bypass mode. */
-        mpu_set_bypass(0);
-        /* Keep constant sample rate, FIFO rate controlled by DMP. */
-        mpu_set_sample_rate(st.chip_cfg.dmp_sample_rate);
-        /* Remove FIFO elements. */
-        tmp = 0;
-        i2c_write1(a1, 0x23, 1, &tmp);
-        i2c_write1(b1, 0x23, 1, &tmp);
-        st.chip_cfg.dmp_on = 1;
-        /* Enable DMP interrupt. */
-        set_int_enable(1);
-        mpu_reset_fifo();
-    }
-    else
-    {
-        /* Disable DMP interrupt. */
-        set_int_enable(0);
-        /* Restore FIFO settings. */
-        tmp = st.chip_cfg.fifo_enable;
-        i2c_write1(a1, 0x23, 1, &tmp);
-        i2c_write1(b1, 0x23, 1, &tmp);
-        st.chip_cfg.dmp_on = 0;
-        mpu_reset_fifo();
-    }
-    return 0;
-}
-
-/**
- *  @brief      Get DMP state.
- *  @param[out] enabled 1 if enabled.
- *  @return     0 if successful.
- */
-int mpu_get_dmp_state(unsigned char *enabled)
-{
-    enabled[0] = st.chip_cfg.dmp_on;
-    return 0;
-}
-
-/* This initialization is similar to the one in ak8975.c. */
-static int setup_compass(void)
-{
-#ifdef AK89xx_SECONDARY
-    unsigned char data[4], akm_addr;
-
-    mpu_set_bypass(1);
-
-    /* Find compass. Possible addresses range from 0x0C to 0x0F. */
-    for (akm_addr = 0x0C; akm_addr <= 0x0F; akm_addr++)
-    {
-        int result;
-        result = i2c_read(akm_addr, AKM_REG_WHOAMI, 1, data);
-        if (!result && (data[0] == AKM_WHOAMI))
-            break;
-    }
-
-    if (akm_addr > 0x0F)
-    {
-        /* TODO: Handle this case in all compass-related functions. */
-        log_e("Compass not found.\n");
-        return -1;
-    }
-
-    st.chip_cfg.compass_addr = akm_addr;
-
-    data[0] = AKM_POWER_DOWN;
-    if (i2c_write(st.chip_cfg.compass_addr, AKM_REG_CNTL, 1, data))
-        return -1;
-    delay_ms(1);
-
-    data[0] = AKM_FUSE_ROM_ACCESS;
-    if (i2c_write(st.chip_cfg.compass_addr, AKM_REG_CNTL, 1, data))
-        return -1;
-    delay_ms(1);
-
-    /* Get sensitivity adjustment data from fuse ROM. */
-    if (i2c_read(st.chip_cfg.compass_addr, AKM_REG_ASAX, 3, data))
-        return -1;
-    st.chip_cfg.mag_sens_adj[0] = (long)data[0] + 128;
-    st.chip_cfg.mag_sens_adj[1] = (long)data[1] + 128;
-    st.chip_cfg.mag_sens_adj[2] = (long)data[2] + 128;
-
-    data[0] = AKM_POWER_DOWN;
-    if (i2c_write(st.chip_cfg.compass_addr, AKM_REG_CNTL, 1, data))
-        return -1;
-    delay_ms(1);
-
-    mpu_set_bypass(0);
-
-    /* Set up master mode, master clock, and ES bit. */
-    data[0] = 0x40;
-    if (i2c_write(a, st.reg->i2c_mst, 1, data))
-        return -1;
-
-    /* Slave 0 reads from AKM data registers. */
-    data[0] = BIT_I2C_READ | st.chip_cfg.compass_addr;
-    if (i2c_write(a, st.reg->s0_addr, 1, data))
-        return -1;
-
-    /* Compass reads start at this register. */
-    data[0] = AKM_REG_ST1;
-    if (i2c_write(a, st.reg->s0_reg, 1, data))
-        return -1;
-
-    /* Enable slave 0, 8-byte reads. */
-    data[0] = BIT_SLAVE_EN | 8;
-    if (i2c_write(a, st.reg->s0_ctrl, 1, data))
-        return -1;
-
-    /* Slave 1 changes AKM measurement mode. */
-    data[0] = st.chip_cfg.compass_addr;
-    if (i2c_write(a, st.reg->s1_addr, 1, data))
-        return -1;
-
-    /* AKM measurement mode register. */
-    data[0] = AKM_REG_CNTL;
-    if (i2c_write(a, st.reg->s1_reg, 1, data))
-        return -1;
-
-    /* Enable slave 1, 1-byte writes. */
-    data[0] = BIT_SLAVE_EN | 1;
-    if (i2c_write(a, st.reg->s1_ctrl, 1, data))
-        return -1;
-
-    /* Set slave 1 data. */
-    data[0] = AKM_SINGLE_MEASUREMENT;
-    if (i2c_write(a, st.reg->s1_do, 1, data))
-        return -1;
-
-    /* Trigger slave 0 and slave 1 actions at each sample. */
-    data[0] = 0x03;
-    if (i2c_write(a, st.reg->i2c_delay_ctrl, 1, data))
-        return -1;
-
-#ifdef MPU9150
-    /* For the MPU9150, the auxiliary I2C bus needs to be set to VDD. */
-    data[0] = BIT_I2C_MST_VDDIO;
-    if (i2c_write(a, st.reg->yg_offs_tc, 1, data))
-        return -1;
-#endif
-
-    return 0;
-#else
-    return -1;
-#endif
-}
-
-/**
- *  @brief      Read raw compass data.
- *  @param[out] data        Raw data in hardware units.
- *  @param[out] timestamp   Timestamp in milliseconds. Null if not needed.
- *  @return     0 if successful.
- */
-int mpu_get_compass_reg(short *data, unsigned long *timestamp)
-{
-#ifdef AK89xx_SECONDARY
-    unsigned char tmp[9];
-
-    if (!(st.chip_cfg.sensors & INV_XYZ_COMPASS))
-        return -1;
-
-#ifdef AK89xx_BYPASS
-    if (i2c_read(st.chip_cfg.compass_addr, AKM_REG_ST1, 8, tmp))
-        return -1;
-    tmp[8] = AKM_SINGLE_MEASUREMENT;
-    if (i2c_write(st.chip_cfg.compass_addr, AKM_REG_CNTL, 1, tmp + 8))
-        return -1;
-#else
-    if (i2c_read(a, st.reg->raw_compass, 8, tmp))
-        return -1;
-#endif
-
-#if defined AK8975_SECONDARY
-    /* AK8975 doesn't have the overrun error bit. */
-    if (!(tmp[0] & AKM_DATA_READY))
-        return -2;
-    if ((tmp[7] & AKM_OVERFLOW) || (tmp[7] & AKM_DATA_ERROR))
-        return -3;
-#elif defined AK8963_SECONDARY
-    /* AK8963 doesn't have the data read error bit. */
-    if (!(tmp[0] & AKM_DATA_READY) || (tmp[0] & AKM_DATA_OVERRUN))
-        return -2;
-    if (tmp[7] & AKM_OVERFLOW)
-        return -3;
-#endif
-    data[0] = (tmp[2] << 8) | tmp[1];
-    data[1] = (tmp[4] << 8) | tmp[3];
-    data[2] = (tmp[6] << 8) | tmp[5];
-
-    data[0] = ((long)data[0] * st.chip_cfg.mag_sens_adj[0]) >> 8;
-    data[1] = ((long)data[1] * st.chip_cfg.mag_sens_adj[1]) >> 8;
-    data[2] = ((long)data[2] * st.chip_cfg.mag_sens_adj[2]) >> 8;
-
-    if (timestamp)
-        get_ms(timestamp);
-    return 0;
-#else
-    return -1;
-#endif
-}
-
-/**
- *  @brief      Get the compass full-scale range.
- *  @param[out] fsr Current full-scale range.
- *  @return     0 if successful.
- */
-int mpu_get_compass_fsr(unsigned short *fsr)
-{
-#ifdef AK89xx_SECONDARY
-    fsr[0] = st.hw->compass_fsr;
-    return 0;
-#else
-    return -1;
-#endif
-}
-
-/**
- *  @brief      Enters LP accel motion interrupt mode.
- *  The behaviour of this feature is very different between the MPU6050 and the
- *  MPU6500. Each chip's version of this feature is explained below.
- *
- *  \n The hardware motion threshold can be between 32mg and 8160mg in 32mg
- *  increments.
- *
- *  \n Low-power accel mode supports the following frequencies:
- *  \n 1.25Hz, 5Hz, 20Hz, 40Hz
- *
- *  \n MPU6500:
- *  \n Unlike the MPU6050 version, the hardware does not "lock in" a reference
- *  sample. The hardware monitors the accel data and detects any large change
- *  over a short period of time.
- *
- *  \n The hardware motion threshold can be between 4mg and 1020mg in 4mg
- *  increments.
- *
- *  \n MPU6500 Low-power accel mode supports the following frequencies:
- *  \n 1.25Hz, 2.5Hz, 5Hz, 10Hz, 20Hz, 40Hz, 80Hz, 160Hz, 320Hz, 640Hz
- *
- *  \n\n NOTES:
- *  \n The driver will round down @e thresh to the nearest supported value if
- *  an unsupported threshold is selected.
- *  \n To select a fractional wake-up frequency, round down the value passed to
- *  @e lpa_freq.
- *  \n The MPU6500 does not support a delay parameter. If this function is used
- *  for the MPU6500, the value passed to @e time will be ignored.
- *  \n To disable this mode, set @e lpa_freq to zero. The driver will restore
- *  the previous configuration.
- *
- *  @param[in]  thresh      Motion threshold in mg.
- *  @param[in]  time        Duration in milliseconds that the accel data must
- *                          exceed @e thresh before motion is reported.
- *  @param[in]  lpa_freq    Minimum sampling rate, or zero to disable.
- *  @return     0 if successful.
- */
-int mpu_lp_motion_interrupt(unsigned short thresh, unsigned char time,
-                            unsigned char lpa_freq)
-{
-    unsigned char data[3];
-
-    if (lpa_freq)
-    {
-        unsigned char thresh_hw;
-
-#if defined MPU6500
-        /* 1LSb = 4mg. */
-        if (thresh > 1020)
-            thresh_hw = 255;
-        else if (thresh < 4)
-            thresh_hw = 1;
-        else
-            thresh_hw = thresh >> 2;
-#endif
-
-        if (!time)
-            /* Minimum duration must be 1ms. */
-            time = 1;
-
-#if defined MPU6500
-        if (lpa_freq > 640)
-#endif
-            /* At this point, the chip has not been re-configured, so the
-             * function can safely exit.
-             */
-            return -1;
-
-        if (!st.chip_cfg.int_motion_only)
-        {
-            /* Store current settings for later. */
-            if (st.chip_cfg.dmp_on)
-            {
-                mpu_set_dmp_state(0);
-                st.chip_cfg.cache.dmp_on = 1;
-            }
-            else
-                st.chip_cfg.cache.dmp_on = 0;
-            mpu_get_gyro_fsr(&st.chip_cfg.cache.gyro_fsr);
-            mpu_get_accel_fsr(&st.chip_cfg.cache.accel_fsr);
-            mpu_get_lpf(&st.chip_cfg.cache.lpf);
-            mpu_get_sample_rate(&st.chip_cfg.cache.sample_rate);
-            st.chip_cfg.cache.sensors_on = st.chip_cfg.sensors;
-            mpu_get_fifo_config(&st.chip_cfg.cache.fifo_sensors);
-        }
-
-#if defined MPU6500
-        /* Disable hardware interrupts. */
-        set_int_enable(0);
-
-        /* Enter full-power accel-only mode, no FIFO/DMP. */
-        data[0] = 0;
-        data[1] = 0;
-        data[2] = BIT_STBY_XYZG;
-        if (i2c_write(a, st.reg->user_ctrl, 3, data))
-            goto lp_int_restore;
-
-        /* Set motion threshold. */
-        data[0] = thresh_hw;
-        if (i2c_write(a, st.reg->motion_thr, 1, data))
-            goto lp_int_restore;
-
-        /* Set wake frequency. */
-        if (lpa_freq == 1)
-            data[0] = INV_LPA_1_25HZ;
-        else if (lpa_freq == 2)
-            data[0] = INV_LPA_2_5HZ;
-        else if (lpa_freq <= 5)
-            data[0] = INV_LPA_5HZ;
-        else if (lpa_freq <= 10)
-            data[0] = INV_LPA_10HZ;
-        else if (lpa_freq <= 20)
-            data[0] = INV_LPA_20HZ;
-        else if (lpa_freq <= 40)
-            data[0] = INV_LPA_40HZ;
-        else if (lpa_freq <= 80)
-            data[0] = INV_LPA_80HZ;
-        else if (lpa_freq <= 160)
-            data[0] = INV_LPA_160HZ;
-        else if (lpa_freq <= 320)
-            data[0] = INV_LPA_320HZ;
-        else
-            data[0] = INV_LPA_640HZ;
-        if (i2c_write(a, st.reg->lp_accel_odr, 1, data))
-            goto lp_int_restore;
-
-        /* Enable motion interrupt (MPU6500 version). */
-        data[0] = BITS_WOM_EN;
-        if (i2c_write(a, st.reg->accel_intel, 1, data))
-            goto lp_int_restore;
-
-        /* Enable cycle mode. */
-        data[0] = BIT_LPA_CYCLE;
-        if (i2c_write(a, st.reg->pwr_mgmt_1, 1, data))
-            goto lp_int_restore;
-
-        /* Enable interrupt. */
-        data[0] = BIT_MOT_INT_EN;
-        if (i2c_write(a, st.reg->int_enable, 1, data))
-            goto lp_int_restore;
-
-        st.chip_cfg.int_motion_only = 1;
-        return 0;
-#endif
-    }
-    else
-    {
-        /* Don't "restore" the previous state if no state has been saved. */
-        int ii;
-        char *cache_ptr = (char *)&st.chip_cfg.cache;
-        for (ii = 0; ii < sizeof(st.chip_cfg.cache); ii++)
-        {
-            if (cache_ptr[ii] != 0)
-                goto lp_int_restore;
-        }
-        /* If we reach this point, motion interrupt mode hasn't been used yet. */
-        return -1;
-    }
-lp_int_restore:
-    /* Set to invalid values to ensure no I2C writes are skipped. */
-    st.chip_cfg.gyro_fsr = 0xFF;
-    st.chip_cfg.accel_fsr = 0xFF;
-    st.chip_cfg.lpf = 0xFF;
-    st.chip_cfg.sample_rate = 0xFFFF;
-    st.chip_cfg.sensors = 0xFF;
-    st.chip_cfg.fifo_enable = 0xFF;
-    st.chip_cfg.clk_src = INV_CLK_PLL;
-    mpu_set_sensors(st.chip_cfg.cache.sensors_on);
-    mpu_set_gyro_fsr(st.chip_cfg.cache.gyro_fsr);
-    mpu_set_accel_fsr(st.chip_cfg.cache.accel_fsr);
-    mpu_set_lpf(st.chip_cfg.cache.lpf);
-    mpu_set_sample_rate(st.chip_cfg.cache.sample_rate);
-    mpu_configure_fifo(st.chip_cfg.cache.fifo_sensors);
-
-    if (st.chip_cfg.cache.dmp_on)
-        mpu_set_dmp_state(1);
-
-#ifdef MPU6500
-    /* Disable motion interrupt (MPU6500 version). */
-    data[0] = 0;
-    if (i2c_write(a, st.reg->accel_intel, 1, data))
-        goto lp_int_restore;
-#endif
-
-    st.chip_cfg.int_motion_only = 0;
-    return 0;
-}
-
-/**
- *  @}
- */

+ 0 - 136
Core - 副本/imu/inv_mpu.h

@@ -1,136 +0,0 @@
-/*
- $License:
-    Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved.
-    See included License.txt for License information.
- $
- */
-/**
- *  @addtogroup  DRIVERS Sensor Driver Layer
- *  @brief       Hardware drivers to communicate with sensors via I2C.
- *
- *  @{
- *      @file       inv_mpu.h
- *      @brief      An I2C-based driver for Invensense gyroscopes.
- *      @details    This driver currently works for the following devices:
- *                  MPU6050
- *                  MPU6500
- *                  MPU9150 (or MPU6050 w/ AK8975 on the auxiliary bus)
- *                  MPU9250 (or MPU6500 w/ AK8963 on the auxiliary bus)
- */
-
-#ifndef _INV_MPU_H_
-#define _INV_MPU_H_
-
-#define MOTION_DRIVER_TARGET_STM32
-#define MPU6050
-// #define EMPL
-// #define USE_DMP
-
-#define INV_X_GYRO (0x40)
-#define INV_Y_GYRO (0x20)
-#define INV_Z_GYRO (0x10)
-#define INV_XYZ_GYRO (INV_X_GYRO | INV_Y_GYRO | INV_Z_GYRO)
-#define INV_XYZ_ACCEL (0x08)
-#define INV_XYZ_COMPASS (0x01)
-
-struct int_param_s
-{
-#if defined EMPL_TARGET_MSP430 || defined MOTION_DRIVER_TARGET_MSP430 || defined MOTION_DRIVER_TARGET_STM32
-    void (*cb)(void);
-    unsigned short pin;
-    unsigned char lp_exit;
-    unsigned char active_low;
-#elif defined EMPL_TARGET_UC3L0
-    unsigned long pin;
-    void (*cb)(volatile void *);
-    void *arg;
-#endif
-};
-
-#define MPU_INT_STATUS_DATA_READY (0x0001)
-#define MPU_INT_STATUS_DMP (0x0002)
-#define MPU_INT_STATUS_PLL_READY (0x0004)
-#define MPU_INT_STATUS_I2C_MST (0x0008)
-#define MPU_INT_STATUS_FIFO_OVERFLOW (0x0010)
-#define MPU_INT_STATUS_ZMOT (0x0020)
-#define MPU_INT_STATUS_MOT (0x0040)
-#define MPU_INT_STATUS_FREE_FALL (0x0080)
-#define MPU_INT_STATUS_DMP_0 (0x0100)
-#define MPU_INT_STATUS_DMP_1 (0x0200)
-#define MPU_INT_STATUS_DMP_2 (0x0400)
-#define MPU_INT_STATUS_DMP_3 (0x0800)
-#define MPU_INT_STATUS_DMP_4 (0x1000)
-#define MPU_INT_STATUS_DMP_5 (0x2000)
-
-/* Set up APIs */
-int mpu_init(struct int_param_s *int_param);
-int mpu_init_slave(void);
-int mpu_set_bypass(unsigned char bypass_on);
-
-/* Configuration APIs */
-int mpu_lp_accel_mode(unsigned char rate);
-int mpu_lp_motion_interrupt(unsigned short thresh, unsigned char time,
-                            unsigned char lpa_freq);
-int mpu_set_int_level(unsigned char active_low);
-int mpu_set_int_latched(unsigned char enable);
-
-int mpu_set_dmp_state(unsigned char enable);
-int mpu_get_dmp_state(unsigned char *enabled);
-
-int mpu_get_lpf(unsigned short *lpf);
-int mpu_set_lpf(unsigned short lpf);
-
-int mpu_get_gyro_fsr(unsigned short *fsr);
-int mpu_set_gyro_fsr(unsigned short fsr);
-
-int mpu_get_accel_fsr(unsigned char *fsr);
-int mpu_set_accel_fsr(unsigned char fsr);
-
-int mpu_get_compass_fsr(unsigned short *fsr);
-
-int mpu_get_gyro_sens(float *sens);
-int mpu_get_accel_sens(unsigned short *sens);
-
-int mpu_get_sample_rate(unsigned short *rate);
-int mpu_set_sample_rate(unsigned short rate);
-int mpu_get_compass_sample_rate(unsigned short *rate);
-int mpu_set_compass_sample_rate(unsigned short rate);
-
-int mpu_get_fifo_config(unsigned char *sensors);
-int mpu_configure_fifo(unsigned char sensors);
-
-int mpu_get_power_state(unsigned char *power_on);
-int mpu_set_sensors(unsigned char sensors);
-
-int mpu_set_accel_bias(const long *accel_bias);
-
-/* Data getter/setter APIs */
-int mpu_get_gyro_reg(short *data, unsigned long *timestamp);
-int mpu_get_accel_reg(short *data, unsigned long *timestamp);
-int mpu_get_compass_reg(short *data, unsigned long *timestamp);
-int mpu_get_temperature(long *data, unsigned long *timestamp);
-
-int mpu_get_int_status(short *status);
-int mpu_read_fifo(short *gyro, short *accel, unsigned long *timestamp,
-                  unsigned char *sensors, unsigned char *more);
-int mpu_read_fifo_stream(unsigned short length, unsigned char *data,
-                         unsigned char *more);
-int mpu_reset_fifo(void);
-
-int mpu_write_mem(unsigned short mem_addr, unsigned short length,
-                  unsigned char *data);
-int mpu_write_mem1(unsigned short mem_addr, unsigned short length,
-                  unsigned char *data);
-int mpu_read_mem(unsigned short mem_addr, unsigned short length,
-                 unsigned char *data);
-int mpu_read_mem1(unsigned short mem_addr, unsigned short length,
-                 unsigned char *data);
-int mpu_load_firmware(unsigned short length, const unsigned char *firmware,
-                      unsigned short start_addr, unsigned short sample_rate);
-
-int mpu_reg_dump(void);
-int mpu_read_reg(unsigned char reg, unsigned char *data);
-int mpu_run_self_test(long *gyro, long *accel);
-int mpu_register_tap_cb(void (*func)(unsigned char, unsigned char));
-
-#endif /* #ifndef _INV_MPU_H_ */

+ 0 - 1380
Core - 副本/imu/inv_mpu_dmp_motion_driver.c

@@ -1,1380 +0,0 @@
-/*
- $License:
-    Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved.
-    See included License.txt for License information.
- $
- */
-/**
- *  @addtogroup  DRIVERS Sensor Driver Layer
- *  @brief       Hardware drivers to communicate with sensors via I2C.
- *
- *  @{
- *      @file       inv_mpu_dmp_motion_driver.c
- *      @brief      DMP image and interface functions.
- *      @details    All functions are preceded by the dmp_ prefix to
- *                  differentiate among MPL and general driver function calls.
- */
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include "inv_mpu.h"
-#include "inv_mpu_dmp_motion_driver.h"
-#include "dmpKey.h"
-#include "dmpmap.h"
-
-#include "MPU6050.h"
-
-/* The following functions must be defined for this platform:
- * i2c_write(unsigned char slave_addr, unsigned char reg_addr,
- *      unsigned char length, unsigned char const *data)
- * i2c_read(unsigned char slave_addr, unsigned char reg_addr,
- *      unsigned char length, unsigned char *data)
- * delay_ms(unsigned long num_ms)
- * get_ms(unsigned long *count)
- */
-#if defined MOTION_DRIVER_TARGET_MSP430
-#include "msp430.h"
-#include "msp430_clock.h"
-#define delay_ms    msp430_delay_ms
-#define get_ms      msp430_get_clock_ms
-#define log_i(...)     do {} while (0)
-#define log_e(...)     do {} while (0)
-
-#elif defined EMPL_TARGET_MSP430
-#include "msp430.h"
-#include "msp430_clock.h"
-#include "log.h"
-#define delay_ms    msp430_delay_ms
-#define get_ms      msp430_get_clock_ms
-#define log_i       MPL_LOGI
-#define log_e       MPL_LOGE
-
-#elif defined EMPL_TARGET_UC3L0
-/* Instead of using the standard TWI driver from the ASF library, we're using
- * a TWI driver that follows the slave address + register address convention.
- */
-#include "delay.h"
-#include "sysclk.h"
-#include "log.h"
-#include "uc3l0_clock.h"
-/* delay_ms is a function already defined in ASF. */
-#define get_ms  uc3l0_get_clock_ms
-#define log_i       MPL_LOGI
-#define log_e       MPL_LOGE
-
-#elif defined MOTION_DRIVER_TARGET_STM32
-
-#define delay_ms    HAL_Delay
-#define get_ms      get_tick_count
-
-#define log_i(...)     do {} while (0)
-#define log_e(...)     do {} while (0)
-
-#else
-#error  Gyro driver is missing the system layer implementations.
-#endif
-
-/* These defines are copied from dmpDefaultMPU6050.c in the general MPL
- * releases. These defines may change for each DMP image, so be sure to modify
- * these values when switching to a new image.
- */
-#define CFG_LP_QUAT             (2712)
-#define END_ORIENT_TEMP         (1866)
-#define CFG_27                  (2742)
-#define CFG_20                  (2224)
-#define CFG_23                  (2745)
-#define CFG_FIFO_ON_EVENT       (2690)
-#define END_PREDICTION_UPDATE   (1761)
-#define CGNOTICE_INTR           (2620)
-#define X_GRT_Y_TMP             (1358)
-#define CFG_DR_INT              (1029)
-#define CFG_AUTH                (1035)
-#define UPDATE_PROP_ROT         (1835)
-#define END_COMPARE_Y_X_TMP2    (1455)
-#define SKIP_X_GRT_Y_TMP        (1359)
-#define SKIP_END_COMPARE        (1435)
-#define FCFG_3                  (1088)
-#define FCFG_2                  (1066)
-#define FCFG_1                  (1062)
-#define END_COMPARE_Y_X_TMP3    (1434)
-#define FCFG_7                  (1073)
-#define FCFG_6                  (1106)
-#define FLAT_STATE_END          (1713)
-#define SWING_END_4             (1616)
-#define SWING_END_2             (1565)
-#define SWING_END_3             (1587)
-#define SWING_END_1             (1550)
-#define CFG_8                   (2718)
-#define CFG_15                  (2727)
-#define CFG_16                  (2746)
-#define CFG_EXT_GYRO_BIAS       (1189)
-#define END_COMPARE_Y_X_TMP     (1407)
-#define DO_NOT_UPDATE_PROP_ROT  (1839)
-#define CFG_7                   (1205)
-#define FLAT_STATE_END_TEMP     (1683)
-#define END_COMPARE_Y_X         (1484)
-#define SKIP_SWING_END_1        (1551)
-#define SKIP_SWING_END_3        (1588)
-#define SKIP_SWING_END_2        (1566)
-#define TILTG75_START           (1672)
-#define CFG_6                   (2753)
-#define TILTL75_END             (1669)
-#define END_ORIENT              (1884)
-#define CFG_FLICK_IN            (2573)
-#define TILTL75_START           (1643)
-#define CFG_MOTION_BIAS         (1208)
-#define X_GRT_Y                 (1408)
-#define TEMPLABEL               (2324)
-#define CFG_ANDROID_ORIENT_INT  (1853)
-#define CFG_GYRO_RAW_DATA       (2722)
-#define X_GRT_Y_TMP2            (1379)
-
-#define D_0_22                  (22+512)
-#define D_0_24                  (24+512)
-
-#define D_0_36                  (36)
-#define D_0_52                  (52)
-#define D_0_96                  (96)
-#define D_0_104                 (104)
-#define D_0_108                 (108)
-#define D_0_163                 (163)
-#define D_0_188                 (188)
-#define D_0_192                 (192)
-#define D_0_224                 (224)
-#define D_0_228                 (228)
-#define D_0_232                 (232)
-#define D_0_236                 (236)
-
-#define D_1_2                   (256 + 2)
-#define D_1_4                   (256 + 4)
-#define D_1_8                   (256 + 8)
-#define D_1_10                  (256 + 10)
-#define D_1_24                  (256 + 24)
-#define D_1_28                  (256 + 28)
-#define D_1_36                  (256 + 36)
-#define D_1_40                  (256 + 40)
-#define D_1_44                  (256 + 44)
-#define D_1_72                  (256 + 72)
-#define D_1_74                  (256 + 74)
-#define D_1_79                  (256 + 79)
-#define D_1_88                  (256 + 88)
-#define D_1_90                  (256 + 90)
-#define D_1_92                  (256 + 92)
-#define D_1_96                  (256 + 96)
-#define D_1_98                  (256 + 98)
-#define D_1_106                 (256 + 106)
-#define D_1_108                 (256 + 108)
-#define D_1_112                 (256 + 112)
-#define D_1_128                 (256 + 144)
-#define D_1_152                 (256 + 12)
-#define D_1_160                 (256 + 160)
-#define D_1_176                 (256 + 176)
-#define D_1_178                 (256 + 178)
-#define D_1_218                 (256 + 218)
-#define D_1_232                 (256 + 232)
-#define D_1_236                 (256 + 236)
-#define D_1_240                 (256 + 240)
-#define D_1_244                 (256 + 244)
-#define D_1_250                 (256 + 250)
-#define D_1_252                 (256 + 252)
-#define D_2_12                  (512 + 12)
-#define D_2_96                  (512 + 96)
-#define D_2_108                 (512 + 108)
-#define D_2_208                 (512 + 208)
-#define D_2_224                 (512 + 224)
-#define D_2_236                 (512 + 236)
-#define D_2_244                 (512 + 244)
-#define D_2_248                 (512 + 248)
-#define D_2_252                 (512 + 252)
-
-#define CPASS_BIAS_X            (35 * 16 + 4)
-#define CPASS_BIAS_Y            (35 * 16 + 8)
-#define CPASS_BIAS_Z            (35 * 16 + 12)
-#define CPASS_MTX_00            (36 * 16)
-#define CPASS_MTX_01            (36 * 16 + 4)
-#define CPASS_MTX_02            (36 * 16 + 8)
-#define CPASS_MTX_10            (36 * 16 + 12)
-#define CPASS_MTX_11            (37 * 16)
-#define CPASS_MTX_12            (37 * 16 + 4)
-#define CPASS_MTX_20            (37 * 16 + 8)
-#define CPASS_MTX_21            (37 * 16 + 12)
-#define CPASS_MTX_22            (43 * 16 + 12)
-#define D_EXT_GYRO_BIAS_X       (61 * 16)
-#define D_EXT_GYRO_BIAS_Y       (61 * 16) + 4
-#define D_EXT_GYRO_BIAS_Z       (61 * 16) + 8
-#define D_ACT0                  (40 * 16)
-#define D_ACSX                  (40 * 16 + 4)
-#define D_ACSY                  (40 * 16 + 8)
-#define D_ACSZ                  (40 * 16 + 12)
-
-#define FLICK_MSG               (45 * 16 + 4)
-#define FLICK_COUNTER           (45 * 16 + 8)
-#define FLICK_LOWER             (45 * 16 + 12)
-#define FLICK_UPPER             (46 * 16 + 12)
-
-#define D_AUTH_OUT              (992)
-#define D_AUTH_IN               (996)
-#define D_AUTH_A                (1000)
-#define D_AUTH_B                (1004)
-
-#define D_PEDSTD_BP_B           (768 + 0x1C)
-#define D_PEDSTD_HP_A           (768 + 0x78)
-#define D_PEDSTD_HP_B           (768 + 0x7C)
-#define D_PEDSTD_BP_A4          (768 + 0x40)
-#define D_PEDSTD_BP_A3          (768 + 0x44)
-#define D_PEDSTD_BP_A2          (768 + 0x48)
-#define D_PEDSTD_BP_A1          (768 + 0x4C)
-#define D_PEDSTD_INT_THRSH      (768 + 0x68)
-#define D_PEDSTD_CLIP           (768 + 0x6C)
-#define D_PEDSTD_SB             (768 + 0x28)
-#define D_PEDSTD_SB_TIME        (768 + 0x2C)
-#define D_PEDSTD_PEAKTHRSH      (768 + 0x98)
-#define D_PEDSTD_TIML           (768 + 0x2A)
-#define D_PEDSTD_TIMH           (768 + 0x2E)
-#define D_PEDSTD_PEAK           (768 + 0X94)
-#define D_PEDSTD_STEPCTR        (768 + 0x60)
-#define D_PEDSTD_TIMECTR        (964)
-#define D_PEDSTD_DECI           (768 + 0xA0)
-
-#define D_HOST_NO_MOT           (976)
-#define D_ACCEL_BIAS            (660)
-
-#define D_ORIENT_GAP            (76)
-
-#define D_TILT0_H               (48)
-#define D_TILT0_L               (50)
-#define D_TILT1_H               (52)
-#define D_TILT1_L               (54)
-#define D_TILT2_H               (56)
-#define D_TILT2_L               (58)
-#define D_TILT3_H               (60)
-#define D_TILT3_L               (62)
-
-#define DMP_CODE_SIZE           (3062)
-
-static const unsigned char dmp_memory[DMP_CODE_SIZE] = {
-    /* bank # 0 */
-    0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
-    0x00, 0x65, 0x00, 0x54, 0xff, 0xef, 0x00, 0x00, 0xfa, 0x80, 0x00, 0x0b, 0x12, 0x82, 0x00, 0x01,
-    0x03, 0x0c, 0x30, 0xc3, 0x0e, 0x8c, 0x8c, 0xe9, 0x14, 0xd5, 0x40, 0x02, 0x13, 0x71, 0x0f, 0x8e,
-    0x38, 0x83, 0xf8, 0x83, 0x30, 0x00, 0xf8, 0x83, 0x25, 0x8e, 0xf8, 0x83, 0x30, 0x00, 0xf8, 0x83,
-    0xff, 0xff, 0xff, 0xff, 0x0f, 0xfe, 0xa9, 0xd6, 0x24, 0x00, 0x04, 0x00, 0x1a, 0x82, 0x79, 0xa1,
-    0x00, 0x00, 0x00, 0x3c, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x38, 0x83, 0x6f, 0xa2,
-    0x00, 0x3e, 0x03, 0x30, 0x40, 0x00, 0x00, 0x00, 0x02, 0xca, 0xe3, 0x09, 0x3e, 0x80, 0x00, 0x00,
-    0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
-    0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x6e, 0x00, 0x00, 0x06, 0x92, 0x0a, 0x16, 0xc0, 0xdf,
-    0xff, 0xff, 0x02, 0x56, 0xfd, 0x8c, 0xd3, 0x77, 0xff, 0xe1, 0xc4, 0x96, 0xe0, 0xc5, 0xbe, 0xaa,
-    0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x2b, 0x00, 0x00, 0x16, 0x57, 0x00, 0x00, 0x03, 0x59,
-    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0xfa, 0x00, 0x02, 0x6c, 0x1d, 0x00, 0x00, 0x00, 0x00,
-    0x3f, 0xff, 0xdf, 0xeb, 0x00, 0x3e, 0xb3, 0xb6, 0x00, 0x0d, 0x22, 0x78, 0x00, 0x00, 0x2f, 0x3c,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x42, 0xb5, 0x00, 0x00, 0x39, 0xa2, 0x00, 0x00, 0xb3, 0x65,
-    0xd9, 0x0e, 0x9f, 0xc9, 0x1d, 0xcf, 0x4c, 0x34, 0x30, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
-    0x3b, 0xb6, 0x7a, 0xe8, 0x00, 0x64, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    /* bank # 1 */
-    0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0xfa, 0x92, 0x10, 0x00, 0x22, 0x5e, 0x00, 0x0d, 0x22, 0x9f,
-    0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0xff, 0x46, 0x00, 0x00, 0x63, 0xd4, 0x00, 0x00,
-    0x10, 0x00, 0x00, 0x00, 0x04, 0xd6, 0x00, 0x00, 0x04, 0xcc, 0x00, 0x00, 0x04, 0xcc, 0x00, 0x00,
-    0x00, 0x00, 0x10, 0x72, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x06, 0x00, 0x02, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x64, 0x00, 0x20, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x03, 0x00,
-    0x00, 0x00, 0x00, 0x32, 0xf8, 0x98, 0x00, 0x00, 0xff, 0x65, 0x00, 0x00, 0x83, 0x0f, 0x00, 0x00,
-    0xff, 0x9b, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
-    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0xb2, 0x6a, 0x00, 0x02, 0x00, 0x00,
-    0x00, 0x01, 0xfb, 0x83, 0x00, 0x68, 0x00, 0x00, 0x00, 0xd9, 0xfc, 0x00, 0x7c, 0xf1, 0xff, 0x83,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x64, 0x03, 0xe8, 0x00, 0x64, 0x00, 0x28,
-    0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
-    0x00, 0x00, 0x10, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf4, 0x00, 0x00, 0x10, 0x00,
-    /* bank # 2 */
-    0x00, 0x28, 0x00, 0x00, 0xff, 0xff, 0x45, 0x81, 0xff, 0xff, 0xfa, 0x72, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x05, 0x00, 0x05, 0xba, 0xc6, 0x00, 0x47, 0x78, 0xa2,
-    0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x14,
-    0x00, 0x00, 0x25, 0x4d, 0x00, 0x2f, 0x70, 0x6d, 0x00, 0x00, 0x05, 0xae, 0x00, 0x0c, 0x02, 0xd0,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x64, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x0e,
-    0x00, 0x00, 0x0a, 0xc7, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0xff, 0xff, 0xff, 0x9c,
-    0x00, 0x00, 0x0b, 0x2b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64,
-    0xff, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    /* bank # 3 */
-    0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x24, 0x26, 0xd3,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x96, 0x00, 0x3c,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x0c, 0x0a, 0x4e, 0x68, 0xcd, 0xcf, 0x77, 0x09, 0x50, 0x16, 0x67, 0x59, 0xc6, 0x19, 0xce, 0x82,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0xd7, 0x84, 0x00, 0x03, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc7, 0x93, 0x8f, 0x9d, 0x1e, 0x1b, 0x1c, 0x19,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x18, 0x85, 0x00, 0x00, 0x40, 0x00,
-    0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x67, 0x7d, 0xdf, 0x7e, 0x72, 0x90, 0x2e, 0x55, 0x4c, 0xf6, 0xe6, 0x88,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
-    /* bank # 4 */
-    0xd8, 0xdc, 0xb4, 0xb8, 0xb0, 0xd8, 0xb9, 0xab, 0xf3, 0xf8, 0xfa, 0xb3, 0xb7, 0xbb, 0x8e, 0x9e,
-    0xae, 0xf1, 0x32, 0xf5, 0x1b, 0xf1, 0xb4, 0xb8, 0xb0, 0x80, 0x97, 0xf1, 0xa9, 0xdf, 0xdf, 0xdf,
-    0xaa, 0xdf, 0xdf, 0xdf, 0xf2, 0xaa, 0xc5, 0xcd, 0xc7, 0xa9, 0x0c, 0xc9, 0x2c, 0x97, 0xf1, 0xa9,
-    0x89, 0x26, 0x46, 0x66, 0xb2, 0x89, 0x99, 0xa9, 0x2d, 0x55, 0x7d, 0xb0, 0xb0, 0x8a, 0xa8, 0x96,
-    0x36, 0x56, 0x76, 0xf1, 0xba, 0xa3, 0xb4, 0xb2, 0x80, 0xc0, 0xb8, 0xa8, 0x97, 0x11, 0xb2, 0x83,
-    0x98, 0xba, 0xa3, 0xf0, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0xb2, 0xb9, 0xb4, 0x98, 0x83, 0xf1,
-    0xa3, 0x29, 0x55, 0x7d, 0xba, 0xb5, 0xb1, 0xa3, 0x83, 0x93, 0xf0, 0x00, 0x28, 0x50, 0xf5, 0xb2,
-    0xb6, 0xaa, 0x83, 0x93, 0x28, 0x54, 0x7c, 0xf1, 0xb9, 0xa3, 0x82, 0x93, 0x61, 0xba, 0xa2, 0xda,
-    0xde, 0xdf, 0xdb, 0x81, 0x9a, 0xb9, 0xae, 0xf5, 0x60, 0x68, 0x70, 0xf1, 0xda, 0xba, 0xa2, 0xdf,
-    0xd9, 0xba, 0xa2, 0xfa, 0xb9, 0xa3, 0x82, 0x92, 0xdb, 0x31, 0xba, 0xa2, 0xd9, 0xba, 0xa2, 0xf8,
-    0xdf, 0x85, 0xa4, 0xd0, 0xc1, 0xbb, 0xad, 0x83, 0xc2, 0xc5, 0xc7, 0xb8, 0xa2, 0xdf, 0xdf, 0xdf,
-    0xba, 0xa0, 0xdf, 0xdf, 0xdf, 0xd8, 0xd8, 0xf1, 0xb8, 0xaa, 0xb3, 0x8d, 0xb4, 0x98, 0x0d, 0x35,
-    0x5d, 0xb2, 0xb6, 0xba, 0xaf, 0x8c, 0x96, 0x19, 0x8f, 0x9f, 0xa7, 0x0e, 0x16, 0x1e, 0xb4, 0x9a,
-    0xb8, 0xaa, 0x87, 0x2c, 0x54, 0x7c, 0xba, 0xa4, 0xb0, 0x8a, 0xb6, 0x91, 0x32, 0x56, 0x76, 0xb2,
-    0x84, 0x94, 0xa4, 0xc8, 0x08, 0xcd, 0xd8, 0xb8, 0xb4, 0xb0, 0xf1, 0x99, 0x82, 0xa8, 0x2d, 0x55,
-    0x7d, 0x98, 0xa8, 0x0e, 0x16, 0x1e, 0xa2, 0x2c, 0x54, 0x7c, 0x92, 0xa4, 0xf0, 0x2c, 0x50, 0x78,
-    /* bank # 5 */
-    0xf1, 0x84, 0xa8, 0x98, 0xc4, 0xcd, 0xfc, 0xd8, 0x0d, 0xdb, 0xa8, 0xfc, 0x2d, 0xf3, 0xd9, 0xba,
-    0xa6, 0xf8, 0xda, 0xba, 0xa6, 0xde, 0xd8, 0xba, 0xb2, 0xb6, 0x86, 0x96, 0xa6, 0xd0, 0xf3, 0xc8,
-    0x41, 0xda, 0xa6, 0xc8, 0xf8, 0xd8, 0xb0, 0xb4, 0xb8, 0x82, 0xa8, 0x92, 0xf5, 0x2c, 0x54, 0x88,
-    0x98, 0xf1, 0x35, 0xd9, 0xf4, 0x18, 0xd8, 0xf1, 0xa2, 0xd0, 0xf8, 0xf9, 0xa8, 0x84, 0xd9, 0xc7,
-    0xdf, 0xf8, 0xf8, 0x83, 0xc5, 0xda, 0xdf, 0x69, 0xdf, 0x83, 0xc1, 0xd8, 0xf4, 0x01, 0x14, 0xf1,
-    0xa8, 0x82, 0x4e, 0xa8, 0x84, 0xf3, 0x11, 0xd1, 0x82, 0xf5, 0xd9, 0x92, 0x28, 0x97, 0x88, 0xf1,
-    0x09, 0xf4, 0x1c, 0x1c, 0xd8, 0x84, 0xa8, 0xf3, 0xc0, 0xf9, 0xd1, 0xd9, 0x97, 0x82, 0xf1, 0x29,
-    0xf4, 0x0d, 0xd8, 0xf3, 0xf9, 0xf9, 0xd1, 0xd9, 0x82, 0xf4, 0xc2, 0x03, 0xd8, 0xde, 0xdf, 0x1a,
-    0xd8, 0xf1, 0xa2, 0xfa, 0xf9, 0xa8, 0x84, 0x98, 0xd9, 0xc7, 0xdf, 0xf8, 0xf8, 0xf8, 0x83, 0xc7,
-    0xda, 0xdf, 0x69, 0xdf, 0xf8, 0x83, 0xc3, 0xd8, 0xf4, 0x01, 0x14, 0xf1, 0x98, 0xa8, 0x82, 0x2e,
-    0xa8, 0x84, 0xf3, 0x11, 0xd1, 0x82, 0xf5, 0xd9, 0x92, 0x50, 0x97, 0x88, 0xf1, 0x09, 0xf4, 0x1c,
-    0xd8, 0x84, 0xa8, 0xf3, 0xc0, 0xf8, 0xf9, 0xd1, 0xd9, 0x97, 0x82, 0xf1, 0x49, 0xf4, 0x0d, 0xd8,
-    0xf3, 0xf9, 0xf9, 0xd1, 0xd9, 0x82, 0xf4, 0xc4, 0x03, 0xd8, 0xde, 0xdf, 0xd8, 0xf1, 0xad, 0x88,
-    0x98, 0xcc, 0xa8, 0x09, 0xf9, 0xd9, 0x82, 0x92, 0xa8, 0xf5, 0x7c, 0xf1, 0x88, 0x3a, 0xcf, 0x94,
-    0x4a, 0x6e, 0x98, 0xdb, 0x69, 0x31, 0xda, 0xad, 0xf2, 0xde, 0xf9, 0xd8, 0x87, 0x95, 0xa8, 0xf2,
-    0x21, 0xd1, 0xda, 0xa5, 0xf9, 0xf4, 0x17, 0xd9, 0xf1, 0xae, 0x8e, 0xd0, 0xc0, 0xc3, 0xae, 0x82,
-    /* bank # 6 */
-    0xc6, 0x84, 0xc3, 0xa8, 0x85, 0x95, 0xc8, 0xa5, 0x88, 0xf2, 0xc0, 0xf1, 0xf4, 0x01, 0x0e, 0xf1,
-    0x8e, 0x9e, 0xa8, 0xc6, 0x3e, 0x56, 0xf5, 0x54, 0xf1, 0x88, 0x72, 0xf4, 0x01, 0x15, 0xf1, 0x98,
-    0x45, 0x85, 0x6e, 0xf5, 0x8e, 0x9e, 0x04, 0x88, 0xf1, 0x42, 0x98, 0x5a, 0x8e, 0x9e, 0x06, 0x88,
-    0x69, 0xf4, 0x01, 0x1c, 0xf1, 0x98, 0x1e, 0x11, 0x08, 0xd0, 0xf5, 0x04, 0xf1, 0x1e, 0x97, 0x02,
-    0x02, 0x98, 0x36, 0x25, 0xdb, 0xf9, 0xd9, 0x85, 0xa5, 0xf3, 0xc1, 0xda, 0x85, 0xa5, 0xf3, 0xdf,
-    0xd8, 0x85, 0x95, 0xa8, 0xf3, 0x09, 0xda, 0xa5, 0xfa, 0xd8, 0x82, 0x92, 0xa8, 0xf5, 0x78, 0xf1,
-    0x88, 0x1a, 0x84, 0x9f, 0x26, 0x88, 0x98, 0x21, 0xda, 0xf4, 0x1d, 0xf3, 0xd8, 0x87, 0x9f, 0x39,
-    0xd1, 0xaf, 0xd9, 0xdf, 0xdf, 0xfb, 0xf9, 0xf4, 0x0c, 0xf3, 0xd8, 0xfa, 0xd0, 0xf8, 0xda, 0xf9,
-    0xf9, 0xd0, 0xdf, 0xd9, 0xf9, 0xd8, 0xf4, 0x0b, 0xd8, 0xf3, 0x87, 0x9f, 0x39, 0xd1, 0xaf, 0xd9,
-    0xdf, 0xdf, 0xf4, 0x1d, 0xf3, 0xd8, 0xfa, 0xfc, 0xa8, 0x69, 0xf9, 0xf9, 0xaf, 0xd0, 0xda, 0xde,
-    0xfa, 0xd9, 0xf8, 0x8f, 0x9f, 0xa8, 0xf1, 0xcc, 0xf3, 0x98, 0xdb, 0x45, 0xd9, 0xaf, 0xdf, 0xd0,
-    0xf8, 0xd8, 0xf1, 0x8f, 0x9f, 0xa8, 0xca, 0xf3, 0x88, 0x09, 0xda, 0xaf, 0x8f, 0xcb, 0xf8, 0xd8,
-    0xf2, 0xad, 0x97, 0x8d, 0x0c, 0xd9, 0xa5, 0xdf, 0xf9, 0xba, 0xa6, 0xf3, 0xfa, 0xf4, 0x12, 0xf2,
-    0xd8, 0x95, 0x0d, 0xd1, 0xd9, 0xba, 0xa6, 0xf3, 0xfa, 0xda, 0xa5, 0xf2, 0xc1, 0xba, 0xa6, 0xf3,
-    0xdf, 0xd8, 0xf1, 0xba, 0xb2, 0xb6, 0x86, 0x96, 0xa6, 0xd0, 0xca, 0xf3, 0x49, 0xda, 0xa6, 0xcb,
-    0xf8, 0xd8, 0xb0, 0xb4, 0xb8, 0xd8, 0xad, 0x84, 0xf2, 0xc0, 0xdf, 0xf1, 0x8f, 0xcb, 0xc3, 0xa8,
-    /* bank # 7 */
-    0xb2, 0xb6, 0x86, 0x96, 0xc8, 0xc1, 0xcb, 0xc3, 0xf3, 0xb0, 0xb4, 0x88, 0x98, 0xa8, 0x21, 0xdb,
-    0x71, 0x8d, 0x9d, 0x71, 0x85, 0x95, 0x21, 0xd9, 0xad, 0xf2, 0xfa, 0xd8, 0x85, 0x97, 0xa8, 0x28,
-    0xd9, 0xf4, 0x08, 0xd8, 0xf2, 0x8d, 0x29, 0xda, 0xf4, 0x05, 0xd9, 0xf2, 0x85, 0xa4, 0xc2, 0xf2,
-    0xd8, 0xa8, 0x8d, 0x94, 0x01, 0xd1, 0xd9, 0xf4, 0x11, 0xf2, 0xd8, 0x87, 0x21, 0xd8, 0xf4, 0x0a,
-    0xd8, 0xf2, 0x84, 0x98, 0xa8, 0xc8, 0x01, 0xd1, 0xd9, 0xf4, 0x11, 0xd8, 0xf3, 0xa4, 0xc8, 0xbb,
-    0xaf, 0xd0, 0xf2, 0xde, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xd8, 0xf1, 0xb8, 0xf6,
-    0xb5, 0xb9, 0xb0, 0x8a, 0x95, 0xa3, 0xde, 0x3c, 0xa3, 0xd9, 0xf8, 0xd8, 0x5c, 0xa3, 0xd9, 0xf8,
-    0xd8, 0x7c, 0xa3, 0xd9, 0xf8, 0xd8, 0xf8, 0xf9, 0xd1, 0xa5, 0xd9, 0xdf, 0xda, 0xfa, 0xd8, 0xb1,
-    0x85, 0x30, 0xf7, 0xd9, 0xde, 0xd8, 0xf8, 0x30, 0xad, 0xda, 0xde, 0xd8, 0xf2, 0xb4, 0x8c, 0x99,
-    0xa3, 0x2d, 0x55, 0x7d, 0xa0, 0x83, 0xdf, 0xdf, 0xdf, 0xb5, 0x91, 0xa0, 0xf6, 0x29, 0xd9, 0xfb,
-    0xd8, 0xa0, 0xfc, 0x29, 0xd9, 0xfa, 0xd8, 0xa0, 0xd0, 0x51, 0xd9, 0xf8, 0xd8, 0xfc, 0x51, 0xd9,
-    0xf9, 0xd8, 0x79, 0xd9, 0xfb, 0xd8, 0xa0, 0xd0, 0xfc, 0x79, 0xd9, 0xfa, 0xd8, 0xa1, 0xf9, 0xf9,
-    0xf9, 0xf9, 0xf9, 0xa0, 0xda, 0xdf, 0xdf, 0xdf, 0xd8, 0xa1, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xac,
-    0xde, 0xf8, 0xad, 0xde, 0x83, 0x93, 0xac, 0x2c, 0x54, 0x7c, 0xf1, 0xa8, 0xdf, 0xdf, 0xdf, 0xf6,
-    0x9d, 0x2c, 0xda, 0xa0, 0xdf, 0xd9, 0xfa, 0xdb, 0x2d, 0xf8, 0xd8, 0xa8, 0x50, 0xda, 0xa0, 0xd0,
-    0xde, 0xd9, 0xd0, 0xf8, 0xf8, 0xf8, 0xdb, 0x55, 0xf8, 0xd8, 0xa8, 0x78, 0xda, 0xa0, 0xd0, 0xdf,
-    /* bank # 8 */
-    0xd9, 0xd0, 0xfa, 0xf8, 0xf8, 0xf8, 0xf8, 0xdb, 0x7d, 0xf8, 0xd8, 0x9c, 0xa8, 0x8c, 0xf5, 0x30,
-    0xdb, 0x38, 0xd9, 0xd0, 0xde, 0xdf, 0xa0, 0xd0, 0xde, 0xdf, 0xd8, 0xa8, 0x48, 0xdb, 0x58, 0xd9,
-    0xdf, 0xd0, 0xde, 0xa0, 0xdf, 0xd0, 0xde, 0xd8, 0xa8, 0x68, 0xdb, 0x70, 0xd9, 0xdf, 0xdf, 0xa0,
-    0xdf, 0xdf, 0xd8, 0xf1, 0xa8, 0x88, 0x90, 0x2c, 0x54, 0x7c, 0x98, 0xa8, 0xd0, 0x5c, 0x38, 0xd1,
-    0xda, 0xf2, 0xae, 0x8c, 0xdf, 0xf9, 0xd8, 0xb0, 0x87, 0xa8, 0xc1, 0xc1, 0xb1, 0x88, 0xa8, 0xc6,
-    0xf9, 0xf9, 0xda, 0x36, 0xd8, 0xa8, 0xf9, 0xda, 0x36, 0xd8, 0xa8, 0xf9, 0xda, 0x36, 0xd8, 0xa8,
-    0xf9, 0xda, 0x36, 0xd8, 0xa8, 0xf9, 0xda, 0x36, 0xd8, 0xf7, 0x8d, 0x9d, 0xad, 0xf8, 0x18, 0xda,
-    0xf2, 0xae, 0xdf, 0xd8, 0xf7, 0xad, 0xfa, 0x30, 0xd9, 0xa4, 0xde, 0xf9, 0xd8, 0xf2, 0xae, 0xde,
-    0xfa, 0xf9, 0x83, 0xa7, 0xd9, 0xc3, 0xc5, 0xc7, 0xf1, 0x88, 0x9b, 0xa7, 0x7a, 0xad, 0xf7, 0xde,
-    0xdf, 0xa4, 0xf8, 0x84, 0x94, 0x08, 0xa7, 0x97, 0xf3, 0x00, 0xae, 0xf2, 0x98, 0x19, 0xa4, 0x88,
-    0xc6, 0xa3, 0x94, 0x88, 0xf6, 0x32, 0xdf, 0xf2, 0x83, 0x93, 0xdb, 0x09, 0xd9, 0xf2, 0xaa, 0xdf,
-    0xd8, 0xd8, 0xae, 0xf8, 0xf9, 0xd1, 0xda, 0xf3, 0xa4, 0xde, 0xa7, 0xf1, 0x88, 0x9b, 0x7a, 0xd8,
-    0xf3, 0x84, 0x94, 0xae, 0x19, 0xf9, 0xda, 0xaa, 0xf1, 0xdf, 0xd8, 0xa8, 0x81, 0xc0, 0xc3, 0xc5,
-    0xc7, 0xa3, 0x92, 0x83, 0xf6, 0x28, 0xad, 0xde, 0xd9, 0xf8, 0xd8, 0xa3, 0x50, 0xad, 0xd9, 0xf8,
-    0xd8, 0xa3, 0x78, 0xad, 0xd9, 0xf8, 0xd8, 0xf8, 0xf9, 0xd1, 0xa1, 0xda, 0xde, 0xc3, 0xc5, 0xc7,
-    0xd8, 0xa1, 0x81, 0x94, 0xf8, 0x18, 0xf2, 0xb0, 0x89, 0xac, 0xc3, 0xc5, 0xc7, 0xf1, 0xd8, 0xb8,
-    /* bank # 9 */
-    0xb4, 0xb0, 0x97, 0x86, 0xa8, 0x31, 0x9b, 0x06, 0x99, 0x07, 0xab, 0x97, 0x28, 0x88, 0x9b, 0xf0,
-    0x0c, 0x20, 0x14, 0x40, 0xb0, 0xb4, 0xb8, 0xf0, 0xa8, 0x8a, 0x9a, 0x28, 0x50, 0x78, 0xb7, 0x9b,
-    0xa8, 0x29, 0x51, 0x79, 0x24, 0x70, 0x59, 0x44, 0x69, 0x38, 0x64, 0x48, 0x31, 0xf1, 0xbb, 0xab,
-    0x88, 0x00, 0x2c, 0x54, 0x7c, 0xf0, 0xb3, 0x8b, 0xb8, 0xa8, 0x04, 0x28, 0x50, 0x78, 0xf1, 0xb0,
-    0x88, 0xb4, 0x97, 0x26, 0xa8, 0x59, 0x98, 0xbb, 0xab, 0xb3, 0x8b, 0x02, 0x26, 0x46, 0x66, 0xb0,
-    0xb8, 0xf0, 0x8a, 0x9c, 0xa8, 0x29, 0x51, 0x79, 0x8b, 0x29, 0x51, 0x79, 0x8a, 0x24, 0x70, 0x59,
-    0x8b, 0x20, 0x58, 0x71, 0x8a, 0x44, 0x69, 0x38, 0x8b, 0x39, 0x40, 0x68, 0x8a, 0x64, 0x48, 0x31,
-    0x8b, 0x30, 0x49, 0x60, 0x88, 0xf1, 0xac, 0x00, 0x2c, 0x54, 0x7c, 0xf0, 0x8c, 0xa8, 0x04, 0x28,
-    0x50, 0x78, 0xf1, 0x88, 0x97, 0x26, 0xa8, 0x59, 0x98, 0xac, 0x8c, 0x02, 0x26, 0x46, 0x66, 0xf0,
-    0x89, 0x9c, 0xa8, 0x29, 0x51, 0x79, 0x24, 0x70, 0x59, 0x44, 0x69, 0x38, 0x64, 0x48, 0x31, 0xa9,
-    0x88, 0x09, 0x20, 0x59, 0x70, 0xab, 0x11, 0x38, 0x40, 0x69, 0xa8, 0x19, 0x31, 0x48, 0x60, 0x8c,
-    0xa8, 0x3c, 0x41, 0x5c, 0x20, 0x7c, 0x00, 0xf1, 0x87, 0x98, 0x19, 0x86, 0xa8, 0x6e, 0x76, 0x7e,
-    0xa9, 0x99, 0x88, 0x2d, 0x55, 0x7d, 0xd8, 0xb1, 0xb5, 0xb9, 0xa3, 0xdf, 0xdf, 0xdf, 0xae, 0xd0,
-    0xdf, 0xaa, 0xd0, 0xde, 0xf2, 0xab, 0xf8, 0xf9, 0xd9, 0xb0, 0x87, 0xc4, 0xaa, 0xf1, 0xdf, 0xdf,
-    0xbb, 0xaf, 0xdf, 0xdf, 0xb9, 0xd8, 0xb1, 0xf1, 0xa3, 0x97, 0x8e, 0x60, 0xdf, 0xb0, 0x84, 0xf2,
-    0xc8, 0xf8, 0xf9, 0xd9, 0xde, 0xd8, 0x93, 0x85, 0xf1, 0x4a, 0xb1, 0x83, 0xa3, 0x08, 0xb5, 0x83,
-    /* bank # 10 */
-    0x9a, 0x08, 0x10, 0xb7, 0x9f, 0x10, 0xd8, 0xf1, 0xb0, 0xba, 0xae, 0xb0, 0x8a, 0xc2, 0xb2, 0xb6,
-    0x8e, 0x9e, 0xf1, 0xfb, 0xd9, 0xf4, 0x1d, 0xd8, 0xf9, 0xd9, 0x0c, 0xf1, 0xd8, 0xf8, 0xf8, 0xad,
-    0x61, 0xd9, 0xae, 0xfb, 0xd8, 0xf4, 0x0c, 0xf1, 0xd8, 0xf8, 0xf8, 0xad, 0x19, 0xd9, 0xae, 0xfb,
-    0xdf, 0xd8, 0xf4, 0x16, 0xf1, 0xd8, 0xf8, 0xad, 0x8d, 0x61, 0xd9, 0xf4, 0xf4, 0xac, 0xf5, 0x9c,
-    0x9c, 0x8d, 0xdf, 0x2b, 0xba, 0xb6, 0xae, 0xfa, 0xf8, 0xf4, 0x0b, 0xd8, 0xf1, 0xae, 0xd0, 0xf8,
-    0xad, 0x51, 0xda, 0xae, 0xfa, 0xf8, 0xf1, 0xd8, 0xb9, 0xb1, 0xb6, 0xa3, 0x83, 0x9c, 0x08, 0xb9,
-    0xb1, 0x83, 0x9a, 0xb5, 0xaa, 0xc0, 0xfd, 0x30, 0x83, 0xb7, 0x9f, 0x10, 0xb5, 0x8b, 0x93, 0xf2,
-    0x02, 0x02, 0xd1, 0xab, 0xda, 0xde, 0xd8, 0xf1, 0xb0, 0x80, 0xba, 0xab, 0xc0, 0xc3, 0xb2, 0x84,
-    0xc1, 0xc3, 0xd8, 0xb1, 0xb9, 0xf3, 0x8b, 0xa3, 0x91, 0xb6, 0x09, 0xb4, 0xd9, 0xab, 0xde, 0xb0,
-    0x87, 0x9c, 0xb9, 0xa3, 0xdd, 0xf1, 0xb3, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0xb0, 0x87, 0xa3, 0xa3,
-    0xa3, 0xa3, 0xb2, 0x8b, 0xb6, 0x9b, 0xf2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
-    0xa3, 0xf1, 0xb0, 0x87, 0xb5, 0x9a, 0xa3, 0xf3, 0x9b, 0xa3, 0xa3, 0xdc, 0xba, 0xac, 0xdf, 0xb9,
-    0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
-    0xd8, 0xd8, 0xd8, 0xbb, 0xb3, 0xb7, 0xf1, 0xaa, 0xf9, 0xda, 0xff, 0xd9, 0x80, 0x9a, 0xaa, 0x28,
-    0xb4, 0x80, 0x98, 0xa7, 0x20, 0xb7, 0x97, 0x87, 0xa8, 0x66, 0x88, 0xf0, 0x79, 0x51, 0xf1, 0x90,
-    0x2c, 0x87, 0x0c, 0xa7, 0x81, 0x97, 0x62, 0x93, 0xf0, 0x71, 0x71, 0x60, 0x85, 0x94, 0x01, 0x29,
-    /* bank # 11 */
-    0x51, 0x79, 0x90, 0xa5, 0xf1, 0x28, 0x4c, 0x6c, 0x87, 0x0c, 0x95, 0x18, 0x85, 0x78, 0xa3, 0x83,
-    0x90, 0x28, 0x4c, 0x6c, 0x88, 0x6c, 0xd8, 0xf3, 0xa2, 0x82, 0x00, 0xf2, 0x10, 0xa8, 0x92, 0x19,
-    0x80, 0xa2, 0xf2, 0xd9, 0x26, 0xd8, 0xf1, 0x88, 0xa8, 0x4d, 0xd9, 0x48, 0xd8, 0x96, 0xa8, 0x39,
-    0x80, 0xd9, 0x3c, 0xd8, 0x95, 0x80, 0xa8, 0x39, 0xa6, 0x86, 0x98, 0xd9, 0x2c, 0xda, 0x87, 0xa7,
-    0x2c, 0xd8, 0xa8, 0x89, 0x95, 0x19, 0xa9, 0x80, 0xd9, 0x38, 0xd8, 0xa8, 0x89, 0x39, 0xa9, 0x80,
-    0xda, 0x3c, 0xd8, 0xa8, 0x2e, 0xa8, 0x39, 0x90, 0xd9, 0x0c, 0xd8, 0xa8, 0x95, 0x31, 0x98, 0xd9,
-    0x0c, 0xd8, 0xa8, 0x09, 0xd9, 0xff, 0xd8, 0x01, 0xda, 0xff, 0xd8, 0x95, 0x39, 0xa9, 0xda, 0x26,
-    0xff, 0xd8, 0x90, 0xa8, 0x0d, 0x89, 0x99, 0xa8, 0x10, 0x80, 0x98, 0x21, 0xda, 0x2e, 0xd8, 0x89,
-    0x99, 0xa8, 0x31, 0x80, 0xda, 0x2e, 0xd8, 0xa8, 0x86, 0x96, 0x31, 0x80, 0xda, 0x2e, 0xd8, 0xa8,
-    0x87, 0x31, 0x80, 0xda, 0x2e, 0xd8, 0xa8, 0x82, 0x92, 0xf3, 0x41, 0x80, 0xf1, 0xd9, 0x2e, 0xd8,
-    0xa8, 0x82, 0xf3, 0x19, 0x80, 0xf1, 0xd9, 0x2e, 0xd8, 0x82, 0xac, 0xf3, 0xc0, 0xa2, 0x80, 0x22,
-    0xf1, 0xa6, 0x2e, 0xa7, 0x2e, 0xa9, 0x22, 0x98, 0xa8, 0x29, 0xda, 0xac, 0xde, 0xff, 0xd8, 0xa2,
-    0xf2, 0x2a, 0xf1, 0xa9, 0x2e, 0x82, 0x92, 0xa8, 0xf2, 0x31, 0x80, 0xa6, 0x96, 0xf1, 0xd9, 0x00,
-    0xac, 0x8c, 0x9c, 0x0c, 0x30, 0xac, 0xde, 0xd0, 0xde, 0xff, 0xd8, 0x8c, 0x9c, 0xac, 0xd0, 0x10,
-    0xac, 0xde, 0x80, 0x92, 0xa2, 0xf2, 0x4c, 0x82, 0xa8, 0xf1, 0xca, 0xf2, 0x35, 0xf1, 0x96, 0x88,
-    0xa6, 0xd9, 0x00, 0xd8, 0xf1, 0xff
-};
-
-static const unsigned short sStartAddress = 0x0400;
-
-/* END OF SECTION COPIED FROM dmpDefaultMPU6050.c */
-
-#define INT_SRC_TAP             (0x01)
-#define INT_SRC_ANDROID_ORIENT  (0x08)
-
-#define DMP_FEATURE_SEND_ANY_GYRO   (DMP_FEATURE_SEND_RAW_GYRO | \
-                                     DMP_FEATURE_SEND_CAL_GYRO)
-
-#define MAX_PACKET_LENGTH   (32)
-
-#define DMP_SAMPLE_RATE     (200)
-#define GYRO_SF             (46850825LL * 200 / DMP_SAMPLE_RATE)
-
-#define FIFO_CORRUPTION_CHECK
-#ifdef FIFO_CORRUPTION_CHECK
-#define QUAT_ERROR_THRESH       (1L<<24)
-#define QUAT_MAG_SQ_NORMALIZED  (1L<<28)
-#define QUAT_MAG_SQ_MIN         (QUAT_MAG_SQ_NORMALIZED - QUAT_ERROR_THRESH)
-#define QUAT_MAG_SQ_MAX         (QUAT_MAG_SQ_NORMALIZED + QUAT_ERROR_THRESH)
-#endif
-
-struct dmp_s {
-    void (*tap_cb)(unsigned char count, unsigned char direction);
-    void (*android_orient_cb)(unsigned char orientation);
-    unsigned short orient;
-    unsigned short feature_mask;
-    unsigned short fifo_rate;
-    unsigned char packet_length;
-};
-
-static struct dmp_s dmp = {
-    .tap_cb = NULL,
-    .android_orient_cb = NULL,
-    .orient = 0,
-    .feature_mask = 0,
-    .fifo_rate = 0,
-    .packet_length = 0
-};
-
-/**
- *  @brief  Load the DMP with this image.
- *  @return 0 if successful.
- */
-int dmp_load_motion_driver_firmware(void)
-{
-    return mpu_load_firmware(DMP_CODE_SIZE, dmp_memory, sStartAddress,
-        DMP_SAMPLE_RATE);
-}
-
-/**
- *  @brief      Push gyro and accel orientation to the DMP.
- *  The orientation is represented here as the output of
- *  @e inv_orientation_matrix_to_scalar.
- *  @param[in]  orient  Gyro and accel orientation in body frame.
- *  @return     0 if successful.
- */
-int dmp_set_orientation(unsigned short orient)
-{
-    unsigned char gyro_regs[3], accel_regs[3];
-    const unsigned char gyro_axes[3] = {DINA4C, DINACD, DINA6C};
-    const unsigned char accel_axes[3] = {DINA0C, DINAC9, DINA2C};
-    const unsigned char gyro_sign[3] = {DINA36, DINA56, DINA76};
-    const unsigned char accel_sign[3] = {DINA26, DINA46, DINA66};
-
-    gyro_regs[0] = gyro_axes[orient & 3];
-    gyro_regs[1] = gyro_axes[(orient >> 3) & 3];
-    gyro_regs[2] = gyro_axes[(orient >> 6) & 3];
-    accel_regs[0] = accel_axes[orient & 3];
-    accel_regs[1] = accel_axes[(orient >> 3) & 3];
-    accel_regs[2] = accel_axes[(orient >> 6) & 3];
-
-    /* Chip-to-body, axes only. */
-    if (mpu_write_mem1(FCFG_1, 3, gyro_regs))
-        return -1;
-    if (mpu_write_mem1(FCFG_2, 3, accel_regs))
-        return -1;
-
-    memcpy(gyro_regs, gyro_sign, 3);
-    memcpy(accel_regs, accel_sign, 3);
-    if (orient & 4) {
-        gyro_regs[0] |= 1;
-        accel_regs[0] |= 1;
-    }
-    if (orient & 0x20) {
-        gyro_regs[1] |= 1;
-        accel_regs[1] |= 1;
-    }
-    if (orient & 0x100) {
-        gyro_regs[2] |= 1;
-        accel_regs[2] |= 1;
-    }
-
-    /* Chip-to-body, sign only. */
-    if (mpu_write_mem1(FCFG_3, 3, gyro_regs))
-        return -1;
-    if (mpu_write_mem1(FCFG_7, 3, accel_regs))
-        return -1;
-    dmp.orient = orient;
-    return 0;
-}
-
-/**
- *  @brief      Push gyro biases to the DMP.
- *  Because the gyro integration is handled in the DMP, any gyro biases
- *  calculated by the MPL should be pushed down to DMP memory to remove
- *  3-axis quaternion drift.
- *  \n NOTE: If the DMP-based gyro calibration is enabled, the DMP will
- *  overwrite the biases written to this location once a new one is computed.
- *  @param[in]  bias    Gyro biases in q16.
- *  @return     0 if successful.
- */
-int dmp_set_gyro_bias(long *bias)
-{
-    long gyro_bias_body[3];
-    unsigned char regs[4];
-
-    gyro_bias_body[0] = bias[dmp.orient & 3];
-    if (dmp.orient & 4)
-        gyro_bias_body[0] *= -1;
-    gyro_bias_body[1] = bias[(dmp.orient >> 3) & 3];
-    if (dmp.orient & 0x20)
-        gyro_bias_body[1] *= -1;
-    gyro_bias_body[2] = bias[(dmp.orient >> 6) & 3];
-    if (dmp.orient & 0x100)
-        gyro_bias_body[2] *= -1;
-
-#ifdef EMPL_NO_64BIT
-    gyro_bias_body[0] = (long)(((float)gyro_bias_body[0] * GYRO_SF) / 1073741824.f);
-    gyro_bias_body[1] = (long)(((float)gyro_bias_body[1] * GYRO_SF) / 1073741824.f);
-    gyro_bias_body[2] = (long)(((float)gyro_bias_body[2] * GYRO_SF) / 1073741824.f);
-#else
-    gyro_bias_body[0] = (long)(((long long)gyro_bias_body[0] * GYRO_SF) >> 30);
-    gyro_bias_body[1] = (long)(((long long)gyro_bias_body[1] * GYRO_SF) >> 30);
-    gyro_bias_body[2] = (long)(((long long)gyro_bias_body[2] * GYRO_SF) >> 30);
-#endif
-
-    regs[0] = (unsigned char)((gyro_bias_body[0] >> 24) & 0xFF);
-    regs[1] = (unsigned char)((gyro_bias_body[0] >> 16) & 0xFF);
-    regs[2] = (unsigned char)((gyro_bias_body[0] >> 8) & 0xFF);
-    regs[3] = (unsigned char)(gyro_bias_body[0] & 0xFF);
-    if (mpu_write_mem1(D_EXT_GYRO_BIAS_X, 4, regs))
-        return -1;
-
-    regs[0] = (unsigned char)((gyro_bias_body[1] >> 24) & 0xFF);
-    regs[1] = (unsigned char)((gyro_bias_body[1] >> 16) & 0xFF);
-    regs[2] = (unsigned char)((gyro_bias_body[1] >> 8) & 0xFF);
-    regs[3] = (unsigned char)(gyro_bias_body[1] & 0xFF);
-    if (mpu_write_mem1(D_EXT_GYRO_BIAS_Y, 4, regs))
-        return -1;
-
-    regs[0] = (unsigned char)((gyro_bias_body[2] >> 24) & 0xFF);
-    regs[1] = (unsigned char)((gyro_bias_body[2] >> 16) & 0xFF);
-    regs[2] = (unsigned char)((gyro_bias_body[2] >> 8) & 0xFF);
-    regs[3] = (unsigned char)(gyro_bias_body[2] & 0xFF);
-    return mpu_write_mem1(D_EXT_GYRO_BIAS_Z, 4, regs);
-}
-
-/**
- *  @brief      Push accel biases to the DMP.
- *  These biases will be removed from the DMP 6-axis quaternion.
- *  @param[in]  bias    Accel biases in q16.
- *  @return     0 if successful.
- */
-int dmp_set_accel_bias(long *bias)
-{
-    long accel_bias_body[3];
-    unsigned char regs[12];
-    long long accel_sf;
-    unsigned short accel_sens;
-
-    mpu_get_accel_sens(&accel_sens);
-    accel_sf = (long long)accel_sens << 15;
-//    __no_operation();
-    __NOP();
-
-    accel_bias_body[0] = bias[dmp.orient & 3];
-    if (dmp.orient & 4)
-        accel_bias_body[0] *= -1;
-    accel_bias_body[1] = bias[(dmp.orient >> 3) & 3];
-    if (dmp.orient & 0x20)
-        accel_bias_body[1] *= -1;
-    accel_bias_body[2] = bias[(dmp.orient >> 6) & 3];
-    if (dmp.orient & 0x100)
-        accel_bias_body[2] *= -1;
-
-#ifdef EMPL_NO_64BIT
-    accel_bias_body[0] = (long)(((float)accel_bias_body[0] * accel_sf) / 1073741824.f);
-    accel_bias_body[1] = (long)(((float)accel_bias_body[1] * accel_sf) / 1073741824.f);
-    accel_bias_body[2] = (long)(((float)accel_bias_body[2] * accel_sf) / 1073741824.f);
-#else
-    accel_bias_body[0] = (long)(((long long)accel_bias_body[0] * accel_sf) >> 30);
-    accel_bias_body[1] = (long)(((long long)accel_bias_body[1] * accel_sf) >> 30);
-    accel_bias_body[2] = (long)(((long long)accel_bias_body[2] * accel_sf) >> 30);
-#endif
-
-    regs[0] = (unsigned char)((accel_bias_body[0] >> 24) & 0xFF);
-    regs[1] = (unsigned char)((accel_bias_body[0] >> 16) & 0xFF);
-    regs[2] = (unsigned char)((accel_bias_body[0] >> 8) & 0xFF);
-    regs[3] = (unsigned char)(accel_bias_body[0] & 0xFF);
-    regs[4] = (unsigned char)((accel_bias_body[1] >> 24) & 0xFF);
-    regs[5] = (unsigned char)((accel_bias_body[1] >> 16) & 0xFF);
-    regs[6] = (unsigned char)((accel_bias_body[1] >> 8) & 0xFF);
-    regs[7] = (unsigned char)(accel_bias_body[1] & 0xFF);
-    regs[8] = (unsigned char)((accel_bias_body[2] >> 24) & 0xFF);
-    regs[9] = (unsigned char)((accel_bias_body[2] >> 16) & 0xFF);
-    regs[10] = (unsigned char)((accel_bias_body[2] >> 8) & 0xFF);
-    regs[11] = (unsigned char)(accel_bias_body[2] & 0xFF);
-    return mpu_write_mem(D_ACCEL_BIAS, 12, regs);
-}
-
-/**
- *  @brief      Set DMP output rate.
- *  Only used when DMP is on.
- *  @param[in]  rate    Desired fifo rate (Hz).
- *  @return     0 if successful.
- */
-int dmp_set_fifo_rate(unsigned short rate)
-{
-    const unsigned char regs_end[12] = {DINAFE, DINAF2, DINAAB,
-        0xc4, DINAAA, DINAF1, DINADF, DINADF, 0xBB, 0xAF, DINADF, DINADF};
-    unsigned short div;
-    unsigned char tmp[8];
-
-    if (rate > DMP_SAMPLE_RATE)
-        return -1;
-    div = DMP_SAMPLE_RATE / rate - 1;
-    tmp[0] = (unsigned char)((div >> 8) & 0xFF);
-    tmp[1] = (unsigned char)(div & 0xFF);
-    if (mpu_write_mem1(D_0_22, 2, tmp))
-        return -1;
-    if (mpu_write_mem1(CFG_6, 12, (unsigned char*)regs_end))
-        return -1;
-
-    dmp.fifo_rate = rate;
-    return 0;
-}
-
-/**
- *  @brief      Get DMP output rate.
- *  @param[out] rate    Current fifo rate (Hz).
- *  @return     0 if successful.
- */
-int dmp_get_fifo_rate1(unsigned short *rate)
-{
-    rate[0] = dmp.fifo_rate;
-    return 0;
-}
-
-/**
- *  @brief      Set tap threshold for a specific axis.
- *  @param[in]  axis    1, 2, and 4 for XYZ accel, respectively.
- *  @param[in]  thresh  Tap threshold, in mg/ms.
- *  @return     0 if successful.
- */
-int dmp_set_tap_thresh(unsigned char axis, unsigned short thresh)
-{
-    unsigned char tmp[4], accel_fsr;
-    float scaled_thresh;
-    unsigned short dmp_thresh, dmp_thresh_2;
-    if (!(axis & TAP_XYZ) || thresh > 1600)
-        return -1;
-
-    scaled_thresh = (float)thresh / DMP_SAMPLE_RATE;
-
-    mpu_get_accel_fsr(&accel_fsr);
-    switch (accel_fsr) {
-    case 2:
-        dmp_thresh = (unsigned short)(scaled_thresh * 16384);
-        /* dmp_thresh * 0.75 */
-        dmp_thresh_2 = (unsigned short)(scaled_thresh * 12288);
-        break;
-    case 4:
-        dmp_thresh = (unsigned short)(scaled_thresh * 8192);
-        /* dmp_thresh * 0.75 */
-        dmp_thresh_2 = (unsigned short)(scaled_thresh * 6144);
-        break;
-    case 8:
-        dmp_thresh = (unsigned short)(scaled_thresh * 4096);
-        /* dmp_thresh * 0.75 */
-        dmp_thresh_2 = (unsigned short)(scaled_thresh * 3072);
-        break;
-    case 16:
-        dmp_thresh = (unsigned short)(scaled_thresh * 2048);
-        /* dmp_thresh * 0.75 */
-        dmp_thresh_2 = (unsigned short)(scaled_thresh * 1536);
-        break;
-    default:
-        return -1;
-    }
-    tmp[0] = (unsigned char)(dmp_thresh >> 8);
-    tmp[1] = (unsigned char)(dmp_thresh & 0xFF);
-    tmp[2] = (unsigned char)(dmp_thresh_2 >> 8);
-    tmp[3] = (unsigned char)(dmp_thresh_2 & 0xFF);
-
-    if (axis & TAP_X) {
-        if (mpu_write_mem1(DMP_TAP_THX, 2, tmp))
-            return -1;
-        if (mpu_write_mem1(D_1_36, 2, tmp+2))
-            return -1;
-    }
-    if (axis & TAP_Y) {
-        if (mpu_write_mem1(DMP_TAP_THY, 2, tmp))
-            return -1;
-        if (mpu_write_mem1(D_1_40, 2, tmp+2))
-            return -1;
-    }
-    if (axis & TAP_Z) {
-        if (mpu_write_mem1(DMP_TAP_THZ, 2, tmp))
-            return -1;
-        if (mpu_write_mem1(D_1_44, 2, tmp+2))
-            return -1;
-    }
-    return 0;
-}
-
-/**
- *  @brief      Set which axes will register a tap.
- *  @param[in]  axis    1, 2, and 4 for XYZ, respectively.
- *  @return     0 if successful.
- */
-int dmp_set_tap_axes(unsigned char axis)
-{
-    unsigned char tmp = 0;
-
-    if (axis & TAP_X)
-        tmp |= 0x30;
-    if (axis & TAP_Y)
-        tmp |= 0x0C;
-    if (axis & TAP_Z)
-        tmp |= 0x03;
-    return mpu_write_mem(D_1_72, 1, &tmp);
-}
-
-/**
- *  @brief      Set minimum number of taps needed for an interrupt.
- *  @param[in]  min_taps    Minimum consecutive taps (1-4).
- *  @return     0 if successful.
- */
-int dmp_set_tap_count(unsigned char min_taps)
-{
-    unsigned char tmp;
-
-    if (min_taps < 1)
-        min_taps = 1;
-    else if (min_taps > 4)
-        min_taps = 4;
-
-    tmp = min_taps - 1;
-    return mpu_write_mem(D_1_79, 1, &tmp);
-}
-
-/**
- *  @brief      Set length between valid taps.
- *  @param[in]  time    Milliseconds between taps.
- *  @return     0 if successful.
- */
-int dmp_set_tap_time(unsigned short time)
-{
-    unsigned short dmp_time;
-    unsigned char tmp[2];
-
-    dmp_time = time / (1000 / DMP_SAMPLE_RATE);
-    tmp[0] = (unsigned char)(dmp_time >> 8);
-    tmp[1] = (unsigned char)(dmp_time & 0xFF);
-    return mpu_write_mem(DMP_TAPW_MIN, 2, tmp);
-}
-
-/**
- *  @brief      Set max time between taps to register as a multi-tap.
- *  @param[in]  time    Max milliseconds between taps.
- *  @return     0 if successful.
- */
-int dmp_set_tap_time_multi(unsigned short time)
-{
-    unsigned short dmp_time;
-    unsigned char tmp[2];
-
-    dmp_time = time / (1000 / DMP_SAMPLE_RATE);
-    tmp[0] = (unsigned char)(dmp_time >> 8);
-    tmp[1] = (unsigned char)(dmp_time & 0xFF);
-    return mpu_write_mem(D_1_218, 2, tmp);
-}
-
-/**
- *  @brief      Set shake rejection threshold.
- *  If the DMP detects a gyro sample larger than @e thresh, taps are rejected.
- *  @param[in]  sf      Gyro scale factor.
- *  @param[in]  thresh  Gyro threshold in dps.
- *  @return     0 if successful.
- */
-int dmp_set_shake_reject_thresh(long sf, unsigned short thresh)
-{
-    unsigned char tmp[4];
-    long thresh_scaled = sf / 1000 * thresh;
-    tmp[0] = (unsigned char)(((long)thresh_scaled >> 24) & 0xFF);
-    tmp[1] = (unsigned char)(((long)thresh_scaled >> 16) & 0xFF);
-    tmp[2] = (unsigned char)(((long)thresh_scaled >> 8) & 0xFF);
-    tmp[3] = (unsigned char)((long)thresh_scaled & 0xFF);
-    return mpu_write_mem(D_1_92, 4, tmp);
-}
-
-/**
- *  @brief      Set shake rejection time.
- *  Sets the length of time that the gyro must be outside of the threshold set
- *  by @e gyro_set_shake_reject_thresh before taps are rejected. A mandatory
- *  60 ms is added to this parameter.
- *  @param[in]  time    Time in milliseconds.
- *  @return     0 if successful.
- */
-int dmp_set_shake_reject_time(unsigned short time)
-{
-    unsigned char tmp[2];
-
-    time /= (1000 / DMP_SAMPLE_RATE);
-    tmp[0] = time >> 8;
-    tmp[1] = time & 0xFF;
-    return mpu_write_mem(D_1_90,2,tmp);
-}
-
-/**
- *  @brief      Set shake rejection timeout.
- *  Sets the length of time after a shake rejection that the gyro must stay
- *  inside of the threshold before taps can be detected again. A mandatory
- *  60 ms is added to this parameter.
- *  @param[in]  time    Time in milliseconds.
- *  @return     0 if successful.
- */
-int dmp_set_shake_reject_timeout(unsigned short time)
-{
-    unsigned char tmp[2];
-
-    time /= (1000 / DMP_SAMPLE_RATE);
-    tmp[0] = time >> 8;
-    tmp[1] = time & 0xFF;
-    return mpu_write_mem(D_1_88,2,tmp);
-}
-
-/**
- *  @brief      Get current step count.
- *  @param[out] count   Number of steps detected.
- *  @return     0 if successful.
- */
-int dmp_get_pedometer_step_count(unsigned long *count)
-{
-    unsigned char tmp[4];
-    if (!count)
-        return -1;
-
-    if (mpu_read_mem(D_PEDSTD_STEPCTR, 4, tmp))
-        return -1;
-
-    count[0] = ((unsigned long)tmp[0] << 24) | ((unsigned long)tmp[1] << 16) |
-        ((unsigned long)tmp[2] << 8) | tmp[3];
-    return 0;
-}
-
-/**
- *  @brief      Overwrite current step count.
- *  WARNING: This function writes to DMP memory and could potentially encounter
- *  a race condition if called while the pedometer is enabled.
- *  @param[in]  count   New step count.
- *  @return     0 if successful.
- */
-int dmp_set_pedometer_step_count(unsigned long count)
-{
-    unsigned char tmp[4];
-
-    tmp[0] = (unsigned char)((count >> 24) & 0xFF);
-    tmp[1] = (unsigned char)((count >> 16) & 0xFF);
-    tmp[2] = (unsigned char)((count >> 8) & 0xFF);
-    tmp[3] = (unsigned char)(count & 0xFF);
-    return mpu_write_mem(D_PEDSTD_STEPCTR, 4, tmp);
-}
-
-/**
- *  @brief      Get duration of walking time.
- *  @param[in]  time    Walk time in milliseconds.
- *  @return     0 if successful.
- */
-int dmp_get_pedometer_walk_time(unsigned long *time)
-{
-    unsigned char tmp[4];
-    if (!time)
-        return -1;
-
-    if (mpu_read_mem(D_PEDSTD_TIMECTR, 4, tmp))
-        return -1;
-
-    time[0] = (((unsigned long)tmp[0] << 24) | ((unsigned long)tmp[1] << 16) |
-        ((unsigned long)tmp[2] << 8) | tmp[3]) * 20;
-    return 0;
-}
-
-/**
- *  @brief      Overwrite current walk time.
- *  WARNING: This function writes to DMP memory and could potentially encounter
- *  a race condition if called while the pedometer is enabled.
- *  @param[in]  time    New walk time in milliseconds.
- */
-int dmp_set_pedometer_walk_time(unsigned long time)
-{
-    unsigned char tmp[4];
-
-    time /= 20;
-
-    tmp[0] = (unsigned char)((time >> 24) & 0xFF);
-    tmp[1] = (unsigned char)((time >> 16) & 0xFF);
-    tmp[2] = (unsigned char)((time >> 8) & 0xFF);
-    tmp[3] = (unsigned char)(time & 0xFF);
-    return mpu_write_mem(D_PEDSTD_TIMECTR, 4, tmp);
-}
-
-/**
- *  @brief      Enable DMP features.
- *  The following \#define's are used in the input mask:
- *  \n DMP_FEATURE_TAP
- *  \n DMP_FEATURE_ANDROID_ORIENT
- *  \n DMP_FEATURE_LP_QUAT
- *  \n DMP_FEATURE_6X_LP_QUAT
- *  \n DMP_FEATURE_GYRO_CAL
- *  \n DMP_FEATURE_SEND_RAW_ACCEL
- *  \n DMP_FEATURE_SEND_RAW_GYRO
- *  \n NOTE: DMP_FEATURE_LP_QUAT and DMP_FEATURE_6X_LP_QUAT are mutually
- *  exclusive.
- *  \n NOTE: DMP_FEATURE_SEND_RAW_GYRO and DMP_FEATURE_SEND_CAL_GYRO are also
- *  mutually exclusive.
- *  @param[in]  mask    Mask of features to enable.
- *  @return     0 if successful.
- */
-int dmp_enable_feature(unsigned short mask)
-{
-    unsigned char tmp[10];
-
-    /* TODO: All of these settings can probably be integrated into the default
-     * DMP image.
-     */
-    /* Set integration scale factor. */
-    tmp[0] = (unsigned char)((GYRO_SF >> 24) & 0xFF);
-    tmp[1] = (unsigned char)((GYRO_SF >> 16) & 0xFF);
-    tmp[2] = (unsigned char)((GYRO_SF >> 8) & 0xFF);
-    tmp[3] = (unsigned char)(GYRO_SF & 0xFF);
-    mpu_write_mem(D_0_104, 4, tmp);
-
-    /* Send sensor data to the FIFO. */
-    tmp[0] = 0xA3;
-    if (mask & DMP_FEATURE_SEND_RAW_ACCEL) {
-        tmp[1] = 0xC0;
-        tmp[2] = 0xC8;
-        tmp[3] = 0xC2;
-    } else {
-        tmp[1] = 0xA3;
-        tmp[2] = 0xA3;
-        tmp[3] = 0xA3;
-    }
-    if (mask & DMP_FEATURE_SEND_ANY_GYRO) {
-        tmp[4] = 0xC4;
-        tmp[5] = 0xCC;
-        tmp[6] = 0xC6;
-    } else {
-        tmp[4] = 0xA3;
-        tmp[5] = 0xA3;
-        tmp[6] = 0xA3;
-    }
-    tmp[7] = 0xA3;
-    tmp[8] = 0xA3;
-    tmp[9] = 0xA3;
-    mpu_write_mem(CFG_15,10,tmp);
-
-    /* Send gesture data to the FIFO. */
-    if (mask & (DMP_FEATURE_TAP | DMP_FEATURE_ANDROID_ORIENT))
-        tmp[0] = DINA20;
-    else
-        tmp[0] = 0xD8;
-    mpu_write_mem1(CFG_27,1,tmp);
-
-    if (mask & DMP_FEATURE_GYRO_CAL)
-        dmp_enable_gyro_cal(1);
-    else
-        dmp_enable_gyro_cal(0);
-
-    if (mask & DMP_FEATURE_SEND_ANY_GYRO) {
-        if (mask & DMP_FEATURE_SEND_CAL_GYRO) {
-            tmp[0] = 0xB2;
-            tmp[1] = 0x8B;
-            tmp[2] = 0xB6;
-            tmp[3] = 0x9B;
-        } else {
-            tmp[0] = DINAC0;
-            tmp[1] = DINA80;
-            tmp[2] = DINAC2;
-            tmp[3] = DINA90;
-        }
-        mpu_write_mem1(CFG_GYRO_RAW_DATA, 4, tmp);
-    }
-
-    if (mask & DMP_FEATURE_TAP) {
-        /* Enable tap. */
-        tmp[0] = 0xF8;
-        mpu_write_mem1(CFG_20, 1, tmp);
-        dmp_set_tap_thresh(TAP_XYZ, 250);
-        dmp_set_tap_axes(TAP_XYZ);
-        dmp_set_tap_count(1);
-        dmp_set_tap_time(100);
-        dmp_set_tap_time_multi(500);
-
-        dmp_set_shake_reject_thresh(GYRO_SF, 200);
-        dmp_set_shake_reject_time(40);
-        dmp_set_shake_reject_timeout(10);
-    } else {
-        tmp[0] = 0xD8;
-        mpu_write_mem1(CFG_20, 1, tmp);
-    }
-
-    if (mask & DMP_FEATURE_ANDROID_ORIENT) {
-        tmp[0] = 0xD9;
-    } else
-        tmp[0] = 0xD8;
-    mpu_write_mem1(CFG_ANDROID_ORIENT_INT, 1, tmp);
-
-    if (mask & DMP_FEATURE_LP_QUAT)
-        dmp_enable_lp_quat(1);
-    else
-        dmp_enable_lp_quat(0);
-
-    if (mask & DMP_FEATURE_6X_LP_QUAT)
-        dmp_enable_6x_lp_quat(1);
-    else
-        dmp_enable_6x_lp_quat(0);
-
-    /* Pedometer is always enabled. */
-    dmp.feature_mask = mask | DMP_FEATURE_PEDOMETER;
-    mpu_reset_fifo();
-
-    dmp.packet_length = 0;
-    if (mask & DMP_FEATURE_SEND_RAW_ACCEL)
-        dmp.packet_length += 6;
-    if (mask & DMP_FEATURE_SEND_ANY_GYRO)
-        dmp.packet_length += 6;
-    if (mask & (DMP_FEATURE_LP_QUAT | DMP_FEATURE_6X_LP_QUAT))
-        dmp.packet_length += 16;
-    if (mask & (DMP_FEATURE_TAP | DMP_FEATURE_ANDROID_ORIENT))
-        dmp.packet_length += 4;
-
-    return 0;
-}
-
-/**
- *  @brief      Get list of currently enabled DMP features.
- *  @param[out] Mask of enabled features.
- *  @return     0 if successful.
- */
-int dmp_get_enabled_features(unsigned short *mask)
-{
-    mask[0] = dmp.feature_mask;
-    return 0;
-}
-
-/**
- *  @brief      Calibrate the gyro data in the DMP.
- *  After eight seconds of no motion, the DMP will compute gyro biases and
- *  subtract them from the quaternion output. If @e dmp_enable_feature is
- *  called with @e DMP_FEATURE_SEND_CAL_GYRO, the biases will also be
- *  subtracted from the gyro output.
- *  @param[in]  enable  1 to enable gyro calibration.
- *  @return     0 if successful.
- */
-int dmp_enable_gyro_cal(unsigned char enable)
-{
-    if (enable) {
-        unsigned char regs[9] = {0xb8, 0xaa, 0xb3, 0x8d, 0xb4, 0x98, 0x0d, 0x35, 0x5d};
-        return mpu_write_mem(CFG_MOTION_BIAS, 9, regs);
-    } else {
-        unsigned char regs[9] = {0xb8, 0xaa, 0xaa, 0xaa, 0xb0, 0x88, 0xc3, 0xc5, 0xc7};
-        return mpu_write_mem(CFG_MOTION_BIAS, 9, regs);
-    }
-}
-
-/**
- *  @brief      Generate 3-axis quaternions from the DMP.
- *  In this driver, the 3-axis and 6-axis DMP quaternion features are mutually
- *  exclusive.
- *  @param[in]  enable  1 to enable 3-axis quaternion.
- *  @return     0 if successful.
- */
-int dmp_enable_lp_quat(unsigned char enable)
-{
-    unsigned char regs[4];
-    if (enable) {
-        regs[0] = DINBC0;
-        regs[1] = DINBC2;
-        regs[2] = DINBC4;
-        regs[3] = DINBC6;
-    }
-    else
-        memset(regs, 0x8B, 4);
-
-    mpu_write_mem(CFG_LP_QUAT, 4, regs);
-
-    return mpu_reset_fifo();
-}
-
-/**
- *  @brief       Generate 6-axis quaternions from the DMP.
- *  In this driver, the 3-axis and 6-axis DMP quaternion features are mutually
- *  exclusive.
- *  @param[in]   enable  1 to enable 6-axis quaternion.
- *  @return      0 if successful.
- */
-int dmp_enable_6x_lp_quat(unsigned char enable)
-{
-    unsigned char regs[4];
-    if (enable) {
-        regs[0] = DINA20;
-        regs[1] = DINA28;
-        regs[2] = DINA30;
-        regs[3] = DINA38;
-    } else
-        memset(regs, 0xA3, 4);
-
-    mpu_write_mem(CFG_8, 4, regs);
-
-    return mpu_reset_fifo();
-}
-
-/**
- *  @brief      Decode the four-byte gesture data and execute any callbacks.
- *  @param[in]  gesture Gesture data from DMP packet.
- *  @return     0 if successful.
- */
-static int decode_gesture(unsigned char *gesture)
-{
-    unsigned char tap, android_orient;
-
-    android_orient = gesture[3] & 0xC0;
-    tap = 0x3F & gesture[3];
-
-    if (gesture[1] & INT_SRC_TAP) {
-        unsigned char direction, count;
-        direction = tap >> 3;
-        count = (tap % 8) + 1;
-        if (dmp.tap_cb)
-            dmp.tap_cb(direction, count);
-    }
-
-    if (gesture[1] & INT_SRC_ANDROID_ORIENT) {
-        if (dmp.android_orient_cb)
-            dmp.android_orient_cb(android_orient >> 6);
-    }
-
-    return 0;
-}
-
-/**
- *  @brief      Specify when a DMP interrupt should occur.
- *  A DMP interrupt can be configured to trigger on either of the two
- *  conditions below:
- *  \n a. One FIFO period has elapsed (set by @e mpu_set_sample_rate).
- *  \n b. A tap event has been detected.
- *  @param[in]  mode    DMP_INT_GESTURE or DMP_INT_CONTINUOUS.
- *  @return     0 if successful.
- */
-int dmp_set_interrupt_mode(unsigned char mode)
-{
-    const unsigned char regs_continuous[11] =
-        {0xd8, 0xb1, 0xb9, 0xf3, 0x8b, 0xa3, 0x91, 0xb6, 0x09, 0xb4, 0xd9};
-    const unsigned char regs_gesture[11] =
-        {0xda, 0xb1, 0xb9, 0xf3, 0x8b, 0xa3, 0x91, 0xb6, 0xda, 0xb4, 0xda};
-
-    switch (mode) {
-    case DMP_INT_CONTINUOUS:
-        return mpu_write_mem(CFG_FIFO_ON_EVENT, 11,
-            (unsigned char*)regs_continuous);
-    case DMP_INT_GESTURE:
-        return mpu_write_mem(CFG_FIFO_ON_EVENT, 11,
-            (unsigned char*)regs_gesture);
-    default:
-        return -1;
-    }
-}
-
-/**
- *  @brief      Get one packet from the FIFO.
- *  If @e sensors does not contain a particular sensor, disregard the data
- *  returned to that pointer.
- *  \n @e sensors can contain a combination of the following flags:
- *  \n INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO
- *  \n INV_XYZ_GYRO
- *  \n INV_XYZ_ACCEL
- *  \n INV_WXYZ_QUAT
- *  \n If the FIFO has no new data, @e sensors will be zero.
- *  \n If the FIFO is disabled, @e sensors will be zero and this function will
- *  return a non-zero error code.
- *  @param[out] gyro        Gyro data in hardware units.
- *  @param[out] accel       Accel data in hardware units.
- *  @param[out] quat        3-axis quaternion data in hardware units.
- *  @param[out] timestamp   Timestamp in milliseconds.
- *  @param[out] sensors     Mask of sensors read from FIFO.
- *  @param[out] more        Number of remaining packets.
- *  @return     0 if successful.
- */
-int dmp_read_fifo(short *gyro, short *accel, long *quat,
-    unsigned long *timestamp, short *sensors, unsigned char *more)
-{
-    unsigned char fifo_data[MAX_PACKET_LENGTH];
-    unsigned char ii = 0;
-
-    /* TODO: sensors[0] only changes when dmp_enable_feature is called. We can
-     * cache this value and save some cycles.
-     */
-    sensors[0] = 0;
-
-    /* Get a packet. */
-    if (mpu_read_fifo_stream(dmp.packet_length, fifo_data, more))
-        return -1;
-
-    /* Parse DMP packet. */
-    if (dmp.feature_mask & (DMP_FEATURE_LP_QUAT | DMP_FEATURE_6X_LP_QUAT)) {
-#ifdef FIFO_CORRUPTION_CHECK
-        long quat_q14[4], quat_mag_sq;
-#endif
-        quat[0] = ((long)fifo_data[0] << 24) | ((long)fifo_data[1] << 16) |
-            ((long)fifo_data[2] << 8) | fifo_data[3];
-        quat[1] = ((long)fifo_data[4] << 24) | ((long)fifo_data[5] << 16) |
-            ((long)fifo_data[6] << 8) | fifo_data[7];
-        quat[2] = ((long)fifo_data[8] << 24) | ((long)fifo_data[9] << 16) |
-            ((long)fifo_data[10] << 8) | fifo_data[11];
-        quat[3] = ((long)fifo_data[12] << 24) | ((long)fifo_data[13] << 16) |
-            ((long)fifo_data[14] << 8) | fifo_data[15];
-        ii += 16;
-#ifdef FIFO_CORRUPTION_CHECK
-        /* We can detect a corrupted FIFO by monitoring the quaternion data and
-         * ensuring that the magnitude is always normalized to one. This
-         * shouldn't happen in normal operation, but if an I2C error occurs,
-         * the FIFO reads might become misaligned.
-         *
-         * Let's start by scaling down the quaternion data to avoid long long
-         * math.
-         */
-        quat_q14[0] = quat[0] >> 16;
-        quat_q14[1] = quat[1] >> 16;
-        quat_q14[2] = quat[2] >> 16;
-        quat_q14[3] = quat[3] >> 16;
-        quat_mag_sq = quat_q14[0] * quat_q14[0] + quat_q14[1] * quat_q14[1] +
-            quat_q14[2] * quat_q14[2] + quat_q14[3] * quat_q14[3];
-        if ((quat_mag_sq < QUAT_MAG_SQ_MIN) ||
-            (quat_mag_sq > QUAT_MAG_SQ_MAX)) {
-            /* Quaternion is outside of the acceptable threshold. */
-            mpu_reset_fifo();
-            sensors[0] = 0;
-            return -1;
-        }
-        sensors[0] |= INV_WXYZ_QUAT;
-#endif
-    }
-
-    if (dmp.feature_mask & DMP_FEATURE_SEND_RAW_ACCEL) {
-        accel[0] = ((short)fifo_data[ii+0] << 8) | fifo_data[ii+1];
-        accel[1] = ((short)fifo_data[ii+2] << 8) | fifo_data[ii+3];
-        accel[2] = ((short)fifo_data[ii+4] << 8) | fifo_data[ii+5];
-        ii += 6;
-        sensors[0] |= INV_XYZ_ACCEL;
-    }
-
-    if (dmp.feature_mask & DMP_FEATURE_SEND_ANY_GYRO) {
-        gyro[0] = ((short)fifo_data[ii+0] << 8) | fifo_data[ii+1];
-        gyro[1] = ((short)fifo_data[ii+2] << 8) | fifo_data[ii+3];
-        gyro[2] = ((short)fifo_data[ii+4] << 8) | fifo_data[ii+5];
-        ii += 6;
-        sensors[0] |= INV_XYZ_GYRO;
-    }
-
-    /* Gesture data is at the end of the DMP packet. Parse it and call
-     * the gesture callbacks (if registered).
-     */
-    if (dmp.feature_mask & (DMP_FEATURE_TAP | DMP_FEATURE_ANDROID_ORIENT))
-        decode_gesture(fifo_data + ii);
-
-    get_ms(timestamp);
-    return 0;
-}
-
-/**
- *  @brief      Register a function to be executed on a tap event.
- *  The tap direction is represented by one of the following:
- *  \n TAP_X_UP
- *  \n TAP_X_DOWN
- *  \n TAP_Y_UP
- *  \n TAP_Y_DOWN
- *  \n TAP_Z_UP
- *  \n TAP_Z_DOWN
- *  @param[in]  func    Callback function.
- *  @return     0 if successful.
- */
-int dmp_register_tap_cb(void (*func)(unsigned char, unsigned char))
-{
-    dmp.tap_cb = func;
-    return 0;
-}
-
-/**
- *  @brief      Register a function to be executed on a android orientation event.
- *  @param[in]  func    Callback function.
- *  @return     0 if successful.
- */
-int dmp_register_android_orient_cb(void (*func)(unsigned char))
-{
-    dmp.android_orient_cb = func;
-    return 0;
-}
-
-/**
- *  @}
- */
-

+ 0 - 97
Core - 副本/imu/inv_mpu_dmp_motion_driver.h

@@ -1,97 +0,0 @@
-/*
- $License:
-    Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved.
-    See included License.txt for License information.
- $
- */
-/**
- *  @addtogroup  DRIVERS Sensor Driver Layer
- *  @brief       Hardware drivers to communicate with sensors via I2C.
- *
- *  @{
- *      @file       inv_mpu_dmp_motion_driver.h
- *      @brief      DMP image and interface functions.
- *      @details    All functions are preceded by the dmp_ prefix to
- *                  differentiate among MPL and general driver function calls.
- */
-#ifndef _INV_MPU_DMP_MOTION_DRIVER_H_
-#define _INV_MPU_DMP_MOTION_DRIVER_H_
-
-#define TAP_X               (0x01)
-#define TAP_Y               (0x02)
-#define TAP_Z               (0x04)
-#define TAP_XYZ             (0x07)
-
-#define TAP_X_UP            (0x01)
-#define TAP_X_DOWN          (0x02)
-#define TAP_Y_UP            (0x03)
-#define TAP_Y_DOWN          (0x04)
-#define TAP_Z_UP            (0x05)
-#define TAP_Z_DOWN          (0x06)
-
-#define ANDROID_ORIENT_PORTRAIT             (0x00)
-#define ANDROID_ORIENT_LANDSCAPE            (0x01)
-#define ANDROID_ORIENT_REVERSE_PORTRAIT     (0x02)
-#define ANDROID_ORIENT_REVERSE_LANDSCAPE    (0x03)
-
-#define DMP_INT_GESTURE     (0x01)
-#define DMP_INT_CONTINUOUS  (0x02)
-
-#define DMP_FEATURE_TAP             (0x001)
-#define DMP_FEATURE_ANDROID_ORIENT  (0x002)
-#define DMP_FEATURE_LP_QUAT         (0x004)
-#define DMP_FEATURE_PEDOMETER       (0x008)
-#define DMP_FEATURE_6X_LP_QUAT      (0x010)
-#define DMP_FEATURE_GYRO_CAL        (0x020)
-#define DMP_FEATURE_SEND_RAW_ACCEL  (0x040)
-#define DMP_FEATURE_SEND_RAW_GYRO   (0x080)
-#define DMP_FEATURE_SEND_CAL_GYRO   (0x100)
-
-#define INV_WXYZ_QUAT       (0x100)
-
-/* Set up functions. */
-int dmp_load_motion_driver_firmware(void);
-int dmp_set_fifo_rate(unsigned short rate);
-int dmp_get_fifo_rate(unsigned short *rate);
-int dmp_enable_feature(unsigned short mask);
-int dmp_get_enabled_features(unsigned short *mask);
-int dmp_set_interrupt_mode(unsigned char mode);
-int dmp_set_orientation(unsigned short orient);
-int dmp_set_gyro_bias(long *bias);
-int dmp_set_accel_bias(long *bias);
-
-/* Tap functions. */
-int dmp_register_tap_cb(void (*func)(unsigned char, unsigned char));
-int dmp_set_tap_thresh(unsigned char axis, unsigned short thresh);
-int dmp_set_tap_axes(unsigned char axis);
-int dmp_set_tap_count(unsigned char min_taps);
-int dmp_set_tap_time(unsigned short time);
-int dmp_set_tap_time_multi(unsigned short time);
-int dmp_set_shake_reject_thresh(long sf, unsigned short thresh);
-int dmp_set_shake_reject_time(unsigned short time);
-int dmp_set_shake_reject_timeout(unsigned short time);
-
-/* Android orientation functions. */
-int dmp_register_android_orient_cb(void (*func)(unsigned char));
-
-/* LP quaternion functions. */
-int dmp_enable_lp_quat(unsigned char enable);
-int dmp_enable_6x_lp_quat(unsigned char enable);
-
-/* Pedometer functions. */
-int dmp_get_pedometer_step_count(unsigned long *count);
-int dmp_set_pedometer_step_count(unsigned long count);
-int dmp_get_pedometer_walk_time(unsigned long *time);
-int dmp_set_pedometer_walk_time(unsigned long time);
-
-/* DMP gyro calibration functions. */
-int dmp_enable_gyro_cal(unsigned char enable);
-
-/* Read function. This function should be called whenever the MPU interrupt is
- * detected.
- */
-int dmp_read_fifo(short *gyro, short *accel, long *quat,
-    unsigned long *timestamp, short *sensors, unsigned char *more);
-
-#endif  /* #ifndef _INV_MPU_DMP_MOTION_DRIVER_H_ */
-