InterruptVectors.c

Go to the documentation of this file.
00001 #include "SensorOnlyMode.h"
00002 #include "global.h"
00003 #include <avr/interrupt.h>
00004 #include <avr/signal.h>
00005 
00006 volatile int wheel1 = 0;
00007 volatile int wheel2 = 0; // not in use yet
00008 
00009 extern Smartbuffer interruptbuff;
00010 extern int softwareMode;
00011 
00012 
00014 SIGNAL(SIG_INTERRUPT0) {
00015 
00016      cli();
00017 
00018      register unsigned char pd = PIND;
00019 
00020      if (( (pd & (1<<PIND6))>=1  &&  (pd & (1<<PIND2))==0 ) ||
00021          ( (pd & (1<<PIND6))==0  &&  (pd & (1<<PIND2))>=1 ) 
00022      ) {
00023           if (softwareMode == SENSOR_MODE) {
00024                wheel1++;
00025           } else if (wheel1 < 127) { // only a char-byte will be saved in memory
00026                wheel1++;
00027           }
00028 
00029      } else {  
00030           if (softwareMode == SENSOR_MODE) {
00031                wheel1--;
00032           } else if (wheel1 > -127) { // only a char-byte will be saved in memory
00033                wheel1--;
00034           }    
00035      }
00036 
00037      sei();
00038 }
00039 // code from markus 
00040 /*SIGNAL(SIG_INTERRUPT0)
00041 { 
00042   register unsigned char pd = PIND;
00043   register unsigned char pb = PINB;
00044   
00045   // if the signals are different is was
00046   // a forwad movement - else a backward movement
00047      if(
00048      ((pd & (1<<PIND2))>=1  &&  (pb & (1<<PINB0))==0) ||
00049      ((pd & (1<<PIND2))==0  &&  (pb & (1<<PINB0))>=1) 
00050      ){
00051     wheel1++;
00052      } 
00053   else{   
00054     wheel1--;
00055      }
00056 }
00057 SIGNAL(SIG_INTERRUPT1)
00058 { 
00059   register unsigned char pd = PIND;
00060   register unsigned char pb = PINB;
00061   
00062   // if the signals are different is was
00063   // a forwad movement - else a backward movement
00064      if(
00065      ((pd & (1<<PIND3))>=1  &&  (pb & (1<<PINB1))==0) ||
00066      ((pd & (1<<PIND3))==0  &&  (pb & (1<<PINB1))>=1) 
00067      ){
00068     wheel2++;
00069      } 
00070   else{   
00071     wheel2--;
00072      }
00073 }
00074 */
00075 
00076 
00077 /* Serial Interrupt Handler */
00078 //ISR(USART_RXC_vect)
00079 // SIGNAL(SIG_UART_RECV)
00080 // {
00081 //   if (softwareMode == SENSOR_MODE) {
00082 //             push(interruptbuff, RXD_DATA);
00083 //   }
00084 // }
00085 

Generated on Wed Nov 25 11:27:41 2009 for Crawling Robot Microcontroller Software by  doxygen 1.5.5