Forráskód Böngészése

Print clic when encoder is clicked

String is persistent.
DricomDragon 5 éve
szülő
commit
64b416fd3c
2 módosított fájl, 20 hozzáadás és 0 törlés
  1. 17 0
      prog/sources/setup-loop.cpp
  2. 3 0
      prog/sources/setup-loop.h

+ 17 - 0
prog/sources/setup-loop.cpp

@@ -1,10 +1,27 @@
 #include "all-headers.h"
 
 int ultimate_answer(42);
+uint32_t clicCounter(0);
 
 void setup (USER_MODE) {
+	// Enable interruption triggered by encoder clic
+	PORTD_PCR (0) |= PORT_PCR_IRQC (10);
+	NVIC_ENABLE_IRQ (ISRSlot::PORTD);
 }
 
 void loop (USER_MODE) {
 	assertion (ultimate_answer == 42, 101, __FILE__, __LINE__) ;
+
+	if (clicCounter > 0) {
+		gotoLineColumn(MODE_ 0, 0);
+		printString(MODE_ "Clic");
+	}
+}
+
+void clicInterruptSection(SECTION_MODE) {
+	clicCounter ++;
+
+	// Acquit interruption
+	PORTD_PCR (0) |= PORT_PCR_ISF ;
+	const uint32_t x __attribute__((unused)) = PORTD_PCR (0) ;
 }

+ 3 - 0
prog/sources/setup-loop.h

@@ -12,3 +12,6 @@ void incrementations (USER_MODE) asm ("fonction.incrementations") ;
 
 void section_incrementations (SECTION_MODE) asm ("section.fonction.incrementations") ;
 
+//$interrupt-section PORTD
+
+void clicInterruptSection(SECTION_MODE) asm ("interrupt.section.PORTD");