From 6fcfd50b86e55a25b80e06d6c4e821e0ca23f987 Mon Sep 17 00:00:00 2001
From: Terraneo Federico <fede.tft@miosix.org>
Date: Thu, 19 May 2016 11:29:45 +0200
Subject: [PATCH] Added temporary context switch profiling code, to be removed
 when optimization is done

---
 debugpin.h                                    | 25 +++++++++++++++++++
 .../common/interfaces-impl/cstimer.cpp        |  3 +++
 2 files changed, 28 insertions(+)
 create mode 100644 debugpin.h

diff --git a/debugpin.h b/debugpin.h
new file mode 100644
index 00000000..5349383e
--- /dev/null
+++ b/debugpin.h
@@ -0,0 +1,25 @@
+
+
+#ifndef DEBUGPIN_H
+#define	DEBUGPIN_H
+
+#include "miosix/interfaces/gpio.h"
+
+typedef miosix::Gpio<GPIOA_BASE, 1> debug1;
+typedef miosix::Gpio<GPIOA_BASE,15> debug2;
+
+template<typename T>
+class HighPin
+{
+public:
+    HighPin()  { T::high(); }
+    ~HighPin() { T::low();  }
+};
+
+inline void initDebugPins()
+{
+    debug1::mode(miosix::Mode::OUTPUT);
+    debug2::mode(miosix::Mode::OUTPUT);
+}
+
+#endif //DEBUGPIN_H
diff --git a/miosix/arch/cortexM4_stm32f4/common/interfaces-impl/cstimer.cpp b/miosix/arch/cortexM4_stm32f4/common/interfaces-impl/cstimer.cpp
index d990a281..0874558e 100644
--- a/miosix/arch/cortexM4_stm32f4/common/interfaces-impl/cstimer.cpp
+++ b/miosix/arch/cortexM4_stm32f4/common/interfaces-impl/cstimer.cpp
@@ -3,6 +3,7 @@
 #include "interfaces/arch_registers.h"
 #include "kernel/kernel.h"
 #include "kernel/scheduler/timer_interrupt.h"
+#include "../../../../../debugpin.h"
 
 using namespace miosix;
 
@@ -60,12 +61,14 @@ void __attribute__((naked)) TIM2_IRQHandler()
 
 void __attribute__((used)) cstirqhnd()
 {
+    HighPin<debug1> h1;
     if(TIM2->SR & TIM_SR_CC1IF || lateIrq)
     {
         TIM2->SR = ~TIM_SR_CC1IF;
         if(ms32time==ms32chkp || lateIrq)
         {
             lateIrq=false;
+            HighPin<debug2> h2;
             IRQtimerInterrupt(nextInterrupt());
         }
 
-- 
GitLab