jnlj

Dependencies:   mbed-rtos mbed

Fork of TFOX_CDMS_VR_1_0_WORKING by Team Fox

science.cpp

Committer:
pradeepvk2208
Date:
2015-06-15
Revision:
2:4c79b3dfef31
Parent:
0:d6e3d1e21484
Child:
3:0c3f7c3fabc9

File content as of revision 2:4c79b3dfef31:

#include "mbed.h"
#include "func_head.h"

Serial sr(USBTX,USBRX);

SPISlave pl_spi2(PTD6, PTD7, PTD5, PTD4 ); // mosi, miso, sclk, ssel --> using SPI1

int payloadBins = 4;

void FUNC_PL_RCV_SC_DATA()
{
        sr.printf("in FUNC_PL_RCV_SC_DATA\r\n");
        uint8_t scienceRawPacket[payloadBins];
        for(int i=0; i<payloadBins;i++)
        {
            while(!pl_spi2.receive()); // blocking statement --> waiting for data from Payload
            uint8_t v = pl_spi2.read();   // Read byte from master
            scienceRawPacket[i] = v;
        }
        // serial feedback
        sr.printf("Packet recieved\r\r\n");
        for(int i=0;i<payloadBins;i++)
        {
            sr.printf("%0x\t",scienceRawPacket[i]);
            scienceRawPacket[i] = 0;
        }
        sr.printf("\r\r\n");
}