PIC18F BootLoader
Macros | Typedefs | Enumerations | Functions | Variables
system.h File Reference

The functions are declared and defined state enumerations. More...

#include <xc.h>
#include <p18f4431.h>
#include <string.h>
#include <stdlib.h>
Include dependency graph for system.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NVM_ROW_SIZE   8
 
#define NVM_PAGE_SIZE   64
 
#define NVM_START_ADDRESS   0x00
 
#define NVM_END_ADDRESS   0x3fff
 

Typedefs

typedef unsigned char uint8_t
 
typedef unsigned short uint16_t
 
typedef unsigned long uint32_t
 
typedef enum SYSTEM_STATUS_Tag SYS_STATE_t
 Enumeral represents different system states.
 
typedef enum SYSTEM_COM_PROTOCOL_MSG_Tag SYS_COM_PROTOCL_MSG_t
 Enumeral represents handshaking signals between programmer and controller.
 

Enumerations

enum  SYSTEM_STATUS_Tag {
  SYS_WAIT_FOR_START_CMND, SYS_CONFIG_FLASH, SYS_RCV_FIRMWARE_HEADER, SYS_FIRMWARE_UPDATE,
  SYS_RUN_APPLCN, SYS_SND_ADDRS_RANGE
}
 Enumeral represents different system states. More...
 
enum  SYSTEM_COM_PROTOCOL_MSG_Tag {
  SYS_START_CMND_FROM_PROGRMR = 0x01, SYS_READY_FOR_FIRMWARE_HEADER, SYS_FIRMWARE_HEADER_POS_ACK, SYS_FIRMWARE_HEADER_NEG_ACK,
  SYS_SND_NXT_CHUNK, SYS_ADDRESS_RANGE_TAG, SYS_ADDRESS_RANGE_RQT
}
 Enumeral represents handshaking signals between programmer and controller. More...
 

Functions

void runStateMachine (void)
 function executes different states of the system. SYS_SND_ADDRS_RANGE - Send the PIC programmable start and end address of the program memory SYS_WAIT_FOR_START_CMND - The Start command triggers system to start the process and initializes buffer counter SYS_RCV_FIRMWARE_HEADER - Get the total packet count from the host and applcn start address SYS_CONFIG_FLASH - Erase application program area and update table pointer SYS_FIRMWARE_UPDATE - Receive and put the binary chunks in the flash memory SYS_RUN_APPLCN - Run the application
 
void initVarConfigPort (void)
 function configures and initializes IO ports.
 
void runApplcn (void)
 PC is updated with the new pointer to execute loaded binary from the application flash program memory.
 

Variables

uint16_t applStartAdd
 
uint8_t totalNumberOfPacckets
 
uint8_t progMemRange []
 

Detailed Description

The functions are declared and defined state enumerations.

Author
Mallikarjun Tirlapur
Date
16 May, 2016

Macro Definition Documentation

◆ NVM_END_ADDRESS

#define NVM_END_ADDRESS   0x3fff

NVM end adress.

◆ NVM_PAGE_SIZE

#define NVM_PAGE_SIZE   64

NVM each page size 64 bytes.

◆ NVM_ROW_SIZE

#define NVM_ROW_SIZE   8

NVM each row size 8 bytes.

◆ NVM_START_ADDRESS

#define NVM_START_ADDRESS   0x00

NVM start adress.

Typedef Documentation

◆ uint16_t

typedef unsigned short uint16_t

typedef for unsigned short.

◆ uint32_t

typedef unsigned long uint32_t

typedef for unsigned long.

◆ uint8_t

typedef unsigned char uint8_t

typedef for unsigned char.

Enumeration Type Documentation

◆ SYSTEM_COM_PROTOCOL_MSG_Tag

Enumeral represents handshaking signals between programmer and controller.

Enumerator
SYS_START_CMND_FROM_PROGRMR 

Config command signal from the programmer.

SYS_READY_FOR_FIRMWARE_HEADER 

Ready for firmware header signal sent to the programmer.

SYS_FIRMWARE_HEADER_POS_ACK 

Firmware header positive acknowledgement.

SYS_FIRMWARE_HEADER_NEG_ACK 

Firmware header negative acknowledgement.

SYS_SND_NXT_CHUNK 

send next chunk signal.

SYS_ADDRESS_RANGE_TAG 

send address with this tag.

SYS_ADDRESS_RANGE_RQT 

Rquest for the address from the host.

◆ SYSTEM_STATUS_Tag

Enumeral represents different system states.

Enumerator
SYS_WAIT_FOR_START_CMND 

State where system waits for a start command from the programmer.

SYS_CONFIG_FLASH 

State where system configs flash

SYS_RCV_FIRMWARE_HEADER 

State where system waits for firmware header from the programmer

SYS_FIRMWARE_UPDATE 

State where system loads the binary into the NVM

SYS_RUN_APPLCN 

State where system jumps to the application

SYS_SND_ADDRS_RANGE 

State where the system sends the PIC programmable start and end address of the program memory

Variable Documentation

◆ applStartAdd

uint16_t applStartAdd

Application start address.

◆ progMemRange

uint8_t progMemRange[]
Initial value:
(uint8_t)((NVM_END_ADDRESS & 0xff000000) >> 24),
(uint8_t)((NVM_END_ADDRESS & 0x00ff0000) >> 16),
(uint8_t)((NVM_END_ADDRESS & 0x0000ff00) >> 8),
(uint8_t)(NVM_END_ADDRESS & 0x000000ff),
(uint8_t)((NVM_START_ADDRESS & 0xff000000) >> 24),
(uint8_t)((NVM_START_ADDRESS & 0x00ff0000) >> 16),
(uint8_t)((NVM_START_ADDRESS & 0x0000ff00) >> 8),
(uint8_t)(NVM_START_ADDRESS & 0x000000ff)}
Definition: system.h:94
#define NVM_PAGE_SIZE
Definition: system.h:58
#define NVM_END_ADDRESS
Definition: system.h:61
unsigned char uint8_t
Definition: system.h:53
#define NVM_START_ADDRESS
Definition: system.h:60

◆ totalNumberOfPacckets

uint8_t totalNumberOfPacckets

Variable holds the (size of the firmware/64) in bytes.