Thomas Morris / Mbed 2 deprecated Grid_Tie_V9

Dependencies:   mbed mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "SETUP.hpp"
00002 Ticker frequency_ticker;
00003 //Can only use 3 threads including main
00004 void Frequency_set()
00005 {
00006     OUTPUT_THREAD.signal_set(1);//Sets the output thread to output data every time this interrupt is run
00007     //This interrupt is set to run from a ticker   
00008 }
00009 
00010 void Output_Thread_Function()
00011 {
00012     while(1)
00013     {
00014         Thread::signal_wait(1);
00015         OUTPUT_THREAD.signal_set(0);
00016         //pc.printf("In output thread function\n");
00017         DRIVER_1.Output_Sine_Wave();
00018         Thread::wait(1);//Small wait   
00019     }   
00020 }
00021 void Input_Thread_Function()
00022 {
00023     while(1)
00024     {
00025         Thread::signal_wait(1);
00026         //pc.printf("In input thread function\n");
00027         Thread::wait(1000);
00028     }   
00029 }  
00030 int main() 
00031 {
00032     pc.printf("Outputing data to serial\n");
00033     
00034     DRIVER_1.Sine_Lookup_Table_Generator();
00035     Thread::wait(1000);
00036     OUTPUT_THREAD.start(Output_Thread_Function);
00037     INPUT_THREAD.start(Input_Thread_Function);
00038     frequency_ticker.attach(&Frequency_set,0.0002f);//Sets the frequency to 50Hz
00039     while(1) 
00040     {
00041         Thread::signal_wait(1);
00042         myled = !myled;
00043         //pc.printf("In main thread\n");
00044         Thread::wait(1000);
00045         
00046     }
00047 }