00001
00002
00003
00016
00017
00018
00019
00020 #define MAIN_C
00021
00022 #include "main.h"
00023 #include "mdns.h"
00024 #include "sralloc.h"
00025
00026
00027
00028
00029
00030
00031
00032 void main()
00033 {
00034 u16GlobalFlags = 0;
00035
00036
00037 OSCTUNE = 0x40;
00038
00039 INTCON = 0;
00040
00041 TickInit();
00042
00043 RCONbits.IPEN = 1;
00044 INTCONbits.GIEL = 1;
00045 INTCONbits.GIEH = 1;
00046
00047
00048 OutInit();
00049
00050
00051
00052 #ifdef EEPROM_ERASE
00053 XEEEraseEEPROM( );
00054 #endif
00055
00056
00057 SRAMInitHeap();
00058
00059
00060 MPFSInit();
00061
00062
00063 InputInit();
00064
00065
00066 ApplInit();
00067
00068
00069 MACInit();
00070
00071 while(ApplIsRunning() == TRUE)
00072 {
00073 if (u16GlobalFlags & LINKISUP_MASK)
00074 {
00075
00076
00077
00078 StackTask();
00079
00080 StackApplications();
00081
00082
00083 MDNSResponder();
00084 }
00085
00086 ApplMain();
00087
00088 OutMain();
00089 }
00090
00091
00092
00093 OutSwitchOffLCD();
00094 OutSwitchOffAllLEDs();
00095 MACPowerDown();
00096
00097
00098 if (u16GlobalFlags & FACRES_MASK)
00099 {
00100 ApplResetToFactory(FALSE);
00101 }
00102 else if (!(u16GlobalFlags & RESTART_MASK))
00103 {
00104
00105 ApplStop();
00106 }
00107 else if (u16GlobalFlags & BOOTLOADER_MASK)
00108 {
00109
00110 BootupEnterBootloader();
00111 RCONbits.NOT_POR = 0;
00112 Reset();
00113 }
00114
00115 RCONbits.POR = 1;
00116 Reset();
00117 }
00118
00119
00120
00121
00123
00125
00126 #pragma interruptlow _peripheralTimerISR
00127
00128 void _peripheralTimerISR(void)
00129 {
00130 InputInterruptHandler();
00131
00132 OutInterruptHandler();
00133 }
00134
00135
00136
00137
00138 #pragma code low_vector=0x18
00139 void low_interrupt(void)
00140 {
00141 _asm GOTO _peripheralTimerISR _endasm
00142 }
00143
00144 #pragma code
00145
00146
00147