For NTHU_Racing MCU tutorial Learn to use timer inturrupt

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
open4416
Date:
Fri Jan 20 14:13:02 2017 +0000
Parent:
1:5968363c5d23
Commit message:
some trim nothing new

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
sample_timebase.cpp Show diff for this revision Revisions of this file
diff -r 5968363c5d23 -r d8165b8ea789 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 20 14:13:02 2017 +0000
@@ -0,0 +1,59 @@
+#include "mbed.h"
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~GPIO registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+DigitalOut  led =           D13;            //link leg
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of GPIO registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~Varible registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+Ticker  TT1;                                //call a timer
+Ticker  TT2;                                //call a timer
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of Varible registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~Function registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+void init_IO();                         //initialize IO state
+void init_TIMER();                      //set TT_main{} rate
+void TT1_main();                        //timebase function rated by TT1
+void TT2_main();                        //timebase function rated by TT2
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of Function registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~main funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+int main()
+{
+    init_IO();                          //initialized value
+    init_TIMER();                       //initialized Timer Inturrupt rate
+
+    while(1) {                          //main() loop
+    }
+}
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of main funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~init_IO funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+void init_IO(void)                      //initialize
+{
+    led = 1;
+}
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of init_IO funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~Timebase funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+void init_TIMER()                       //set TTx_main{} rate
+{
+    TT1.attach_us(&TT1_main, 1000);
+    TT2.attach_us(&TT2_main, 1001);
+}
+
+void TT1_main()                         //interrupt function by TT1
+{
+    led = !led;
+}
+
+void TT2_main()                         //interrupt function by TT2
+{
+    led = !led;
+}
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of Timebase funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
\ No newline at end of file
diff -r 5968363c5d23 -r d8165b8ea789 sample_timebase.cpp
--- a/sample_timebase.cpp	Thu Jan 19 07:42:30 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-#include "mbed.h"
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~GPIO registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-DigitalOut  led =           D13;            //link leg
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of GPIO registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~Varible registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-Ticker  TT1;                                //call a timer
-Ticker  TT2;                                //call a timer
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of Varible registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~Function registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-void init_IO();                         //initialize IO state
-void init_TIMER();                      //set TT_main{} rate
-void TT1_main();                        //timebase function rated by TT1
-void TT2_main();                        //timebase function rated by TT2
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of Function registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~main funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-int main()
-{
-    init_IO();                          //initialized value
-    init_TIMER();                       //initialized Timer Inturrupt rate
-
-    while(1) {                          //main() loop
-    }
-}
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of main funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~init_IO funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-void init_IO(void)                      //initialize
-{
-    led = 1;
-}
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of init_IO funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-
-
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~Timebase funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-void init_TIMER()                       //set TTx_main{} rate
-{
-    TT1.attach_us(&TT1_main, 1000);
-    TT2.attach_us(&TT2_main, 1010);
-}
-
-void TT1_main()                         //interrupt function by TT1
-{
-    led = !led;
-}
-
-      void TT2_main()                         //interrupt function by TT2
-{
-    led = !led;
-}
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~end of Timebase funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
\ No newline at end of file