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 PADVS-C3Signalmbed
13DATMISO
24CMDMOSI
3+5-7V
410GNDGND
59+3V+3.3V
65SELCS
76CLKSCK
8
9ACK
Committer:
okini3939
Date:
Wed Dec 11 04:42:44 2013 +0000
Revision:
0:6eeefcf5a37a
Child:
1:840370e1dcce
1st build;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 0:6eeefcf5a37a 1 /*
okini3939 0:6eeefcf5a37a 2 * PlayStation Controller library
okini3939 0:6eeefcf5a37a 3 * Copyright (c) 2013 Hiroshi Suga
okini3939 0:6eeefcf5a37a 4 */
okini3939 0:6eeefcf5a37a 5
okini3939 0:6eeefcf5a37a 6 #include "mbed.h"
okini3939 0:6eeefcf5a37a 7
okini3939 0:6eeefcf5a37a 8 class PS_PAD {
okini3939 0:6eeefcf5a37a 9 public:
okini3939 0:6eeefcf5a37a 10 enum TYPE {
okini3939 0:6eeefcf5a37a 11 PAD_LEFT,
okini3939 0:6eeefcf5a37a 12 PAD_BOTTOM,
okini3939 0:6eeefcf5a37a 13 PAD_RIGHT,
okini3939 0:6eeefcf5a37a 14 PAD_TOP,
okini3939 0:6eeefcf5a37a 15 PAD_START,
okini3939 0:6eeefcf5a37a 16 ANALOG_LEFT,
okini3939 0:6eeefcf5a37a 17 ANALOG_RIGHT,
okini3939 0:6eeefcf5a37a 18 PAD_SELECT,
okini3939 0:6eeefcf5a37a 19 PAD_SQUARE,
okini3939 0:6eeefcf5a37a 20 PAD_X,
okini3939 0:6eeefcf5a37a 21 PAD_CIRCLE,
okini3939 0:6eeefcf5a37a 22 PAD_TRIANGLE,
okini3939 0:6eeefcf5a37a 23 PAD_R1,
okini3939 0:6eeefcf5a37a 24 PAD_L1,
okini3939 0:6eeefcf5a37a 25 PAD_R2,
okini3939 0:6eeefcf5a37a 26 PAD_L2,
okini3939 0:6eeefcf5a37a 27 ANALOG_RX,
okini3939 0:6eeefcf5a37a 28 ANALOG_RY,
okini3939 0:6eeefcf5a37a 29 ANALOG_LX,
okini3939 0:6eeefcf5a37a 30 ANALOG_LY,
okini3939 0:6eeefcf5a37a 31 };
okini3939 0:6eeefcf5a37a 32
okini3939 0:6eeefcf5a37a 33 PS_PAD (PinName mosi, PinName miso, PinName sck, PinName cs);
okini3939 0:6eeefcf5a37a 34 PS_PAD (SPI &spi, PinName cs);
okini3939 0:6eeefcf5a37a 35
okini3939 0:6eeefcf5a37a 36 int init ();
okini3939 0:6eeefcf5a37a 37 int poll ();
okini3939 0:6eeefcf5a37a 38 int read (TYPE t);
okini3939 0:6eeefcf5a37a 39 int vibration (int v1, int v2);
okini3939 0:6eeefcf5a37a 40
okini3939 0:6eeefcf5a37a 41 private:
okini3939 0:6eeefcf5a37a 42 SPI _spi;
okini3939 0:6eeefcf5a37a 43 DigitalOut _cs;
okini3939 0:6eeefcf5a37a 44 char _pad[6];
okini3939 0:6eeefcf5a37a 45 int _vib1, _vib2;
okini3939 0:6eeefcf5a37a 46
okini3939 0:6eeefcf5a37a 47 int send (const char *cmd, int len, char *dat);
okini3939 0:6eeefcf5a37a 48 };