From d2db1680f7b2ef8b120294a79c7309a0b3263393 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期四, 10 二月 2022 19:43:22 +0800 Subject: [PATCH] 2.47 增加加速计校验 --- 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 efb87ff..23b692a 100644 --- a/Drivers/ExternlDrivers/lis3dh_driver.c +++ b/Drivers/ExternlDrivers/lis3dh_driver.c @@ -74,7 +74,44 @@ HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStructure); HAL_GPIO_WritePin(SCL_GPIO_Port,SCL_Pin|SDA_Pin,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