![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
4-10-2015 BAE_RTOS_TEST ACS_DATA_ACQ and I2C sending 25 bytes to CDMS
Fork of BAE_RTOS_test_1 by
main.cpp@1:b8c71afbe6e5, 2015-10-04 (annotated)
- Committer:
- gkumar
- Date:
- Sun Oct 04 07:06:22 2015 +0000
- Revision:
- 1:b8c71afbe6e5
- Parent:
- 0:f417d854dc29
- Child:
- 2:f26706e0d779
4-10-2015 BAE_RTOS_TEST1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gkumar | 0:f417d854dc29 | 1 | #include "mbed.h" |
gkumar | 0:f417d854dc29 | 2 | #include "rtos.h" |
gkumar | 1:b8c71afbe6e5 | 3 | #include "pin_config.h" |
gkumar | 1:b8c71afbe6e5 | 4 | //#include "HK.h" |
gkumar | 1:b8c71afbe6e5 | 5 | #include "ACS.h" |
gkumar | 1:b8c71afbe6e5 | 6 | //#include "beacon.h" |
gkumar | 1:b8c71afbe6e5 | 7 | |
gkumar | 0:f417d854dc29 | 8 | Serial pc(USBTX, USBRX); |
gkumar | 1:b8c71afbe6e5 | 9 | InterruptIn irpt_4m_mstr(PIN38); //I2c interrupt from CDMS |
gkumar | 1:b8c71afbe6e5 | 10 | DigitalOut irpt_2_mstr(PIN4); //I2C interrupt to CDMS |
gkumar | 1:b8c71afbe6e5 | 11 | I2CSlave slave (PIN1,PIN2); |
gkumar | 1:b8c71afbe6e5 | 12 | const int addr = 0x20; //slave address |
gkumar | 1:b8c71afbe6e5 | 13 | Thread *ptr_t_i2c; |
gkumar | 1:b8c71afbe6e5 | 14 | Timer t; // time taken from isr to reach i2c function |
gkumar | 1:b8c71afbe6e5 | 15 | Timer t1; |
gkumar | 1:b8c71afbe6e5 | 16 | Timer t_exec; //To know the time of execution each thread |
gkumar | 1:b8c71afbe6e5 | 17 | |
gkumar | 1:b8c71afbe6e5 | 18 | Timer t_start; //To know the time of entering of each thread |
gkumar | 1:b8c71afbe6e5 | 19 | Timer t_i2c_start; //To check the time sync in i2c communication |
gkumar | 1:b8c71afbe6e5 | 20 | Timer t_i2c_exec; //To know the time taken by i2c read/write function |
gkumar | 0:f417d854dc29 | 21 | |
gkumar | 0:f417d854dc29 | 22 | Thread *ptr_t_hk; |
gkumar | 0:f417d854dc29 | 23 | Thread *ptr_t_acs; |
gkumar | 0:f417d854dc29 | 24 | Thread *ptr_t_bea; |
gkumar | 0:f417d854dc29 | 25 | |
gkumar | 1:b8c71afbe6e5 | 26 | /**************************************************************global variables*********************************************************************************/ |
gkumar | 1:b8c71afbe6e5 | 27 | char hk_data[25]; |
gkumar | 1:b8c71afbe6e5 | 28 | |
gkumar | 1:b8c71afbe6e5 | 29 | /**************************************************************funtion header**********************************************************************************/ |
gkumar | 1:b8c71afbe6e5 | 30 | |
gkumar | 1:b8c71afbe6e5 | 31 | void FCTN_HK_DATA_CATENATE(); |
gkumar | 1:b8c71afbe6e5 | 32 | |
gkumar | 1:b8c71afbe6e5 | 33 | |
gkumar | 1:b8c71afbe6e5 | 34 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 35 | //TASK : HK |
gkumar | 1:b8c71afbe6e5 | 36 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 37 | //extern SensorDataQuantised SensorQuantised; |
gkumar | 0:f417d854dc29 | 38 | void T_HK(void const *args) |
gkumar | 0:f417d854dc29 | 39 | { |
gkumar | 0:f417d854dc29 | 40 | while(1){ |
gkumar | 1:b8c71afbe6e5 | 41 | Thread::signal_wait(0x2); |
gkumar | 1:b8c71afbe6e5 | 42 | //SensorQuantised.power_mode='3'; //default power mode(dummy) |
gkumar | 1:b8c71afbe6e5 | 43 | // printf("\n\rTHIS IS HK %f\n\r",t_start.read()); |
gkumar | 1:b8c71afbe6e5 | 44 | // t_exec.start(); |
gkumar | 1:b8c71afbe6e5 | 45 | // FCTN_HK_MAIN(); //Collecting HK data |
gkumar | 1:b8c71afbe6e5 | 46 | // FCTN_HK_DATA_CATENATE(); //sending HK data to CDMS |
gkumar | 1:b8c71afbe6e5 | 47 | // t_exec.stop(); |
gkumar | 1:b8c71afbe6e5 | 48 | // //printf("The time to execute hk_acq is %f seconds\n\r",t_exec.read()); |
gkumar | 1:b8c71afbe6e5 | 49 | // t_exec.reset(); |
gkumar | 1:b8c71afbe6e5 | 50 | printf("\n\rTHIS IS HK %f\n\r",t_start.read()); |
gkumar | 0:f417d854dc29 | 51 | } |
gkumar | 0:f417d854dc29 | 52 | |
gkumar | 0:f417d854dc29 | 53 | } |
gkumar | 1:b8c71afbe6e5 | 54 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 55 | //TASK : ACS data |
gkumar | 1:b8c71afbe6e5 | 56 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 57 | |
gkumar | 0:f417d854dc29 | 58 | void T_ACS(void const *args){ |
gkumar | 1:b8c71afbe6e5 | 59 | |
gkumar | 1:b8c71afbe6e5 | 60 | float mag_field1[3]; |
gkumar | 1:b8c71afbe6e5 | 61 | float omega1[3]; |
gkumar | 1:b8c71afbe6e5 | 62 | //float tauc1[3]; |
gkumar | 1:b8c71afbe6e5 | 63 | //float moment[3]; |
gkumar | 1:b8c71afbe6e5 | 64 | //float *mnm_data; |
gkumar | 1:b8c71afbe6e5 | 65 | while(1) |
gkumar | 1:b8c71afbe6e5 | 66 | { |
gkumar | 1:b8c71afbe6e5 | 67 | Thread::signal_wait(0x1); |
gkumar | 1:b8c71afbe6e5 | 68 | printf("\n\rEntered ACS %f\n",t_start.read()); |
gkumar | 1:b8c71afbe6e5 | 69 | FCTN_ATS_DATA_ACQ(omega1,mag_field1); //the angular velocity is stored in the first 3 values and magnetic field values in next 3 |
gkumar | 1:b8c71afbe6e5 | 70 | printf("\n\rmnm gyro values\n"); //printing the angular velocity and magnetic field values |
gkumar | 1:b8c71afbe6e5 | 71 | for(int i=0; i<3; i++) |
gkumar | 1:b8c71afbe6e5 | 72 | { |
gkumar | 1:b8c71afbe6e5 | 73 | printf("%f\t",omega1[i]); |
gkumar | 1:b8c71afbe6e5 | 74 | } |
gkumar | 1:b8c71afbe6e5 | 75 | printf("\n\r mnm mag values\n"); |
gkumar | 1:b8c71afbe6e5 | 76 | for(int i=0; i<3; i++) |
gkumar | 1:b8c71afbe6e5 | 77 | { |
gkumar | 1:b8c71afbe6e5 | 78 | printf("%f\t",mag_field1[i]); |
gkumar | 1:b8c71afbe6e5 | 79 | } |
gkumar | 1:b8c71afbe6e5 | 80 | t_exec.reset(); |
gkumar | 1:b8c71afbe6e5 | 81 | |
gkumar | 1:b8c71afbe6e5 | 82 | } |
gkumar | 0:f417d854dc29 | 83 | } |
gkumar | 1:b8c71afbe6e5 | 84 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 85 | //TASK : Beacon |
gkumar | 1:b8c71afbe6e5 | 86 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 87 | int beac_flag=0; |
gkumar | 0:f417d854dc29 | 88 | void T_BEA(void const *args){ |
gkumar | 0:f417d854dc29 | 89 | while(1){ |
gkumar | 0:f417d854dc29 | 90 | Thread::signal_wait(0x3); |
gkumar | 1:b8c71afbe6e5 | 91 | printf("\n\rTHIS IS BEACON %f\n\r",t_start.read()); |
gkumar | 1:b8c71afbe6e5 | 92 | // t_exec.start(); |
gkumar | 1:b8c71afbe6e5 | 93 | // FCTN_BEA_MAIN(); |
gkumar | 1:b8c71afbe6e5 | 94 | // if(beac_flag==1) |
gkumar | 1:b8c71afbe6e5 | 95 | // { |
gkumar | 1:b8c71afbe6e5 | 96 | // Thread::wait(600000); |
gkumar | 1:b8c71afbe6e5 | 97 | // beac_flag = 0; |
gkumar | 1:b8c71afbe6e5 | 98 | // } |
gkumar | 1:b8c71afbe6e5 | 99 | // printf("The time to execute beacon thread is %f seconds\n\r",t_exec.read()); |
gkumar | 1:b8c71afbe6e5 | 100 | // t_exec.reset(); |
gkumar | 1:b8c71afbe6e5 | 101 | } |
gkumar | 0:f417d854dc29 | 102 | } |
gkumar | 0:f417d854dc29 | 103 | |
gkumar | 1:b8c71afbe6e5 | 104 | |
gkumar | 1:b8c71afbe6e5 | 105 | |
gkumar | 1:b8c71afbe6e5 | 106 | //extern SensorDataQuantised SensorQuantised; |
gkumar | 1:b8c71afbe6e5 | 107 | |
gkumar | 1:b8c71afbe6e5 | 108 | |
gkumar | 1:b8c71afbe6e5 | 109 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 110 | //TASK : Scheduler |
gkumar | 1:b8c71afbe6e5 | 111 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 112 | |
gkumar | 0:f417d854dc29 | 113 | uint8_t schedcount=1; |
gkumar | 0:f417d854dc29 | 114 | void T_SC(void const *args) |
gkumar | 0:f417d854dc29 | 115 | { |
gkumar | 0:f417d854dc29 | 116 | |
gkumar | 0:f417d854dc29 | 117 | |
gkumar | 0:f417d854dc29 | 118 | if(schedcount == 4) //to reset the counter |
gkumar | 0:f417d854dc29 | 119 | { |
gkumar | 0:f417d854dc29 | 120 | schedcount = 1; |
gkumar | 0:f417d854dc29 | 121 | } |
gkumar | 0:f417d854dc29 | 122 | pc.printf("\n\rThe value of i in scheduler is %d\n\r",schedcount); |
gkumar | 0:f417d854dc29 | 123 | if(schedcount%1==0) |
gkumar | 0:f417d854dc29 | 124 | { |
gkumar | 0:f417d854dc29 | 125 | ptr_t_acs -> signal_set(0x1); |
gkumar | 0:f417d854dc29 | 126 | } |
gkumar | 0:f417d854dc29 | 127 | |
gkumar | 0:f417d854dc29 | 128 | if(schedcount%2==0) |
gkumar | 0:f417d854dc29 | 129 | { |
gkumar | 0:f417d854dc29 | 130 | ptr_t_hk -> signal_set(0x2); |
gkumar | 0:f417d854dc29 | 131 | |
gkumar | 0:f417d854dc29 | 132 | } |
gkumar | 0:f417d854dc29 | 133 | if(schedcount%3==0) |
gkumar | 0:f417d854dc29 | 134 | { |
gkumar | 0:f417d854dc29 | 135 | |
gkumar | 0:f417d854dc29 | 136 | ptr_t_bea -> signal_set(0x3); |
gkumar | 0:f417d854dc29 | 137 | |
gkumar | 0:f417d854dc29 | 138 | } |
gkumar | 0:f417d854dc29 | 139 | schedcount++; |
gkumar | 0:f417d854dc29 | 140 | } |
gkumar | 1:b8c71afbe6e5 | 141 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 142 | //TASK : i2c data |
gkumar | 1:b8c71afbe6e5 | 143 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 144 | //void FCTN_I2C_READ(char *data,int length); |
gkumar | 1:b8c71afbe6e5 | 145 | //void FCTN_I2C_WRITE(char *data,int length); |
gkumar | 0:f417d854dc29 | 146 | |
gkumar | 0:f417d854dc29 | 147 | |
gkumar | 1:b8c71afbe6e5 | 148 | bool write_ack = 1; |
gkumar | 1:b8c71afbe6e5 | 149 | bool read_ack = 1; |
gkumar | 1:b8c71afbe6e5 | 150 | char data_send[10]; |
gkumar | 1:b8c71afbe6e5 | 151 | char data_receive[10]; |
gkumar | 1:b8c71afbe6e5 | 152 | char short_tc[10]; |
gkumar | 1:b8c71afbe6e5 | 153 | char long_tc[134]; |
gkumar | 1:b8c71afbe6e5 | 154 | char mstr_cmd = '0'; |
gkumar | 1:b8c71afbe6e5 | 155 | bool cmd_flag = 1; |
gkumar | 1:b8c71afbe6e5 | 156 | int length=10; |
gkumar | 1:b8c71afbe6e5 | 157 | |
gkumar | 1:b8c71afbe6e5 | 158 | void T_I2C_SLAVE(void const * args) |
gkumar | 1:b8c71afbe6e5 | 159 | { |
gkumar | 1:b8c71afbe6e5 | 160 | while(1) |
gkumar | 1:b8c71afbe6e5 | 161 | { |
gkumar | 1:b8c71afbe6e5 | 162 | cmd_flag = 1; |
gkumar | 1:b8c71afbe6e5 | 163 | Thread::signal_wait(0x4); |
gkumar | 1:b8c71afbe6e5 | 164 | wait_us(100); // can be between 38 to 15700 |
gkumar | 1:b8c71afbe6e5 | 165 | //printf("\n\r check 1\n"); |
gkumar | 1:b8c71afbe6e5 | 166 | t.stop(); |
gkumar | 1:b8c71afbe6e5 | 167 | if( slave.receive() == 0) |
gkumar | 1:b8c71afbe6e5 | 168 | slave.stop(); |
gkumar | 1:b8c71afbe6e5 | 169 | if( slave.receive() == 1) // slave writes to master |
gkumar | 1:b8c71afbe6e5 | 170 | { |
gkumar | 1:b8c71afbe6e5 | 171 | t1.start(); |
gkumar | 1:b8c71afbe6e5 | 172 | write_ack=slave.write(data_send,length); |
gkumar | 1:b8c71afbe6e5 | 173 | t1.stop(); |
gkumar | 1:b8c71afbe6e5 | 174 | if(write_ack == 0) |
gkumar | 1:b8c71afbe6e5 | 175 | printf("\n\rData sent to CDMS is %s \n",data_send); |
gkumar | 1:b8c71afbe6e5 | 176 | slave.stop(); |
gkumar | 1:b8c71afbe6e5 | 177 | } |
gkumar | 1:b8c71afbe6e5 | 178 | if( slave.receive()==3 || slave.receive()==2) // slave read |
gkumar | 1:b8c71afbe6e5 | 179 | { |
gkumar | 1:b8c71afbe6e5 | 180 | t1.start(); |
gkumar | 1:b8c71afbe6e5 | 181 | read_ack=slave.read(data_receive,length); |
gkumar | 1:b8c71afbe6e5 | 182 | t1.stop(); |
gkumar | 1:b8c71afbe6e5 | 183 | if(read_ack == 0) |
gkumar | 1:b8c71afbe6e5 | 184 | printf("\n\r Data received from CDMS is %s \n",data_receive); |
gkumar | 1:b8c71afbe6e5 | 185 | slave.stop(); |
gkumar | 1:b8c71afbe6e5 | 186 | } |
gkumar | 1:b8c71afbe6e5 | 187 | printf("\n \r %d %d\n",t.read_us(),t1.read_us()); |
gkumar | 1:b8c71afbe6e5 | 188 | t.reset(); |
gkumar | 1:b8c71afbe6e5 | 189 | t1.reset(); |
gkumar | 1:b8c71afbe6e5 | 190 | } |
gkumar | 1:b8c71afbe6e5 | 191 | |
gkumar | 1:b8c71afbe6e5 | 192 | // if(cmd_flag == 1) |
gkumar | 1:b8c71afbe6e5 | 193 | // { |
gkumar | 1:b8c71afbe6e5 | 194 | // t.stop(); |
gkumar | 1:b8c71afbe6e5 | 195 | // if( slave.receive()==3 || slave.receive()==2) // slave read |
gkumar | 1:b8c71afbe6e5 | 196 | // { |
gkumar | 1:b8c71afbe6e5 | 197 | // |
gkumar | 1:b8c71afbe6e5 | 198 | // t1.start(); |
gkumar | 1:b8c71afbe6e5 | 199 | // read_ack=slave.read(&mstr_cmd,1); |
gkumar | 1:b8c71afbe6e5 | 200 | // t1.stop(); |
gkumar | 1:b8c71afbe6e5 | 201 | // if(read_ack == 0) |
gkumar | 1:b8c71afbe6e5 | 202 | // { |
gkumar | 1:b8c71afbe6e5 | 203 | // printf("\n\r Data received from CDMS is %c \n",mstr_cmd); |
gkumar | 1:b8c71afbe6e5 | 204 | // switch(mstr_cmd) |
gkumar | 1:b8c71afbe6e5 | 205 | // { |
gkumar | 1:b8c71afbe6e5 | 206 | // case 's': |
gkumar | 1:b8c71afbe6e5 | 207 | // length = 11; |
gkumar | 1:b8c71afbe6e5 | 208 | // cmd_flag = 0; |
gkumar | 1:b8c71afbe6e5 | 209 | // break; |
gkumar | 1:b8c71afbe6e5 | 210 | // |
gkumar | 1:b8c71afbe6e5 | 211 | // case 'l': |
gkumar | 1:b8c71afbe6e5 | 212 | // length = 135; |
gkumar | 1:b8c71afbe6e5 | 213 | // cmd_flag = 0; |
gkumar | 1:b8c71afbe6e5 | 214 | // break; |
gkumar | 1:b8c71afbe6e5 | 215 | // |
gkumar | 1:b8c71afbe6e5 | 216 | // case 'h': |
gkumar | 1:b8c71afbe6e5 | 217 | // length = 25; |
gkumar | 1:b8c71afbe6e5 | 218 | // cmd_flag = 0; |
gkumar | 1:b8c71afbe6e5 | 219 | // FCTN_I2C_WRITE(hk_data,length ); |
gkumar | 1:b8c71afbe6e5 | 220 | // break; |
gkumar | 1:b8c71afbe6e5 | 221 | // |
gkumar | 1:b8c71afbe6e5 | 222 | // default: |
gkumar | 1:b8c71afbe6e5 | 223 | // printf("\n\r invalid command \n"); |
gkumar | 1:b8c71afbe6e5 | 224 | // //cmd_err = 0; |
gkumar | 1:b8c71afbe6e5 | 225 | // cmd_flag = 1; |
gkumar | 1:b8c71afbe6e5 | 226 | // } |
gkumar | 1:b8c71afbe6e5 | 227 | // } |
gkumar | 1:b8c71afbe6e5 | 228 | // else |
gkumar | 1:b8c71afbe6e5 | 229 | // cmd_flag = 1; |
gkumar | 1:b8c71afbe6e5 | 230 | // } |
gkumar | 1:b8c71afbe6e5 | 231 | // else |
gkumar | 1:b8c71afbe6e5 | 232 | // cmd_flag = 1; |
gkumar | 1:b8c71afbe6e5 | 233 | // } |
gkumar | 1:b8c71afbe6e5 | 234 | // printf("\n \r %d %d\n",t.read_us(),t1.read_us()); |
gkumar | 1:b8c71afbe6e5 | 235 | // t.reset(); |
gkumar | 1:b8c71afbe6e5 | 236 | // t1.reset(); |
gkumar | 1:b8c71afbe6e5 | 237 | // |
gkumar | 1:b8c71afbe6e5 | 238 | // |
gkumar | 1:b8c71afbe6e5 | 239 | // } |
gkumar | 1:b8c71afbe6e5 | 240 | //} |
gkumar | 1:b8c71afbe6e5 | 241 | // |
gkumar | 1:b8c71afbe6e5 | 242 | //void FCTN_I2C_READ(char *data, int length ) |
gkumar | 1:b8c71afbe6e5 | 243 | //{ |
gkumar | 1:b8c71afbe6e5 | 244 | // t1.start(); |
gkumar | 1:b8c71afbe6e5 | 245 | // read_ack=slave.read(data,length); |
gkumar | 1:b8c71afbe6e5 | 246 | // t1.stop(); |
gkumar | 1:b8c71afbe6e5 | 247 | // if(read_ack == 0) |
gkumar | 1:b8c71afbe6e5 | 248 | // printf("\n\rData received from CDMS is %s \n",data); |
gkumar | 1:b8c71afbe6e5 | 249 | // else |
gkumar | 1:b8c71afbe6e5 | 250 | // printf("\n\r data not received \n"); |
gkumar | 1:b8c71afbe6e5 | 251 | //} |
gkumar | 1:b8c71afbe6e5 | 252 | // |
gkumar | 1:b8c71afbe6e5 | 253 | //void FCTN_I2C_WRITE(char *data,int length) |
gkumar | 1:b8c71afbe6e5 | 254 | //{ |
gkumar | 1:b8c71afbe6e5 | 255 | // t1.start(); |
gkumar | 1:b8c71afbe6e5 | 256 | // write_ack=slave.write(data,length); |
gkumar | 1:b8c71afbe6e5 | 257 | // t1.stop(); |
gkumar | 1:b8c71afbe6e5 | 258 | // if(write_ack == 0) |
gkumar | 1:b8c71afbe6e5 | 259 | // printf("\n\rData sent to CDMS is %s \n",data); |
gkumar | 1:b8c71afbe6e5 | 260 | // else |
gkumar | 1:b8c71afbe6e5 | 261 | // printf("\n\r data not sent\n"); |
gkumar | 1:b8c71afbe6e5 | 262 | } |
gkumar | 1:b8c71afbe6e5 | 263 | |
gkumar | 1:b8c71afbe6e5 | 264 | |
gkumar | 1:b8c71afbe6e5 | 265 | void FCTN_ISR_I2C() |
gkumar | 1:b8c71afbe6e5 | 266 | { |
gkumar | 1:b8c71afbe6e5 | 267 | ptr_t_i2c->signal_set(0x4); |
gkumar | 1:b8c71afbe6e5 | 268 | t.start(); |
gkumar | 1:b8c71afbe6e5 | 269 | } |
gkumar | 1:b8c71afbe6e5 | 270 | //void FCTN_HK_DATA_CATENATE() |
gkumar | 1:b8c71afbe6e5 | 271 | //{ |
gkumar | 1:b8c71afbe6e5 | 272 | // strcpy(hk_data,"hk_Data"); |
gkumar | 1:b8c71afbe6e5 | 273 | // strcat(hk_data,SensorQuantised.Voltage); |
gkumar | 1:b8c71afbe6e5 | 274 | // strcat(hk_data,SensorQuantised.Current); |
gkumar | 1:b8c71afbe6e5 | 275 | // strcat(hk_data,SensorQuantised.PanelTemperature); |
gkumar | 1:b8c71afbe6e5 | 276 | // strcat(hk_data,SensorQuantised.AngularSpeed); |
gkumar | 1:b8c71afbe6e5 | 277 | // strcat(hk_data,SensorQuantised.Bnewvalue); |
gkumar | 1:b8c71afbe6e5 | 278 | // char fdata[5] = {SensorQuantised.BatteryTemperature,SensorQuantised.faultpoll,SensorQuantised.faultir,SensorQuantised.power_mode}; |
gkumar | 1:b8c71afbe6e5 | 279 | // /*strcat(hk_data,sfaultpoll); |
gkumar | 1:b8c71afbe6e5 | 280 | // strcat(hk_data,sfaultir); |
gkumar | 1:b8c71afbe6e5 | 281 | // strcat(hk_data,spower_mode);*/ |
gkumar | 1:b8c71afbe6e5 | 282 | // strcat(hk_data,fdata); |
gkumar | 1:b8c71afbe6e5 | 283 | // printf("\n\r hk data being sent is %s ",hk_data); |
gkumar | 1:b8c71afbe6e5 | 284 | //} |
gkumar | 1:b8c71afbe6e5 | 285 | |
gkumar | 1:b8c71afbe6e5 | 286 | //----------------------------------------------------------------------------BAE_INIT------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 287 | |
gkumar | 1:b8c71afbe6e5 | 288 | void FCTN_BAE_INIT() |
gkumar | 1:b8c71afbe6e5 | 289 | { |
gkumar | 1:b8c71afbe6e5 | 290 | slave.address(0x20); // setting slave address for BAE for I2C communication |
gkumar | 1:b8c71afbe6e5 | 291 | FCTN_ACS_INIT(); // Initializing mnm blue |
gkumar | 1:b8c71afbe6e5 | 292 | //FCTN_BAE_HK_INIT(); |
gkumar | 1:b8c71afbe6e5 | 293 | //FCTN_BEA_INIT(); |
gkumar | 1:b8c71afbe6e5 | 294 | } |
gkumar | 1:b8c71afbe6e5 | 295 | |
gkumar | 1:b8c71afbe6e5 | 296 | |
gkumar | 1:b8c71afbe6e5 | 297 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 298 | //TASK : Main |
gkumar | 1:b8c71afbe6e5 | 299 | //--------------------------------------------------------------------------------------------------------------------------------------------------- |
gkumar | 1:b8c71afbe6e5 | 300 | |
gkumar | 0:f417d854dc29 | 301 | |
gkumar | 0:f417d854dc29 | 302 | |
gkumar | 0:f417d854dc29 | 303 | int main(){ |
gkumar | 0:f417d854dc29 | 304 | ptr_t_hk = new Thread(T_HK); |
gkumar | 0:f417d854dc29 | 305 | ptr_t_acs = new Thread(T_ACS); |
gkumar | 0:f417d854dc29 | 306 | ptr_t_bea = new Thread(T_BEA); |
gkumar | 1:b8c71afbe6e5 | 307 | ptr_t_i2c= new Thread(T_I2C_SLAVE); |
gkumar | 0:f417d854dc29 | 308 | |
gkumar | 0:f417d854dc29 | 309 | ptr_t_acs->set_priority(osPriorityAboveNormal); |
gkumar | 0:f417d854dc29 | 310 | ptr_t_hk->set_priority(osPriorityAboveNormal); |
gkumar | 0:f417d854dc29 | 311 | ptr_t_bea->set_priority(osPriorityAboveNormal); |
gkumar | 1:b8c71afbe6e5 | 312 | ptr_t_i2c->set_priority(osPriorityRealtime); |
gkumar | 1:b8c71afbe6e5 | 313 | |
gkumar | 0:f417d854dc29 | 314 | RtosTimer t_sc_timer(T_SC,osTimerPeriodic); // Initiating the scheduler thread |
gkumar | 1:b8c71afbe6e5 | 315 | t_sc_timer.start(10000); |
gkumar | 1:b8c71afbe6e5 | 316 | printf("\n\r BAE ACTIVATED\n"); |
gkumar | 1:b8c71afbe6e5 | 317 | FCTN_BAE_INIT(); |
gkumar | 1:b8c71afbe6e5 | 318 | //strcpy(data_send,"sakthi"); |
gkumar | 1:b8c71afbe6e5 | 319 | slave.address(addr); |
gkumar | 1:b8c71afbe6e5 | 320 | irpt_4m_mstr.enable_irq(); |
gkumar | 1:b8c71afbe6e5 | 321 | irpt_4m_mstr.rise(&FCTN_ISR_I2C); |
gkumar | 1:b8c71afbe6e5 | 322 | |
gkumar | 0:f417d854dc29 | 323 | |
gkumar | 0:f417d854dc29 | 324 | while(1) //required to prevent main from terminating |
gkumar | 0:f417d854dc29 | 325 | { |
gkumar | 0:f417d854dc29 | 326 | ; |
gkumar | 0:f417d854dc29 | 327 | } |
gkumar | 0:f417d854dc29 | 328 | } |