#include #include #include #include #include #include #include "i2cmaster.h" #include "ip_arp_udp.h" #include "enc28j60.h" #include "net.h" #include "Definitions.h" //image width and height #define MAXLINES 290 #define MAXPIXELS 400 #define CAMADDR 0xc0 #define HREF PORTC & (1<command) { case LINEARSTEP: commandFlag = STEP; break; case ROTATIONSTEP: commandFlag = SPIN; break; case IMAGE: commandFlag = CAPTURE; break; } } //reply to pings if(sendBuffer[IP_PROTO_P]==IP_PROTO_ICMP_V && sendBuffer[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V) { //a ping packet, let's send pong make_echo_reply_from_request(sendBuffer,plen); } //clear the flag EIFR = 0x00; } ISR(PCINT2_vect) { PORTD = PORTD ^ (1<= MAXLINES) { commandFlag = IDLE; syncState = VSYNC; //turn off href ISR PCMSK2 = 0x00; } else { syncState = HREFUP; ///Send some data commandFlag = SEND; } break; } //Clear the flag PORTD = PORTD ^ (1< 0) { dataSize = (bytesToSend >= MAXSENDSIZE) ? MAXSENDSIZE : bytesToSend; send_udp_packet(&sendBuffer[0], &lineBuffer[loc], dataSize, lineNum, seq); bytesToSend -=dataSize; loc+=dataSize; seq++; _delay_us(100); } } void Initialize() { ///Set PORTA as an input DDRA = 0x00; ///Set External interrupt pins as inputs //CHANGED -- if input low not high DDRD = DDRD & ~(1 << PIND2); DDRC = DDRC & ~(1 << PINC2) & ~(1 << PINC3); ///Set Stepper output ports C[4:7], D[4:7] DDRD = DDRD | (0xf << PORTD4); DDRC = DDRC | (0xf << PORTC4); ///Set up i2c communcation i2c_init(); //Setup ethernet communication /* enable PB0, reset as output */ ETHERNET_RESET_PORT_DD |= (1<lineScan) { setLineScanningRegs(); } else { setNormalImageRegs(); } if (!cameraOn) { turnOnCamera(); } commandFlag = IDLE; break; case SEND: sendLineBuffer(pixelNum); commandFlag = IDLE; break; case STEP: moveActuator(command->numSteps, command->direction); commandFlag = IDLE; break; case SPIN: spinTurnTable(command->numSteps, command->direction); commandFlag = IDLE; break; } //clear all flags PCIFR = 0x00; } /* //Turn on VREF ISR PCICR = (1<