![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
jkjkjkjk
Fork of all_combined_week6 by
main.cpp@2:94ca2059f8b2, 2014-07-11 (annotated)
- Committer:
- greenroshks
- Date:
- Fri Jul 11 05:14:12 2014 +0000
- Revision:
- 2:94ca2059f8b2
- Parent:
- 1:37fa1c3eba16
- Child:
- 4:79b97f9cab00
Updated BAE RTOS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
harshit_felicity | 0:cbe0ea884289 | 1 | #include "mbed.h" |
harshit_felicity | 0:cbe0ea884289 | 2 | #include "rtos.h" |
harshit_felicity | 0:cbe0ea884289 | 3 | #include "hkfinal.h" |
harshit_felicity | 0:cbe0ea884289 | 4 | #include "slave.h" |
harshit_felicity | 0:cbe0ea884289 | 5 | #include "ShortBeacon.h" |
greenroshks | 2:94ca2059f8b2 | 6 | |
harshit_felicity | 0:cbe0ea884289 | 7 | Serial pc(USBTX, USBRX); |
harshit_felicity | 0:cbe0ea884289 | 8 | |
greenroshks | 2:94ca2059f8b2 | 9 | |
harshit_felicity | 0:cbe0ea884289 | 10 | |
harshit_felicity | 0:cbe0ea884289 | 11 | Timer t; |
harshit_felicity | 0:cbe0ea884289 | 12 | Timer t1; |
harshit_felicity | 0:cbe0ea884289 | 13 | |
harshit_felicity | 0:cbe0ea884289 | 14 | Thread *ptr_t_hk_acq; |
harshit_felicity | 0:cbe0ea884289 | 15 | Thread *ptr_t_acs; |
harshit_felicity | 0:cbe0ea884289 | 16 | Thread *ptr_t_acs_write2flash; |
harshit_felicity | 0:cbe0ea884289 | 17 | Thread *ptr_t_bea; |
harshit_felicity | 0:cbe0ea884289 | 18 | Thread *ptr_t_bea_telecommand; |
greenroshks | 2:94ca2059f8b2 | 19 | Thread *ptr_t_fault; |
greenroshks | 2:94ca2059f8b2 | 20 | |
harshit_felicity | 0:cbe0ea884289 | 21 | |
harshit_felicity | 0:cbe0ea884289 | 22 | //----------------------------------------------HOUSE-KEEPING(HK)------------------------------------------------------------------------------------------ |
harshit_felicity | 0:cbe0ea884289 | 23 | //void func_hk_mux() |
harshit_felicity | 0:cbe0ea884289 | 24 | //{ |
harshit_felicity | 0:cbe0ea884289 | 25 | // pc.printf("Something related to mux\n"); |
harshit_felicity | 0:cbe0ea884289 | 26 | //} |
harshit_felicity | 0:cbe0ea884289 | 27 | // |
harshit_felicity | 0:cbe0ea884289 | 28 | //void func_hk_adc() |
harshit_felicity | 0:cbe0ea884289 | 29 | //{ |
harshit_felicity | 0:cbe0ea884289 | 30 | // pc.printf("Converting analog to digital\n"); |
harshit_felicity | 0:cbe0ea884289 | 31 | //} |
harshit_felicity | 0:cbe0ea884289 | 32 | // |
harshit_felicity | 0:cbe0ea884289 | 33 | //void func_hk_write2flash() |
harshit_felicity | 0:cbe0ea884289 | 34 | //{ |
harshit_felicity | 0:cbe0ea884289 | 35 | // pc.printf("Writing the house keeping data to flash\n"); |
harshit_felicity | 0:cbe0ea884289 | 36 | //} |
harshit_felicity | 0:cbe0ea884289 | 37 | // |
harshit_felicity | 0:cbe0ea884289 | 38 | //void func_hk_readram() |
harshit_felicity | 0:cbe0ea884289 | 39 | //{ |
harshit_felicity | 0:cbe0ea884289 | 40 | // pc.printf("Reading hk data from ram\n"); |
harshit_felicity | 0:cbe0ea884289 | 41 | //} |
harshit_felicity | 0:cbe0ea884289 | 42 | |
harshit_felicity | 0:cbe0ea884289 | 43 | //void func_hk_send2cdms() |
harshit_felicity | 0:cbe0ea884289 | 44 | //{ |
harshit_felicity | 0:cbe0ea884289 | 45 | // pc.printf("Send the data to sd card\n"); |
harshit_felicity | 0:cbe0ea884289 | 46 | //} |
harshit_felicity | 0:cbe0ea884289 | 47 | |
harshit_felicity | 0:cbe0ea884289 | 48 | void t_hk_send2cdms(void const *args) |
harshit_felicity | 0:cbe0ea884289 | 49 | { |
harshit_felicity | 0:cbe0ea884289 | 50 | while(1) |
harshit_felicity | 0:cbe0ea884289 | 51 | { |
harshit_felicity | 0:cbe0ea884289 | 52 | t.start(); |
greenroshks | 2:94ca2059f8b2 | 53 | Thread::signal_wait(0x4); |
harshit_felicity | 0:cbe0ea884289 | 54 | printf("The state of hk_acq thread is %d\n",ptr_t_hk_acq->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 55 | printf("The state of acs_main thread is %d\n",ptr_t_acs->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 56 | printf("The state of acs_write2flash thread is %d\n",ptr_t_acs_write2flash->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 57 | printf("The state of beacon thread is %d\n",ptr_t_bea->get_state()); |
greenroshks | 2:94ca2059f8b2 | 58 | |
harshit_felicity | 0:cbe0ea884289 | 59 | FUNC_I2C_SLAVE_MAIN(); |
harshit_felicity | 0:cbe0ea884289 | 60 | printf("The time to execute send2cdms is %f\n",t.read()); |
harshit_felicity | 0:cbe0ea884289 | 61 | t.reset(); |
harshit_felicity | 0:cbe0ea884289 | 62 | } |
harshit_felicity | 0:cbe0ea884289 | 63 | } |
harshit_felicity | 0:cbe0ea884289 | 64 | |
harshit_felicity | 0:cbe0ea884289 | 65 | void t_hk_acq(void const *args) |
harshit_felicity | 0:cbe0ea884289 | 66 | { |
harshit_felicity | 0:cbe0ea884289 | 67 | Thread thread_2(t_hk_send2cdms); |
harshit_felicity | 0:cbe0ea884289 | 68 | while(1) |
harshit_felicity | 0:cbe0ea884289 | 69 | { |
harshit_felicity | 0:cbe0ea884289 | 70 | Thread::signal_wait(0x2); |
greenroshks | 2:94ca2059f8b2 | 71 | |
greenroshks | 2:94ca2059f8b2 | 72 | printf("\nTHIS IS HK %f\n",t1.read()); |
harshit_felicity | 0:cbe0ea884289 | 73 | t.start(); |
greenroshks | 2:94ca2059f8b2 | 74 | |
harshit_felicity | 0:cbe0ea884289 | 75 | FUNC_HK_MAIN(); |
harshit_felicity | 0:cbe0ea884289 | 76 | thread_2.signal_set(0x4); |
harshit_felicity | 0:cbe0ea884289 | 77 | printf("The state of hk_acq thread is %d\n",ptr_t_hk_acq->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 78 | printf("The state of acs_main thread is %d\n",ptr_t_acs->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 79 | printf("The state of acs_write2flash thread is %d\n",ptr_t_acs_write2flash->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 80 | printf("The state of beacon thread is %d\n",ptr_t_bea->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 81 | t.stop(); |
harshit_felicity | 0:cbe0ea884289 | 82 | printf("The time to execute hk_acq is %f seconds\n",t.read()); |
harshit_felicity | 0:cbe0ea884289 | 83 | t.reset(); |
harshit_felicity | 0:cbe0ea884289 | 84 | } |
harshit_felicity | 0:cbe0ea884289 | 85 | } |
harshit_felicity | 0:cbe0ea884289 | 86 | |
harshit_felicity | 0:cbe0ea884289 | 87 | //--------------------------------------------------------------------------------------------------------------------------------------- |
harshit_felicity | 0:cbe0ea884289 | 88 | |
harshit_felicity | 0:cbe0ea884289 | 89 | typedef struct { |
harshit_felicity | 0:cbe0ea884289 | 90 | float mag_field; |
harshit_felicity | 0:cbe0ea884289 | 91 | float omega; |
harshit_felicity | 0:cbe0ea884289 | 92 | } sensor_data; |
harshit_felicity | 0:cbe0ea884289 | 93 | |
harshit_felicity | 0:cbe0ea884289 | 94 | Mail <sensor_data, 16> q_acs; |
harshit_felicity | 0:cbe0ea884289 | 95 | |
harshit_felicity | 0:cbe0ea884289 | 96 | void func_acs_readdata(sensor_data *ptr) |
harshit_felicity | 0:cbe0ea884289 | 97 | { |
harshit_felicity | 0:cbe0ea884289 | 98 | pc.printf("Reading the data\n"); |
harshit_felicity | 0:cbe0ea884289 | 99 | ptr -> mag_field = 10; |
harshit_felicity | 0:cbe0ea884289 | 100 | ptr -> omega = 3; |
harshit_felicity | 0:cbe0ea884289 | 101 | } |
harshit_felicity | 0:cbe0ea884289 | 102 | |
harshit_felicity | 0:cbe0ea884289 | 103 | void func_acs_ctrlalgo() |
harshit_felicity | 0:cbe0ea884289 | 104 | { |
harshit_felicity | 0:cbe0ea884289 | 105 | pc.printf("Executing control algo\n"); |
harshit_felicity | 0:cbe0ea884289 | 106 | } |
harshit_felicity | 0:cbe0ea884289 | 107 | |
harshit_felicity | 0:cbe0ea884289 | 108 | void func_acs_pwmgen() |
harshit_felicity | 0:cbe0ea884289 | 109 | { |
harshit_felicity | 0:cbe0ea884289 | 110 | pc.printf("Generating PWM signal\n"); |
harshit_felicity | 0:cbe0ea884289 | 111 | } |
harshit_felicity | 0:cbe0ea884289 | 112 | |
harshit_felicity | 0:cbe0ea884289 | 113 | void func_acs_write2flash(sensor_data *ptr2) |
harshit_felicity | 0:cbe0ea884289 | 114 | { |
harshit_felicity | 0:cbe0ea884289 | 115 | pc.printf("The magnetic field is %.2f T\n\r",ptr2->mag_field); |
harshit_felicity | 0:cbe0ea884289 | 116 | pc.printf("The angular velocity is %.2f rad/s\n\r",ptr2->omega); |
harshit_felicity | 0:cbe0ea884289 | 117 | } |
harshit_felicity | 0:cbe0ea884289 | 118 | |
harshit_felicity | 0:cbe0ea884289 | 119 | void t_acs(void const *args) |
harshit_felicity | 0:cbe0ea884289 | 120 | { |
harshit_felicity | 0:cbe0ea884289 | 121 | while(1) |
harshit_felicity | 0:cbe0ea884289 | 122 | { |
harshit_felicity | 0:cbe0ea884289 | 123 | Thread::signal_wait(0x1); |
greenroshks | 2:94ca2059f8b2 | 124 | printf("\nTHIS IS ACS %f\n",t1.read()); |
harshit_felicity | 0:cbe0ea884289 | 125 | t.start(); |
harshit_felicity | 0:cbe0ea884289 | 126 | sensor_data *ptr = q_acs.alloc(); |
harshit_felicity | 0:cbe0ea884289 | 127 | func_acs_readdata(ptr); |
greenroshks | 2:94ca2059f8b2 | 128 | q_acs.put(ptr); |
harshit_felicity | 0:cbe0ea884289 | 129 | func_acs_ctrlalgo(); |
harshit_felicity | 0:cbe0ea884289 | 130 | func_acs_pwmgen(); |
greenroshks | 2:94ca2059f8b2 | 131 | |
harshit_felicity | 0:cbe0ea884289 | 132 | printf("The state of hk_acq thread is %d\n",ptr_t_hk_acq->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 133 | printf("The state of acs_main thread is %d\n",ptr_t_acs->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 134 | printf("The state of acs_write2flash thread is %d\n",ptr_t_acs_write2flash->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 135 | printf("The state of beacon thread is %d\n",ptr_t_bea->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 136 | printf("The time to execute t_acs is %f seconds\n",t.read()); |
harshit_felicity | 0:cbe0ea884289 | 137 | // Thread::wait(10000); |
harshit_felicity | 0:cbe0ea884289 | 138 | t.reset(); |
harshit_felicity | 0:cbe0ea884289 | 139 | } |
harshit_felicity | 0:cbe0ea884289 | 140 | } |
harshit_felicity | 0:cbe0ea884289 | 141 | |
harshit_felicity | 0:cbe0ea884289 | 142 | void t_acs_write2flash(void const *args) |
harshit_felicity | 0:cbe0ea884289 | 143 | { |
harshit_felicity | 0:cbe0ea884289 | 144 | while(1) |
harshit_felicity | 0:cbe0ea884289 | 145 | { |
harshit_felicity | 0:cbe0ea884289 | 146 | //printf("Writing in the flash\n"); |
harshit_felicity | 0:cbe0ea884289 | 147 | osEvent evt = q_acs.get(); |
harshit_felicity | 0:cbe0ea884289 | 148 | if(evt.status == osEventMail) |
harshit_felicity | 0:cbe0ea884289 | 149 | { |
harshit_felicity | 0:cbe0ea884289 | 150 | sensor_data *ptr = (sensor_data*)evt.value.p; |
harshit_felicity | 0:cbe0ea884289 | 151 | func_acs_write2flash(ptr); |
harshit_felicity | 0:cbe0ea884289 | 152 | q_acs.free(ptr); |
harshit_felicity | 0:cbe0ea884289 | 153 | } |
harshit_felicity | 0:cbe0ea884289 | 154 | printf("Writing in the flash\n"); |
harshit_felicity | 0:cbe0ea884289 | 155 | } |
harshit_felicity | 0:cbe0ea884289 | 156 | } |
harshit_felicity | 0:cbe0ea884289 | 157 | |
harshit_felicity | 0:cbe0ea884289 | 158 | //---------------------------------------------------BEACON-------------------------------------------------------------------------------------------- |
harshit_felicity | 0:cbe0ea884289 | 159 | |
greenroshks | 2:94ca2059f8b2 | 160 | int beac_flag=0; |
harshit_felicity | 0:cbe0ea884289 | 161 | |
harshit_felicity | 0:cbe0ea884289 | 162 | /*void func_bea_readbaeflash() |
harshit_felicity | 0:cbe0ea884289 | 163 | { |
harshit_felicity | 0:cbe0ea884289 | 164 | pc.printf("Reading data from beacon flash\n"); |
harshit_felicity | 0:cbe0ea884289 | 165 | wait(0.01); |
harshit_felicity | 0:cbe0ea884289 | 166 | } |
harshit_felicity | 0:cbe0ea884289 | 167 | |
harshit_felicity | 0:cbe0ea884289 | 168 | void func_bea_spiwrite() |
harshit_felicity | 0:cbe0ea884289 | 169 | { |
harshit_felicity | 0:cbe0ea884289 | 170 | pc.printf("Writing through SPI\n"); |
harshit_felicity | 0:cbe0ea884289 | 171 | wait(0.01); |
harshit_felicity | 0:cbe0ea884289 | 172 | } |
harshit_felicity | 0:cbe0ea884289 | 173 | */ |
harshit_felicity | 0:cbe0ea884289 | 174 | void t_bea_telecommand(void const *args) |
harshit_felicity | 0:cbe0ea884289 | 175 | { |
harshit_felicity | 0:cbe0ea884289 | 176 | char c = pc.getc(); |
harshit_felicity | 0:cbe0ea884289 | 177 | if(c=='a') |
harshit_felicity | 0:cbe0ea884289 | 178 | { |
harshit_felicity | 0:cbe0ea884289 | 179 | pc.printf("Telecommand detected\n"); |
greenroshks | 2:94ca2059f8b2 | 180 | beac_flag=1; |
harshit_felicity | 0:cbe0ea884289 | 181 | } |
harshit_felicity | 0:cbe0ea884289 | 182 | } |
harshit_felicity | 0:cbe0ea884289 | 183 | |
harshit_felicity | 0:cbe0ea884289 | 184 | void t_bea(void const *args) |
harshit_felicity | 0:cbe0ea884289 | 185 | { |
harshit_felicity | 0:cbe0ea884289 | 186 | |
harshit_felicity | 0:cbe0ea884289 | 187 | while(1) |
harshit_felicity | 0:cbe0ea884289 | 188 | { |
harshit_felicity | 0:cbe0ea884289 | 189 | Thread::signal_wait(0x3); |
greenroshks | 2:94ca2059f8b2 | 190 | printf("\nTHIS IS BEACON %f\n",t1.read()); |
harshit_felicity | 0:cbe0ea884289 | 191 | t.start(); |
harshit_felicity | 0:cbe0ea884289 | 192 | printf("The state of hk_acq thread is %d\n",ptr_t_hk_acq->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 193 | printf("The state of acs_main thread is %d\n",ptr_t_acs->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 194 | printf("The state of acs_write2flash thread is %d\n",ptr_t_acs_write2flash->get_state()); |
harshit_felicity | 0:cbe0ea884289 | 195 | printf("The state of beacon thread is %d\n",ptr_t_bea->get_state()); |
greenroshks | 2:94ca2059f8b2 | 196 | if(beac_flag==0) |
harshit_felicity | 0:cbe0ea884289 | 197 | { |
harshit_felicity | 0:cbe0ea884289 | 198 | //func_bea_readbaeflash(); |
harshit_felicity | 0:cbe0ea884289 | 199 | //func_bea_spiwrite(); |
harshit_felicity | 0:cbe0ea884289 | 200 | Thread::wait(30000); |
harshit_felicity | 0:cbe0ea884289 | 201 | } |
harshit_felicity | 0:cbe0ea884289 | 202 | else |
harshit_felicity | 0:cbe0ea884289 | 203 | { |
greenroshks | 2:94ca2059f8b2 | 204 | Thread::wait(600000); |
greenroshks | 2:94ca2059f8b2 | 205 | beac_flag = 0; |
harshit_felicity | 0:cbe0ea884289 | 206 | } |
harshit_felicity | 0:cbe0ea884289 | 207 | |
harshit_felicity | 0:cbe0ea884289 | 208 | printf("The time to execute beacon thread is %f seconds\n",t.read()); |
harshit_felicity | 0:cbe0ea884289 | 209 | t.reset(); |
harshit_felicity | 0:cbe0ea884289 | 210 | } |
harshit_felicity | 0:cbe0ea884289 | 211 | } |
harshit_felicity | 0:cbe0ea884289 | 212 | |
greenroshks | 2:94ca2059f8b2 | 213 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
greenroshks | 2:94ca2059f8b2 | 214 | //TASK 4 : FAULT MANAGEMENT |
greenroshks | 2:94ca2059f8b2 | 215 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
greenroshks | 2:94ca2059f8b2 | 216 | //Dummy fault rectifier functions |
greenroshks | 2:94ca2059f8b2 | 217 | |
greenroshks | 2:94ca2059f8b2 | 218 | Mail<int,16> faults; |
greenroshks | 2:94ca2059f8b2 | 219 | |
greenroshks | 2:94ca2059f8b2 | 220 | void FUNC_FAULT_FUNCT1() |
greenroshks | 2:94ca2059f8b2 | 221 | { |
greenroshks | 2:94ca2059f8b2 | 222 | pc.printf("\nFault 1 detected... \n"); |
greenroshks | 2:94ca2059f8b2 | 223 | } |
greenroshks | 2:94ca2059f8b2 | 224 | |
greenroshks | 2:94ca2059f8b2 | 225 | void FUNC_FAULT_FUNCT2() |
greenroshks | 2:94ca2059f8b2 | 226 | { |
greenroshks | 2:94ca2059f8b2 | 227 | pc.printf("\nFault 2 detected...\n"); |
greenroshks | 2:94ca2059f8b2 | 228 | } |
greenroshks | 2:94ca2059f8b2 | 229 | |
greenroshks | 2:94ca2059f8b2 | 230 | void T_FAULT(void const *args) |
greenroshks | 2:94ca2059f8b2 | 231 | { |
greenroshks | 2:94ca2059f8b2 | 232 | while(1) |
greenroshks | 2:94ca2059f8b2 | 233 | { |
greenroshks | 2:94ca2059f8b2 | 234 | osEvent evt = faults.get(); |
greenroshks | 2:94ca2059f8b2 | 235 | if(evt.status==osEventMail) |
greenroshks | 2:94ca2059f8b2 | 236 | { |
greenroshks | 2:94ca2059f8b2 | 237 | int *fault_id= (int *)evt.value.p; |
greenroshks | 2:94ca2059f8b2 | 238 | switch(*fault_id) |
greenroshks | 2:94ca2059f8b2 | 239 | { |
greenroshks | 2:94ca2059f8b2 | 240 | case 1: FUNC_FAULT_FUNCT1(); |
greenroshks | 2:94ca2059f8b2 | 241 | break; |
greenroshks | 2:94ca2059f8b2 | 242 | case 2: FUNC_FAULT_FUNCT2(); |
greenroshks | 2:94ca2059f8b2 | 243 | break; |
greenroshks | 2:94ca2059f8b2 | 244 | } |
greenroshks | 2:94ca2059f8b2 | 245 | faults.free(fault_id); |
greenroshks | 2:94ca2059f8b2 | 246 | } |
greenroshks | 2:94ca2059f8b2 | 247 | } |
greenroshks | 2:94ca2059f8b2 | 248 | } |
greenroshks | 2:94ca2059f8b2 | 249 | |
harshit_felicity | 0:cbe0ea884289 | 250 | //------------------------------------------------------------------------------------------------------------------------------------------------ |
greenroshks | 2:94ca2059f8b2 | 251 | //SCHEDULER |
greenroshks | 2:94ca2059f8b2 | 252 | //------------------------------------------------------------------------------------------------------------------------------------------------ |
greenroshks | 2:94ca2059f8b2 | 253 | uint16_t schedcount=1; |
harshit_felicity | 0:cbe0ea884289 | 254 | void t_sc(void const *args) |
harshit_felicity | 0:cbe0ea884289 | 255 | { |
harshit_felicity | 0:cbe0ea884289 | 256 | |
greenroshks | 2:94ca2059f8b2 | 257 | //printf("The value of i in scheduler is %d\n",i); |
greenroshks | 2:94ca2059f8b2 | 258 | if(schedcount == 65532) //to reset the counter |
greenroshks | 2:94ca2059f8b2 | 259 | { |
greenroshks | 2:94ca2059f8b2 | 260 | schedcount = 0; |
greenroshks | 2:94ca2059f8b2 | 261 | } |
greenroshks | 2:94ca2059f8b2 | 262 | |
greenroshks | 2:94ca2059f8b2 | 263 | if(schedcount%1==0) |
harshit_felicity | 0:cbe0ea884289 | 264 | { |
harshit_felicity | 0:cbe0ea884289 | 265 | ptr_t_acs -> signal_set(0x1); |
harshit_felicity | 0:cbe0ea884289 | 266 | } |
greenroshks | 2:94ca2059f8b2 | 267 | if(schedcount%2==0) |
harshit_felicity | 0:cbe0ea884289 | 268 | { |
harshit_felicity | 0:cbe0ea884289 | 269 | ptr_t_hk_acq -> signal_set(0x2); |
harshit_felicity | 0:cbe0ea884289 | 270 | } |
greenroshks | 2:94ca2059f8b2 | 271 | if(schedcount%3==0) |
harshit_felicity | 0:cbe0ea884289 | 272 | { |
harshit_felicity | 0:cbe0ea884289 | 273 | ptr_t_bea -> signal_set(0x3); |
harshit_felicity | 0:cbe0ea884289 | 274 | } |
greenroshks | 2:94ca2059f8b2 | 275 | schedcount++; |
harshit_felicity | 0:cbe0ea884289 | 276 | } |
harshit_felicity | 0:cbe0ea884289 | 277 | |
harshit_felicity | 0:cbe0ea884289 | 278 | //--------------------------------------------------------------------------------------------------------------------------------------------- |
harshit_felicity | 0:cbe0ea884289 | 279 | |
harshit_felicity | 0:cbe0ea884289 | 280 | int main() |
harshit_felicity | 0:cbe0ea884289 | 281 | { |
harshit_felicity | 0:cbe0ea884289 | 282 | t1.start(); |
harshit_felicity | 0:cbe0ea884289 | 283 | |
harshit_felicity | 0:cbe0ea884289 | 284 | ptr_t_hk_acq = new Thread(t_hk_acq); |
harshit_felicity | 0:cbe0ea884289 | 285 | ptr_t_acs = new Thread(t_acs); |
harshit_felicity | 0:cbe0ea884289 | 286 | ptr_t_acs_write2flash = new Thread(t_acs_write2flash); |
harshit_felicity | 0:cbe0ea884289 | 287 | ptr_t_bea = new Thread(t_bea); |
harshit_felicity | 0:cbe0ea884289 | 288 | ptr_t_bea_telecommand = new Thread(t_bea_telecommand); |
greenroshks | 2:94ca2059f8b2 | 289 | ptr_t_fault = new Thread(T_FAULT); |
harshit_felicity | 0:cbe0ea884289 | 290 | //ptr_t_sc = new Thread(t_sc); |
harshit_felicity | 0:cbe0ea884289 | 291 | |
greenroshks | 2:94ca2059f8b2 | 292 | ptr_t_fault -> set_priority(osPriorityRealtime); |
greenroshks | 2:94ca2059f8b2 | 293 | ptr_t_acs->set_priority(osPriorityHigh); |
greenroshks | 2:94ca2059f8b2 | 294 | ptr_t_hk_acq->set_priority(osPriorityNormal); |
harshit_felicity | 0:cbe0ea884289 | 295 | ptr_t_acs_write2flash->set_priority(osPriorityBelowNormal); |
harshit_felicity | 0:cbe0ea884289 | 296 | ptr_t_bea->set_priority(osPriorityAboveNormal); |
harshit_felicity | 0:cbe0ea884289 | 297 | ptr_t_bea_telecommand->set_priority(osPriorityIdle); |
harshit_felicity | 0:cbe0ea884289 | 298 | //ptr_t_sc->set_priority(osPriorityAboveNormal); |
harshit_felicity | 0:cbe0ea884289 | 299 | |
harshit_felicity | 0:cbe0ea884289 | 300 | /*RtosTimer for individual thread------------------------------------------------------------------------------------------- |
harshit_felicity | 0:cbe0ea884289 | 301 | RtosTimer t_hk_acq_timer(t_hk_acq, osTimerPeriodic); |
harshit_felicity | 0:cbe0ea884289 | 302 | RtosTimer t_acs_timer(t_acs, osTimerPeriodic); |
harshit_felicity | 0:cbe0ea884289 | 303 | RtosTimer t_bea_timer(t_bea, osTimerPeriodic); |
harshit_felicity | 0:cbe0ea884289 | 304 | |
harshit_felicity | 0:cbe0ea884289 | 305 | t_hk_acq_timer.start(20000); |
harshit_felicity | 0:cbe0ea884289 | 306 | t_acs_timer.start(10000); |
harshit_felicity | 0:cbe0ea884289 | 307 | t_bea_timer.start(30000); |
harshit_felicity | 0:cbe0ea884289 | 308 | ----------------------------------------------------------------------------------------------*/ |
greenroshks | 2:94ca2059f8b2 | 309 | pc.printf("\n T_FAULT priority is %d",ptr_t_fault->get_priority()); |
greenroshks | 2:94ca2059f8b2 | 310 | pc.printf("\n T_ACS priority is %d",ptr_t_acs->get_priority()); |
greenroshks | 2:94ca2059f8b2 | 311 | pc.printf("\n T_HK_ACQ priority is %d",ptr_t_hk_acq->get_priority()); |
greenroshks | 2:94ca2059f8b2 | 312 | pc.printf("\n T_ACS_WRITE2FLASH priority is %d",ptr_t_acs_write2flash->get_priority()); |
greenroshks | 2:94ca2059f8b2 | 313 | pc.printf("\n T_BEA priority is %d",ptr_t_bea->get_priority()); |
harshit_felicity | 0:cbe0ea884289 | 314 | RtosTimer t_sc_timer(t_sc,osTimerPeriodic); |
greenroshks | 2:94ca2059f8b2 | 315 | t_sc_timer.start(10000); |
greenroshks | 2:94ca2059f8b2 | 316 | printf("\n%f\n",t1.read()); |
greenroshks | 2:94ca2059f8b2 | 317 | |
harshit_felicity | 0:cbe0ea884289 | 318 | while(1) |
harshit_felicity | 0:cbe0ea884289 | 319 | { |
harshit_felicity | 0:cbe0ea884289 | 320 | ; |
harshit_felicity | 0:cbe0ea884289 | 321 | } |
harshit_felicity | 0:cbe0ea884289 | 322 | |
harshit_felicity | 0:cbe0ea884289 | 323 | } |