Usada bajo permiso del autor tony63

Dependents:   IR-NEC

Fork of Pulse1 by Gustavo Ramirez

Committer:
PabloViana
Date:
Sat Nov 07 22:07:03 2015 +0000
Revision:
2:a91e76505e52
Parent:
1:48651f86a80c
v1;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tony63 1:48651f86a80c 1
tony63 1:48651f86a80c 2 #ifndef MBED_PULSE1_H
tony63 1:48651f86a80c 3 #define MBED_PULSE1_H
tony63 1:48651f86a80c 4
tony63 1:48651f86a80c 5 #include "mbed.h"
tony63 1:48651f86a80c 6
tony63 1:48651f86a80c 7 /** Pulse Input/Output Class(es)
tony63 1:48651f86a80c 8 */
tony63 1:48651f86a80c 9
tony63 1:48651f86a80c 10 class PulseInOut {
tony63 1:48651f86a80c 11 public:
tony63 1:48651f86a80c 12 /** Create a PulseInOut object connected to the specified pin
tony63 1:48651f86a80c 13 * @param pin i/o pin to connect to
tony63 1:48651f86a80c 14 */
tony63 1:48651f86a80c 15 PulseInOut(PinName);
tony63 1:48651f86a80c 16 ~PulseInOut();
tony63 1:48651f86a80c 17 /** Set the value of the pin
tony63 1:48651f86a80c 18 * @param val Value to set, 0 for LOW, otherwise HIGH
tony63 1:48651f86a80c 19 */
tony63 1:48651f86a80c 20 void write(int val);
tony63 1:48651f86a80c 21 /** Send a pulse of a given value for a specified time
tony63 1:48651f86a80c 22 * @param val Value to set, 0 for LOW, otherwise HIGH
tony63 1:48651f86a80c 23 * @param time Length of pulse in microseconds
tony63 1:48651f86a80c 24 */
tony63 1:48651f86a80c 25 void write_us(int val, int time);
tony63 1:48651f86a80c 26 /** Return the length of the next HIGH pulse in microsconds
tony63 1:48651f86a80c 27 */
tony63 1:48651f86a80c 28 int read_high_us();
tony63 1:48651f86a80c 29 /** Return the length of the next HIGH pulse in microseconds or -1 if longer than timeout
tony63 1:48651f86a80c 30 * @param timeout Time before pulse reading aborts and returns -1, in microseconds
tony63 1:48651f86a80c 31 */
tony63 1:48651f86a80c 32 int read_high_us(int timeout);
tony63 1:48651f86a80c 33 /** Return the length of the next LOW pulse in microsconds
tony63 1:48651f86a80c 34 */
tony63 1:48651f86a80c 35 int read_low_us();
tony63 1:48651f86a80c 36 /** Return the length of the next LOW pulse in microseconds or -1 if longer than timeout
tony63 1:48651f86a80c 37 * @param timeout Time before pulse reading aborts and returns -1, in microseconds
tony63 1:48651f86a80c 38 */
tony63 1:48651f86a80c 39 int read_low_us(int timeout);
tony63 1:48651f86a80c 40 /** Return the length of the next pulse in microsconds
tony63 1:48651f86a80c 41 */
tony63 1:48651f86a80c 42 int read_us();
tony63 1:48651f86a80c 43 /** Return the length of the next pulse in microseconds or -1 if longer than timeout
tony63 1:48651f86a80c 44 * @param timeout Time before pulse reading aborts and returns -1, in microseconds
tony63 1:48651f86a80c 45 */
tony63 1:48651f86a80c 46 int read_us(int timeout);
tony63 1:48651f86a80c 47 private:
tony63 1:48651f86a80c 48 int startval;
tony63 1:48651f86a80c 49 Timer pulsetime, runtime;
tony63 1:48651f86a80c 50 DigitalInOut io;
PabloViana 2:a91e76505e52 51 Timer Temp1;
PabloViana 2:a91e76505e52 52 int flag1;
tony63 1:48651f86a80c 53 };
tony63 1:48651f86a80c 54
tony63 1:48651f86a80c 55 #endif