MyTetra Share
Делитесь знаниями!
Sample Receiving
Время создания: 15.01.2020 01:04
Раздел: Electronics - Microcontrollers - STM32 - Deutsch

while(1)

{

static const uint16_t ethBufSize = 2048;

static const uint16_t usbBufSize = APP_TX_DATA_SIZE;

static const uint8_t size16 = 2; //sizeof(uint16_t);

static uint16_t sampleSize = DEFAULT_SAMPLE_SIZE;

static uint16_t tick=0;

static uint16_t usbBufIndex = 0;

static uint16_t ethBufIndex = 0;

static int16_t ethShifting = -1;

static uint8_t connectedToServer = 0;

static uint8_t usbConnected = 1;


if(FPGA_Signal && (usbConnected || connectedToServer))

{

ethShifting = -1;

if(tick < sampleSize)

{

static const uint8_t delay = 10;

static const uint8_t hDelay = 150;


uint16_t regState = 0;


regState = GPIOE->IDR;

memcpy(UserTxBufferFS+usbBufIndex, &regState, size16);

usbBufIndex += size16;

ethBufIndex += size16;

addressStrobe();

}


//---------------------

// TCP BLOCK

//---------------------

if((ethShifting > -1) && clientRcvdACK)

{

tcpClientSendData(UserTxBufferFS+((tick*size16)-ethBufSize), ethBufSize);

ethShifting = -1;

}


if(ethBufIndex == ethBufSize && connectedToServer)

{

if(ethShifting == -1)// && clientRcvdACK)

{

ethShifting = (tick*size16) - ethBufSize;

ethBufIndex = 0;

}

else if(!clientRcvdACK)

{

//ACK after last transfering is not received or

//data have not been sent yet!

//This means something is wrong,

//Transfering of this sample should be aborted.

ethShifting == -2;

}

}


//---------------------

// USB BLOCK

//---------------------

if(usbBufIndex == usbBufSize && usbConnected)

{

CDC_Transmit_FS(UserTxBufferFS, sizeof(UserTxBufferFS));

ticksDelay(hDelay);

usbBufIndex = 0;

}


//---------------------

// FINAL BLOCK

//---------------------

if(tick == sampleSize)

{


usbBufIndex = 0;

ethBufIndex = 0;

ethShifting = -1;

FPGA_Signal = 0;

tick = 0;

rstStausReadingData();

}

}

}

Так же в этом разделе:
  • Sample Receiving
  • 2
 
MyTetra Share v.0.53
Яндекс индекс цитирования