主導機 mbed用のプログラムです

Dependencies:   mbed

Fork of F3RC_syudou_master by F3RC1班

Committer:
yuto17320508
Date:
Mon Aug 21 08:43:52 2017 +0000
Revision:
17:c5c41fcf316e
Parent:
16:b232fd9ee9c2
Child:
18:2579c275ef57
make

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hirokimineshita 0:736c76a75def 1 #include "Utils.h"
hirokimineshita 0:736c76a75def 2 #include "USBHost.h"
hirokimineshita 0:736c76a75def 3 #include "hci.h"
hirokimineshita 0:736c76a75def 4 #include "ps3.h"
hirokimineshita 0:736c76a75def 5 #include "User.h"
hirokimineshita 0:736c76a75def 6 #include "mbed.h"
hirokimineshita 0:736c76a75def 7
hirokimineshita 0:736c76a75def 8 int RSX,RSY,LSX,LSY,BSU,BSL;
hirokimineshita 9:e5437ba3e920 9 //これより下に関数外に書く要素を記入する
yuto17320508 16:b232fd9ee9c2 10 //spi通信用
yuto17320508 16:b232fd9ee9c2 11 SPI spi(p5,p6,p7);
yuto17320508 16:b232fd9ee9c2 12 DigitalOut cs(p8);
yuto17320508 16:b232fd9ee9c2 13
baba2357 11:86d717718dbf 14
yuto17320508 16:b232fd9ee9c2 15 void UserLoopSetting()
yuto17320508 16:b232fd9ee9c2 16 {
yuto17320508 17:c5c41fcf316e 17 spi.format(8,3);
yuto17320508 16:b232fd9ee9c2 18 spi.frequency(1000000);
hirokimineshita 0:736c76a75def 19 }
hirokimineshita 0:736c76a75def 20
yuto17320508 16:b232fd9ee9c2 21 void UserLoop(char n,const u8* data)
yuto17320508 16:b232fd9ee9c2 22 {
hirokimineshita 0:736c76a75def 23 u16 ButtonState;
yuto17320508 16:b232fd9ee9c2 24 if(n==0) { //有線Ps3USB.cpp
hirokimineshita 0:736c76a75def 25 RSX = ((ps3report*)data)->RightStickX;
hirokimineshita 0:736c76a75def 26 RSY = ((ps3report*)data)->RightStickY;
hirokimineshita 0:736c76a75def 27 LSX = ((ps3report*)data)->LeftStickX;
hirokimineshita 0:736c76a75def 28 LSY = ((ps3report*)data)->LeftStickY;
hirokimineshita 0:736c76a75def 29 BSU = (u8)(((ps3report*)data)->ButtonState & 0x00ff);
hirokimineshita 0:736c76a75def 30 BSL = (u8)(((ps3report*)data)->ButtonState >> 8);
hirokimineshita 0:736c76a75def 31 //ボタンの処理
hirokimineshita 0:736c76a75def 32 ButtonState = ((ps3report*)data)->ButtonState;
yuto17320508 16:b232fd9ee9c2 33 } else {//無線TestShell.cpp
hirokimineshita 0:736c76a75def 34 RSX = ((ps3report*)(data + 1))->RightStickX;
hirokimineshita 0:736c76a75def 35 RSY = ((ps3report*)(data + 1))->RightStickY;
hirokimineshita 0:736c76a75def 36 LSX = ((ps3report*)(data + 1))->LeftStickX;
hirokimineshita 0:736c76a75def 37 LSY = ((ps3report*)(data + 1))->LeftStickY;
hirokimineshita 0:736c76a75def 38 BSU = (u8)(((ps3report*)(data + 1))->ButtonState & 0x00ff);
hirokimineshita 0:736c76a75def 39 BSL = (u8)(((ps3report*)(data + 1))->ButtonState >> 8);
hirokimineshita 0:736c76a75def 40 //ボタンの処理
hirokimineshita 0:736c76a75def 41 ButtonState = ((ps3report*)(data + 1))->ButtonState;
hirokimineshita 0:736c76a75def 42 }
hirokimineshita 0:736c76a75def 43 //ここより下にプログラムを書く
yuto17320508 16:b232fd9ee9c2 44 //spi通信用プログラム
yuto17320508 16:b232fd9ee9c2 45
yuto17320508 17:c5c41fcf316e 46 int a,b,c,d,e,f,g,h;
yuto17320508 16:b232fd9ee9c2 47 int send = 0;
yuto17320508 16:b232fd9ee9c2 48
yuto17320508 16:b232fd9ee9c2 49
yuto17320508 16:b232fd9ee9c2 50 while(1) {
yuto17320508 17:c5c41fcf316e 51 if((ButtonState >> BUTTONUP)&1 == 1) {//対応するボタンを書く(今回上ボタン
yuto17320508 16:b232fd9ee9c2 52 a = 1;
yuto17320508 16:b232fd9ee9c2 53 } else {
yuto17320508 16:b232fd9ee9c2 54 a = 0;
yuto17320508 16:b232fd9ee9c2 55 }
yuto17320508 16:b232fd9ee9c2 56
yuto17320508 17:c5c41fcf316e 57 if((ButtonState >> BUTTONDOWN)&1 == 1) {//対応するボタンを書く(今回下ボタン
yuto17320508 16:b232fd9ee9c2 58 b = 2;
yuto17320508 16:b232fd9ee9c2 59 } else {
yuto17320508 16:b232fd9ee9c2 60 b = 0;
yuto17320508 16:b232fd9ee9c2 61 }
yuto17320508 16:b232fd9ee9c2 62
yuto17320508 17:c5c41fcf316e 63 if((ButtonState >> BUTTONL1)&1 == 1) {//対応するボタンを書く(今回L1ボタン
yuto17320508 16:b232fd9ee9c2 64 c = 4;
yuto17320508 16:b232fd9ee9c2 65 } else {
yuto17320508 16:b232fd9ee9c2 66 c = 0;
yuto17320508 16:b232fd9ee9c2 67 }
yuto17320508 16:b232fd9ee9c2 68
yuto17320508 17:c5c41fcf316e 69 if((ButtonState >> BUTTONL2)&1 == 1) {//対応するボタンを書く(今回L2ボタン
yuto17320508 16:b232fd9ee9c2 70 d = 8;
yuto17320508 16:b232fd9ee9c2 71 } else {
yuto17320508 16:b232fd9ee9c2 72 d = 0;
yuto17320508 16:b232fd9ee9c2 73 }
yuto17320508 16:b232fd9ee9c2 74
yuto17320508 17:c5c41fcf316e 75 if((ButtonState >> BUTTONTRIANGEL)&1 == 1) {//対応するボタンを書く(今回△ボタン
yuto17320508 16:b232fd9ee9c2 76 e = 16;
yuto17320508 16:b232fd9ee9c2 77 } else {
yuto17320508 16:b232fd9ee9c2 78 e = 0;
abcdefgh 13:3d7a8cb91eeb 79 }
yuto17320508 16:b232fd9ee9c2 80
yuto17320508 17:c5c41fcf316e 81 if((ButtonState >> BUTTONCROSS)&1 == 1) {//対応するボタンを書く(今回×ボタン
yuto17320508 16:b232fd9ee9c2 82 f = 32;
yuto17320508 16:b232fd9ee9c2 83 } else {
yuto17320508 16:b232fd9ee9c2 84 f = 0;
yuto17320508 16:b232fd9ee9c2 85 }
yuto17320508 16:b232fd9ee9c2 86
yuto17320508 17:c5c41fcf316e 87 if((ButtonState >> BUTTONR1)&1 == 1) {//対応するボタンを書く(今回R1ボタン
yuto17320508 16:b232fd9ee9c2 88 g = 64;
yuto17320508 16:b232fd9ee9c2 89 } else {
yuto17320508 16:b232fd9ee9c2 90 g = 0;
yuto17320508 16:b232fd9ee9c2 91 }
yuto17320508 16:b232fd9ee9c2 92
yuto17320508 17:c5c41fcf316e 93 if((ButtonState >> BUTTONR2)&1 == 1) {//対応するボタンを書く(今回R2ボタン
yuto17320508 16:b232fd9ee9c2 94 h = 128;
yuto17320508 16:b232fd9ee9c2 95 } else {
yuto17320508 16:b232fd9ee9c2 96 h = 0;
yuto17320508 16:b232fd9ee9c2 97 }
yuto17320508 16:b232fd9ee9c2 98
yuto17320508 16:b232fd9ee9c2 99
yuto17320508 16:b232fd9ee9c2 100
yuto17320508 17:c5c41fcf316e 101 send = a+b+c+d+e+f+g+h;
yuto17320508 16:b232fd9ee9c2 102
yuto17320508 16:b232fd9ee9c2 103 cs = 0;
yuto17320508 16:b232fd9ee9c2 104 spi. write(send);
yuto17320508 16:b232fd9ee9c2 105 cs = 1;
yuto17320508 16:b232fd9ee9c2 106 printf("%d\r\n",send);
yuto17320508 16:b232fd9ee9c2 107
yuto17320508 16:b232fd9ee9c2 108 }
hirokimineshita 0:736c76a75def 109 }