Simple version of COM_MNG_TMTC_CODE for IITMSAT.
Dependencies: mbed-rtos mbed FreescaleIAP SimpleDMA
Diff: adf.h
- Revision:
- 88:b9beee1a7a3e
- Parent:
- 86:a26f5f22631d
- Child:
- 89:cca875337dd5
- Child:
- 95:42d6747900cb
diff -r 6e154fd43531 -r b9beee1a7a3e adf.h --- a/adf.h Wed Jan 20 17:00:54 2016 +0000 +++ b/adf.h Thu Jan 21 14:35:11 2016 +0000 @@ -245,7 +245,7 @@ #define send_data {\ - if(sent_tmfrom_SDcard){\ +if(sent_tmfrom_SDcard){\ send_tm_from_SD_card();\ }else{\ snd_tm.transmit_data(buffer_112,&last_buffer);\ @@ -282,54 +282,6 @@ SPI_mutex.unlock();\ /*ticker.attach_us(&check,32000);*/\ } - - - -#define adf_SND_SDCard {\ - buffer_state = true;\ - last_buffer = false;\ - loop_on = true;\ - ADF_off = false;\ - sent_tmfrom_SDcard = true;\ - signal = COM_MNG_TMTC_SIGNAL_ADF_SD;\ - start_block_num = starting_add;\ - end_block_num = ending_add;\ - initial_adf_check;\ - initiate;\ - send_data;\ - while(loop_on){\ - /*led2=!led2;*/\ - gCOM_MNG_TMTC_THREAD->signal_wait(COM_MNG_TMTC_SIGNAL_ADF_SD);\ - if(ADF_off){\ - SPI_mutex.lock();\ - /*ticker.detach();*/\ - gCS_ADF=0;\ - spi.write(0xB1);\ - gCS_ADF=1;\ - SPI_mutex.unlock();\ - /*gPC.puts("transmission done\r\n");*/\ - loop_on = false;\ - }else{\ - write_data;\ - if(!last_buffer)\ - send_tm_from_SD_card();\ - }\ - }\ -} - -//void read_TC(Base_tc* TC_ptr){ -// //gPC.puts("Inside sd card sending\r\n"); -// unsigned char service_subtype = 0; -// uint64_t starting_add = 0, ending_add = 0; -// service_subtype = (TC_ptr->TC_string[2])&0x0f; -// starting_add = (TC_ptr->TC_string[5]) + ( (TC_ptr->TC_string[4])<<8 ) + ( (TC_ptr->TC_string[3]) <<16); -// ending_add = (TC_ptr->TC_string[8]) + ( (TC_ptr->TC_string[7])<<8 ) + ( (TC_ptr->TC_string[6]) <<16); -// starting_add = 10; // for now -// ending_add = 20; -//// adf_SND_SDCard(starting_add , ending_add); -// //gPC.puts("sending from sd card\r\n"); -// adf_SND_SDCard; -//} #define configure_adf {\ finish_write_data = false;\ @@ -372,4 +324,35 @@ }\ }\ /*gPC.puts("after while loop\r\n");*/\ -} \ No newline at end of file +} + +void adf_SND_SDCard() { + sent_tmfrom_SDcard = true; + configure_adf; + signal = COM_MNG_TMTC_SIGNAL_ADF_SD; + send_data; + while(loop_on){ + wait_ms(COM_TX_TICKER_LIMIT); + if(IRQ || bypass_adf){ + if(finish_write_data){ + if(ADF_off){ + SPI_mutex.lock(); + gCS_ADF=0; + spi.write(0xB1); + gCS_ADF=1; + SPI_mutex.unlock(); + loop_on = false; + gPC.puts("Transmission done\r\n"); + } + else{ + ADF_off = true; + } + }else{ + write_data; + send_tm_from_SD_card(); + } + } + } + /*gPC.puts("after while loop\r\n");*/ +} +