Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of interupt_counter by
Revision 0:6ef5de7d9560, committed 2016-01-18
- Comitter:
- schoeni_91
- Date:
- Mon Jan 18 09:44:43 2016 +0000
- Commit message:
- Test
Changed in this revision
diff -r 000000000000 -r 6ef5de7d9560 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Jan 18 09:44:43 2016 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+
+InterruptIn iiUp(p15);
+InterruptIn iiDown (p12);
+BusOut boLeds(LED1,LED2,LED3,LED4);
+
+
+void cntUp()
+{
+ boLeds=boLeds +1;
+}
+
+void cntDown()
+{
+ boLeds=boLeds -1;
+}
+
+
+
+int main() {
+ boLeds=0;
+ iiUp.fall(&cntUp);
+ iiDown.rise(&cntDown);
+ while (1) {
+ }
+ }
+
diff -r 000000000000 -r 6ef5de7d9560 main1.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main1.cpp Mon Jan 18 09:44:43 2016 +0000
@@ -0,0 +1,60 @@
+#include "mbed.h"
+
+InterruptIn iiUp(p15);
+DigitalIn diUp(p15);
+InterruptIn iiDown(p12);
+DigitalIn diDown(p12);
+BusOut leds(LED1, LED2, LED3, LED4);
+
+// prototypes
+
+// functions
+// Diese Funktion ist zum Entprellen von Tastern geeignet:
+// Durch den zusätzlichen Code kann eine Entprellzeit von durchschnittlich 1,5-4ms
+// (mindestens 8*150us = 1,2ms) erreicht werden.
+// Grundsätzlich prüft die Funktion den Pegel des Pins eine DigitalIn.
+// Wenn der Pegel 8 Mal konstant war, wird die Schleife verlassen.
+// Diese Funktion kann sehr gut eingesetzt werden, um in einer Endlosschleife Taster
+// anzufragen, da sie, wie erwähnt, eine kurze Wartezeit hat.
+uint8_t debounce(DigitalIn myIn)
+{
+#define LEVEL_CHECKS 8
+#define MAX_LOOPS 30 // stoppt das Überprüfen des Prellen nach max. MAX_LOOPS Durchläufen
+ unsigned char port_buffer;
+ unsigned char debounceCounter = 0;
+ uint8_t loopCounter = 0;
+
+ do {
+ port_buffer = myIn;
+ wait_us(150);
+ loopCounter++;
+ if(myIn == port_buffer)
+ debounceCounter++; // mindestens 'LEVEL_CHECKS' Abtastungen in Folge: gleicher Pegel
+ else
+ debounceCounter = 0;
+ } while ((debounceCounter <= LEVEL_CHECKS) && (loopCounter <= MAX_LOOPS));
+ return loopCounter;
+}
+
+// ISR
+void cntUp()
+{
+ debounce(diUp);
+ leds = leds + 1;
+}
+
+void cntDown()
+{
+ debounce(diDown);
+ leds = leds - 1;
+}
+
+
+// main program
+int main()
+{
+ iiUp.rise(&cntUp);
+ iiDown.rise(&cntDown);
+ while(1) {
+ }
+}
diff -r 000000000000 -r 6ef5de7d9560 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jan 18 09:44:43 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file
