手動機アーム、mbed基盤のspiをおくるだけのプログラムです(9/4)

Dependencies:   SPI_master_arm_shudouki mbed

Fork of SPI_master_arm_shudouki2 by F^3 RC 2班

Committer:
yoka06
Date:
Mon Sep 04 13:02:43 2017 +0000
Revision:
2:faa028d2f2f8
Parent:
0:76d1c7f13415
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yoka06 0:76d1c7f13415 1 /*
yoka06 0:76d1c7f13415 2 Copyright (c) 2011 Bart Janssens
yoka06 0:76d1c7f13415 3
yoka06 0:76d1c7f13415 4 Permission is hereby granted, free of charge, to any person obtaining a copy
yoka06 0:76d1c7f13415 5 of this software and associated documentation files (the "Software"), to deal
yoka06 0:76d1c7f13415 6 in the Software without restriction, including without limitation the rights
yoka06 0:76d1c7f13415 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
yoka06 0:76d1c7f13415 8 copies of the Software, and to permit persons to whom the Software is
yoka06 0:76d1c7f13415 9 furnished to do so, subject to the following conditions:
yoka06 0:76d1c7f13415 10
yoka06 0:76d1c7f13415 11 The above copyright notice and this permission notice shall be included in
yoka06 0:76d1c7f13415 12 all copies or substantial portions of the Software.
yoka06 0:76d1c7f13415 13
yoka06 0:76d1c7f13415 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
yoka06 0:76d1c7f13415 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
yoka06 0:76d1c7f13415 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
yoka06 0:76d1c7f13415 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
yoka06 0:76d1c7f13415 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
yoka06 0:76d1c7f13415 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
yoka06 0:76d1c7f13415 20 THE SOFTWARE.
yoka06 0:76d1c7f13415 21 */
yoka06 0:76d1c7f13415 22
yoka06 0:76d1c7f13415 23 /* Defines for the PS3 Buttons
yoka06 0:76d1c7f13415 24 */
yoka06 0:76d1c7f13415 25
yoka06 0:76d1c7f13415 26
yoka06 0:76d1c7f13415 27 #define BUTTONSELECT 0
yoka06 0:76d1c7f13415 28 #define BUTTONLANALOG 1
yoka06 0:76d1c7f13415 29 #define BUTTONRANALOG 2
yoka06 0:76d1c7f13415 30 #define BUTTONSTART 3
yoka06 0:76d1c7f13415 31 #define BUTTONUP 4
yoka06 0:76d1c7f13415 32 #define BUTTONRIGHT 5
yoka06 0:76d1c7f13415 33 #define BUTTONDOWN 6
yoka06 0:76d1c7f13415 34 #define BUTTONLEFT 7
yoka06 0:76d1c7f13415 35 #define BUTTONL2 8
yoka06 0:76d1c7f13415 36 #define BUTTONR2 9
yoka06 0:76d1c7f13415 37 #define BUTTONL1 10
yoka06 0:76d1c7f13415 38 #define BUTTONR1 11
yoka06 0:76d1c7f13415 39 #define BUTTONTRIANGEL 12
yoka06 0:76d1c7f13415 40 #define BUTTONCIRCLE 13
yoka06 0:76d1c7f13415 41 #define BUTTONCROSS 14
yoka06 0:76d1c7f13415 42 #define BUTTONSQUARE 15
yoka06 0:76d1c7f13415 43 #define BUTTONPS 16
yoka06 0:76d1c7f13415 44
yoka06 0:76d1c7f13415 45
yoka06 0:76d1c7f13415 46 /* Defines for the PS3 Joysticks
yoka06 0:76d1c7f13415 47 */
yoka06 0:76d1c7f13415 48
yoka06 0:76d1c7f13415 49 #define LEFTJOYSTICKX 0
yoka06 0:76d1c7f13415 50 #define LEFTJOYSTICKY 1
yoka06 0:76d1c7f13415 51 #define RIGHTJOYSTICKX 2
yoka06 0:76d1c7f13415 52 #define RIGHTJOYSTICKY 3
yoka06 0:76d1c7f13415 53
yoka06 0:76d1c7f13415 54
yoka06 0:76d1c7f13415 55 /* Defines for the PS3 Accelerometers and Gyro
yoka06 0:76d1c7f13415 56 */
yoka06 0:76d1c7f13415 57
yoka06 0:76d1c7f13415 58 #define ACCELOROMETERX 0
yoka06 0:76d1c7f13415 59 #define ACCELOROMETERY 1
yoka06 0:76d1c7f13415 60 #define ACCELOROMETERZ 2
yoka06 0:76d1c7f13415 61 #define GYROMETERZ 3
yoka06 0:76d1c7f13415 62
yoka06 0:76d1c7f13415 63 /* Defines for the PS3 LED and Rumble
yoka06 0:76d1c7f13415 64 */
yoka06 0:76d1c7f13415 65 #define PS3LED1 0x01
yoka06 0:76d1c7f13415 66 #define PS3LED2 0x02
yoka06 0:76d1c7f13415 67 #define PS3LED3 0x04
yoka06 0:76d1c7f13415 68 #define PS3LED4 0x08
yoka06 0:76d1c7f13415 69 #define PSRUMBLEHIGH 0x10
yoka06 0:76d1c7f13415 70 #define PSRUMBLELOW 0x20
yoka06 0:76d1c7f13415 71
yoka06 0:76d1c7f13415 72 //Structure which describes the type 01 input report
yoka06 0:76d1c7f13415 73 typedef struct {
yoka06 0:76d1c7f13415 74 u8 ReportType; //Report Type 01
yoka06 0:76d1c7f13415 75 u8 Reserved1; // Unknown
yoka06 0:76d1c7f13415 76 u16 ButtonState; // Main buttons
yoka06 0:76d1c7f13415 77 u8 PSButtonState; // PS button
yoka06 0:76d1c7f13415 78 u8 Reserved2; // Unknown
yoka06 0:76d1c7f13415 79 u8 LeftStickX; // left Joystick X axis 0 - 255, 128 is mid
yoka06 0:76d1c7f13415 80 u8 LeftStickY; // left Joystick Y axis 0 - 255, 128 is mid
yoka06 0:76d1c7f13415 81 u8 RightStickX; // right Joystick X axis 0 - 255, 128 is mid
yoka06 0:76d1c7f13415 82 u8 RightStickY; // right Joystick Y axis 0 - 255, 128 is mid
yoka06 0:76d1c7f13415 83 u8 Reserved3[4]; // Unknown
yoka06 0:76d1c7f13415 84 u8 PressureUp; // digital Pad Up button Pressure 0 - 255
yoka06 0:76d1c7f13415 85 u8 PressureRight; // digital Pad Right button Pressure 0 - 255
yoka06 0:76d1c7f13415 86 u8 PressureDown; // digital Pad Down button Pressure 0 - 255
yoka06 0:76d1c7f13415 87 u8 PressureLeft; // digital Pad Left button Pressure 0 - 255
yoka06 0:76d1c7f13415 88 u8 PressureL2; // digital Pad L2 button Pressure 0 - 255
yoka06 0:76d1c7f13415 89 u8 PressureR2; // digital Pad R2 button Pressure 0 - 255
yoka06 0:76d1c7f13415 90 u8 PressureL1; // digital Pad L1 button Pressure 0 - 255
yoka06 0:76d1c7f13415 91 u8 PressureR1; // digital Pad R1 button Pressure 0 - 255
yoka06 0:76d1c7f13415 92 u8 PressureTriangle; // digital Pad Triangle button Pressure 0 - 255
yoka06 0:76d1c7f13415 93 u8 PressureCircle; // digital Pad Circle button Pressure 0 - 255
yoka06 0:76d1c7f13415 94 u8 PressureCross; // digital Pad Cross button Pressure 0 - 255
yoka06 0:76d1c7f13415 95 u8 PressureSquare; // digital Pad Square button Pressure 0 - 255
yoka06 0:76d1c7f13415 96 u8 Reserved4[3]; // Unknown
yoka06 0:76d1c7f13415 97 u8 Charge; // charging status ? 02 = charge, 03 = normal
yoka06 0:76d1c7f13415 98 u8 Power; // Battery status ?
yoka06 0:76d1c7f13415 99 u8 Connection; // Connection Type ?
yoka06 0:76d1c7f13415 100 u8 Reserved5[9]; // Unknown
yoka06 0:76d1c7f13415 101 u16 AccelX; // X axis accelerometer Big Endian 0 - 1023
yoka06 0:76d1c7f13415 102 u16 AccelY; // Y axis accelerometer Big Endian 0 - 1023
yoka06 0:76d1c7f13415 103 u16 AccelZ; // Z axis accelerometer Big Endian 0 - 1023
yoka06 0:76d1c7f13415 104 u16 GyroZ; // Z axis Gyro Big Endian 0 - 1023
yoka06 0:76d1c7f13415 105
yoka06 0:76d1c7f13415 106 } ps3report;
yoka06 0:76d1c7f13415 107
yoka06 0:76d1c7f13415 108 class Ps3USB
yoka06 0:76d1c7f13415 109 {
yoka06 0:76d1c7f13415 110
yoka06 0:76d1c7f13415 111
yoka06 0:76d1c7f13415 112 public:
yoka06 0:76d1c7f13415 113 Ps3USB(int device, int configuration, int interfaceNumber);
yoka06 0:76d1c7f13415 114 int Enable();
yoka06 0:76d1c7f13415 115 int SetPair(u8* bdAddr);
yoka06 0:76d1c7f13415 116 int ShowPair();
yoka06 0:76d1c7f13415 117 int Led(int i);
yoka06 0:76d1c7f13415 118 int Rumble(u8 duration_right, u8 power_right, u8 duration_left, u8 power_left);
yoka06 0:76d1c7f13415 119 int _count;
yoka06 0:76d1c7f13415 120
yoka06 0:76d1c7f13415 121 private:
yoka06 0:76d1c7f13415 122 int input_ep;
yoka06 0:76d1c7f13415 123 int output_ep;
yoka06 0:76d1c7f13415 124 int _device;
yoka06 0:76d1c7f13415 125 int _configuration;
yoka06 0:76d1c7f13415 126 int _interfaceNumber;
yoka06 0:76d1c7f13415 127
yoka06 0:76d1c7f13415 128 u8 ledrumble[48] ;
yoka06 0:76d1c7f13415 129
yoka06 0:76d1c7f13415 130 };
yoka06 0:76d1c7f13415 131
yoka06 0:76d1c7f13415 132 void PS3EventCallback(int device, int endpoint, int status, u8* data, int len, void* userData);
yoka06 0:76d1c7f13415 133 int ParsePs3Result(const u8* data, int len, int count);
yoka06 0:76d1c7f13415 134
yoka06 0:76d1c7f13415 135