PIC18F BootLoader
system.h
Go to the documentation of this file.
1 /*
2  * The MIT License
3  *
4  * Copyright(c) 2016 Mallikarjun Tirlapur.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
32 #ifndef SYSTEM_H
33 #define SYSTEM_H
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 #include <xc.h>
39 #include <p18f4431.h>
40 #include <string.h>
41 #include <stdlib.h>
42 
43 #pragma config OSC = HS
44 #pragma config WDTEN = OFF
45 #pragma config MCLRE = ON
46 #pragma config CPD = OFF
47 #pragma config BOREN = ON
48 #pragma config IESO = ON
49 #pragma config FCMEN = ON
50 #pragma config STVREN = ON
51 #pragma config LVP = ON
52 
53 typedef unsigned char uint8_t;
54 typedef unsigned short uint16_t;
55 typedef unsigned long uint32_t;
57 #define NVM_ROW_SIZE 8
58 #define NVM_PAGE_SIZE 64
60 #define NVM_START_ADDRESS 0x00
61 #define NVM_END_ADDRESS 0x3fff
63 uint16_t applStartAdd;
65 void runStateMachine(void);
66 
67 void initVarConfigPort(void);
68 
69 void runApplcn(void);
70 
76 typedef enum SYSTEM_STATUS_Tag {
83 } SYS_STATE_t;
84 
97 
98 
99 uint8_t progMemRange[] = {SYS_ADDRESS_RANGE_TAG, NVM_PAGE_SIZE,
100  (uint8_t)((NVM_END_ADDRESS & 0xff000000) >> 24),
101  (uint8_t)((NVM_END_ADDRESS & 0x00ff0000) >> 16),
102  (uint8_t)((NVM_END_ADDRESS & 0x0000ff00) >> 8),
103  (uint8_t)(NVM_END_ADDRESS & 0x000000ff),
104  (uint8_t)((NVM_START_ADDRESS & 0xff000000) >> 24),
105  (uint8_t)((NVM_START_ADDRESS & 0x00ff0000) >> 16),
106  (uint8_t)((NVM_START_ADDRESS & 0x0000ff00) >> 8),
107  (uint8_t)(NVM_START_ADDRESS & 0x000000ff)};
108 
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif /* SYSTEM_H */
115 
SYSTEM_COM_PROTOCOL_MSG_Tag
Enumeral represents handshaking signals between programmer and controller.
Definition: system.h:88
Definition: system.h:94
Definition: system.h:95
#define NVM_PAGE_SIZE
Definition: system.h:58
SYSTEM_STATUS_Tag
Enumeral represents different system states.
Definition: system.h:76
Definition: system.h:81
unsigned short uint16_t
Definition: system.h:54
#define NVM_END_ADDRESS
Definition: system.h:61
unsigned char uint8_t
Definition: system.h:53
Definition: system.h:80
Definition: system.h:93
Definition: system.h:79
Definition: system.h:92
void runApplcn(void)
PC is updated with the new pointer to execute loaded binary from the application flash program memory...
Definition: main.c:67
Definition: system.h:91
void initVarConfigPort(void)
function configures and initializes IO ports.
Definition: main.c:51
unsigned long uint32_t
Definition: system.h:55
Definition: system.h:78
Definition: system.h:90
Definition: system.h:77
#define NVM_START_ADDRESS
Definition: system.h:60
enum SYSTEM_COM_PROTOCOL_MSG_Tag SYS_COM_PROTOCL_MSG_t
Enumeral represents handshaking signals between programmer and controller.
enum SYSTEM_STATUS_Tag SYS_STATE_t
Enumeral represents different system states.
Definition: system.h:89
uint8_t totalNumberOfPacckets
Definition: system.h:71
Definition: system.h:82