Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 19:812c3572622a, committed 2021-05-07
- Comitter:
- shunsuke0427
- Date:
- Fri May 07 08:31:36 2021 +0000
- Parent:
- 18:065d88f01f2b
- Commit message:
- to be published
Changed in this revision
--- a/Socket.h Thu Sep 12 09:51:42 2019 +0000 +++ b/Socket.h Fri May 07 08:31:36 2021 +0000 @@ -24,6 +24,8 @@ Tue Apr 26 2011 Bart Janssens: added a socket listener */ +//#pragma once + #ifndef SOCKET_H_INCLUDED #define SOCKET_H_INCLUDED
--- a/TestShell.cpp Thu Sep 12 09:51:42 2019 +0000 +++ b/TestShell.cpp Fri May 07 08:31:36 2021 +0000 @@ -572,6 +572,7 @@ void TestShell() { + //pc.printf("TestShell()\r\n"); USBInit(); gApp.Run(); }
--- a/USBHost.cpp Thu Sep 12 09:51:42 2019 +0000 +++ b/USBHost.cpp Fri May 07 08:31:36 2021 +0000 @@ -921,6 +921,7 @@ void USBInit() { + //pc.printf("USBInit()\r\n"); return _controller.Init(); }
--- a/USBHost.h Thu Sep 12 09:51:42 2019 +0000 +++ b/USBHost.h Fri May 07 08:31:36 2021 +0000 @@ -21,6 +21,8 @@ THE SOFTWARE. */ +//#pragma once + #ifndef USBHOST_H #define USBHOST_H
--- a/User.cpp Thu Sep 12 09:51:42 2019 +0000 +++ b/User.cpp Fri May 07 08:31:36 2021 +0000 @@ -1,4 +1,8 @@ +//PS3コンの値をSPIで送信 +//最初に255を送る→L,RスティックのX,Yの値を送る + #include "Utils.h" + #include "USBHost.h" #include "hci.h" #include "ps3.h" @@ -6,21 +10,54 @@ #include "mbed.h" +#define waitTime 0.1 + +//#define serial + + int RSX,RSY,LSX,LSY,BSU,BSL; //これより下に関数外に書く要素を記入する + +#ifdef serial +//Serial pc(USBTX, USBRX); +#endif + +DigitalOut cs(p8); + +//PwmOut pin(p9); +SPI mySPI(p5, p6, p7); + +//SPIHalfDuplex mySPI(p5, p6, p7); PwmOut led1(LED1); PwmOut led2(LED2); -DigitalOut led3(LED3); -DigitalOut led4(LED4); +PwmOut led3(LED3); +PwmOut led4(LED4); +//DigitalOut myled(LED1); -void UserLoopSetting(){ + +void UserLoopSetting() +{ + // pc.printf("UserLoopSetting()\r\n"); //一度だけ行いたい初期設定をここに書く led1.period_ms(20); + + mySPI.format(8,3); + mySPI.frequency(1000000); + + //mySPI.format(8,3); + //mySPI.frequency(1000000); + + //mySPI.reply(0X00); + + //uint8_t reg[] = {0,1}; + + //printf("Setting...\n"); } -void UserLoop(char n,const u8* data){ +void UserLoop(char n,const u8* data) +{ u16 ButtonState; - if(n==0){//有線Ps3USB.cpp + if(n==0) { //有線Ps3USB.cpp RSX = ((ps3report*)data)->RightStickX; RSY = ((ps3report*)data)->RightStickY; LSX = ((ps3report*)data)->LeftStickX; @@ -29,7 +66,7 @@ BSL = (u8)(((ps3report*)data)->ButtonState >> 8); //ボタンの処理 ButtonState = ((ps3report*)data)->ButtonState; - }else {//無線TestShell.cpp + } else {//無線TestShell.cpp RSX = ((ps3report*)(data + 1))->RightStickX; RSY = ((ps3report*)(data + 1))->RightStickY; LSX = ((ps3report*)(data + 1))->LeftStickX; @@ -40,24 +77,40 @@ ButtonState = ((ps3report*)(data + 1))->ButtonState; } //ここより下にプログラムを書く - + + led3=LSX/256.0f; + led4=LSY/256.0f; + led1=RSX/256.0f; + led2=RSY/256.0f; + + #ifdef serial + printf("LSX:%d LSY:%d RSX:%d RSY:%d\r\n", LSX, LSY, RSX, RSY); + #endif + //led3=ButtonState & 0x0400; //L1の状態 + //led4=ButtonState & 0x0200; //R1の状態 + + /* + 0x0200 : L2 + 0x0400 : L1 + 0x0800 : L1 + */ + + + //値の取得はps3.hを参照 - //データ取得例 - if(((ButtonState >> BUTTONCIRCLE)&1) == 1) { - led1 = 1; - //○が押されたとき - }else{ - led1 = 0; - //○を押してないとき - } - - led1=LSX/256.0f; - led2=LSY/256.0f; - led3=ButtonState & 0x0400; //L1の状態 - led4=ButtonState & 0x0800; //R1の状態 - //値の取得はps3.hを参照 - //ここまでプログラム例 実機に乗せるときは消して大丈夫です - - - + + /*uint8_t first; + uint8_t second; + first = (uint8_t) ButtonState & 0XFF; + second = (uint8_t) (ButtonState>>8) & 0XFF;*/ + cs = 0; + mySPI.write(255); + mySPI.write(LSX*255/256); + mySPI.write(LSY*255/256); + mySPI.write(RSX*255/256); + mySPI.write(RSY*255/256); + //myled = 1; + cs = 1; + wait(waitTime); + //myled = 0; } \ No newline at end of file
--- a/User.h Thu Sep 12 09:51:42 2019 +0000 +++ b/User.h Fri May 07 08:31:36 2021 +0000 @@ -1,2 +1,3 @@ +//#pragma once void UserLoopSetting(void); void UserLoop(char,const u8*); \ No newline at end of file
--- a/Utils.cpp Thu Sep 12 09:51:42 2019 +0000 +++ b/Utils.cpp Fri May 07 08:31:36 2021 +0000 @@ -3,6 +3,8 @@ #include "mbed.h" #include "Utils.h" +//SPISlave mySPI(p5, p6, p7, p8); + void printfBytes(const char* s, const u8* data, int len) { printf("%s %d:",s,len);
--- a/Utils.h Thu Sep 12 09:51:42 2019 +0000 +++ b/Utils.h Fri May 07 08:31:36 2021 +0000 @@ -1,3 +1,4 @@ +//#pragma once typedef unsigned char u8; typedef unsigned short u16;
--- a/hci.h Thu Sep 12 09:51:42 2019 +0000 +++ b/hci.h Fri May 07 08:31:36 2021 +0000 @@ -20,6 +20,8 @@ THE SOFTWARE. */ +//#pragma once + #ifndef HCI_H_INCLUDED #define HCI_H_INCLUDED
--- a/main.cpp Thu Sep 12 09:51:42 2019 +0000 +++ b/main.cpp Fri May 07 08:31:36 2021 +0000 @@ -26,6 +26,7 @@ #include "FATFileSystem.h" #include "User.h" + int MassStorage_ReadCapacity(int device, u32* blockCount, u32* blockSize); int MassStorage_Read(int device, u32 blockAddr, u32 blockCount, u8* dst, u32 blockSize); int MassStorage_Write(int device, u32 blockAddr, u32 blockCount, u8* dst, u32 blockSize); @@ -103,6 +104,7 @@ */ Serial pc(USBTX, USBRX); + int GetConsoleChar() { if (!pc.readable())
--- a/mbed.bld Thu Sep 12 09:51:42 2019 +0000 +++ b/mbed.bld Fri May 07 08:31:36 2021 +0000 @@ -1,1 +1,2 @@ http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_config.h Fri May 07 08:31:36 2021 +0000 @@ -0,0 +1,26 @@ +/* + * mbed SDK + * Copyright (c) 2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Automatically generated configuration file. +// DO NOT EDIT, content will be overwritten. + +#ifndef __MBED_CONFIG_DATA__ +#define __MBED_CONFIG_DATA__ + + +#endif +
--- a/ps3.h Thu Sep 12 09:51:42 2019 +0000 +++ b/ps3.h Fri May 07 08:31:36 2021 +0000 @@ -23,6 +23,7 @@ /* Defines for the PS3 Buttons */ +//#pragma once #define BUTTONSELECT 0 #define BUTTONLANALOG 1