📄 bootldr.h
字号:
#ifndef _BOOTLDR_H_#define _BOOTLDR_H_/* must be <= 9 */#define BOOT_TIMEOUT 5#define FILL_BYTE 0xFF#ifndef PROG_START #ifdef VERBOSE #define PROG_START 0x300 #else #define PROG_START 0x200 #endif#endif/* definition ROMSIZE found in chip specific header file */#if !defined(MPLAB_ICD) #define MEM_TOP (_ROMSIZE&0xFFFF) #if _ROMSIZE >= 65536 #define UPPER_ADDRESS_BYTE ((_ROMSIZE>>16)&0xFF) #endif#else // Don't bootload over ICD reserved region #define MEM_TOP (_ICDROM_START&0xFFFF) #if (_ICDROM_START) > 65536 #define UPPER_ADDRESS_BYTE ((_ICDROM_START>>16)&0xFF) #endif#endif#if !defined(MEM_TOP) #error Could not determine program memory size.#endif// Serial communication settings#define BAUD 9600 #define FOSC 4000000L#define NINE 0 /* Use 9bit communication? FALSE=8bit */#define OUTPUT 0#define INPUT 1#define DIVIDER ((int)(FOSC/(16UL * BAUD) -1))#define HIGH_SPEED 1#if NINE == 1#define NINE_BITS 0x40#else#define NINE_BITS 0#endif#if HIGH_SPEED == 1#define SPEED 0x4#else#define SPEED 0#endif/* Serial initialization */#define init_comms() \ { \ SPBRG = DIVIDER; \ TXSTA = (SPEED|NINE_BITS|0x20); \ RCSTA = (NINE_BITS|0x90); \ TRISC=0x80; \ }/* Most flash devices write in 8 byte widths, * newer parts can write 32 or 64 bytes at a time. * If these haven't been defined by user, use defaults. */#ifndef _FLASH_WRITE_SIZE #define _FLASH_WRITE_SIZE 8#endif#ifndef _FLASH_ERASE_SIZE #define _FLASH_ERASE_SIZE 64#endif// Check to see that legitimate values have been entered#define _POW2(a) (((a)&((a)-1))==0)#define _NOT_POW2(a) (! _POW2(a)) #if _NOT_POW2(_FLASH_WRITE_SIZE) || (_FLASH_WRITE_SIZE == 0) || (_FLASH_WRITE_SIZE > 128)#error Invalid definition of _FLASH_WRITE_SIZE, must be a power of two ranging from 1 to 128#endif#if _NOT_POW2(_FLASH_ERASE_SIZE) || (_FLASH_ERASE_SIZE == 0) || (_FLASH_ERASE_SIZE > 128)#error Invalid definition of _FLASH_ERASE_SIZE, must be a power of two ranging from 1 to 128#endif#ifndef NOP()#define NOP() asm("nop")#endif#ifndef RESET()#define RESET() asm("reset")#endif/* test conditions */#define FLASH EEPGD==1#define EEPROM EEPGD==0#define CONFIG CFGS==1/* hex record types */#define DATA 0#define END 1#define EXTEND_ADDRESS 4#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -