working version with calibration done

Fork of Eurobot2013 by Oskar Weigl

Committer:
xiaxia686
Date:
Tue Apr 09 15:32:47 2013 +0000
Revision:
11:5ba926692210
Parent:
10:2bd9f4e02b74
woking version (calibrated)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sv 1:6799c07fe510 1 #ifndef MBED_RFSRF05_H
sv 1:6799c07fe510 2 #define MBED_RFSRF05_H
sv 1:6799c07fe510 3
sv 1:6799c07fe510 4
sv 1:6799c07fe510 5
sv 1:6799c07fe510 6 #include "mbed.h"
sv 1:6799c07fe510 7 #include "RF12B.h"
sv 1:6799c07fe510 8 #include "globals.h"
sv 1:6799c07fe510 9
sv 1:6799c07fe510 10
sv 1:6799c07fe510 11 #define CODE0 0x22
sv 1:6799c07fe510 12 #define CODE1 0x44
sv 1:6799c07fe510 13 #define CODE2 0x88
sv 1:6799c07fe510 14
sv 1:6799c07fe510 15 /* SAMPLE IMPLEMENTATION!
sv 1:6799c07fe510 16 RFSRF05 my_srf(p13,p21,p22,p23,p24,p25,p26,p5,p6,p7,p8,p9);
sv 1:6799c07fe510 17
sv 1:6799c07fe510 18
sv 1:6799c07fe510 19 void callbinmain(int num, float dist) {
sv 1:6799c07fe510 20 //Here is where you deal with your brand new reading ;D
sv 1:6799c07fe510 21 }
sv 1:6799c07fe510 22
sv 1:6799c07fe510 23 int main() {
sv 1:6799c07fe510 24 pc.printf("Hello World of RobotSonar!\r\n");
sv 1:6799c07fe510 25 my_srf.callbackfunc = callbinmain;
sv 1:6799c07fe510 26
sv 1:6799c07fe510 27 while (1);
sv 1:6799c07fe510 28 }
sv 1:6799c07fe510 29
sv 1:6799c07fe510 30 */
sv 1:6799c07fe510 31
sv 1:6799c07fe510 32 class DummyCT;
sv 1:6799c07fe510 33
sv 1:6799c07fe510 34 class RFSRF05 {
sv 1:6799c07fe510 35 public:
sv 1:6799c07fe510 36
sv 1:6799c07fe510 37 RFSRF05(
sv 1:6799c07fe510 38 PinName trigger,
sv 1:6799c07fe510 39 PinName echo0,
sv 1:6799c07fe510 40 PinName echo1,
sv 1:6799c07fe510 41 PinName echo2,
sv 1:6799c07fe510 42 PinName echo3,
sv 1:6799c07fe510 43 PinName echo4,
sv 1:6799c07fe510 44 PinName echo5,
sv 1:6799c07fe510 45 PinName SDI,
sv 1:6799c07fe510 46 PinName SDO,
sv 1:6799c07fe510 47 PinName SCK,
sv 1:6799c07fe510 48 PinName NCS,
sv 1:6799c07fe510 49 PinName NIRQ);
sv 1:6799c07fe510 50
sv 1:6799c07fe510 51 /** A non-blocking function that will return the last measurement
sv 1:6799c07fe510 52 *
sv 1:6799c07fe510 53 * @returns floating point representation of distance in mm
sv 1:6799c07fe510 54 */
sv 1:6799c07fe510 55 float read0();
sv 1:6799c07fe510 56 float read1();
sv 1:6799c07fe510 57 float read2();
sv 1:6799c07fe510 58 float read(unsigned int beaconnum);
sv 1:6799c07fe510 59
sv 1:6799c07fe510 60
sv 1:6799c07fe510 61 /** A assigns a callback function when a new reading is available **/
xiaxia686 11:5ba926692210 62 void (*callbackfunc)(int beaconnum, float distance, float variance);
sv 1:6799c07fe510 63 DummyCT* callbackobj;
sv 1:6799c07fe510 64 void (DummyCT::*mcallbackfunc)(int beaconnum, float distance, float variance);
sv 1:6799c07fe510 65
sv 1:6799c07fe510 66 //triggers a read
sv 1:6799c07fe510 67 #ifndef ROBOT_PRIMARY
sv 1:6799c07fe510 68 void startRange(unsigned char rx_code);
sv 1:6799c07fe510 69 #endif
sv 1:6799c07fe510 70
sv 1:6799c07fe510 71 //set codes
sv 1:6799c07fe510 72 void setCode(int code_index, unsigned char code);
sv 1:6799c07fe510 73 unsigned char codes[3];
sv 1:6799c07fe510 74
sv 1:6799c07fe510 75 /** A short hand way of using the read function */
sv 1:6799c07fe510 76 //operator float();
sv 1:6799c07fe510 77
sv 1:6799c07fe510 78 private :
sv 1:6799c07fe510 79 RF12B _rf;
sv 1:6799c07fe510 80 DigitalOut _trigger;
sv 1:6799c07fe510 81 InterruptIn _echo0;
sv 1:6799c07fe510 82 InterruptIn _echo1;
sv 1:6799c07fe510 83 InterruptIn _echo2;
sv 1:6799c07fe510 84 InterruptIn _echo3;
sv 1:6799c07fe510 85 InterruptIn _echo4;
sv 1:6799c07fe510 86 InterruptIn _echo5;
sv 1:6799c07fe510 87 Timer _timer;
sv 1:6799c07fe510 88 Ticker _ticker;
sv 1:6799c07fe510 89 #ifdef ROBOT_PRIMARY
sv 1:6799c07fe510 90 void _startRange(void);
sv 1:6799c07fe510 91 #endif
sv 1:6799c07fe510 92 void _rising (void);
sv 1:6799c07fe510 93 void _falling (void);
sv 1:6799c07fe510 94 float _dist[3];
sv 1:6799c07fe510 95 int _beacon_counter;
sv 1:6799c07fe510 96 bool ValidPulse;
sv 1:6799c07fe510 97 bool expValidPulse;
sv 1:6799c07fe510 98
sv 1:6799c07fe510 99 };
sv 1:6799c07fe510 100
sv 1:6799c07fe510 101 #endif