|
@@ -1,2 +1,48 @@
|
|
|
|
|
|
|
|
# ICM 20948 driver for STM32
|
|
# ICM 20948 driver for STM32
|
|
|
|
|
+
|
|
|
|
|
+```c
|
|
|
|
|
+
|
|
|
|
|
+#include "icm20948.h"
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+Device_TypeDef *module;
|
|
|
|
|
+
|
|
|
|
|
+void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|
|
|
|
+{
|
|
|
|
|
+ if(GPIO_Pin == ICM_INT_Pin){
|
|
|
|
|
+ module->Read();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+int main(void)
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+ // HAL_Init, etc...
|
|
|
|
|
+
|
|
|
|
|
+ axises *my_gyro2 = NULL;
|
|
|
|
|
+ axises *my_accel2 = NULL;
|
|
|
|
|
+
|
|
|
|
|
+ module = &icmModule;
|
|
|
|
|
+
|
|
|
|
|
+ McuPin_typeDef pinCS; // CS for SPI
|
|
|
|
|
+ McuPin_typeDef pinINT; // INT pin from ICM
|
|
|
|
|
+
|
|
|
|
|
+ pinCS.port = SPI2_CS_GPIO_Port;
|
|
|
|
|
+ pinCS.pin = SPI2_CS_Pin;
|
|
|
|
|
+
|
|
|
|
|
+ pinINT.port = ICM_INT_GPIO_Port;
|
|
|
|
|
+ pinINT.pin = ICM_INT_Pin;
|
|
|
|
|
+
|
|
|
|
|
+ // initialization of module
|
|
|
|
|
+ module->Init(&hspi2, &pinCS, &pinINT);
|
|
|
|
|
+
|
|
|
|
|
+ while (1)
|
|
|
|
|
+ {
|
|
|
|
|
+ my_accel2 = module->acc->Get();
|
|
|
|
|
+ my_gyro2 = module->gyro->Get();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+```
|