Subversion Repositories pentevo

Rev

Rev 6 | Rev 75 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3.  
  4. #include "mytypes.h"
  5. #include "pins.h"
  6. #include "ps2.h"
  7. #include "zx.h"
  8. #include "spi.h"
  9.  
  10. ISR(TIMER2_OVF_vect)
  11. {
  12.         static UBYTE counter=0x00;
  13.         static BYTE dir=0x01;
  14.         static BYTE ocr=0x00;
  15.  
  16.         counter++; // just fucking shit to fadein-fadeout LED :-)))
  17.         if( counter&128 )
  18.         {
  19.                 counter=0;
  20.  
  21.                 ocr += dir;
  22.                 if( (ocr==(-1)) && (dir==(-1)) )
  23.                 {
  24.                         dir = -dir;
  25.                         ocr = 1;
  26.                 } else if( (ocr==0) && (dir==1) )
  27.                 {
  28.                         dir = -dir;
  29.                         ocr = 0xFF;
  30.                 }
  31.  
  32.                 OCR2 = ocr;
  33.         }
  34.  
  35.  
  36.         // PS/2 timeout tracking
  37.         if( (ps2_count<11) && (ps2_count!=0) ) // track timeout for PS/2
  38.         {
  39.                 if( ps2_timeout ) ps2_timeout--;
  40.  
  41.                 if( !ps2_timeout )
  42.                 {
  43.                         ps2_count = 11;
  44.                 }
  45.         }
  46.  
  47.  
  48.         // pause for keyboard CS|SS
  49.         if( shift_pause )
  50.                 shift_pause--;
  51. }
  52.  
  53.  
  54.  
  55.  
  56. ISR(INT4_vect) // receive PS/2 data. TODO: sending mode...
  57. {
  58.         ps2_shifter >>= 1;
  59.         if( (PS2KBDAT_PIN&(1<<PS2KBDAT)) ) ps2_shifter |= 0x8000;
  60.  
  61.         if( !(--ps2_count) )
  62.         {
  63.                 PS2KBCLK_PORT &= ~(1<<PS2KBCLK);
  64.                 PS2KBCLK_DDR  |= (1<<PS2KBCLK);
  65.  
  66.                 EIFR = (1<<INTF4); // clr any additional int which can happen when we pulldown clock pin
  67.         }
  68.  
  69.         ps2_timeout = PS2_TIMEOUT;
  70.  
  71.         EIFR = (1<<INTF4);
  72. }
  73.  
  74.  
  75.