From 09bfbf52a6fa408e6a1cb6ab58c147627402216a Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期六, 22 一月 2022 12:15:53 +0800
Subject: [PATCH] V2.46 增加加速计配置校验功能

---
 Drivers/ExternlDrivers/lis3dh_driver.c |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/Drivers/ExternlDrivers/lis3dh_driver.c b/Drivers/ExternlDrivers/lis3dh_driver.c
index ae6fbf0..3f81bbe 100644
--- a/Drivers/ExternlDrivers/lis3dh_driver.c
+++ b/Drivers/ExternlDrivers/lis3dh_driver.c
@@ -74,7 +74,44 @@
 	HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
 	HAL_GPIO_WritePin(GPIOA,GPIO_PIN_2|GPIO_PIN_3,GPIO_PIN_SET); 	//PB6,PB7 输出高
 }
-
+uint8_t LIS3DH_ReadReg(uint8_t Reg, uint8_t* Data);
+void LIS3DH_Check(void)
+{
+u8 error = 0,temp;
+	 
+	LIS3DH_ReadReg(LIS3DH_CTRL_REG1,&temp);
+	if(temp!=0x57)
+	{error=1;}
+	
+	LIS3DH_ReadReg(LIS3DH_CTRL_REG2,&temp);
+	if(temp!=0x03)
+	{error=1;}
+	
+	LIS3DH_ReadReg(LIS3DH_CTRL_REG3,&temp);
+	if(temp!=0x40)
+	{error=1;}
+	
+	LIS3DH_ReadReg(LIS3DH_CTRL_REG4,&temp);
+	if(temp!=0x08)
+	{error=1;}
+	
+		LIS3DH_ReadReg(LIS3DH_INT1_CFG,&temp);
+	if(temp!=0xaa)
+	{error=1;}
+	
+		LIS3DH_ReadReg(LIS3DH_INT1_THS,&temp);
+	if(temp!=g_com_map[IMU_THRES])
+	{error=1;}
+	
+		LIS3DH_ReadReg(LIS3DH_INT1_DURATION,&temp);
+	if(temp!=g_com_map[IMU_DUARTION])
+	{error=1;}
+	
+	if(error==1)
+	{
+		SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; 
+	}
+}
 
 void LIS3DH_Data_Init()	
 {

--
Gitblit v1.9.3