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
spi_nucleo.h
- Committer:
- baba2357
- Date:
- 2016-03-25
- Revision:
- 1:86d25c1c4bd5
- Child:
- 2:bed6b204e64c
File content as of revision 1:86d25c1c4bd5:
#ifndef SPI_NUCLEO_H #define SPI_NUCLEO_H //SPI mbed SPI from_mbed(PA_5, PA_6, PA_7); DigitalIn (PA_4); int FM; bool RR; bool LR; char speed_X; char speed_Y; //SPI NUCLEO SPI from_gyro(PB_13, PB_14, PB_15); DigitalIn (PB_12); int G; void spi_mbed(); void spi_nucleo(); #endif void spiInit(){ from_mbed.format(16,3); from_gyro.format(16,3); from_mbed.frequency(1000000); from_gyro.frequency(1000000); } void spi_mbed(){ if(from_mbed.receive()){ FM=from_mbed.read(); RR=FM>>15; LR=FM>>14; if(RR==1) //右旋回の関数へ else if(LR==1) //左旋回の関数へ else if(FM>>13==1){ //コントローラーのX方向成分入力 speed_X=FM>>7-128; if(FM>>6==1) speed_Y=FM-128; else speed_Y=FM; } else{ speed_X=FM>>7*(-1); if(FM>>6==1) speed_Y=FM-128; else speed_Y=FM; } } void getGyro(){ u16 data; if(from_gyro.receive()) { data = gyro_gyro.read(); if(data >> 15) angle = -(data & 0x7fff); else angle = data & 0x7fff; now_angle = (double)angle / 10; } }