]> sigrok.org Git - libsigrokdecode.git/blob - decoders/nes_gamepad/__init__.py
nes_gamepad: implement and add decoder
[libsigrokdecode.git] / decoders / nes_gamepad / __init__.py
1 ##
2 ## This file is part of the libsigrokdecode project.
3 ##
4 ## Copyright (C) 2019 Stephan Thiele <stephan.thiele@mailbox.org>
5 ##
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2 of the License, or
9 ## (at your option) any later version.
10 ##
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ## GNU General Public License for more details.
15 ##
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
18 ##
19
20 '''
21 This decoder stacks on top of the 'spi' PD and decodes the button states
22 of an NES gamepad.
23
24 The SPI decoder needs to be configured as follows:
25
26 Clock polarity = 1
27 Clock phase    = 0
28 Bit order      = msb-first
29 Word size      = 8
30
31 Chip-select is not used and must not be assigned to any channel.
32
33 Hardware setup is as follows:
34         ___
35    GND |o  \
36    CUP |o o| VCC
37  OUT 0 |o o| D3
38     D1 |o o| D4
39        -----
40 NES Gamepad Connector
41
42 VCC   - Power 5V
43 GND   - Ground
44 CUP   - Shift register clock (CLK)
45 OUT 0 - Shift register latch (optional)
46 D1    - Gamepad data (MOSI)
47 D3    - Data (unused)
48 D4    - Data (unused)
49
50 Data pins D3 and D4 are not used by the standard gamepad but
51 by special controllers like the Nintento Zapper light gun.
52 '''
53
54 from .pd import Decoder