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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
#include <Container.h>
#include "include.h"
/*#include <stdbool.h>
#include <stdio.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
//#include <ti/drivers/USBMSCHFatFs.h>
#include <driverlib/sysctl.h>
#include <driverlib/interrupt.h>
#include <driverlib/rom_map.h>
#include <ti/sysbios/knl/Semaphore.h>
*/
#include <driverlib/sysctl.h>
#include "Drivers/USB_Communication/USBCDCD.h"
#include "Drivers/I2C_Communication/I2C.h"
#include "PMR/common/MessageContainer.pb-c.h"
#include "Common/Sys_PinOut_Config/Pin.h"
#include "Common/Sys_PinOut_Config/Pin_config.h"
#include "Common/utilities/idle_task.h"
#include "Drivers/ADC_Sampling/ADC.h"
#include "drivers/Heater/Heater.h"
#include "drivers/Motors/Motor.h"
#include "Communication/CommunicationTask.h"
#include <drivers/Flash_Memory/Flash_Memory.h>
#include "drivers/Flash_ram/FlashProgram.h"
#include <DataDef.h>
#include "Sys_PinOut_Config/MCU_MAIN_pinout.h"
/*
#include "Drivers/SPI_SDCARD/SDSPI.h"
#include "Drivers/SPI_SDCARD/SDCardSPI.h"
#include "Drivers/Ethernet_Config/EMACCommon.h"
#include "Drivers/USBStick_FileSys/USBstick.h"
#include "Drivers/USBStick_FileSys/USBMSCHFatFs.h"
*/
#include "Modules/Control/control.h"
#include "Modules/Control/MillisecTask.h"
#include "Modules/Heaters/Heaters_ex.h"
#include "Modules/Ids/Ids_ex.h"
#include "StateMachines/Printing/PrintingSTM.h"
#include "StateMachines/Initialization/InitSequence.h"
#include "StateMachines/Initialization/PowerIdle.h"
#include <Drivers/SSI_Comm/SSI_Comm.h>
#include "drivers/SPI/SPI_Comm.h"
#include "drivers/Uart_Comm/Uart.h"
#include "drivers/valves/valve.h"
#include "drivers/FPGA/FPGA.h"
#include <drivers/FPGA/FPGA_Comm.h>
#include <drivers/FPGA/FPGA_INTERRUPTS/fpga_interrupts.h>
#include "Drivers/I2C_Communication/I2C.h"
#include "Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.h"
#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h"
#include "drivers/Flash_Memory/FATFS/ff.h"
#include "drivers/Flash_Memory/FATFS/Control_File_System.h"
#include "Modules/General/buttons.h"
#include "Modules/Waste/Waste.h"
//#define WATCHDOG
//*****************************************************************************
//
// The system tick rate expressed both as ticks per second and a millisecond
// period.
//
//*****************************************************************************
#define TICKS_PER_SECOND 1000
//*****************************************************************************
//
// Global system tick counter
//
//*****************************************************************************
static volatile uint32_t g_ui32SysTickCount = 0;
// Flags used to pass commands from interrupt context to the main loop.
static volatile uint32_t g_ui32Flags;
bool Machine_Idle_Mode = false;
F2_CTRL_REG F2_CTRL_Reg;
F1_GPO_REG F1_GPO_Reg;
F3_GPO_01_REG F3_GPO_01_Reg;
//MessageContainer createContainer(MessageType type, char* token, protobuf_c_boolean completed, void* response, size_t (*packPtr)(void*, uint8_t*), size_t (*sizePtr)(void*));
uint32_t MainDummyFunction(uint32_t IfIndex, uint32_t ReadValue)
{
return OK;
}
uint32_t HWControlId;
uint32_t MainHWInitCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag)
{
RemoveControlCallback(HWControlId, MainHWInitCallBackFunction );
HWConfigurationInit();
return OK;
}
//*****************************************************************************
//
// Interrupt handler for the system tick counter.
//
//*****************************************************************************
void SysTickHandler(void)
{
// Update our system time.
g_ui32SysTickCount++;
}
void Init_EVB()
{
InitPinOutPullUps();
#ifdef Stub_Mode
//MOTOR Driver L6470 SPI
SPI2_Init();
init_BUSY_Pin();
//Danser_ENC:
SSI1_Init(); // Read dancer ENC SSI
#endif
}
int main(void)
{
// Enable interrupts to the processor.
//
ROM_IntMasterDisable();
//Set the clock 120MHz
uint32_t ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), SYS_CLK_FREQ);
// Enable the system tick.
ROM_SysTickPeriodSet(ui32SysClock / TICKS_PER_SECOND);
ROM_SysTickIntEnable();
ROM_SysTickEnable();
// FlashInit();
Calculateinit();
PortFunctionInit();
#ifdef EVALUATION_BOARD
Init_EVB();
#endif
Init_All_I2C();
#ifndef EVALUATION_BOARD
STATUS_GREEN_LED_ON;
FPGA_Init();
#endif
MAP_FPULazyStackingEnable();
SysCtlUSBPLLEnable();
#ifndef EVALUATION_BOARD
DeActivateAllSSR();
Control_Dryer_Fan(STOP,0);//Preventing unwanted movement at power up, since the default from FPGA is "0" (= START)
#endif
#ifdef WATCHDOG
InitWatchdog(ui32SysClock);
#endif
CommunicationTaskInit();
utilsInit(ui32SysClock);
#ifndef EVALUATION_BOARD
//Turn_the_Blower_On();//Turn on with the Default_Voltage
ActivateChiller();//SSR12
//ActivateHeadMagnet();
#endif
//EMAC_initEMAC();
ControlInit();
MillisecInit();
ControlStart();
Heaters_Init();
MotorsInit();
//Shai WHS_HW_test(); // for WHS sensor test
// WHS_init();
Buttons_Init();
//IDS_ModuleInit();
Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste);
////////////////////////////
Check_Dispenser_Type();
//FPGA_Read_limit_Switches_Registers();
//calibration(); //test vme communication
FRESULT iFResult = Init_Flash_File_System(false);
if(iFResult != FR_OK)
{
LOG_ERROR (iFResult, "Error during init Flash File System");
assert(iFResult);
}
//Control_File_System();// test file system
//IDS_ModuleInit();
//GetFiles(); - to start jtag
//GetVmeByte();
//I2C_NFC_Test();
//
//test_avi(); //example for shai
Set_Speed_Sensor_TypeII_Registers(2,2);//set default values
//Read_Speed_Sensor_TypeII();//must be delay between Set_Speed_Sensor_TypeII_Registers to Read_Speed_Sensor_TypeII
//Test_ADS120_Internal_Temperature_Sensor(0);
#ifndef EVALUATION_BOARD
Init_Machine_Leds();
#endif
// Enable interrupts to the processor.
//
ROM_IntMasterEnable();
IDLE_TASK_package_init();
// HWControlId = AddControlCallback( MainHWInitCallBackFunction, 2* eOneSecond/*eHundredMillisecond*/, MainDummyFunction,0,0, 0 );
Start_InitSequence();
PowerIdleInit();
BIOS_start();
return (0);
//while(1){};
}
|