TELECOMMAND MANAGER V1
Dependencies: mbed SLCD mbed-rtos
main.cpp
- Committer:
- shreeshas95
- Date:
- 2015-08-17
- Revision:
- 14:a4c259ca0325
- Parent:
- 13:7b27a8e9cbb4
File content as of revision 14:a4c259ca0325:
//how to handle interrupt while running other thread ? #include "mbed.h" #include "rtos.h" #include "iostream" #include "bitset" using namespace std; #define ENDL "\r" << endl #include "SLCD.h" SLCD lcd; #define RX_TIMEOUT_LIMIT 1 #define PASS_TIME_LIMIT 1200 #define PAYLOAD_DMA_SIZE 2190 Serial PC(USBTX, USBRX); RawSerial rx1m(PTE0, PTE1); SPI spi(PTA16, PTA17, PTA15); //MOSI, MISO, CLOCK Mutex SPI_mutex; DigitalOut ledr(LED_RED); DigitalOut ledg(LED_GREEN); #include "Structures.h" struct data_list{ unsigned char val; struct data_list* next; }; namespace VAR_SPACE{ TC_list *Head_node = NULL; TC_list *last_node = NULL; int rx_state = 0; /* 0 : idle 1 : executing normal 2 : executing obosc 3 : idle 2 : obosc received incorrectly */ struct data_list *head_data; data_list *data_node; struct data_list *rx_new_node; bool new_tc_received = false; bool execute_obosc = false; uint8_t payload_dma_buffer[PAYLOAD_DMA_SIZE]; Thread *mng_tmtc_thread = NULL; Thread *COM_RCV_TC_thread = NULL; // Thread *COM_payload_thread = NULL; } Timeout rx_timeout; bool pass_over = false; bool first_time = true; Timeout pass_time; void after_pass(){ pass_time.detach(); pass_over = true; } #include "crc.h" #include "mbed_debug.h" #include "Convolution.h" #include "interleave.h" #include "snd_tm_class.h" #include "SD_read.h" #include "adf.h" #include "compression.h" #include "SDCard_initionalisation.h" #include "COM_RCV_TC.h" #include "MNG_TC.h" #include "ThreadFunctions.h" void rx_read() { // store value // rx_char = UART1->D; ledg = !ledg; VAR_SPACE::rx_new_node->val = rx1m.getc(); VAR_SPACE::COM_RCV_TC_thread->signal_set(0x01); } int main(){ printf("welcome to mng_tm_tc\r\n"); cs_adf=1; cs_SDCard=1; PC.baud(9600); rx1m.baud(1200); VAR_SPACE::head_data = new data_list; VAR_SPACE::head_data->next = NULL; VAR_SPACE::rx_new_node = VAR_SPACE::head_data; rx1m.attach(&rx_read, Serial::RxIrq); VAR_SPACE::mng_tmtc_thread = new Thread(com_mng_fun); MNG_TC::init(); VAR_SPACE::COM_RCV_TC_thread = new Thread(com_rcv_tc_fun); // VAR_SPACE::COM_payload_thread = new Thread(com_pay_thread_fun); lcd.printf("0"); struct data_list *hehe = VAR_SPACE::head_data; while( hehe != NULL ){ printf("%x ", hehe->val); hehe = hehe->next; } printf("\r\n"); while(true){ // ledg = !ledg; if(pass_over){ pass_over = false; first_time = true; // pass got over reset all reset_all(); //also consider frame_no } } }