-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.h
97 lines (89 loc) · 4.04 KB
/
Main.h
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
/*********************************************************************
*
* Headers for TCPIP Demo App
*
*********************************************************************
* FileName: MainDemo.h
* Dependencies: Compiler.h
* Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32
* Compiler: Microchip C32 v1.05 or higher
* Microchip C30 v3.12 or higher
* Microchip C18 v3.30 or higher
* HI-TECH PICC-18 PRO 9.63PL2 or higher
* Company: Microchip Technology, Inc.
*
* Software License Agreement
*
* Copyright (C) 2002-2010 Microchip Technology Inc. All rights
* reserved.
*
* Microchip licenses to you the right to use, modify, copy, and
* distribute:
* (i) the Software when embedded on a Microchip microcontroller or
* digital signal controller product ("Device") which is
* integrated into Licensee's product; or
* (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h,
* ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device
* used in conjunction with a Microchip ethernet controller for
* the sole purpose of interfacing with the ethernet controller.
*
* You should refer to the license agreement accompanying this
* Software for additional information regarding your rights and
* obligations.
*
* THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
* WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
* LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
* PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
* BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
* THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
* SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
* (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
*
*
* Author Date Comment
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* E. Wood 4/26/08 Copied from MainDemo.c
********************************************************************/
#define TRISOUT 0
#define TRISINP 1
#define ON 1
#define OFF 0
#define LOW 0
#define HIGH 1
#define TRUE 1
#define FALSE 0
#define BOARDLED_TRIS TRISBbits.TRISB3 // LED on RB3
#define BOARDLED LATBbits.LATB3 // Use LAT for outputs
#define BOARDSW_TRIS TRISDbits.TRISD0
#define BOARDSW PORTDbits.RD0 // Use PORT for inputs
#define BOARDAUXPWR_TRIS TRISDbits.TRISD1
#define BOARDAUXPWR LATDbits.LATD1
#ifndef _MAINDEMO_H
#define _MAINDEMO_H
#define BAUD_RATE (19200) // bps
#if defined(EEPROM_CS_TRIS) || defined(SPIFLASH_CS_TRIS)
void SaveAppConfig(const APP_CONFIG *AppConfig);
#else
#define SaveAppConfig(a)
#endif
void PingDemo(void);
//void GenericTCPClient(void);
//void GenericTCPServer(void);
char StartSocketsClient(const char *, WORD Portnum);
int SendStr(char SvrSock, BYTE String[]);
int SendInt(BYTE SvrSock, BYTE byteArr[], BYTE len);
void BerkeleyTCPServerDemo(void);
void BerkeleyUDPClientDemo(void);
void MQTTClientTask(void);
// Define a header structure for validating the AppConfig data structure in EEPROM/Flash
typedef struct
{
unsigned short wConfigurationLength; // Number of bytes saved in EEPROM/Flash (sizeof(APP_CONFIG))
unsigned short wOriginalChecksum; // Checksum of the original AppConfig defaults as loaded from ROM (to detect when to wipe the EEPROM/Flash record of AppConfig due to a stack change, such as when switching from Ethernet to Wi-Fi)
unsigned short wCurrentChecksum; // Checksum of the current EEPROM/Flash data. This protects against using corrupt values if power failure occurs while writing them and helps detect coding errors in which some other task writes to the EEPROM in the AppConfig area.
} NVM_VALIDATION_STRUCT;
#endif // _MAINDEMO_H