1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#include <Container.h>
#include <DataDef.h>
#include <PMR/Stubs/StubFPGAReadBackRegRequest.pb-c.h>
#include <PMR/Stubs/StubFPGAReadBackRegResponse.pb-c.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_uart.h"
#include "Drivers/USB_Communication/USBCDCD.h"
#include "MessageContainer.pb-c.h"
#include "Stub_Status.h"
#include "drivers/FPGA/FPGA.h"
void Stub_FPGAReadBackRegRequest(MessageContainer* requestContainer)
{
uint32_t status = FAILED;
unsigned short ReadBack_Value;
MessageContainer responseContainer;
StubFPGAReadBackRegRequest* request = stub_fpgaread_back_reg_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
status = FPGA_Test_ReadBack((unsigned char) request->fpgaid, (unsigned short) request->value, &ReadBack_Value);
StubFPGAReadBackRegResponse response = STUB_FPGAREAD_BACK_REG_RESPONSE__INIT;
status_response(status,&response.status, &response.statusword ,&response.has_statusword);
response.fpgaid = request->fpgaid;
response.has_fpgaid = true;
response.readbackvalue = ReadBack_Value;
response.has_readbackvalue = true;
responseContainer = createContainer(MESSAGE_TYPE__StubFPGAReadBackRegResponse, requestContainer->token, true, &response, &stub_fpgaread_back_reg_response__pack, &stub_fpgaread_back_reg_response__get_packed_size);
//free(request);
stub_fpgaread_back_reg_request__free_unpacked(request,NULL);
//-------------------------------------------------------------------------------------------
uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
size_t container_size = message_container__pack(&responseContainer, container_buffer);
free(responseContainer.data.data);
SendChars((char*)container_buffer, container_size);
//free(container_buffer);
//free(requestContainer);
}
|