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