Ohnishi_Gundan / Mbed 2 deprecated Master-FM

Dependencies:   MODSERIAL mbed-rtos mbed

Fork of Master by Ohnishi_Gundan

main.cpp

Committer:
9uS7
Date:
2014-09-12
Revision:
6:df6d8ba1907a
Parent:
5:37733f175430
Child:
8:bfcfda6b38fe

File content as of revision 6:df6d8ba1907a:

//Master mbed Program

#include "mbed.h"
#include "fm.h"
#include "bluetooth.h"
#include "control.h"

//BT_MASTER or BT_SLAVE
#define DEVICE_ROLE BT_SLAVE

//Serial pc(USBTX, USBRX);   // tx, rx
 
//debug
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led4(LED4);


void masterLoop(void);

int main()
{
    //FM_FREQUENCY is defined in fm.h
    unsigned int fm_frequency = DEVICE_ROLE==BT_MASTER ? FM_FREQUENCY1 : FM_FREQUENCY2;
    
    //fmSetup( fm_frequency );
    btSetup(DEVICE_ROLE);
    //motorSetup();
    
    while(1){
        if( DEVICE_ROLE==BT_MASTER ){
            masterLoop();
        }
        /*i2c.start();
        i2c.write(0x11);
        i2c.write(0x42);
        i2c.write(0x07);
        i2c.write(0x0F);
        i2c.stop();
        wait(0.05);*/
    }
 }

void masterLoop(){
    float ir_m,fsr_m;   //sensor of master
    float ir_s,fsr_s;   //sensor of slave
    sync(SYNC_SENSOR,NULL,NULL);
    recieveSensor( &ir_s, &fsr_s );
    led4 = ( ir_s>0.5 ? 1 : 0 );
    led2 = ( led2 ? 0 : 1 );
    wait(1);
}