![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Updated BAE RTOS
Fork of all_combined_week6 by
Revision 7:b3f876f605d9, committed 2014-09-19
- Comitter:
- greenroshks
- Date:
- Fri Sep 19 05:12:40 2014 +0000
- Parent:
- 6:82153349cc9b
- Commit message:
- latest
Changed in this revision
--- a/HK.cpp Tue Jul 15 10:04:38 2014 +0000 +++ b/HK.cpp Fri Sep 19 05:12:40 2014 +0000 @@ -17,24 +17,24 @@ if(y>=15)y=15; return y; } - +ShortBeacy Shortbeacon; void init_beacon(ShortBeacy x){ - x.Voltage[0]=1; - x.AngularSpeed[0]=2; - x.AngularSpeed[1]=3; - x.SubsystemStatus[0]=145; - x.Temp[0]=1; - x.Temp[1]=2; - x.Temp[2]=3; - x.ErrorFlag[0]=3; + ; } -ShortBeacy Shortbeacon; + void FUNC_HK_MAIN() { printf("\nEntered function HK MAIN\n"); - init_beacon(Shortbeacon); + Shortbeacon.Voltage[0]=1; + Shortbeacon.AngularSpeed[0]=2; + Shortbeacon.AngularSpeed[1]=3; + Shortbeacon.SubsystemStatus[0]=145; + Shortbeacon.Temp[0]=1; + Shortbeacon.Temp[1]=2; + Shortbeacon.Temp[2]=3; + Shortbeacon.ErrorFlag[0]=3; int LoopIterator; @@ -69,12 +69,11 @@ wait_us(10.0); // A delay of 10 microseconds between each sensor output. Can be changed. } - for(int i=0;i<8;i++) - { - printf("\nVoltage %d is %u\n",i,Sensor.Voltage[i]); - printf("\nCurrent %d is %u\n",i,Sensor.Current[i]); - printf("\nTemperature %d is %u\n",i,Sensor.Temperature[i]); - } + + printf("\nVoltage is %u\n",Sensor.Voltage[0]); + printf("\nCurrent is %u\n",Sensor.Current[0]); + printf("\ntemperature is %u\n",Sensor.Temperature[0]); + printf("\nExited function HK MAIN\n"); -} \ No newline at end of file +}
--- a/beacon.cpp Tue Jul 15 10:04:38 2014 +0000 +++ b/beacon.cpp Fri Sep 19 05:12:40 2014 +0000 @@ -31,7 +31,7 @@ }*/ -extern ShortBeacy Shortbeacon; +extern ShortBeacy Shortbeacon; void writereg(uint8_t reg,uint8_t val) { cs_bar = 0; @@ -49,7 +49,7 @@ return val; } -void beacon_func() { +void FUNC_BEA() { //button.rise(&interrupt_func); //interrupt enabled ( rising edge of pin 9) printf("\nBeacon function entered\n"); @@ -72,10 +72,10 @@ //mask //uint8_t mask[] = {0x80, 0x40, 0x20,0x10,0x8,0x4,0x2,0x1}; - /* for(int i = 0; i < 15 ; i++) + for(int i = 0; i < 15 ; i++) { chavan.printf("0x%X\n",(short_beacon[i])); - }*/ + } spi.format(8,0); spi.frequency(10000000); //10MHz SCLK frequency(its max for rfm69hcw)
--- a/beacon.h Tue Jul 15 10:04:38 2014 +0000 +++ b/beacon.h Fri Sep 19 05:12:40 2014 +0000 @@ -2,7 +2,7 @@ void writereg(uint8_t reg,uint8_t val); uint8_t readreg(uint8_t reg); -void beacon_func(); +void FUNC_BEA(); /*struct ShortBeacon { char Voltage[1]; char AngularSpeed[2];
--- a/main.cpp Tue Jul 15 10:04:38 2014 +0000 +++ b/main.cpp Fri Sep 19 05:12:40 2014 +0000 @@ -4,13 +4,13 @@ #include "slave.h" #include "beacon.h" #include "ACS.h" -//watda? + Serial pc(USBTX, USBRX); -Timer t; -Timer t1; +Timer t; //To know the time of entering each thread +Timer t1; //To know the time of execution of each thread Thread *ptr_t_hk_acq; Thread *ptr_t_acs; @@ -20,53 +20,15 @@ Thread *ptr_t_fault; -//----------------------------------------------HOUSE-KEEPING(HK)------------------------------------------------------------------------------------------ -//void func_hk_mux() -//{ -// pc.printf("Something related to mux\n"); -//} -// -//void func_hk_adc() -//{ -// pc.printf("Converting analog to digital\n"); -//} -// -//void func_hk_write2flash() -//{ -// pc.printf("Writing the house keeping data to flash\n"); -//} -// -//void func_hk_readram() -//{ -// pc.printf("Reading hk data from ram\n"); -//} +//-------------------------------------------------------------------------------------------------------------------------------------------------- +//TASK 2 : HK +//-------------------------------------------------------------------------------------------------------------------------------------------------- -//void func_hk_send2cdms() -//{ -// pc.printf("Send the data to sd card\n"); -//} -void t_hk_send2cdms(void const *args) -{ - while(1) - { - t.start(); - Thread::signal_wait(0x4); - printf("\nEntered t_hk_send2cdms\n"); - /*printf("The state of hk_acq thread is %d\n",ptr_t_hk_acq->get_state()); - printf("The state of acs_main thread is %d\n",ptr_t_acs->get_state()); - printf("The state of acs_write2flash thread is %d\n",ptr_t_acs_write2flash->get_state()); - printf("The state of beacon thread is %d\n",ptr_t_bea->get_state());*/ - - //FUNC_I2C_SLAVE_MAIN(24); - printf("The time to execute send2cdms is %f\n",t.read()); - t.reset(); - } -} void t_hk_acq(void const *args) { - Thread thread_2(t_hk_send2cdms); + while(1) { Thread::signal_wait(0x2); @@ -74,13 +36,10 @@ printf("\nTHIS IS HK %f\n",t1.read()); t.start(); - FUNC_HK_MAIN(); + FUNC_HK_MAIN(); //Collecting HK data //thread_2.signal_set(0x4); - FUNC_I2C_SLAVE_MAIN(24); - /*printf("The state of hk_acq thread is %d\n",ptr_t_hk_acq->get_state()); - printf("The state of acs_main thread is %d\n",ptr_t_acs->get_state()); - printf("The state of acs_write2flash thread is %d\n",ptr_t_acs_write2flash->get_state()); - printf("The state of beacon thread is %d\n",ptr_t_bea->get_state());*/ + FUNC_I2C_SLAVE_MAIN(24); //Sending to CDMS via I2C + t.stop(); printf("The time to execute hk_acq is %f seconds\n",t.read()); t.reset(); @@ -88,7 +47,8 @@ } //--------------------------------------------------------------------------------------------------------------------------------------- - +//TASK 1 : ACS +//--------------------------------------------------------------------------------------------------------------------------------------- typedef struct { float mag_field; float omega; @@ -108,10 +68,7 @@ pc.printf("Executing control algo\n"); } -/*void func_acs_pwmgen() -{ - pc.printf("Generating PWM signal\n"); -}*/ + void func_acs_write2flash(sensor_data *ptr2) { @@ -130,14 +87,9 @@ func_acs_readdata(ptr); q_acs.put(ptr); func_acs_ctrlalgo(); - FUNC_ACS_GENPWM(); + FUNC_ACS_GENPWM(); //Generating PWM signal. - /*printf("The state of hk_acq thread is %d\n",ptr_t_hk_acq->get_state()); - printf("The state of acs_main thread is %d\n",ptr_t_acs->get_state()); - printf("The state of acs_write2flash thread is %d\n",ptr_t_acs_write2flash->get_state()); - printf("The state of beacon thread is %d\n",ptr_t_bea->get_state()); - printf("The time to execute t_acs is %f seconds\n",t.read());*/ - // Thread::wait(10000); + t.reset(); } } @@ -154,26 +106,16 @@ func_acs_write2flash(ptr); q_acs.free(ptr); } - printf("Writing acsd data in the flash\n"); + printf("Writing acs data in the flash\n"); } } + //---------------------------------------------------BEACON-------------------------------------------------------------------------------------------- -int beac_flag=0; +int beac_flag=0; //To receive telecommand from ground. -/*void func_bea_readbaeflash() -{ - pc.printf("Reading data from beacon flash\n"); - wait(0.01); -} -void func_bea_spiwrite() -{ - pc.printf("Writing through SPI\n"); - wait(0.01); -} -*/ void t_bea_telecommand(void const *args) { char c = pc.getc(); @@ -192,18 +134,13 @@ Thread::signal_wait(0x3); printf("\nTHIS IS BEACON %f\n",t1.read()); t.start(); - /*printf("The state of hk_acq thread is %d\n",ptr_t_hk_acq->get_state()); - printf("The state of acs_main thread is %d\n",ptr_t_acs->get_state()); - printf("The state of acs_write2flash thread is %d\n",ptr_t_acs_write2flash->get_state()); - printf("The state of beacon thread is %d\n",ptr_t_bea->get_state());*/ - if(beac_flag==0) - { - //func_bea_readbaeflash(); - //func_bea_spiwrite(); - beacon_func(); - //Thread::wait(30000); - } - else + + + + FUNC_BEA(); + + + if(beac_flag==1) { Thread::wait(600000); beac_flag = 0; @@ -274,7 +211,11 @@ } if(schedcount%3==0) { - ptr_t_bea -> signal_set(0x3); + if(beac_flag==0) + { + + ptr_t_bea -> signal_set(0x3); + } } schedcount++; } @@ -301,15 +242,8 @@ ptr_t_bea_telecommand->set_priority(osPriorityIdle); //ptr_t_sc->set_priority(osPriorityAboveNormal); - /*RtosTimer for individual thread------------------------------------------------------------------------------------------- - RtosTimer t_hk_acq_timer(t_hk_acq, osTimerPeriodic); - RtosTimer t_acs_timer(t_acs, osTimerPeriodic); - RtosTimer t_bea_timer(t_bea, osTimerPeriodic); - - t_hk_acq_timer.start(20000); - t_acs_timer.start(10000); - t_bea_timer.start(30000); - ----------------------------------------------------------------------------------------------*/ + + // ---------------------------------------------------------------------------------------------- pc.printf("\n T_FAULT priority is %d",ptr_t_fault->get_priority()); pc.printf("\n T_ACS priority is %d",ptr_t_acs->get_priority()); pc.printf("\n T_HK_ACQ priority is %d",ptr_t_hk_acq->get_priority());
--- a/slave.cpp Tue Jul 15 10:04:38 2014 +0000 +++ b/slave.cpp Fri Sep 19 05:12:40 2014 +0000 @@ -27,6 +27,7 @@ screen.printf("\nSlave entered\n"); slave.address(slave_address); //assigning slave address + slave.stop(); char Switch_Variable;