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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
#include <Container.h>
#include <DataDef.h>
#include <Drivers/FPGA/Motors_Driver/L6470.h>
#include <PMR/Stubs/StubL6470DriverResponse.pb-c.h>
#include <PMR/Stubs/StubL6470DriverRequest.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 "MessageContainer.pb-c.h"
#include "Stub_Status.h"
//#include "drivers/FPGA/FPGA.h"
#include "drivers/SPI/SPI_Comm.h"
#include "driverlib/ssi.h"
/*
unsigned long Run_Value = 136902 ;
unsigned long Pos_Value;
unsigned long Mov_Value ;
bool Direction ;
unsigned long Time_2_Change_Direction ;
bool Display_Tx_ON_LCD;
bool Display_Rx_on_LCD;
unsigned long Init_MicroStep ;
unsigned long Init_Acc;
unsigned long Init_Dec;
bool TestBool_1;
bool TestBool_2;
bool TestBool_3;
bool TestBool_4;
bool TestBool_5;
unsigned long TestUint32_1;
unsigned long TestUint32_2;
unsigned long TestUint32_3;
unsigned long TestUint32_4;
unsigned long TestUint32_5;
unsigned long TestUint32_6;
*/
extern unsigned long Run_Value ;
extern unsigned long Mov_Value ;
extern unsigned long Pos_Value;
extern bool Direction ;
extern unsigned long Time_2_Change_Direction ;
extern bool Display_Tx_ON_LCD;
extern bool Display_Rx_on_LCD;
extern unsigned long Init_MicroStep ;
extern unsigned long Init_Acc;
extern unsigned long Init_Dec;
extern bool TestBool_1;
extern bool TestBool_2;
extern bool TestBool_3;
extern bool TestBool_4;
extern bool TestBool_5;
extern unsigned long TestUint32_1;
extern unsigned long TestUint32_2;
extern unsigned long TestUint32_3;
extern unsigned long TestUint32_4;
extern unsigned long TestUint32_5;
extern unsigned long TestUint32_6;
void Stub_L6470DriverRequest(MessageContainer* requestContainer)
{
uint32_t status = PASSED;
MessageContainer responseContainer;
StubL6470DriverRequest* request = stub_l6470_driver_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
Run_Value = request->run_value;
Mov_Value = request->mov_value;
Direction = request->direction;
Time_2_Change_Direction = request->time_2_change_direction;
Display_Tx_ON_LCD = request->display_tx_on_lcd;
Display_Rx_on_LCD = request->display_rx_on_lcd;
Init_MicroStep = request->init_microstep;
Init_Acc = request->init_acc;
Init_Dec = request->init_dec;
TestBool_1 = request->testbool_1;
TestBool_2 = request->testbool_2;
TestBool_3 = request->testbool_3;
TestBool_4 = request->testbool_4;
TestBool_5 = request->testbool_5;
TestUint32_1 = request->testuint32_1;
TestUint32_2 = request->testuint32_2;
TestUint32_3 = request->testuint32_3;
TestUint32_4 = request->testuint32_4;
TestUint32_5 = request->testuint32_5;
TestUint32_6 = request->testuint32_6;
//status = FPGA_ReadVersion((unsigned char)request->fpgaid, &Version, &Year, &Month, &Day);
//SPI_Control(INIT);
//temp_init_spi2();
StubL6470DriverResponse response = STUB_L6470_DRIVER_RESPONSE__INIT;
status_response(status,&response.status, &response.statusword ,&response.has_statusword);
//response.run_value = Get_Param(x_SPEED);
/*
response.mov_value = ;
response.day = Day;
response.has_day = true;
response.month = Month;
response.has_month = true;
response.year = Year;
response.has_year = true;
response.ver_num = Version;
response.has_ver_num = true;
*/
responseContainer = createContainer(MESSAGE_TYPE__StubL6470DriverResponse, requestContainer->token, true, &response, &stub_l6470_driver_response__pack, &stub_l6470_driver_response__get_packed_size);
//free(request);
//-------------------------------------------------------------------------------------------
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);
stub_l6470_driver_request__free_unpacked(request,NULL);
//StartUSB(ui32SysClock); //todo to test the USB comm problem after using 6470
}
|