Merge "Use sched_setscheduler instead of scheduling policy service"
diff --git a/firmware/os/drivers/st_mag40/st_mag40.c b/firmware/os/drivers/st_mag40/st_mag40.c
index bdc874a..1b09fd5 100644
--- a/firmware/os/drivers/st_mag40/st_mag40.c
+++ b/firmware/os/drivers/st_mag40/st_mag40.c
@@ -674,8 +674,6 @@
     if (!extiIsPendingGpio(mTask.Int1))
         return false;
 
-    mTask.timestampInt = rtcGetTime();
-
     /* Start sampling for a value */
     if (!osEnqueuePrivateEvt(EVT_SENSOR_INTERRUPT, NULL, NULL, mTask.tid))
         ERROR_PRINT("st_mag40_int1_isr: osEnqueuePrivateEvt() failed\n");
@@ -701,6 +699,8 @@
     float xi, yi, zi;
 #endif
 
+    mTask.timestampInt = sensorGetTime();
+
 	/* Discard samples generated during sensor turn-on time */
     if (mTask.samplesToDiscard > 0) {
         mTask.samplesToDiscard--;
@@ -1024,6 +1024,9 @@
 static void endTask(void)
 {
     INFO_PRINT("ended\n");
+#if defined(ST_MAG40_CAL_ENABLED)
+    magCalDestroy(&mTask.moc);
+#endif /* ST_MAG40_CAL_ENABLED */
     slabAllocatorDestroy(mTask.magDataSlab);
     disableInterrupt(mTask.Int1, &mTask.Isr1);
 }