亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? avrnet.lss

?? ATmage32 + microchip的enc28j60實現web server的解決方案
?? LSS
?? 第 1 頁 / 共 5 頁
字號:
	ENC28J60_DDR |= _BV(ENC28J60_RESET_PIN_DDR);

	// enable PD2/INT0, as input /
	ENC28J60_DDR &= ~_BV(ENC28J60_INT_PIN_DDR);

	// set output to gnd, reset the ethernet chip /
	ENC28J60_PORT &= ~_BV(ENC28J60_RESET_PIN);
	_delay_ms(10);
	// set output to Vcc, reset inactive /
	ENC28J60_PORT |= _BV(ENC28J60_RESET_PIN);
	_delay_ms(200);

	//initialize enc28j60/
	//enc28j60Init( avr_mac );
	//_delay_ms( 20 );


	DDRB  |= _BV( DDB4 ) | _BV( DDB5 ) | _BV( DDB7 ); // mosi, sck, ss output
	//DDRB &= ~_BV( DDB6 ); // MISO is input

	CSPASSIVE;

	PORTB &= ~(_BV( PB5 ) | _BV( PB7 ) );

	// initialize SPI interface
	// master mode and Fosc/2 clock:
	SPCR = _BV( SPE ) | _BV( MSTR );
	SPSR |= _BV( SPI2X );

	// perform system reset
	enc28j60WriteOp(ENC28J60_SOFT_RESET, 0, ENC28J60_SOFT_RESET);
	_delay_ms(50);

	// check CLKRDY bit to see if reset is complete
	// The CLKRDY does not work. See Rev. B4 Silicon Errata point. Just wait.
	//while(!(enc28j60Read(ESTAT) & ESTAT_CLKRDY));
	// do bank 0 stuff
	// initialize receive buffer
	// 16-bit transfers, must write low byte first
	// set receive buffer start address
	next_packet_ptr.word = RXSTART_INIT;
	// Rx start
	enc28j60Write(ERXSTL, RXSTART_INIT&0xFF);
	enc28j60Write(ERXSTH, RXSTART_INIT>>8);
	// set receive pointer address
	enc28j60Write(ERXRDPTL, RXSTART_INIT&0xFF);
	enc28j60Write(ERXRDPTH, RXSTART_INIT>>8);
	// RX end
	enc28j60Write(ERXNDL, RXSTOP_INIT&0xFF);
	enc28j60Write(ERXNDH, RXSTOP_INIT>>8);
	// TX start
	enc28j60Write(ETXSTL, TXSTART_INIT&0xFF);
	enc28j60Write(ETXSTH, TXSTART_INIT>>8);
	// TX end
	enc28j60Write(ETXNDL, TXSTOP_INIT&0xFF);
	enc28j60Write(ETXNDH, TXSTOP_INIT>>8);
	// do bank 1 stuff, packet filter:
	// For broadcast packets we allow only ARP packtets
	// All other packets should be unicast only for our mac (MAADR)
	//
	// The pattern to match on is therefore
	// Type     ETH.DST
	// ARP      BROADCAST
	// 06 08 -- ff ff ff ff ff ff -> ip checksum for theses bytes=f7f9
	// in binary these poitions are:11 0000 0011 1111
	// This is hex 303F->EPMM0=0x3f,EPMM1=0x30
	enc28j60Write(ERXFCON, ERXFCON_UCEN|ERXFCON_CRCEN|ERXFCON_PMEN);
	enc28j60Write(EPMM0, 0x3f);
	enc28j60Write(EPMM1, 0x30);
	enc28j60Write(EPMCSL, 0xf9);
	enc28j60Write(EPMCSH, 0xf7);

	

	// do bank 2 stuff
	// enable MAC receive
	enc28j60Write(MACON1, MACON1_MARXEN|MACON1_TXPAUS|MACON1_RXPAUS);
	// bring MAC out of reset
	//enc28j60Write(MACON2, 0x00);
	// enable automatic padding to 60bytes and CRC operations
	enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, MACON3, MACON3_PADCFG0|MACON3_TXCRCEN|MACON3_FRMLNEN);
	// set inter-frame gap (non-back-to-back)
	enc28j60Write(MAIPGL, 0x12);
	enc28j60Write(MAIPGH, 0x0C);
	// set inter-frame gap (back-to-back)
	enc28j60Write(MABBIPG, 0x12);
	// Set the maximum packet size which the controller will accept
	// Do not send packets longer than MAX_FRAMELEN:
	enc28j60Write(MAMXFLL, MAX_FRAMELEN&0xFF);	
	enc28j60Write(MAMXFLH, MAX_FRAMELEN>>8);
	// do bank 3 stuff
	// write MAC address
	// NOTE: MAC address in ENC28J60 is byte-backward

	// ENC28J60 is big-endian avr gcc is little-endian
	enc28j60Write(MAADR5, avr_mac[0]);
	enc28j60Write(MAADR4, avr_mac[1]);
	enc28j60Write(MAADR3, avr_mac[2]);
	enc28j60Write(MAADR2, avr_mac[3]);
	enc28j60Write(MAADR1, avr_mac[4]);
	enc28j60Write(MAADR0, avr_mac[5]);
	// no loopback of transmitted frames
	enc28j60PhyWrite(PHCON2, (WORD_BYTES){PHCON2_HDLDIS});
	// switch to bank 0
	enc28j60SetBank(ECON1);
	// enable interrutps
	enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, EIE, EIE_INTIE|EIE_PKTIE);
	// enable packet reception
	enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN);



	// Magjack leds configuration, see enc28j60 datasheet, page 11 /
	// LEDB=yellow LEDA=green
	//
	// 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit
	// enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10);
	enc28j60PhyWrite(PHLCON,(WORD_BYTES){0x0472});

	// set LED B to display recieve and transmit activate

	//enc28j60PhyWrite( PHLCON, 0x0476 );



	//enc28j60_flag.rx_buffer_is_free = 1;
	_delay_ms(20);
}
*/
void enc28j60_init( BYTE *avr_mac)
{
	// initialize I/O
	//DDRB |= _BV( DDB4 );
	//CSPASSIVE;

	// enable PB0, reset as output 
	ENC28J60_DDR |= _BV(ENC28J60_RESET_PIN_DDR);

	// enable PD2/INT0, as input
	ENC28J60_DDR &= ~_BV(ENC28J60_INT_PIN_DDR);
	ENC28J60_PORT |= _BV(ENC28J60_INT_PIN);

	// set output to gnd, reset the ethernet chip
	ENC28J60_PORT &= ~_BV(ENC28J60_RESET_PIN);
	_delay_ms(10);

	// set output to Vcc, reset inactive
	ENC28J60_PORT |= _BV(ENC28J60_RESET_PIN);
	_delay_ms(200);

    //	
	DDRB  |= _BV( DDB4 ) | _BV( DDB5 ) | _BV( DDB7 ); // mosi, sck, ss output
	//DDRB &= ~_BV( DDB6 ); // MISO is input

	CSPASSIVE;
	PORTB &= ~(_BV( PB5 ) | _BV( PB7 ) );
	//
	// initialize SPI interface
	// master mode and Fosc/2 clock:
    SPCR = _BV( SPE ) | _BV( MSTR );
    SPSR |= _BV( SPI2X );

	// perform system reset
	enc28j60WriteOp(ENC28J60_SOFT_RESET, 0, ENC28J60_SOFT_RESET);
	_delay_ms(50);

	// check CLKRDY bit to see if reset is complete
	// The CLKRDY does not work. See Rev. B4 Silicon Errata point. Just wait.
	//while(!(enc28j60Read(ESTAT) & ESTAT_CLKRDY));
	// do bank 0 stuff
	// initialize receive buffer
	// 16-bit transfers, must write low byte first
	// set receive buffer start address
	next_packet_ptr.word = RXSTART_INIT;
    // Rx start
	enc28j60Write(ERXSTL, RXSTART_INIT&0xFF);
	enc28j60Write(ERXSTH, RXSTART_INIT>>8);
	// set receive pointer address
	enc28j60Write(ERXRDPTL, RXSTART_INIT&0xFF);
	enc28j60Write(ERXRDPTH, RXSTART_INIT>>8);
	// RX end
	enc28j60Write(ERXNDL, RXSTOP_INIT&0xFF);
	enc28j60Write(ERXNDH, RXSTOP_INIT>>8);
	// TX start
	enc28j60Write(ETXSTL, TXSTART_INIT&0xFF);
	enc28j60Write(ETXSTH, TXSTART_INIT>>8);
	// TX end
	enc28j60Write(ETXNDL, TXSTOP_INIT&0xFF);
	enc28j60Write(ETXNDH, TXSTOP_INIT>>8);

	// do bank 2 stuff
	// enable MAC receive
	enc28j60Write(MACON1, MACON1_MARXEN|MACON1_TXPAUS|MACON1_RXPAUS);
	
	// bring MAC out of reset
	//enc28j60Write(MACON2, 0x00);

	// enable automatic padding to 60bytes and CRC operations
	enc28j60Write(MACON3, MACON3_PADCFG0|MACON3_TXCRCEN|MACON3_FRMLNEN);

	// Allow infinite deferals if the medium is continuously busy 
    // (do not time out a transmission if the half duplex medium is 
    // completely saturated with other people's data)
    enc28j60Write(MACON4, MACON4_DEFER);

	// Late collisions occur beyond 63+8 bytes (8 bytes for preamble/start of frame delimiter)
	// 55 is all that is needed for IEEE 802.3, but ENC28J60 B5 errata for improper link pulse 
	// collisions will occur less often with a larger number.
    enc28j60Write(MACLCON2, 63);
	
	// Set non-back-to-back inter-packet gap to 9.6us.  The back-to-back 
	// inter-packet gap (MABBIPG) is set by MACSetDuplex() which is called 
	// later.
	enc28j60Write(MAIPGL, 0x12);
	enc28j60Write(MAIPGH, 0x0C);
	
	// Set the maximum packet size which the controller will accept
    // Do not send packets longer than MAX_FRAMELEN:
	enc28j60Write(MAMXFLL, MAX_FRAMELEN&0xFF);	
	enc28j60Write(MAMXFLH, MAX_FRAMELEN>>8);
	
	// do bank 3 stuff
    // write MAC address
	// NOTE: MAC address in ENC28J60 is byte-backward
	// ENC28J60 is big-endian avr gcc is little-endian
	enc28j60Write(MAADR5, avr_mac[0]);
	enc28j60Write(MAADR4, avr_mac[1]);
	enc28j60Write(MAADR3, avr_mac[2]);
	enc28j60Write(MAADR2, avr_mac[3]);
	enc28j60Write(MAADR1, avr_mac[4]);
	enc28j60Write(MAADR0, avr_mac[5]);
	
	// no loopback of transmitted frames
	enc28j60PhyWrite(PHCON2, (WORD_BYTES){PHCON2_HDLDIS});
	
	// Magjack leds configuration, see enc28j60 datasheet, page 11
	// 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit
	// enc28j60PhyWrite(PHLCON,0b0000 0100 0111 00 10);
	enc28j60PhyWrite(PHLCON,(WORD_BYTES){0x0472});

	// do bank 1 stuff, packet filter:
	// For broadcast packets we allow only ARP packtets
	// All other packets should be unicast only for our mac (MAADR)
	//
	// The pattern to match on is therefore
	// Type     ETH.DST
	// ARP      BROADCAST
 	// 06 08 -- ff ff ff ff ff ff -> ip checksum for theses bytes=f7f9
	// in binary these poitions are:11 0000 0011 1111
	// This is hex 303F->EPMM0=0x3f,EPMM1=0x30
	enc28j60Write(ERXFCON, ERXFCON_UCEN|ERXFCON_CRCEN|ERXFCON_PMEN);
	enc28j60Write(EPMM0, 0x3f);
	enc28j60Write(EPMM1, 0x30);
	enc28j60Write(EPMCSL, 0xf9);
	enc28j60Write(EPMCSH, 0xf7);

	// set inter-frame gap (back-to-back)
	enc28j60Write(MABBIPG, 0x12);
	
	// switch to bank 0
	enc28j60SetBank(ECON1);

	// enable interrutps
	enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, EIE, EIE_INTIE|EIE_PKTIE);

	// enable packet reception
	enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN);

	_delay_ms(20);
}
//*******************************************************************************************
//
// Function : enc28j60getrev
// Description : read the revision of the chip.
//
//*******************************************************************************************
BYTE enc28j60getrev(void)
{
	return(enc28j60Read(EREVID));
}
//*******************************************************************************************
//
// Function : enc28j60_packet_send
// Description : Send packet to network.
//
//*******************************************************************************************
void enc28j60_packet_send ( BYTE *buffer, WORD length )
{
	//Set the write pointer to start of transmit buffer area
	enc28j60Write(EWRPTL, LOW(TXSTART_INIT) );
     87a:	82 e7       	ldi	r24, 0x72	; 114
     87c:	0e 94 e8 03 	call	0x7d0	; 0x7d0 <enc28j60Read>
	enc28j60Write(EWRPTH, HIGH(TXSTART_INIT) );

     880:	99 27       	eor	r25, r25
     882:	08 95       	ret

00000884 <enc28j60_packet_send>:
	// Set the TXND pointer to correspond to the packet size given
	enc28j60Write(ETXNDL, LOW((TXSTART_INIT+length)) );
	enc28j60Write(ETXNDH, HIGH((TXSTART_INIT+length)) );

	// write per-packet control byte (0x00 means use macon3 settings)
	enc28j60WriteOp(ENC28J60_WRITE_BUF_MEM, 0, 0x00);

	CSACTIVE;
     884:	0f 93       	push	r16
     886:	1f 93       	push	r17
     888:	cf 93       	push	r28
     88a:	df 93       	push	r29
     88c:	8c 01       	movw	r16, r24
     88e:	eb 01       	movw	r28, r22
	// issue write command
	SPDR = ENC28J60_WRITE_BUF_MEM;
     890:	64 e2       	ldi	r22, 0x24	; 36
     892:	82 e0       	ldi	r24, 0x02	; 2
     894:	0e 94 f3 03 	call	0x7e6	; 0x7e6 <enc28j60Write>
	waitspi();
     898:	6a e1       	ldi	r22, 0x1A	; 26
     89a:	83 e0       	ldi	r24, 0x03	; 3
     89c:	0e 94 f3 03 	call	0x7e6	; 0x7e6 <enc28j60Write>
	while(length)
	{
		length--;
     8a0:	ce 01       	movw	r24, r28
     8a2:	8c 5d       	subi	r24, 0xDC	; 220
     8a4:	68 2f       	mov	r22, r24
     8a6:	86 e0       	ldi	r24, 0x06	; 6
     8a8:	0e 94 f3 03 	call	0x7e6	; 0x7e6 <enc28j60Write>
		// write data
     8ac:	cc 5d       	subi	r28, 0xDC	; 220
     8ae:	d5 4e       	sbci	r29, 0xE5	; 229
     8b0:	6d 2f       	mov	r22, r29
     8b2:	77 27       	eor	r23, r23
     8b4:	c4 52       	subi	r28, 0x24	; 36
     8b6:	da 41       	sbci	r29, 0x1A	; 26
     8b8:	87 e0       	ldi	r24, 0x07	; 7
     8ba:	0e 94 f3 03 	call	0x7e6	; 0x7e6 <enc28j60Write>
		SPDR = *buffer++;
		waitspi();
	}
     8be:	40 e0       	ldi	r20, 0x00	; 0
     8c0:	60 e0       	ldi	r22, 0x00	; 0
     8c2:	8a e7       	ldi	r24, 0x7A	; 122

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
夜夜爽夜夜爽精品视频| 国产精品成人在线观看| 久久久蜜桃精品| 亚洲一区在线播放| 国产美女视频一区| 欧美日韩不卡在线| 亚洲欧美欧美一区二区三区| 国产美女av一区二区三区| 精品视频在线免费看| 国产天堂亚洲国产碰碰| 日韩福利视频网| 99精品视频在线观看免费| 日韩欧美一二区| 午夜久久久久久久久| voyeur盗摄精品| 精品99999| 男人的天堂久久精品| 欧美日韩一区二区三区四区五区 | 国产在线视频精品一区| 欧美日韩中字一区| 亚洲综合免费观看高清完整版 | 夜夜爽夜夜爽精品视频| 成人黄色av电影| 久久久精品中文字幕麻豆发布| 丝袜亚洲另类丝袜在线| 欧洲一区二区av| 亚洲综合色噜噜狠狠| 91美女片黄在线观看| 中文字幕av在线一区二区三区| 久久99久久99精品免视看婷婷| 欧美久久久久久久久| 亚洲高清视频中文字幕| 欧美婷婷六月丁香综合色| 最新中文字幕一区二区三区| 不卡一区二区三区四区| 国产精品免费丝袜| 成人国产精品免费观看视频| 日韩一区中文字幕| 国产欧美一区二区三区网站| 国产亚洲欧美中文| 日韩限制级电影在线观看| 色婷婷精品久久二区二区蜜臀av| 成人精品鲁一区一区二区| 国产一区二区三区四| 麻豆专区一区二区三区四区五区| 婷婷六月综合亚洲| 视频一区中文字幕| 日韩精品一二区| 狠狠色丁香婷综合久久| 精品一区二区三区久久| 777午夜精品视频在线播放| 国产高清精品网站| 在线观看国产精品网站| 污片在线观看一区二区| 日韩欧美久久久| 国产精品99精品久久免费| |精品福利一区二区三区| 色婷婷国产精品| 日韩精品一二三| 久久久国际精品| 欧美伊人久久大香线蕉综合69| 午夜精品一区二区三区电影天堂 | 蜜桃91丨九色丨蝌蚪91桃色| 精品国产乱码久久久久久闺蜜| 国产麻豆成人传媒免费观看| 亚洲精品欧美激情| 日韩三级视频在线看| 99在线视频精品| 久久99深爱久久99精品| 久久福利视频一区二区| 成人黄色av电影| |精品福利一区二区三区| 国产精品高潮呻吟久久| 蜜臀久久99精品久久久画质超高清| 三级影片在线观看欧美日韩一区二区 | 久久久久国产一区二区三区四区| 国产亚洲一区二区三区| 日本欧美加勒比视频| www亚洲一区| 色狠狠av一区二区三区| 秋霞影院一区二区| 欧美极品aⅴ影院| 欧美色国产精品| 日本午夜一本久久久综合| 中日韩免费视频中文字幕| 色婷婷av久久久久久久| 国产精品91一区二区| 欧美精品免费视频| 波多野结衣欧美| 亚洲图片你懂的| 久久久久青草大香线综合精品| 懂色av一区二区夜夜嗨| 日韩不卡免费视频| 亚州成人在线电影| 中文字幕一区二区三区色视频| 日韩免费视频一区| 欧美无砖专区一中文字| 99视频在线精品| 国产福利91精品| 午夜精品在线视频一区| 国产精品福利影院| 国产日韩欧美一区二区三区综合| 欧美午夜不卡在线观看免费| 色综合久久综合| 亚洲成人免费视频| 亚洲精品写真福利| 欧美激情一区二区三区全黄| 2024国产精品| 欧美一区二区日韩| 日韩午夜在线观看| 欧美午夜精品理论片a级按摩| 色综合色综合色综合色综合色综合 | 风间由美性色一区二区三区| 日本怡春院一区二区| 香蕉久久夜色精品国产使用方法| 中文字幕中文在线不卡住| 日韩欧美国产电影| 精品av久久707| 欧美岛国在线观看| 欧美午夜一区二区三区免费大片| 久久97超碰色| 蜜桃精品在线观看| 欧洲亚洲国产日韩| 国产在线播放一区二区三区| 国产精品对白交换视频| 欧美日韩精品一区二区三区| 久久国产精品免费| 伊人性伊人情综合网| 精品久久久久久最新网址| 91片黄在线观看| 国产91综合网| 久久99国产精品尤物| 亚洲主播在线播放| 精品88久久久久88久久久| 欧美一区二区三区在线观看 | 在线视频亚洲一区| 日本伦理一区二区| 91蜜桃传媒精品久久久一区二区| 成人av中文字幕| 97成人超碰视| 色8久久精品久久久久久蜜| 欧日韩精品视频| 6080亚洲精品一区二区| 欧美丝袜丝交足nylons图片| 51精品秘密在线观看| 欧美mv日韩mv国产网站app| 欧美videofree性高清杂交| 精品伦理精品一区| 亚洲国产精品99久久久久久久久 | 国产剧情一区二区| 国产精品亚洲午夜一区二区三区| 福利电影一区二区| 91亚洲男人天堂| 欧美日韩一区二区不卡| 日韩欧美国产不卡| 国产精品乱人伦中文| 欧美高清在线一区| 亚洲另类在线制服丝袜| 日韩精品午夜视频| 国产成人av一区二区三区在线观看| 精油按摩中文字幕久久| 成人精品视频一区二区三区| 色婷婷综合在线| 91精品国产色综合久久不卡电影| 国产精品久线在线观看| 五月天视频一区| 成人妖精视频yjsp地址| 欧美性淫爽ww久久久久无| 国产日韩欧美高清| 亚洲h在线观看| 99国产精品久久久久久久久久| 欧美日韩不卡一区二区| 亚洲视频图片小说| 亚洲一区二区精品久久av| 美女在线一区二区| 欧美精品一二三区| 欧美高清一级片在线观看| 激情六月婷婷综合| 91福利区一区二区三区| 日本一区二区视频在线| 国产专区欧美精品| 欧美日韩日日摸| 欧美日本一区二区三区| 日韩欧美国产三级电影视频| 欧美最猛黑人xxxxx猛交| 5月丁香婷婷综合| 国产在线不卡视频| 成人深夜福利app| 91丨国产丨九色丨pron| 制服丝袜成人动漫| 久久免费视频一区| 国产精品成人在线观看| 亚洲资源在线观看| 极品少妇一区二区三区精品视频| 国产91精品免费| 色88888久久久久久影院野外| 欧美久久婷婷综合色| 久久久青草青青国产亚洲免观| 综合av第一页| 美女视频黄频大全不卡视频在线播放|