rtos test

Dependencies:   mbed-rtos mbed

Fork of rtos-test by Ryuichiro Ohira

Committer:
machines94
Date:
Sat May 14 21:15:12 2016 +0000
Revision:
1:ae213d6a0adf
Electromobility 2016
;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
machines94 1:ae213d6a0adf 1 /* Copyright (c) 2013 Prabhu Desai
machines94 1:ae213d6a0adf 2 * pdtechworld@gmail.com
machines94 1:ae213d6a0adf 3 *
machines94 1:ae213d6a0adf 4 *
machines94 1:ae213d6a0adf 5 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
machines94 1:ae213d6a0adf 6 * and associated documentation files (the "Software"), to deal in the Software without restriction,
machines94 1:ae213d6a0adf 7 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
machines94 1:ae213d6a0adf 8 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
machines94 1:ae213d6a0adf 9 * furnished to do so, subject to the following conditions:
machines94 1:ae213d6a0adf 10 *
machines94 1:ae213d6a0adf 11 * The above copyright notice and this permission notice shall be included in all copies or
machines94 1:ae213d6a0adf 12 * substantial portions of the Software.
machines94 1:ae213d6a0adf 13 *
machines94 1:ae213d6a0adf 14 * For more details on the sensor :
machines94 1:ae213d6a0adf 15 * http://www.elecfreaks.com/store/hcsr04-ultrasonic-sensor-distance-measuring-module-p-91.html?zenid=pgm8pgnvaodbe36dibq5s1soi3
machines94 1:ae213d6a0adf 16 *
machines94 1:ae213d6a0adf 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
machines94 1:ae213d6a0adf 18 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
machines94 1:ae213d6a0adf 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
machines94 1:ae213d6a0adf 20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
machines94 1:ae213d6a0adf 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
machines94 1:ae213d6a0adf 22 */
machines94 1:ae213d6a0adf 23
machines94 1:ae213d6a0adf 24 #ifndef MBED_HCSR04_H
machines94 1:ae213d6a0adf 25 #define MBED_HCSR04_H
machines94 1:ae213d6a0adf 26
machines94 1:ae213d6a0adf 27 #include "mbed.h"
machines94 1:ae213d6a0adf 28
machines94 1:ae213d6a0adf 29 /** HCSR04 Class(es)
machines94 1:ae213d6a0adf 30 */
machines94 1:ae213d6a0adf 31
machines94 1:ae213d6a0adf 32 class HCSR04
machines94 1:ae213d6a0adf 33 {
machines94 1:ae213d6a0adf 34 public:
machines94 1:ae213d6a0adf 35 /** Create a HCSR04 object connected to the specified pin
machines94 1:ae213d6a0adf 36 * @param pin i/o pin to connect to
machines94 1:ae213d6a0adf 37 */
machines94 1:ae213d6a0adf 38 HCSR04(PinName TrigPin,PinName EchoPin);
machines94 1:ae213d6a0adf 39 ~HCSR04();
machines94 1:ae213d6a0adf 40
machines94 1:ae213d6a0adf 41 /** Return the distance from obstacle in cm
machines94 1:ae213d6a0adf 42 * @param distance in cms and returns -1, in case of failure
machines94 1:ae213d6a0adf 43 */
machines94 1:ae213d6a0adf 44 unsigned int get_dist_cm(void);
machines94 1:ae213d6a0adf 45 /** Return the pulse duration equal to sonic waves travelling to obstacle and back to receiver.
machines94 1:ae213d6a0adf 46 * @param pulse duration in microseconds.
machines94 1:ae213d6a0adf 47 */
machines94 1:ae213d6a0adf 48 unsigned int get_pulse_us(void);
machines94 1:ae213d6a0adf 49 /** Generates the trigger pulse of 10us on the trigger PIN.
machines94 1:ae213d6a0adf 50 */
machines94 1:ae213d6a0adf 51 void start(void );
machines94 1:ae213d6a0adf 52 void isr_rise(void);
machines94 1:ae213d6a0adf 53 void isr_fall(void);
machines94 1:ae213d6a0adf 54 void fall (void (*fptr)(void));
machines94 1:ae213d6a0adf 55 void rise (void (*fptr)(void));
machines94 1:ae213d6a0adf 56
machines94 1:ae213d6a0adf 57
machines94 1:ae213d6a0adf 58
machines94 1:ae213d6a0adf 59 private:
machines94 1:ae213d6a0adf 60
machines94 1:ae213d6a0adf 61 Timer pulsetime;
machines94 1:ae213d6a0adf 62 DigitalOut trigger;
machines94 1:ae213d6a0adf 63 InterruptIn echo;
machines94 1:ae213d6a0adf 64 unsigned int pulsedur;
machines94 1:ae213d6a0adf 65 unsigned int distance;
machines94 1:ae213d6a0adf 66 };
machines94 1:ae213d6a0adf 67
machines94 1:ae213d6a0adf 68 #endif