DP

Dependencies:   FastAnalogIn mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ultrasonic.h Source File

ultrasonic.h

00001 #ifndef _ULTRASONIC_H
00002 #define _ULTRASONIC_H
00003 
00004 #include "mbed.h"
00005 #include "rtos.h"
00006 
00007 class cUltrasonic {
00008     public:     
00009         cUltrasonic(PinName pinEcho, PinName pinTrig);
00010         
00011         /* This method set trigger */
00012         void setTrig();
00013         
00014         /* This method returns width of received pulse*/
00015         int getPulseWidth();
00016         
00017         /* Pointer to thread*/
00018         Thread* thread;
00019     
00020     private:
00021         DigitalOut trig;
00022         InterruptIn echo;
00023         
00024         Timer timer;
00025         float pulseWidth;
00026         
00027         /* ISR of rising edge */
00028         void riseEdge(void);
00029         
00030         /* ISR of falling edge*/
00031         void fallEdge(void);
00032     
00033 
00034 };
00035 #endif