-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
77 lines (62 loc) · 3.5 KB
/
main.c
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
/******************************************************************************/
/* Files to Include */
/******************************************************************************/
#ifdef __XC32
#include <xc.h> /* Defines special funciton registers, CP0 regs */
#endif
#include <plib.h> /* Include to use PIC32 peripheral libraries */
#include <stdint.h> /* For uint32_t definition */
#include <stdbool.h> /* For true/false definition */
#include "system.h" /* System funct/params, like osc/periph config */
#include "user.h" /* User funct/params, such as InitApp */
#include "CommandEngine.h"
/******************************************************************************/
/* Global Variable Declaration */
/******************************************************************************/
/* i.e. uint32_t <variable_name>; */
/******************************************************************************/
/* Main Program */
/******************************************************************************/
int32_t main(void)
{
#ifndef PIC32_STARTER_KIT
/*The JTAG is on by default on POR. A PIC32 Starter Kit uses the JTAG, but
for other debug tool use, like ICD 3 and Real ICE, the JTAG should be off
to free up the JTAG I/O */
DDPCONbits.JTAGEN = 0;
#endif
/*Refer to the C32 peripheral library documentation for more
information on the SYTEMConfig function.
This function sets the PB divider, the Flash Wait States, and the DRM
/wait states to the optimum value. It also enables the cacheability for
the K0 segment. It could has side effects of possibly alter the pre-fetch
buffer and cache. It sets the RAM wait states to 0. Other than
the SYS_FREQ, this takes these parameters. The top 3 may be '|'ed
together:
SYS_CFG_WAIT_STATES (configures flash wait states from system clock)
SYS_CFG_PB_BUS (configures the PB bus from the system clock)
SYS_CFG_PCACHE (configures the pCache if used)
SYS_CFG_ALL (configures the flash wait states, PB bus, and pCache)*/
/* TODO Add user clock/system configuration code if appropriate. */
SYSTEMConfig(SYS_FREQ, SYS_CFG_ALL);
/* Initialize I/O and Peripherals for application */
InitApp();
/*Configure Multivector Interrupt Mode. Using Single Vector Mode
is expensive from a timing perspective, so most applications
should probably not use a Single Vector Mode*/
INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
INTEnableInterrupts();
CurrentCommandEngine.WriteToOutput(CMD_CRLF CMD_MAKEGREEN);
CurrentCommandEngine.WriteToOutput(CMD_MAKEBOLD);
CurrentCommandEngine.WriteToOutput("***********************************************************************" CMD_CRLF);
CurrentCommandEngine.WriteToOutput("**" CMD_MAKEWHITE);
CurrentCommandEngine.WriteToOutput(" PIC32-ESP8266 Terminal");
CurrentCommandEngine.WriteToOutput(CMD_MAKEGREEN CMD_CRLF);
CurrentCommandEngine.WriteToOutput("***********************************************************************" CMD_CRLF);
CurrentCommandEngine.WriteToOutput(CMD_CLEARATTRIBUTES CMD_CRLF);
CurrentCommandEngine.WriteToOutput("Press help to start." CMD_CRLF CMD_CRLF);
while(1)
{
DoTasks(&CurrentCommandEngine);
}
}