NTHU_Racing / Mbed 2 deprecated Practice_3_example

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 //~~~~~~~~~~~~~~~~~~~~~~~~~~~GPIO registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00004 DigitalOut  led =           D13;            //link leg
00005 //~~~~~~~~~~~~~~~~~~~~~~~~~~~end of GPIO registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00006 
00007 
00008 //~~~~~~~~~~~~~~~~~~~~~~~~~~~Varible registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00009 Ticker  TT1;                                //call a timer
00010 Ticker  TT2;                                //call a timer
00011 //~~~~~~~~~~~~~~~~~~~~~~~~~~~end of Varible registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00012 
00013 
00014 //~~~~~~~~~~~~~~~~~~~~~~~~~~~Function registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00015 void init_IO();                         //initialize IO state
00016 void init_TIMER();                      //set TT_main{} rate
00017 void TT1_main();                        //timebase function rated by TT1
00018 void TT2_main();                        //timebase function rated by TT2
00019 //~~~~~~~~~~~~~~~~~~~~~~~~~~~end of Function registor~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00020 
00021 
00022 //~~~~~~~~~~~~~~~~~~~~~~~~~~~main funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00023 int main()
00024 {
00025     init_IO();                          //initialized value
00026     init_TIMER();                       //initialized Timer Inturrupt rate
00027 
00028     while(1) {                          //main() loop
00029     }
00030 }
00031 //~~~~~~~~~~~~~~~~~~~~~~~~~~~end of main funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00032 
00033 
00034 //~~~~~~~~~~~~~~~~~~~~~~~~~~~init_IO funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00035 void init_IO(void)                      //initialize
00036 {
00037     led = 1;
00038 }
00039 //~~~~~~~~~~~~~~~~~~~~~~~~~~~end of init_IO funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00040 
00041 
00042 
00043 //~~~~~~~~~~~~~~~~~~~~~~~~~~~Timebase funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
00044 void init_TIMER()                       //set TTx_main{} rate
00045 {
00046     TT1.attach_us(&TT1_main, 1000);
00047     TT2.attach_us(&TT2_main, 1001);
00048 }
00049 
00050 void TT1_main()                         //interrupt function by TT1
00051 {
00052     led = !led;
00053 }
00054 
00055 void TT2_main()                         //interrupt function by TT2
00056 {
00057     led = !led;
00058 }
00059 //~~~~~~~~~~~~~~~~~~~~~~~~~~~end of Timebase funtion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//