Testing 1 blue pill
Dependencies: mbed mbed-rtos TextLCD
main.cpp@30:a35f0ab97a65, 2019-04-04 (annotated)
- Committer:
- thomasmorris
- Date:
- Thu Apr 04 10:52:22 2019 +0000
- Revision:
- 30:a35f0ab97a65
- Parent:
- 29:f3b1387c81f1
Testing 1;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 12:d9c133b360b0 | 1 | #include "SETUP.hpp" |
thomasmorris | 30:a35f0ab97a65 | 2 | void Interface_Serial_thread_function() |
thomasmorris | 30:a35f0ab97a65 | 3 | { |
thomasmorris | 30:a35f0ab97a65 | 4 | while(1) |
thomasmorris | 30:a35f0ab97a65 | 5 | { |
thomasmorris | 30:a35f0ab97a65 | 6 | INTERFACE.Interface_Serial(); |
thomasmorris | 30:a35f0ab97a65 | 7 | } |
thomasmorris | 30:a35f0ab97a65 | 8 | } |
thomasmorris | 30:a35f0ab97a65 | 9 | |
JDickson | 27:22d6fd88828e | 10 | void Polling_thread_function()// Polling thread to look for button press |
thomasmorris | 26:83550fc299aa | 11 | { |
thomasmorris | 26:83550fc299aa | 12 | while(1) |
thomasmorris | 26:83550fc299aa | 13 | { |
JDickson | 27:22d6fd88828e | 14 | if(button_up.read() == 0) //This checks the Up button |
thomasmorris | 26:83550fc299aa | 15 | { |
thomasmorris | 26:83550fc299aa | 16 | printf("Up button read\n"); |
thomasmorris | 29:f3b1387c81f1 | 17 | Thread::wait(Up_Down_Debounce_Time); |
thomasmorris | 29:f3b1387c81f1 | 18 | if(INTERFACE.Get_Function() == 0 || INTERFACE.Get_Function() == 1 || (INTERFACE.Get_Function() == 2 || INTERFACE.Get_Function() == 3) & INTERFACE.Get_Select() == 1 ) |
thomasmorris | 29:f3b1387c81f1 | 19 | { |
thomasmorris | 29:f3b1387c81f1 | 20 | if(button_up.read() == 1) |
thomasmorris | 29:f3b1387c81f1 | 21 | { |
thomasmorris | 29:f3b1387c81f1 | 22 | printf("Up button released\n"); |
thomasmorris | 29:f3b1387c81f1 | 23 | up_thread.signal_set(1); |
thomasmorris | 29:f3b1387c81f1 | 24 | } |
thomasmorris | 29:f3b1387c81f1 | 25 | } |
thomasmorris | 30:a35f0ab97a65 | 26 | else if((INTERFACE.Get_Function() == 2) & INTERFACE.Get_Select() == 0) |
thomasmorris | 29:f3b1387c81f1 | 27 | { |
thomasmorris | 29:f3b1387c81f1 | 28 | if(button_up.read() == 1) |
thomasmorris | 29:f3b1387c81f1 | 29 | { |
thomasmorris | 29:f3b1387c81f1 | 30 | printf("Up button released\n"); |
thomasmorris | 29:f3b1387c81f1 | 31 | up_thread.signal_set(1); |
thomasmorris | 29:f3b1387c81f1 | 32 | } |
thomasmorris | 29:f3b1387c81f1 | 33 | Thread::wait(1000); |
thomasmorris | 29:f3b1387c81f1 | 34 | |
thomasmorris | 29:f3b1387c81f1 | 35 | if(button_up.read() == 0) |
thomasmorris | 29:f3b1387c81f1 | 36 | { |
thomasmorris | 29:f3b1387c81f1 | 37 | printf("Up function coiling or twisting select = 0\n"); |
thomasmorris | 29:f3b1387c81f1 | 38 | while(button_up.read() == 0) |
thomasmorris | 29:f3b1387c81f1 | 39 | { |
thomasmorris | 29:f3b1387c81f1 | 40 | if(INTERFACE.Get_Turns_To_Do() >0) |
thomasmorris | 29:f3b1387c81f1 | 41 | { |
thomasmorris | 29:f3b1387c81f1 | 42 | INTERFACE.Set_Turns_To_Do(INTERFACE.Get_Turns_To_Do()+1); |
thomasmorris | 29:f3b1387c81f1 | 43 | } |
thomasmorris | 29:f3b1387c81f1 | 44 | Thread::wait(50); |
thomasmorris | 29:f3b1387c81f1 | 45 | } |
thomasmorris | 29:f3b1387c81f1 | 46 | } |
thomasmorris | 29:f3b1387c81f1 | 47 | } |
thomasmorris | 26:83550fc299aa | 48 | } |
JDickson | 27:22d6fd88828e | 49 | if(button_down.read() == 0) //This checks the Down button |
thomasmorris | 26:83550fc299aa | 50 | { |
thomasmorris | 26:83550fc299aa | 51 | printf("Down button read\n"); |
thomasmorris | 29:f3b1387c81f1 | 52 | Thread::wait(Up_Down_Debounce_Time); |
thomasmorris | 29:f3b1387c81f1 | 53 | if(INTERFACE.Get_Function() == 0 || INTERFACE.Get_Function() == 1 || (INTERFACE.Get_Function() == 2 || INTERFACE.Get_Function() == 3) & INTERFACE.Get_Select() == 1 ) |
thomasmorris | 29:f3b1387c81f1 | 54 | { |
thomasmorris | 29:f3b1387c81f1 | 55 | if(button_down.read() == 1) |
thomasmorris | 29:f3b1387c81f1 | 56 | { |
thomasmorris | 29:f3b1387c81f1 | 57 | printf("Down button released\n"); |
thomasmorris | 29:f3b1387c81f1 | 58 | down_thread.signal_set(1); |
thomasmorris | 29:f3b1387c81f1 | 59 | } |
thomasmorris | 29:f3b1387c81f1 | 60 | } |
thomasmorris | 30:a35f0ab97a65 | 61 | else if((INTERFACE.Get_Function() == 2) & INTERFACE.Get_Select() == 0) |
thomasmorris | 26:83550fc299aa | 62 | { |
thomasmorris | 29:f3b1387c81f1 | 63 | if(button_down.read() == 1) |
thomasmorris | 29:f3b1387c81f1 | 64 | { |
thomasmorris | 29:f3b1387c81f1 | 65 | printf("Down button released\n"); |
thomasmorris | 29:f3b1387c81f1 | 66 | down_thread.signal_set(1); |
thomasmorris | 29:f3b1387c81f1 | 67 | } |
thomasmorris | 29:f3b1387c81f1 | 68 | Thread::wait(1000); |
thomasmorris | 29:f3b1387c81f1 | 69 | |
thomasmorris | 29:f3b1387c81f1 | 70 | if(button_down.read() == 0) |
thomasmorris | 29:f3b1387c81f1 | 71 | { |
thomasmorris | 29:f3b1387c81f1 | 72 | printf("down function coiling or twisting select = 0\n"); |
thomasmorris | 29:f3b1387c81f1 | 73 | while(button_down.read() == 0) |
thomasmorris | 29:f3b1387c81f1 | 74 | { |
thomasmorris | 29:f3b1387c81f1 | 75 | if(INTERFACE.Get_Turns_To_Do() >0) |
thomasmorris | 29:f3b1387c81f1 | 76 | { |
thomasmorris | 29:f3b1387c81f1 | 77 | INTERFACE.Set_Turns_To_Do(INTERFACE.Get_Turns_To_Do()-1); |
thomasmorris | 29:f3b1387c81f1 | 78 | } |
thomasmorris | 29:f3b1387c81f1 | 79 | Thread::wait(50); |
thomasmorris | 29:f3b1387c81f1 | 80 | } |
thomasmorris | 29:f3b1387c81f1 | 81 | } |
thomasmorris | 29:f3b1387c81f1 | 82 | } |
thomasmorris | 29:f3b1387c81f1 | 83 | } |
JDickson | 27:22d6fd88828e | 84 | if(button_start.read() == 0) //This checks the Start/Stop button |
thomasmorris | 26:83550fc299aa | 85 | { |
thomasmorris | 26:83550fc299aa | 86 | printf("Start/Stop button read\n"); |
thomasmorris | 26:83550fc299aa | 87 | Thread::wait(Debounce_Time); |
thomasmorris | 26:83550fc299aa | 88 | if(button_start.read() == 1) |
thomasmorris | 26:83550fc299aa | 89 | { |
thomasmorris | 26:83550fc299aa | 90 | start_stop_thread.signal_set(1); |
thomasmorris | 26:83550fc299aa | 91 | } |
thomasmorris | 26:83550fc299aa | 92 | } |
JDickson | 27:22d6fd88828e | 93 | if(button_function.read() == 0) //This checks the Function button |
thomasmorris | 26:83550fc299aa | 94 | { |
thomasmorris | 26:83550fc299aa | 95 | printf("Function button read\n"); |
thomasmorris | 26:83550fc299aa | 96 | Thread::wait(Debounce_Time); |
thomasmorris | 26:83550fc299aa | 97 | if(button_function.read() == 1) |
thomasmorris | 26:83550fc299aa | 98 | { |
thomasmorris | 26:83550fc299aa | 99 | function_thread.signal_set(1); |
thomasmorris | 26:83550fc299aa | 100 | } |
thomasmorris | 26:83550fc299aa | 101 | } |
JDickson | 27:22d6fd88828e | 102 | if(button_select.read() == 0) //This checks the Select button |
thomasmorris | 26:83550fc299aa | 103 | { |
thomasmorris | 26:83550fc299aa | 104 | printf("Select button read\n"); |
thomasmorris | 26:83550fc299aa | 105 | Thread::wait(Debounce_Time); |
thomasmorris | 26:83550fc299aa | 106 | if(button_select.read() == 1) |
thomasmorris | 26:83550fc299aa | 107 | { |
thomasmorris | 26:83550fc299aa | 108 | select_thread.signal_set(1); |
thomasmorris | 26:83550fc299aa | 109 | } |
thomasmorris | 26:83550fc299aa | 110 | } |
thomasmorris | 29:f3b1387c81f1 | 111 | Thread::wait(50); |
thomasmorris | 26:83550fc299aa | 112 | } |
thomasmorris | 26:83550fc299aa | 113 | } |
JDickson | 27:22d6fd88828e | 114 | void LCD_thread() //Output data to the LCD for the interface |
JDickson | 27:22d6fd88828e | 115 | /* |
JDickson | 27:22d6fd88828e | 116 | This section of the code decides what data that should be sent to the LCD for each of the modes of the system. |
JDickson | 27:22d6fd88828e | 117 | */ |
thomasmorris | 26:83550fc299aa | 118 | { |
thomasmorris | 16:9f98ec0ededb | 119 | while(1) |
thomasmorris | 16:9f98ec0ededb | 120 | { |
thomasmorris | 17:68b3fdabe4c5 | 121 | lcd.cls();//Clear the LCD screen |
JDickson | 27:22d6fd88828e | 122 | if(INTERFACE.Get_Function() == 0)//Anneal Mode display |
thomasmorris | 25:9751619fa030 | 123 | { |
JDickson | 27:22d6fd88828e | 124 | lcd.printf("Mode: Anneal\n"); //Top LCD line when the device is annealing |
thomasmorris | 25:9751619fa030 | 125 | if(INTERFACE.Get_Select() == 0 || INTERFACE.Get_Select() == 1) |
thomasmorris | 25:9751619fa030 | 126 | { |
thomasmorris | 30:a35f0ab97a65 | 127 | lcd.printf("L:%d,%d Ont:%1.1f\n",INTERFACE.Get_Loops_done(),INTERFACE.Get_Loop(),INTERFACE.Get_On_Time()); //When the On value is selected |
thomasmorris | 30:a35f0ab97a65 | 128 | //lcd.printf("Loop:%d On_t:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_On_Time()); //When the On value is selected |
thomasmorris | 25:9751619fa030 | 129 | } |
thomasmorris | 25:9751619fa030 | 130 | else if(INTERFACE.Get_Select() == 2) |
thomasmorris | 25:9751619fa030 | 131 | { |
thomasmorris | 30:a35f0ab97a65 | 132 | lcd.printf("L:%d,%d Offt:%d\n",INTERFACE.Get_Loops_done(),INTERFACE.Get_Loop(),INTERFACE.Get_Off_Time()); //When the Off value is selected |
thomasmorris | 30:a35f0ab97a65 | 133 | //lcd.printf("Loop:%d Offt:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_Off_Time()); //When the Off value is selected |
thomasmorris | 25:9751619fa030 | 134 | } |
thomasmorris | 25:9751619fa030 | 135 | } |
JDickson | 27:22d6fd88828e | 136 | else if(INTERFACE.Get_Function() == 1)//Testing mode display |
thomasmorris | 25:9751619fa030 | 137 | { |
JDickson | 27:22d6fd88828e | 138 | lcd.printf("Mode: Test\n"); //Top LCD line when the device is Testing |
thomasmorris | 25:9751619fa030 | 139 | lcd.printf("Duty: %dTime: %d\n",INTERFACE.Get_Duty_Cycle(),INTERFACE.Get_Power_Time()); |
thomasmorris | 25:9751619fa030 | 140 | } |
thomasmorris | 25:9751619fa030 | 141 | else if(INTERFACE.Get_Function() == 2)//Coil |
thomasmorris | 16:9f98ec0ededb | 142 | { |
thomasmorris | 29:f3b1387c81f1 | 143 | if(INTERFACE.Get_Select() == 0) |
thomasmorris | 29:f3b1387c81f1 | 144 | { |
thomasmorris | 29:f3b1387c81f1 | 145 | lcd.printf("Mode: Coil\n"); //Top LCD line when the device is Coiling |
thomasmorris | 29:f3b1387c81f1 | 146 | lcd.printf("Done:%dToDo: %d\n",INTERFACE.Get_Turns_Done(),INTERFACE.Get_Turns_To_Do()); |
thomasmorris | 29:f3b1387c81f1 | 147 | } |
thomasmorris | 29:f3b1387c81f1 | 148 | else if(INTERFACE.Get_Select() == 1) |
thomasmorris | 29:f3b1387c81f1 | 149 | { |
thomasmorris | 29:f3b1387c81f1 | 150 | lcd.printf("Mode: Coil\n"); //Top LCD line when the device is Coiling |
thomasmorris | 29:f3b1387c81f1 | 151 | if(INTERFACE.Get_Direction() == 0)//Clockwise |
thomasmorris | 29:f3b1387c81f1 | 152 | { |
thomasmorris | 29:f3b1387c81f1 | 153 | lcd.printf("Dir: Clock\n"); |
thomasmorris | 29:f3b1387c81f1 | 154 | } |
thomasmorris | 29:f3b1387c81f1 | 155 | else if (INTERFACE.Get_Direction() == 1)//AntiClockwise |
thomasmorris | 29:f3b1387c81f1 | 156 | { |
thomasmorris | 29:f3b1387c81f1 | 157 | lcd.printf("Dir: AntiClock\n"); |
thomasmorris | 29:f3b1387c81f1 | 158 | } |
thomasmorris | 29:f3b1387c81f1 | 159 | } |
thomasmorris | 16:9f98ec0ededb | 160 | } |
thomasmorris | 30:a35f0ab97a65 | 161 | else if(INTERFACE.Get_Function() == 3)//Run Once |
thomasmorris | 16:9f98ec0ededb | 162 | { |
thomasmorris | 30:a35f0ab97a65 | 163 | lcd.printf("Mode: RunOnce\n"); //Top LCD line when the device is annealing |
thomasmorris | 30:a35f0ab97a65 | 164 | lcd.printf("Loops: 1 Ont:%1.1f\n",INTERFACE.Get_Run_Once_On_Time()); //When the On value is selected |
thomasmorris | 12:d9c133b360b0 | 165 | } |
thomasmorris | 29:f3b1387c81f1 | 166 | Thread::wait(100);//Refresh rate for Lcd |
thomasmorris | 12:d9c133b360b0 | 167 | } |
thomasmorris | 12:d9c133b360b0 | 168 | } |
thomasmorris | 17:68b3fdabe4c5 | 169 | void LED_thread(){//Led thread to toggle the on board led to show the CPU is running |
thomasmorris | 16:9f98ec0ededb | 170 | while (1) |
thomasmorris | 16:9f98ec0ededb | 171 | { |
thomasmorris | 17:68b3fdabe4c5 | 172 | led2 = !led2; //Toggle the LED |
thomasmorris | 17:68b3fdabe4c5 | 173 | Thread::wait(1000);//Wait 1 second |
emilmont | 1:491820ee784d | 174 | } |
emilmont | 1:491820ee784d | 175 | } |
thomasmorris | 12:d9c133b360b0 | 176 | //Interrupt functions |
thomasmorris | 16:9f98ec0ededb | 177 | void up_thread_function()//Action if the up button is pressed increment |
thomasmorris | 16:9f98ec0ededb | 178 | { |
thomasmorris | 14:63998be3d43c | 179 | while(1) |
thomasmorris | 14:63998be3d43c | 180 | { |
thomasmorris | 29:f3b1387c81f1 | 181 | |
thomasmorris | 25:9751619fa030 | 182 | Thread::signal_wait(1); //Wait to be signaled by the up button interrupt |
thomasmorris | 26:83550fc299aa | 183 | pc.printf("Up Button Pressed in thread function\n");//Output data to the putty terminal |
thomasmorris | 26:83550fc299aa | 184 | Thread::wait(Debounce_Time); //Button debounce to prevent multiple re-runs this debouce time might need to be longer |
thomasmorris | 17:68b3fdabe4c5 | 185 | up_thread.signal_set(0); //Set the thread signal low to wait for the interrupt before reaccuring |
thomasmorris | 17:68b3fdabe4c5 | 186 | pc.printf("Up Button Pressed\n");//Output data to the putty terminal |
thomasmorris | 29:f3b1387c81f1 | 187 | |
thomasmorris | 28:3193157ebb0c | 188 | if(INTERFACE.Get_System_Running() == 0) |
thomasmorris | 28:3193157ebb0c | 189 | { |
thomasmorris | 29:f3b1387c81f1 | 190 | INTERFACE.Up(); //Run the interface up routine |
thomasmorris | 28:3193157ebb0c | 191 | } |
thomasmorris | 14:63998be3d43c | 192 | } |
thomasmorris | 14:63998be3d43c | 193 | } |
thomasmorris | 16:9f98ec0ededb | 194 | void down_thread_function() //Action if the down button is pressed decrement |
thomasmorris | 16:9f98ec0ededb | 195 | { |
thomasmorris | 14:63998be3d43c | 196 | while(1) |
thomasmorris | 14:63998be3d43c | 197 | { |
thomasmorris | 26:83550fc299aa | 198 | Thread::signal_wait(1); //Wait to be signaled by the down button interrupt |
thomasmorris | 26:83550fc299aa | 199 | Thread::wait(Debounce_Time); //Button debounce to prevent multiple re-runsn this debounce time might need to be longer |
thomasmorris | 17:68b3fdabe4c5 | 200 | down_thread.signal_set(0);//Set the thread signal low to wait for the interrupt before reaccuring |
thomasmorris | 17:68b3fdabe4c5 | 201 | pc.printf("Down Button Pressed\n");//Output data to the putty terminal |
thomasmorris | 28:3193157ebb0c | 202 | if(INTERFACE.Get_System_Running() == 0) |
thomasmorris | 28:3193157ebb0c | 203 | { |
thomasmorris | 29:f3b1387c81f1 | 204 | INTERFACE.Down();//Run the interface down routine |
thomasmorris | 28:3193157ebb0c | 205 | } |
thomasmorris | 12:d9c133b360b0 | 206 | } |
thomasmorris | 12:d9c133b360b0 | 207 | } |
thomasmorris | 16:9f98ec0ededb | 208 | void start_stop_thread_function() //Action if the Start/Stop button is pressed |
thomasmorris | 16:9f98ec0ededb | 209 | { |
thomasmorris | 14:63998be3d43c | 210 | while(1) |
thomasmorris | 14:63998be3d43c | 211 | { |
thomasmorris | 26:83550fc299aa | 212 | Thread::signal_wait(1); //Wait to be signaled by the start / stop button interrupt |
thomasmorris | 26:83550fc299aa | 213 | Thread::wait(Debounce_Time); //Button debounce to prevent multiple re-runsn this debounce time might need to be longer |
thomasmorris | 17:68b3fdabe4c5 | 214 | start_stop_thread.signal_set(0);//Set the thread signal low to wait for the interrupt before reaccuring |
thomasmorris | 17:68b3fdabe4c5 | 215 | pc.printf("S/S Button Pressed\n");//Output data to the putty terminal |
thomasmorris | 17:68b3fdabe4c5 | 216 | INTERFACE.Start_Stop();//Run the interface start / stop routine |
thomasmorris | 14:63998be3d43c | 217 | } |
thomasmorris | 14:63998be3d43c | 218 | } |
thomasmorris | 16:9f98ec0ededb | 219 | void Function_Selection_thread_function()//Action if the Function button is pressed |
thomasmorris | 16:9f98ec0ededb | 220 | { |
thomasmorris | 14:63998be3d43c | 221 | while(1) |
thomasmorris | 14:63998be3d43c | 222 | { |
thomasmorris | 26:83550fc299aa | 223 | Thread::signal_wait(1); //Wait to be signaled by the function button interrupt |
thomasmorris | 26:83550fc299aa | 224 | Thread::wait(Debounce_Time); //Button debounce to prevent multiple re-runsn this debounce time might need to be longer |
thomasmorris | 17:68b3fdabe4c5 | 225 | function_thread.signal_set(0);//Set the thread signal low to wait for the interrupt before reaccuring |
thomasmorris | 17:68b3fdabe4c5 | 226 | pc.printf("Function Button Pressed\n");//Output data to the putty terminal |
thomasmorris | 28:3193157ebb0c | 227 | if(INTERFACE.Get_System_Running() == 0) |
thomasmorris | 28:3193157ebb0c | 228 | { |
thomasmorris | 28:3193157ebb0c | 229 | INTERFACE.Function();//Run the interface function routine |
thomasmorris | 28:3193157ebb0c | 230 | } |
emilmont | 1:491820ee784d | 231 | } |
emilmont | 1:491820ee784d | 232 | } |
thomasmorris | 16:9f98ec0ededb | 233 | void Selection_thread_function()//Action if the Select button is pressed |
thomasmorris | 16:9f98ec0ededb | 234 | { |
thomasmorris | 14:63998be3d43c | 235 | while(1) |
thomasmorris | 14:63998be3d43c | 236 | { |
thomasmorris | 26:83550fc299aa | 237 | Thread::signal_wait(1); //Wait to be signaled by the select button interrupt |
thomasmorris | 26:83550fc299aa | 238 | Thread::wait(Debounce_Time); //Button debounce to prevent multiple re-runsn this debounce time might need to be longer |
thomasmorris | 17:68b3fdabe4c5 | 239 | select_thread.signal_set(0);//Set the thread signal low to wait for the interrupt before reaccuring |
thomasmorris | 17:68b3fdabe4c5 | 240 | pc.printf("Select Button Pressed\n");//Output data to the putty terminal |
thomasmorris | 28:3193157ebb0c | 241 | if(INTERFACE.Get_System_Running() == 0) |
thomasmorris | 28:3193157ebb0c | 242 | { |
thomasmorris | 28:3193157ebb0c | 243 | INTERFACE.Select();//Run the interface selection routine |
thomasmorris | 28:3193157ebb0c | 244 | } |
thomasmorris | 14:63998be3d43c | 245 | } |
thomasmorris | 12:d9c133b360b0 | 246 | } |
thomasmorris | 12:d9c133b360b0 | 247 | int main() |
thomasmorris | 28:3193157ebb0c | 248 | { |
thomasmorris | 17:68b3fdabe4c5 | 249 | lcd.printf("Ready Player\n"); |
thomasmorris | 17:68b3fdabe4c5 | 250 | lcd.printf(" One \n"); |
thomasmorris | 17:68b3fdabe4c5 | 251 | Thread::wait(1000); |
thomasmorris | 17:68b3fdabe4c5 | 252 | pc.printf("Program start\n");//Outputs informtation to the putty terminal |
thomasmorris | 14:63998be3d43c | 253 | |
JDickson | 27:22d6fd88828e | 254 | //Thread Initialisation |
thomasmorris | 26:83550fc299aa | 255 | polling_thread.start(Polling_thread_function);//Start the button polling |
thomasmorris | 17:68b3fdabe4c5 | 256 | lcd_thread.start(LCD_thread);//Output data to LCD |
thomasmorris | 17:68b3fdabe4c5 | 257 | led_thread.start(LED_thread);//Blinking led to show CPU running |
thomasmorris | 17:68b3fdabe4c5 | 258 | up_thread.start(up_thread_function);//UP interface thread |
thomasmorris | 17:68b3fdabe4c5 | 259 | down_thread.start(down_thread_function);//Down interface thread |
thomasmorris | 17:68b3fdabe4c5 | 260 | start_stop_thread.start(start_stop_thread_function);//Start / stop interface thread |
thomasmorris | 17:68b3fdabe4c5 | 261 | function_thread.start(Function_Selection_thread_function);//Function interface thread |
thomasmorris | 17:68b3fdabe4c5 | 262 | select_thread.start(Selection_thread_function);//Start interface thread |
thomasmorris | 30:a35f0ab97a65 | 263 | Interface_Serial_thread.start(Interface_Serial_thread_function); |
mwthewsey | 19:384642f39496 | 264 | |
thomasmorris | 23:07a368f2cdb1 | 265 | osThreadSetPriority(osThreadGetId(), osPriorityHigh);//This is done to make sure the code for the stepper motor is the highest priority to ensure correct rotations of the stepper motor |
thomasmorris | 30:a35f0ab97a65 | 266 | INTERFACE.Interface_Init(55);//Pass in turns |
thomasmorris | 17:68b3fdabe4c5 | 267 | while(1)// Main code in a main thread |
thomasmorris | 12:d9c133b360b0 | 268 | { |
thomasmorris | 17:68b3fdabe4c5 | 269 | INTERFACE.Interface_main();//Run main thread code |
mwthewsey | 19:384642f39496 | 270 | Thread::wait(10);//Small delay to save CPU time |
thomasmorris | 16:9f98ec0ededb | 271 | } |
thomasmorris | 12:d9c133b360b0 | 272 | } |