Ohnishi_Gundan / Mbed 2 deprecated Master-FM

Dependencies:   MODSERIAL mbed-rtos mbed

Fork of Master by Ohnishi_Gundan

Committer:
9uS7
Date:
Sat Sep 13 09:42:55 2014 +0000
Revision:
8:bfcfda6b38fe
Parent:
6:df6d8ba1907a
Child:
9:6057314dc8ec
bluetoothable

Who changed what in which revision?

UserRevisionLine numberNew contents of line
9uS7 0:4f07ba929908 1 //Master mbed Program
9uS7 0:4f07ba929908 2
9uS7 0:4f07ba929908 3 #include "mbed.h"
9uS7 0:4f07ba929908 4 #include "fm.h"
9uS7 0:4f07ba929908 5 #include "bluetooth.h"
9uS7 1:e1cfb5850088 6 #include "control.h"
9uS7 0:4f07ba929908 7
9uS7 1:e1cfb5850088 8 //BT_MASTER or BT_SLAVE
9uS7 5:37733f175430 9 #define DEVICE_ROLE BT_SLAVE
9uS7 0:4f07ba929908 10
9uS7 4:aaaadb45cbd9 11 //Serial pc(USBTX, USBRX); // tx, rx
9uS7 0:4f07ba929908 12
9uS7 0:4f07ba929908 13 //debug
9uS7 0:4f07ba929908 14 DigitalOut led1(LED1);
9uS7 0:4f07ba929908 15 DigitalOut led2(LED2);
9uS7 0:4f07ba929908 16 DigitalOut led4(LED4);
9uS7 5:37733f175430 17
9uS7 0:4f07ba929908 18
9uS7 3:12e1f116ea42 19 void masterLoop(void);
9uS7 0:4f07ba929908 20
9uS7 0:4f07ba929908 21 int main()
9uS7 0:4f07ba929908 22 {
9uS7 1:e1cfb5850088 23 //FM_FREQUENCY is defined in fm.h
9uS7 1:e1cfb5850088 24 unsigned int fm_frequency = DEVICE_ROLE==BT_MASTER ? FM_FREQUENCY1 : FM_FREQUENCY2;
9uS7 1:e1cfb5850088 25
9uS7 3:12e1f116ea42 26 //fmSetup( fm_frequency );
9uS7 1:e1cfb5850088 27 btSetup(DEVICE_ROLE);
9uS7 3:12e1f116ea42 28 //motorSetup();
9uS7 2:c610e1a7fbcd 29
9uS7 0:4f07ba929908 30 while(1){
9uS7 3:12e1f116ea42 31 if( DEVICE_ROLE==BT_MASTER ){
9uS7 3:12e1f116ea42 32 masterLoop();
9uS7 3:12e1f116ea42 33 }
9uS7 0:4f07ba929908 34 /*i2c.start();
9uS7 0:4f07ba929908 35 i2c.write(0x11);
9uS7 0:4f07ba929908 36 i2c.write(0x42);
9uS7 0:4f07ba929908 37 i2c.write(0x07);
9uS7 0:4f07ba929908 38 i2c.write(0x0F);
9uS7 0:4f07ba929908 39 i2c.stop();
9uS7 0:4f07ba929908 40 wait(0.05);*/
9uS7 0:4f07ba929908 41 }
9uS7 0:4f07ba929908 42 }
9uS7 0:4f07ba929908 43
9uS7 3:12e1f116ea42 44 void masterLoop(){
9uS7 3:12e1f116ea42 45 float ir_m,fsr_m; //sensor of master
9uS7 3:12e1f116ea42 46 float ir_s,fsr_s; //sensor of slave
9uS7 6:df6d8ba1907a 47 recieveSensor( &ir_s, &fsr_s );
9uS7 4:aaaadb45cbd9 48 led4 = ( ir_s>0.5 ? 1 : 0 );
9uS7 4:aaaadb45cbd9 49 led2 = ( led2 ? 0 : 1 );
9uS7 4:aaaadb45cbd9 50 wait(1);
9uS7 3:12e1f116ea42 51 }