aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Main.c
blob: 4d828b0eaf03811ff8a5fca8b468daf8a15f3161 (plain)
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
#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 <Modules/Stubs_Handler/DataDef.h>
#include "drivers/twine_usblib/usb_serial_adapter.h"
#include "PMR/common/MessageContainer.pb-c.h"
#include "Common/Sys_PinOut_Config/Pin.h"
#include "Common/Sys_PinOut_Config/Pin_config.h"
#include "Drivers/ADC_Sampling/ADC.h"
#include "Drivers/Peripheral_GPIO/GPIO.h"
#include "Modules/Stubs_Handler/Container.h"

#include "drivers/twine_graphicslib/graphics_adapter.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 "StateMachines/Printing/PrintingSTM.h"
extern Semaphore_Handle sdCardSem;
//#define WATCHDOG

int main(void)
{
	//Set the clock 120MHz
	uint32_t ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), SYS_CLK_FREQ);
    // Set the system clock to run at 120MHz from the PLL.

    // Save the PLL rate used by this application.
    //SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate);

    // Enable the system tick.
    ROM_SysTickPeriodSet(ui32SysClock / TICKS_PER_SECOND);
    ROM_SysTickIntEnable();
    ROM_SysTickEnable();

	PortFunctionInit();

	InitPinOutPullUps();

	// Enable interrupts to the processor.
	//
	MAP_IntMasterEnable();

	//
	// Enable lazy stacking for interrupt handlers.  This allows floating-point
	// instructions to be used within interrupt handlers, but at the expense of
	// extra stack usage.
	//
	MAP_FPULazyStackingEnable();

    SysCtlUSBPLLEnable();

#ifdef WATCHDOG
	InitWatchdog(ui32SysClock);
#endif

    utilsInit(ui32SysClock);
    init_graphics(ui32SysClock);
    clear();

    RegisterReceiveCallback(&receive_callback);
    StartUSB(ui32SysClock);
    //messageHostInit();
	//InitUSBMSCHFatFs();

	//EMAC_initEMAC();
    ControlInit();
    JobInit();
    PrintingsInit();
	//LoadManual();
	//Semaphore_post(sdCardSem);


    BIOS_start();

    return (0);
}