139 lines
4.4 KiB
C
139 lines
4.4 KiB
C
|
/***********************************************
|
|||
|
<EFBFBD><EFBFBD>˾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD>Ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾
|
|||
|
Ʒ<EFBFBD>ƣ<EFBFBD>WHEELTEC
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wheeltec.net
|
|||
|
<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD>shop114407458.taobao.com
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ: https://minibalance.aliexpress.com/store/4455017
|
|||
|
<EFBFBD>汾<EFBFBD><EFBFBD>5.7
|
|||
|
<EFBFBD><EFBFBD>ʱ<EFBFBD>䣺2021-04-29
|
|||
|
|
|||
|
|
|||
|
Brand: WHEELTEC
|
|||
|
Website: wheeltec.net
|
|||
|
Taobao shop: shop114407458.taobao.com
|
|||
|
Aliexpress: https://minibalance.aliexpress.com/store/4455017
|
|||
|
Version:5.7
|
|||
|
Update<EFBFBD><EFBFBD>2021-04-29
|
|||
|
|
|||
|
All rights reserved
|
|||
|
***********************************************/
|
|||
|
#ifndef __SYS_H
|
|||
|
#define __SYS_H
|
|||
|
#include <stm32f10x.h>
|
|||
|
//0,<2C><>֧<EFBFBD><D6A7>ucos
|
|||
|
//1,֧<><D6A7>ucos
|
|||
|
#define SYSTEM_SUPPORT_UCOS 0 //<2F><><EFBFBD><EFBFBD>ϵͳ<CFB5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ƿ<EFBFBD>֧<EFBFBD><D6A7>UCOS
|
|||
|
|
|||
|
|
|||
|
//λ<><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ʵ<><CAB5>51<35><31><EFBFBD>Ƶ<EFBFBD>GPIO<49><4F><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD>
|
|||
|
//<2F><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>˼<EFBFBD><CBBC>,<2C>ο<EFBFBD><<CM3Ȩ<33><C8A8>ָ<EFBFBD><D6B8>>><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(87ҳ~92ҳ).
|
|||
|
//IO<49>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>궨<EFBFBD><EAB6A8>
|
|||
|
#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
|
|||
|
#define MEM_ADDR(addr) *((volatile unsigned long *)(addr))
|
|||
|
#define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum))
|
|||
|
//IO<49>ڵ<EFBFBD>ַӳ<D6B7><D3B3>
|
|||
|
#define GPIOA_ODR_Addr (GPIOA_BASE+12) //0x4001080C
|
|||
|
#define GPIOB_ODR_Addr (GPIOB_BASE+12) //0x40010C0C
|
|||
|
#define GPIOC_ODR_Addr (GPIOC_BASE+12) //0x4001100C
|
|||
|
#define GPIOD_ODR_Addr (GPIOD_BASE+12) //0x4001140C
|
|||
|
#define GPIOE_ODR_Addr (GPIOE_BASE+12) //0x4001180C
|
|||
|
#define GPIOF_ODR_Addr (GPIOF_BASE+12) //0x40011A0C
|
|||
|
#define GPIOG_ODR_Addr (GPIOG_BASE+12) //0x40011E0C
|
|||
|
|
|||
|
#define GPIOA_IDR_Addr (GPIOA_BASE+8) //0x40010808
|
|||
|
#define GPIOB_IDR_Addr (GPIOB_BASE+8) //0x40010C08
|
|||
|
#define GPIOC_IDR_Addr (GPIOC_BASE+8) //0x40011008
|
|||
|
#define GPIOD_IDR_Addr (GPIOD_BASE+8) //0x40011408
|
|||
|
#define GPIOE_IDR_Addr (GPIOE_BASE+8) //0x40011808
|
|||
|
#define GPIOF_IDR_Addr (GPIOF_BASE+8) //0x40011A08
|
|||
|
#define GPIOG_IDR_Addr (GPIOG_BASE+8) //0x40011E08
|
|||
|
|
|||
|
//IO<49>ڲ<EFBFBD><DAB2><EFBFBD>,ֻ<>Ե<EFBFBD>һ<EFBFBD><D2BB>IO<49><4F>!
|
|||
|
//ȷ<><C8B7>n<EFBFBD><6E>ֵС<D6B5><D0A1>16!
|
|||
|
#define PAout(n) BIT_ADDR(GPIOA_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PAin(n) BIT_ADDR(GPIOA_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define PBout(n) BIT_ADDR(GPIOB_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PBin(n) BIT_ADDR(GPIOB_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define PCout(n) BIT_ADDR(GPIOC_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PCin(n) BIT_ADDR(GPIOC_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define PDout(n) BIT_ADDR(GPIOD_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PDin(n) BIT_ADDR(GPIOD_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define PEout(n) BIT_ADDR(GPIOE_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PEin(n) BIT_ADDR(GPIOE_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define PFout(n) BIT_ADDR(GPIOF_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PFin(n) BIT_ADDR(GPIOF_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define PGout(n) BIT_ADDR(GPIOG_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PGin(n) BIT_ADDR(GPIOG_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
/////////////////////////////////////////////////////////////////
|
|||
|
//Ex_NVIC_Configר<67>ö<EFBFBD><C3B6><EFBFBD>
|
|||
|
#define GPIO_A 0
|
|||
|
#define GPIO_B 1
|
|||
|
#define GPIO_C 2
|
|||
|
#define GPIO_D 3
|
|||
|
#define GPIO_E 4
|
|||
|
#define GPIO_F 5
|
|||
|
#define GPIO_G 6
|
|||
|
|
|||
|
#define FTIR 1 //<2F>½<EFBFBD><C2BD>ش<EFBFBD><D8B4><EFBFBD>
|
|||
|
#define RTIR 2 //<2F><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>
|
|||
|
#include "delay.h"
|
|||
|
#include "oled.h"
|
|||
|
#include "motor.h"
|
|||
|
#include "ioi2c.h"
|
|||
|
#include "mpu6050.h"
|
|||
|
#include "show.h"
|
|||
|
//JTAGģʽ<C4A3><CABD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>
|
|||
|
#define JTAG_SWD_DISABLE 0X02
|
|||
|
#define SWD_ENABLE 0X01
|
|||
|
#define JTAG_SWD_ENABLE 0X00
|
|||
|
extern int Encoder_Left,Encoder_Right; // <20><><EFBFBD>ұ<EFBFBD><D2B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
extern u8 Flag_Stop; // ֹͣ<CDA3><D6B9>־λ<D6BE><CEBB> <20><>ʾ<EFBFBD><CABE>־λ Ĭ<><C4AC>ֹͣ <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
extern float Angle_Balance,Gyro_Balance; // ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
/*---------------------- <20><><EFBFBD><EFBFBD>Ϊϵͳ<CFB5><CDB3><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD> -------------------------*/
|
|||
|
void Stm32_Clock_Init(u8 PLL); //ʱ<>ӳ<EFBFBD>ʼ<EFBFBD><CABC>
|
|||
|
void Sys_Soft_Reset(void); //ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>λ
|
|||
|
void Sys_Standby(void); //<2F><><EFBFBD><EFBFBD>ģʽ
|
|||
|
void MY_NVIC_SetVectorTable(u32 NVIC_VectTab, u32 Offset);//<2F><><EFBFBD><EFBFBD>ƫ<EFBFBD>Ƶ<EFBFBD>ַ
|
|||
|
void MY_NVIC_PriorityGroupConfig(u8 NVIC_Group);//<2F><><EFBFBD><EFBFBD>NVIC<49><43><EFBFBD><EFBFBD>
|
|||
|
void MY_NVIC_Init(u8 NVIC_PreemptionPriority,u8 NVIC_SubPriority,u8 NVIC_Channel,u8 NVIC_Group);//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
void Ex_NVIC_Config(u8 GPIOx,u8 BITx,u8 TRIM);//<2F>ⲿ<EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ú<EFBFBD><C3BA><EFBFBD>(ֻ<><D6BB>GPIOA~G)
|
|||
|
void JTAG_Set(u8 mode);
|
|||
|
|
|||
|
/*------------------------ <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ຯ<EFBFBD><E0BAAF> ---------------------------*/
|
|||
|
|
|||
|
void WFI_SET(void); // ִ<><D6B4>WFIָ<49><D6B8>
|
|||
|
void INTX_DISABLE(void); // <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
void INTX_ENABLE(void); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
void MSR_MSP(u32 addr); // <20><><EFBFBD>ö<EFBFBD>ջ<EFBFBD><D5BB>ַ
|
|||
|
|
|||
|
#include "inv_mpu.h"
|
|||
|
#include "inv_mpu_dmp_motion_driver.h"
|
|||
|
#include "dmpKey.h"
|
|||
|
#include "dmpmap.h"
|
|||
|
#include <string.h>
|
|||
|
#include <stdio.h>
|
|||
|
#include <stdint.h>
|
|||
|
#include <stdlib.h>
|
|||
|
#include <string.h>
|
|||
|
#include <math.h>
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|