TELECOMMAND MANAGER V1

Dependencies:   mbed SLCD mbed-rtos

main.cpp

Committer:
shreeshas95
Date:
2015-06-24
Revision:
3:eec1097c0dd6
Parent:
2:994e741028c7
Child:
4:f95195748a0c

File content as of revision 3:eec1097c0dd6:

#include "mbed.h"

#include <bitset>
#include <iostream>
using namespace std;


Serial PC(USBTX, USBRX);

DigitalOut ledr(LED_RED);
DigitalOut ledg(LED_GREEN);

#include "Structures.h"

namespace VAR_SPACE{
    
    unsigned char *data = 0;
    TC_list *Head_node = NULL;
    
    int rx_state = 0;
    /*
     * 0 : idle
     * 1 : Rx interrupt received, saving data
     * 2 : interrupt handled, RX_RCV_TX running
     * 3 : RX_RCV_TC handled, MNG_TM_TC handled
     */
}

#include "mbed.h"

#include "crc.h"
#include "SND_TM.h"
#include "MNG_TC.h"
#include "COM_RCV_TC.h"

using namespace VAR_SPACE;

int main(){
    printf("WELCOME\r\n");
    
    PC.baud(9600);
    
    VAR_SPACE::data = new unsigned char[26];
    
    data[0] = 0x7E;
    data[1] = 0x01;
    data[2] = 0x81;
    data[3] = 0x88;
    for(int i =4; i <=9; i++)
            data[i] = 0x88;
    data[10] = 0xc0;
    data[11] = 0x79;
    data[12] = 0x7E;
    data[13] = 0x02;
    data[14] = 0xA1;
    data[15] = 0x88;
    for(int i = 16;i <= 21; i++)
            data[i] = 0x88;
    data[22] = 0x96;
    data[23] = 0x55;
    data[24] = 0x7E;
    data[25] = 0x7E;
    
    VAR_SPACE::rx_state = 2;
    
    while(true){
        ledg = !ledg;
        
        if( VAR_SPACE::rx_state == 2 ){
            printf("Calling rcv_tc\r\n");
            RCV_TC::RX_RCV_TC();
            VAR_SPACE::rx_state = 3;
            
        }
        else if( VAR_SPACE::rx_state == 3 ){
            
            printf("calling mng tc\r\n");
            MNG_TC::init( VAR_SPACE::Head_node );
            MNG_TC::start_with();
            
            VAR_SPACE::rx_state = 0;
            
        }
        wait_ms(10);
    }
}