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 1:86d25c1c4bd5, committed 2016-03-25
- Comitter:
- baba2357
- Date:
- Fri Mar 25 03:08:41 2016 +0000
- Parent:
- 0:fad5ae05b576
- Child:
- 2:bed6b204e64c
- Commit message:
- ??????
Changed in this revision
--- a/main.cpp Thu Mar 24 15:36:02 2016 +0000
+++ b/main.cpp Fri Mar 25 03:08:41 2016 +0000
@@ -0,0 +1,17 @@
+#include "mbed.h"
+#include "pin_file.h"
+#include "spi_nucleo.h"
+#include "transfer.h"
+#include ""
+#include ""
+
+int main(){
+ void transfer();
+ while(pushed_number==0){
+
+ }
+ while(pushed_number==1){
+ }
+
+ }
+
--- a/pin_file.h Thu Mar 24 15:36:02 2016 +0000 +++ b/pin_file.h Fri Mar 25 03:08:41 2016 +0000 @@ -24,6 +24,7 @@ InterruptIn (PC_6); PwmOut (PB_4); PwmOut (PB_5); +DigitalOut (PB_0); //SPI mbed spi (PA_5, PA_6, PA_7); DigitalIn (PA_4); @@ -34,4 +35,6 @@ AnalogIn (PA_1); AnalogIn (PB_1); DigitalInOut (PC_5); +//自動切り替え +DigitalIn (PA_12); #endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/spi_nucleo.h Fri Mar 25 03:08:41 2016 +0000
@@ -0,0 +1,55 @@
+#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;
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/transfer.h Fri Mar 25 03:08:41 2016 +0000
@@ -0,0 +1,15 @@
+#ifndef TRANSFER_H
+#define TRANSFER_H
+
+DigitalIn push(PA_12);
+bool pushed_number=0;
+void transfer();
+
+#endif
+
+void transfer(){
+ push.mode(pullup);
+ if(push.read()==0) pushed_number=!pushed_nuber;
+ }
+
+