Ohnishi_Gundan / Mbed 2 deprecated Master-FM

Dependencies:   MODSERIAL mbed-rtos mbed

Fork of Master by Ohnishi_Gundan

Committer:
9uS7
Date:
Fri Sep 12 08:08:21 2014 +0000
Revision:
4:aaaadb45cbd9
Parent:
3:12e1f116ea42
Child:
5:37733f175430
09/12/17

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 1:e1cfb5850088 9 #define DEVICE_ROLE BT_MASTER
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 0:4f07ba929908 17
9uS7 0:4f07ba929908 18 DigitalOut myled1(LED1);
9uS7 0:4f07ba929908 19 DigitalOut myled2(LED2);
9uS7 0:4f07ba929908 20
9uS7 3:12e1f116ea42 21 void masterLoop(void);
9uS7 0:4f07ba929908 22
9uS7 0:4f07ba929908 23 int main()
9uS7 0:4f07ba929908 24 {
9uS7 1:e1cfb5850088 25 //FM_FREQUENCY is defined in fm.h
9uS7 1:e1cfb5850088 26 unsigned int fm_frequency = DEVICE_ROLE==BT_MASTER ? FM_FREQUENCY1 : FM_FREQUENCY2;
9uS7 1:e1cfb5850088 27
9uS7 3:12e1f116ea42 28 //fmSetup( fm_frequency );
9uS7 1:e1cfb5850088 29 btSetup(DEVICE_ROLE);
9uS7 3:12e1f116ea42 30 //motorSetup();
9uS7 2:c610e1a7fbcd 31
9uS7 0:4f07ba929908 32 while(1){
9uS7 3:12e1f116ea42 33 if( DEVICE_ROLE==BT_MASTER ){
9uS7 3:12e1f116ea42 34 masterLoop();
9uS7 3:12e1f116ea42 35 }
9uS7 0:4f07ba929908 36 /*i2c.start();
9uS7 0:4f07ba929908 37 i2c.write(0x11);
9uS7 0:4f07ba929908 38 i2c.write(0x42);
9uS7 0:4f07ba929908 39 i2c.write(0x07);
9uS7 0:4f07ba929908 40 i2c.write(0x0F);
9uS7 0:4f07ba929908 41 i2c.stop();
9uS7 0:4f07ba929908 42 wait(0.05);*/
9uS7 0:4f07ba929908 43 }
9uS7 0:4f07ba929908 44 }
9uS7 0:4f07ba929908 45
9uS7 3:12e1f116ea42 46 void masterLoop(){
9uS7 3:12e1f116ea42 47 float ir_m,fsr_m; //sensor of master
9uS7 3:12e1f116ea42 48 float ir_s,fsr_s; //sensor of slave
9uS7 3:12e1f116ea42 49 sync(SYNC_SENSOR,NULL,NULL);
9uS7 3:12e1f116ea42 50 receiveSensor( &ir_s, &fsr_s );
9uS7 4:aaaadb45cbd9 51 led4 = ( ir_s>0.5 ? 1 : 0 );
9uS7 4:aaaadb45cbd9 52 led2 = ( led2 ? 0 : 1 );
9uS7 4:aaaadb45cbd9 53 wait(1);
9uS7 3:12e1f116ea42 54 }