GeekIMU/2.Firmware/STM32/Firmware/main.c

77 lines
1.7 KiB
C
Raw Normal View History

2024-11-09 21:39:20 +08:00
/******************** (C) COPYRIGHT 2020 GEEKIMU *******************************
* File Name : main.c
* Current Version : V2.0 & ST 3.5.0
* Author : zhanli 719901725@qq.com & JustFeng.
* Date of Issued : 2017.1.11 zhanli: Create
* Comments : GeekIMUv2 STM32<EFBFBD>̼<EFBFBD>
********************************************************************************/
#include "hw_config.h"
#include "usb_lib.h"
#include "delay.h"
#include "usart.h"
#include "usb_pwr.h"
#include "calibrate.h"
#include "senddata.h"
#include "gpio.h"
#include "led.h"
#include "calibrate.h"
#include "mpu6500.h"
#include "lis3mdl.h"
#include "spi.h"
#include "time.h"
#define USING_UART_DEBUG 1
#define NVIC_VectTab_FLASH1 0x8000000
u8 status = 1;
/**----------------------------------------------------------------------
* Function : main()
* Description : GeekIMU<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* Author : zhanli&719901725@qq.com
* Date : 2021/6/22 zhanli
*---------------------------------------------------------------------**/
int main(void)
{
// <20><><EFBFBD><EFBFBD>STM32<33>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Set_System();
#ifdef USING_UART_DEBUG
uart_init(9600);
#endif
// <20><>ʼ<EFBFBD><CABC>GPIO<49><4F>
GPIO_Configuration();
// IMU SPI IO<49><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MEMS_SPI_Init();
// STM32 USB<53><42><EFBFBD><EFBFBD>
USB_Interrupts_Config();
Set_USBClock();
USB_Init();
// <20><>ʱ200ms<6D>ȴ<EFBFBD>MPU6500<30>ȶ<EFBFBD>
Delay_Ms(200);
// IMU<4D><55>ʼ<EFBFBD><CABC>
status = MPU6500_Init();
LIS3MDL_Init();
Delay_Ms(100);
// IMU У׼ģ<D7BC><C4A3><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
Calibrate_Init();
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>USB<53>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TIM3_Int_Init(9,7199);
while (1)
{
Get_Sensor_Data();
if(status != 0x70){
LED_On();
Delay_Ms(500);
LED_Off();
Delay_Ms(500);
}else{
LED_On();
Delay_Ms(1);
}
}
}