mirror of
https://github.com/clockworkpi/WiringPi.git
synced 2025-12-13 08:18:48 +01:00
Changes to the piNes driver to relect the new delayMicroseconds()
code. Seems the old 4011 in the NES controller isn't that fast afterall!
This commit is contained in:
parent
1bb4989e11
commit
fbab4b8329
@ -38,6 +38,8 @@
|
|||||||
#define NES_A 0x80
|
#define NES_A 0x80
|
||||||
|
|
||||||
|
|
||||||
|
#define PULSE_TIME 25
|
||||||
|
|
||||||
// Data to store the pins for each controller
|
// Data to store the pins for each controller
|
||||||
|
|
||||||
struct nesPinsStruct
|
struct nesPinsStruct
|
||||||
@ -91,10 +93,8 @@ unsigned int readNesJoystick (int joystick)
|
|||||||
|
|
||||||
// Toggle Latch - which presents the first bit
|
// Toggle Latch - which presents the first bit
|
||||||
|
|
||||||
digitalWrite (pins->lPin, HIGH) ;
|
digitalWrite (pins->lPin, HIGH) ; delayMicroseconds (PULSE_TIME) ;
|
||||||
delayMicroseconds (1) ;
|
digitalWrite (pins->lPin, LOW) ; delayMicroseconds (PULSE_TIME) ;
|
||||||
digitalWrite (pins->lPin, LOW) ;
|
|
||||||
delayMicroseconds (1) ;
|
|
||||||
|
|
||||||
// Read first bit
|
// Read first bit
|
||||||
|
|
||||||
@ -104,12 +104,10 @@ unsigned int readNesJoystick (int joystick)
|
|||||||
|
|
||||||
for (i = 0 ; i < 7 ; ++i)
|
for (i = 0 ; i < 7 ; ++i)
|
||||||
{
|
{
|
||||||
digitalWrite (pins->cPin, HIGH) ;
|
digitalWrite (pins->cPin, HIGH) ; delayMicroseconds (PULSE_TIME) ;
|
||||||
delayMicroseconds (1) ;
|
digitalWrite (pins->cPin, LOW) ; delayMicroseconds (PULSE_TIME) ;
|
||||||
digitalWrite (pins->cPin, LOW) ;
|
|
||||||
delayMicroseconds (1) ;
|
|
||||||
value = (value << 1) | digitalRead (pins->dPin) ;
|
value = (value << 1) | digitalRead (pins->dPin) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ~value ;
|
return value ^ 0xFF ;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user