Subversion Repositories pentevo

Rev

Rev 113 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed | ?url?

  1. #include <avr/io.h>
  2.  
  3. #include "pins.h"
  4. #include "mytypes.h"
  5.  
  6. #include "rs232.h"
  7. #include "zx.h"
  8. #include "joystick.h"
  9.  
  10. //if want Log than comment next string
  11. #undef LOGENABLE
  12.  
  13. void joystick_task(void)
  14. {
  15.         static UBYTE joy_state = 0;
  16.         UBYTE temp = (~JOYSTICK_PIN) & JOYSTICK_MASK;
  17.  
  18.         if ( joy_state ^ temp )
  19.         {
  20.                 //change state of joystick pins
  21.                 joy_state = temp;
  22.  
  23.                 //send to port
  24.                 zx_spi_send(SPI_KEMPSTON_JOYSTICK, joy_state, 0x7F);
  25.  
  26. #ifdef LOGENABLE
  27.         char log_joystick[] = "JS..\r\n";
  28.         log_joystick[2] = ((temp >> 4) <= 9 )?'0'+(temp >> 4):'A'+(temp >> 4)-10;
  29.         log_joystick[3] = ((temp & 0x0F) <= 9 )?'0'+(temp & 0x0F):'A'+(temp & 0x0F)-10;
  30.         to_log(log_joystick);
  31. #endif
  32.         }
  33. }
  34.