Browse Source

feature/2015
tixiv 16 years ago
parent
commit
42da4894c8
  1. 10
      joystick/config.in
  2. 5
      joystick/nes_pad.c
  3. 1
      makros.h

10
joystick/config.in

@ -120,11 +120,11 @@ choice 'Port ds' \
'PORTB' NES_PAD_PORT_PL 'PORTB' NES_PAD_PORT_PL
choice 'Pin pl' \ choice 'Pin pl' \
"PINA PINA \ "PORTA PORTA \
PINB PINB \ PORTB PORTB \
PINC PINC \ PORTC PORTC \
PIND PIND" \ PORTD PORTD" \
'PINB' NES_PAD_PIN_DS 'PORTB' NES_PAD_PORT_DS
choice 'Bit clk' \ choice 'Bit clk' \

5
joystick/nes_pad.c

@ -5,7 +5,8 @@
#define NES_PAD_DDR_PL DDR(NES_PAD_PORT_PL) #define NES_PAD_DDR_PL DDR(NES_PAD_PORT_PL)
#define NES_PAD_DDR_CLK DDR(NES_PAD_PORT_CLK) #define NES_PAD_DDR_CLK DDR(NES_PAD_PORT_CLK)
#define NES_PAD_DDR_DS DDR(NES_PAD_PIN_DS) #define NES_PAD_PIN_DS PIN(NES_PAD_PORT_DS)
#define NES_PAD_DDR_DS DDR(NES_PAD_PORT_DS)
volatile unsigned char fakeport; volatile unsigned char fakeport;
unsigned char waitForFire; unsigned char waitForFire;
@ -14,9 +15,9 @@ void joy_init(){
NES_PAD_DDR_PL |= 1<<NES_PAD_BIT_PL; NES_PAD_DDR_PL |= 1<<NES_PAD_BIT_PL;
NES_PAD_DDR_CLK |= 1<<NES_PAD_BIT_CLK; NES_PAD_DDR_CLK |= 1<<NES_PAD_BIT_CLK;
NES_PAD_PORT_DS |= (1<<NES_PAD_BIT_DS);//pullup
NES_PAD_DDR_DS &= ~(1<<NES_PAD_BIT_DS); NES_PAD_DDR_DS &= ~(1<<NES_PAD_BIT_DS);
} }
void readButtons(){ void readButtons(){

1
makros.h

@ -1,5 +1,6 @@
#define DDR(port) (*(volatile uint8_t*)((&port)-1)) #define DDR(port) (*(volatile uint8_t*)((&port)-1))
#define PIN(port) (*(volatile uint8_t*)((&port)-2))
#define DDR_FROM_PIN(pin) (*(volatile uint8_t*)((&pin)+1)) #define DDR_FROM_PIN(pin) (*(volatile uint8_t*)((&pin)+1))

Loading…
Cancel
Save