PARA IRDA

Dependents:   irda irda1 Tarea5 irda ... more

Fork of Pulse by Nick Ryder

Committer:
tony63
Date:
Thu Nov 07 03:34:00 2013 +0000
Revision:
1:48651f86a80c
ESTE PROGRAMA SIRVE PARA LEER EL ANCHO DE PULSO EN MICROSEGUNDOS DE UNA SE?AL APLICADA A UN PUERTO DEL MODULO FRDM_KL25Z, USELO TAMBIEN PARA GENERAR ANCHOS DE PULSO POR ALGUN PIN DE SALIDA. ES POSIBLE PROGRAMAR UN TIME OUT A LA ENTRADA Y DEVOLVER -1

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;
tony63 1:48651f86a80c 51 };
tony63 1:48651f86a80c 52
tony63 1:48651f86a80c 53 #endif