全文预览

MEGA16的W5100以太网模块驱动例程(英文)

上传者:科技星球 |  格式:doc  |  页数:43 |  大小:0KB

文档介绍
one W5100 Initialized!\n");Р}Р// Assign I/O stream to UARTРFILE uart_str = FDEV_SETUP_STREAM(uart_putch, uart_getch, _FDEV_SETUP_RW);Рint main(void){Р // Set the PORTD as Output:Р DDRD=0xFF;Р PORTD=0x00;Р // Define Output/Input StreamР stdout = stdin = &uart_str;Р // Initial UART PeripheralР uart_init();Р // Clear ScreenР ansi_me();Р ansi_cl();Р ansi_me();Р ansi_cl();Р uart_flush();Р // Initial the AVR ATMega168/328 SPI PeripheralР // Set MOSI (PORTB3),SCK (PORTB5) and PORTB2 (SS) as output, others as inputР SPI_DDR = (1<<PORTB3)|(1<<PORTB5)|(1<<PORTB2);Р // CS pin is not activeР SPI_PORT |= (1<<SPI_CS);Р // Enable SPI, Master Mode 0, set the clock rate fck/2Р SPCR = (1<<SPE)|(1<<MSTR);Р SPSR |= (1<<SPI2X);Р // Initial the W5100Р printf(" W5100 Init\n\n");Р W5100_Init();Р // Loop forever

收藏

分享

举报
下载此文档