FM-test

Dependencies:   MODSERIAL mbed-rtos mbed

Fork of Master by Ohnishi_Gundan

Files at this revision

API Documentation at this revision

Comitter:
9uS7
Date:
Thu Sep 11 15:09:05 2014 +0000
Parent:
1:e1cfb5850088
Child:
3:12e1f116ea42
Commit message:
made motorSetup

Changed in this revision

bluetooth.cpp Show annotated file Show diff for this revision Revisions of this file
bluetooth.h Show annotated file Show diff for this revision Revisions of this file
control.cpp Show annotated file Show diff for this revision Revisions of this file
control.h Show annotated file Show diff for this revision Revisions of this file
fm.cpp Show annotated file Show diff for this revision Revisions of this file
fm.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/bluetooth.cpp	Thu Sep 11 14:42:49 2014 +0000
+++ b/bluetooth.cpp	Thu Sep 11 15:09:05 2014 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include "bluetooth.h"
+#include "control.h"
 
 Serial bt(p13, p14);  // tx, rx
 
@@ -16,5 +17,17 @@
     else{
     //if this device is the slave
         ;           //nothing to do
+}
+/*
+void btLoop(int role)
+{
+    if( role==BT_MASATER ){
+    //if this device is the master
+        
     }
-}
\ No newline at end of file
+    else{
+    //if this device is the slave
+        
+    }
+}
+*/
\ No newline at end of file
--- a/bluetooth.h	Thu Sep 11 14:42:49 2014 +0000
+++ b/bluetooth.h	Thu Sep 11 15:09:05 2014 +0000
@@ -6,7 +6,6 @@
 #define BT_MASTER 0
 #define BT_SLAVE -1
 
-
 typedef union _cvt{
     char byte[8];
     int in[2];
@@ -15,4 +14,6 @@
 
 void btSetup(int);          //setup(role) role:BT_MASTER or BT_SLAVE
 
+//void btLoop(int);       //btLoop(role)  role:BT_MASTER or BT_SLAVE
+
 #endif
\ No newline at end of file
--- a/control.cpp	Thu Sep 11 14:42:49 2014 +0000
+++ b/control.cpp	Thu Sep 11 15:09:05 2014 +0000
@@ -10,6 +10,10 @@
 DigitalOut Sig2(p23);
 PwmOut Pwm(p22);
 
+void motorSetup(void){
+    resetPos();    
+}
+
 void pull(float buf){
     Sig1 = 0;
     Sig2 = 1;
@@ -34,7 +38,7 @@
     Pwm = 0;
 }
 
-void ResetPos(void){
+void resetPos(void){
     int pos_flag=0;
     
     while(1){
--- a/control.h	Thu Sep 11 14:42:49 2014 +0000
+++ b/control.h	Thu Sep 11 15:09:05 2014 +0000
@@ -8,9 +8,13 @@
 #define late_time 0.3
 #define zeroPWM 0.17
 
+void motorSetup(void);
+
 void pull(float);   //pull motor(power)   power:0~1
 void loose(float);  //loose motor(power)  power:0~1
 void brake(void);   //brake motor()
 void open(void);    //open motor()
 
+void resetPos(void);
+
 #endif
\ No newline at end of file
--- a/fm.cpp	Thu Sep 11 14:42:49 2014 +0000
+++ b/fm.cpp	Thu Sep 11 15:09:05 2014 +0000
@@ -4,7 +4,7 @@
 
 I2C i2c(p9,p10);    // SDA,SCI
 
-void i2cSetup(unsigned int _f)
+void fmSetup(unsigned int _f)
 {
     char freqH = 0, freqL = 0;//, c, i;
     unsigned int frequencyB, freq, freqB;
--- a/fm.h	Thu Sep 11 14:42:49 2014 +0000
+++ b/fm.h	Thu Sep 11 15:09:05 2014 +0000
@@ -7,6 +7,7 @@
 #define FM_FREQUENCY1 792
 #define FM_FREQUENCY2 898
 
-void i2cSetup(unsigned int);     //setup i2c (int frequency) frequency:760~910
+void fmSetup(unsigned int);     //setup i2c (int frequency) frequency:760~910
+
 
 #endif
\ No newline at end of file
--- a/main.cpp	Thu Sep 11 14:42:49 2014 +0000
+++ b/main.cpp	Thu Sep 11 15:09:05 2014 +0000
@@ -18,8 +18,8 @@
 DigitalOut myled1(LED1);
 DigitalOut myled2(LED2);
 
-//byte converter
-Cvt cvt;
+//buf:for bluetooth
+Cvt buf;
 
 void btRead(void);
 
@@ -28,8 +28,10 @@
     //FM_FREQUENCY is defined in fm.h
     unsigned int fm_frequency = DEVICE_ROLE==BT_MASTER ? FM_FREQUENCY1 : FM_FREQUENCY2;
     
-    i2cSetup( fm_frequency );
+    fmSetup( fm_frequency );
     btSetup(DEVICE_ROLE);
+    motorSetup();
+    
     while(1){
         /*i2c.start();
         i2c.write(0x11);