Nagano kosen robocon
Embed:
(wiki syntax)
Show/hide line numbers
Pulse.h
00001 #ifndef MBED_PULSE_H 00002 #define MBED_PULSE_H 00003 00004 #include "mbed.h" 00005 00006 /** Pulse Input/Output Class(es) 00007 */ 00008 00009 class PulseInOut { 00010 public: 00011 /** Create a PulseInOut object connected to the specified pin 00012 * @param pin i/o pin to connect to 00013 */ 00014 PulseInOut(PinName); 00015 ~PulseInOut(); 00016 /** Set the value of the pin 00017 * @param val Value to set, 0 for LOW, otherwise HIGH 00018 */ 00019 void write(int val); 00020 /** Send a pulse of a given value for a specified time 00021 * @param val Value to set, 0 for LOW, otherwise HIGH 00022 * @param time Length of pulse in microseconds 00023 */ 00024 void write_us(int val, int time); 00025 /** Return the length of the next HIGH pulse in microsconds 00026 */ 00027 int read_high_us(); 00028 /** Return the length of the next HIGH pulse in microseconds or -1 if longer than timeout 00029 * @param timeout Time before pulse reading aborts and returns -1, in microseconds 00030 */ 00031 int read_high_us(int timeout); 00032 /** Return the length of the next LOW pulse in microsconds 00033 */ 00034 int read_low_us(); 00035 /** Return the length of the next LOW pulse in microseconds or -1 if longer than timeout 00036 * @param timeout Time before pulse reading aborts and returns -1, in microseconds 00037 */ 00038 int read_low_us(int timeout); 00039 /** Return the length of the next pulse in microsconds 00040 */ 00041 int read_us(); 00042 /** Return the length of the next pulse in microseconds or -1 if longer than timeout 00043 * @param timeout Time before pulse reading aborts and returns -1, in microseconds 00044 */ 00045 int read_us(int timeout); 00046 private: 00047 int startval; 00048 Timer pulsetime, runtime; 00049 DigitalInOut io; 00050 }; 00051 00052 #endif
Generated on Wed Jul 13 2022 00:47:24 by
1.7.2