TELECOMMAND MANAGER V1

Dependencies:   mbed SLCD mbed-rtos

Revision:
13:7b27a8e9cbb4
Parent:
10:024c2ef51cb1
Child:
14:a4c259ca0325
Child:
16:de2224dd9a0d
--- a/main.cpp	Thu Jul 16 14:14:41 2015 +0000
+++ b/main.cpp	Mon Aug 03 14:29:35 2015 +0000
@@ -7,12 +7,15 @@
 #include "SLCD.h"
 SLCD lcd;
 
-#define RX_TIMEOUT_LIMIT 2
+#define RX_TIMEOUT_LIMIT 1
 #define PASS_TIME_LIMIT 1200
+#define PAYLOAD_DMA_SIZE 2190
 
 Serial PC(USBTX, USBRX);
 RawSerial rx1m(PTE0, PTE1);
 
+Mutex SPI_mutex;
+
 DigitalOut ledr(LED_RED);
 DigitalOut ledg(LED_GREEN);
 
@@ -43,7 +46,11 @@
     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;
@@ -51,39 +58,31 @@
 bool first_time = true;
 Timeout pass_time;
 
-#include "crc.h"
-#include "SND_TM.h"
-#include "COM_RCV_TC.h"
-#include "MNG_TC.h"
-#include "ThreadFunctions.h"
-
 void after_pass(){
     pass_time.detach();
     pass_over = true;
 }
 
-void after_receive(void){
-    rx_timeout.detach();
-    VAR_SPACE::rx_new_node->val = 0x00;
-    
-    if(first_time){
-        first_time = false;
-        pass_time.attach(&after_pass, PASS_TIME_LIMIT);
-    }
-    
-    VAR_SPACE::new_tc_received = true;
-    VAR_SPACE::mng_tmtc_thread->signal_set(0x01);
-}
-
-unsigned char rx_char = 0;
-bool byte_rx = false;
+#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;
-    rx_char = rx1m.getc();
+    ledg = !ledg;
+    VAR_SPACE::rx_new_node->val = rx1m.getc();
     
-    byte_rx = true;
+    VAR_SPACE::COM_RCV_TC_thread->signal_set(0x01);
 }
 
 int main(){
@@ -100,6 +99,8 @@
     
     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");
     
@@ -112,20 +113,6 @@
     
     while(true){
 //        ledg = !ledg;
-        if(byte_rx){
-            ledg = !ledg;
-            byte_rx = false;
-            
-            VAR_SPACE::rx_new_node->val = rx_char;
-            
-            //~ allocate new node
-            VAR_SPACE::rx_new_node->next = new data_list;
-            VAR_SPACE::rx_new_node = VAR_SPACE::rx_new_node->next;
-            VAR_SPACE::rx_new_node->next = NULL;
-            
-            rx_timeout.attach(&after_receive, RX_TIMEOUT_LIMIT);
-        }
-
         if(pass_over){
             pass_over = false;
             first_time = true;