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
Fork of circle_war_ver_A_NUCLEO_ by
Diff: spi_nucleo.h
- Revision:
- 8:554e3d643b2d
- Parent:
- 7:4f5cd0051db0
- Child:
- 14:3403ce49a37a
--- a/spi_nucleo.h Fri Apr 01 06:15:24 2016 +0000 +++ b/spi_nucleo.h Sun Apr 03 18:30:55 2016 +0000 @@ -1,15 +1,12 @@ +#include "mbed.h" +#include "pin_file.h" +#include <string.h> #ifndef SPI_NUCLEO_H #define SPI_NUCLEO_H -#include "pin_file.h" -#include <string.h> //SPI mbed -bool RR=0; -bool LR=0; -int speed_X; -int speed_Y; -bool Xpm=0; -bool Ypm=0; +bool RR=0,LR=0,Xpm=0,cilinder=0,onoff=0,updown=0,Ypm=0; +int speed_X,speed_Y; //SPI NUCLEO void spi_mbed(); void spi_nucleo(); @@ -23,7 +20,7 @@ void spiInit(); void spi_mbed(); void getGyro(); -#endif +#endif void spiInit() { @@ -40,29 +37,32 @@ LR=0; FM=from_mbed.read(); Xpm=FM>>13; - Ypm=(FM&0x40)>>6; - if(FM>>15==1) { + Ypm=(FM&0x10)>>4; + cilinder=(FM&0x0100)>>8; + onoff=(FM&0x0080)>>7; + updown=(FM&0x0040)>>6; + if((FM>>15)==1) { RR=1; } //右旋回の関数へ - else if(FM>>14==1) { + else if((FM>>14)==1) { LR=1; } //左旋回の関数へ else if(Xpm==1) { //コントローラーのX方向成分入力 - speed_X=FM&0x1F80; - speed_X=speed_X>>7; - if(Ypm==0) speed_Y=FM&0x3F; + speed_X=FM&0x1e00; + speed_X=speed_X>>9; + if(Ypm==0) speed_Y=FM&0xf; else { - speed_Y=FM&0x3F; + speed_Y=FM&0xf; speed_Y=(-1)*speed_Y; } } else { - speed_X=FM&0x1F80; - speed_X=speed_X>>7; + speed_X=FM&0x1e00; + speed_X=speed_X>>9; speed_X=(-1)*speed_X; - if(Ypm==0) speed_Y=FM&0x3F; + if(Ypm==0) speed_Y=FM&0xf; else { - speed_Y=FM&0x3F; + speed_Y=FM&0xf; speed_Y=(-1)*speed_Y; } } @@ -80,4 +80,3 @@ // pc.printf("%d\r\n",data); } } -