📄 isp.h
字号:
/*
isp.h - part of USBasp
Autor..........: Thomas Fischl <tfischl@gmx.de>
Description....: Provides functions for communication/programming
over ISP interface
Licence........: GNU GPL v2 (see Readme.txt)
Creation Date..: 2005-02-23
Last change....: 2007-07-23
*/
#ifndef __isp_h_included__
#define __isp_h_included__
#define ISP_OUT PORTB
#define ISP_IN PINB
#define ISP_DDR DDRB
/*注意由于26是用USI仿SPI所以
*与目标MISO、MOSI是交叉连的这点与M8不同*/
/*DI*/
#define ISP_MISO PB0
/*DO*/
#define ISP_MOSI PB1
#define ISP_SCK PB2
#define ISP_RST PB3
#define selectFAST PA3
#ifndef __ASSEMBLER__
#ifndef uchar
#define uchar unsigned char
#endif
void wait64us(void);
/* Prepare connection to target device */
static inline void ispConnect(void){
/* all ISP pins are inputs before */
/* now set output pins */
ISP_DDR |= (1 << ISP_RST) | (1 << ISP_SCK) | (1 << ISP_MOSI);
/* reset device */
ISP_OUT &= ~(1 << ISP_RST); /* RST low */
ISP_OUT &= ~(1 << ISP_SCK); /* SCK low */
/* positive reset pulse > 2 SCK (target) */
wait64us();
ISP_OUT |= (1 << ISP_RST); /* RST high */
wait64us();
ISP_OUT &= ~(1 << ISP_RST); /* RST low */
}
/* Close connection to target device */
static inline void ispDisconnect(void) {
/* set all ISP pins inputs */
ISP_DDR &= ~((1 << ISP_RST) | (1 << ISP_SCK) | (1 << ISP_MOSI));
/* switch pullups off */
ISP_OUT &= ~((1 << ISP_RST) | (1 << ISP_SCK) | (1 << ISP_MOSI));
}
/* read an write a byte from isp using software (slow) */
unsigned long ispTransmit32(unsigned long l_send);
/* enter programming mode */
uchar ispEnterProgrammingMode(void);
/* read byte from eeprom at given address */
uchar ispReadEEPROM(void);
/* write byte to flash at given address */
uchar ispWriteFlash(uchar data);
uchar ispFlushPage(void);
/* read byte from flash at given address */
uchar ispReadFlash(void);
/* write byte to eeprom at given address */
uchar ispWriteEEPROM(uchar data);
/*资源紧缺能省则省*/
void inc_prog_address(void);
#endif /* __ASSEMBLER__*/
#endif /* __isp_h_included__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -