MCPcopy Create free account
hub / github.com/Shim06/Anemoia-ESP32 / NESControllerRead

Function NESControllerRead

src/controller.cpp:35–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35static uint8_t NESControllerRead()
36{
37 uint8_t state = 0x00;
38 digitalWrite(CONTROLLER_NES_LATCH, HIGH);
39 delayMicroseconds(12);
40 digitalWrite(CONTROLLER_NES_LATCH, LOW);
41 delayMicroseconds(6);
42
43 for (int i = 0; i < 8; i++)
44 {
45 if (digitalRead(CONTROLLER_NES_DATA) == LOW) state |= (1 << i);
46 digitalWrite(CONTROLLER_NES_CLK, LOW);
47 delayMicroseconds(6);
48 digitalWrite(CONTROLLER_NES_CLK, HIGH);
49 delayMicroseconds(6);
50 }
51
52 return state;
53}
54
55static uint8_t SNESControllerRead()
56{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected