PlayStation Controller library
Dependents: PSController_Sample coba_stick_PS2 basehybrid_PSPAD Base_Hybrid_V3 ... more
PlayStation Controller
SONY プレイステーション2用コントローラーを mbed に接続して使えるライブラリです。
SPI 機能を使います。
サードパーティ製や、VSTONE製のコントローラー(VS-C1、VS-C3)も使用できます。
ピンアサイン
PS PAD
========================= | 9 8 7 | 6 5 4 | 3 2 1 | -----------------------
PS PAD | VS-C3 | Signal | mbed |
1 | 3 | DAT | MISO |
2 | 4 | CMD | MOSI |
3 | +5-7V | ||
4 | 10 | GND | GND |
5 | 9 | +3V | +3.3V |
6 | 5 | SEL | CS |
7 | 6 | CLK | SCK |
8 | |||
9 | ACK |
PS_PAD.h
- Committer:
- okini3939
- Date:
- 2013-12-12
- Revision:
- 1:840370e1dcce
- Parent:
- 0:6eeefcf5a37a
File content as of revision 1:840370e1dcce:
/* * PlayStation Controller library * Copyright (c) 2013 Hiroshi Suga */ #include "mbed.h" class PS_PAD { public: enum TYPE { PAD_LEFT, PAD_BOTTOM, PAD_RIGHT, PAD_TOP, PAD_START, ANALOG_LEFT, ANALOG_RIGHT, PAD_SELECT, PAD_SQUARE, PAD_X, PAD_CIRCLE, PAD_TRIANGLE, PAD_R1, PAD_L1, PAD_R2, PAD_L2, BUTTONS, ANALOG_RX, ANALOG_RY, ANALOG_LX, ANALOG_LY, }; PS_PAD (PinName mosi, PinName miso, PinName sck, PinName cs); PS_PAD (SPI &spi, PinName cs); int init (); int poll (); int read (TYPE t); int vibration (int v1, int v2); private: SPI _spi; DigitalOut _cs; uint8_t _pad[6]; int _vib1, _vib2; bool _connected; int send (const char *cmd, int len, char *dat); };