RemotoIR Libraryに、IRC Helicopter Propo の受信処理と、受信パルス幅測定処理を追加したものです。
Dependents: SwiftPropoIR_TestProgram irRawDataDisplay spinner2 LPC1114_ir-spinne_main-propo
Fork of RemoteIR by
ReceiverIR.h
00001 /** 00002 * IR receiver (Version 0.0.4) 00003 * 00004 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) 00005 * http://shinta.main.jp/ 00006 * 00007 * ------------------------------------------------------- 00008 * 130616 suupen 00009 * IRC Helicopter "SWIFT" Propo support 00010 * Conditional compilation 00011 * "SWIFT_PROTCOL" 00012 * "IR_RAW_DATA_ANALYSIS" 00013 * "ERRORWAIT" : recive error no fuuki taisaku 00014 *-------------------------------------------------------- 00015 */ 00016 00017 #ifndef _RECEIVER_IR_H_ 00018 #define _RECEIVER_IR_H_ 00019 00020 #include <mbed.h> 00021 00022 #include "RemoteIR.h" 00023 00024 //#define IR_RAW_DATA_ANALYSIS 00025 #define ERRORWAIT 00026 00027 /** 00028 * IR receiver class. 00029 */ 00030 class ReceiverIR { 00031 public: 00032 00033 /** 00034 * Constructor. 00035 * 00036 * @param rxpin Pin for receive IR signal. 00037 */ 00038 explicit ReceiverIR(PinName rxpin); 00039 00040 /** 00041 * Destructor. 00042 */ 00043 ~ReceiverIR(); 00044 00045 /** 00046 * State. 00047 */ 00048 typedef enum { 00049 Idle, 00050 Receiving, 00051 Received, 00052 #ifdef ERRORWAIT 00053 ErrorWait, 00054 #endif // ERRORWAIT 00055 } State; 00056 00057 /** 00058 * Get state. 00059 * 00060 * @return Current state. 00061 */ 00062 State getState(); 00063 00064 /** 00065 * Get data. 00066 * 00067 * @param format Pointer to format. 00068 * @param buf Buffer of a data. 00069 * @param bitlength Bit length of the buffer. 00070 * 00071 * @return Data bit length. 00072 */ 00073 int getData(RemoteIR::Format *format, uint8_t *buf, int bitlength); 00074 00075 private: 00076 00077 typedef struct { 00078 RemoteIR::Format format; 00079 int bitcount; 00080 uint8_t buffer[64]; 00081 } data_t; 00082 00083 typedef struct { 00084 State state; 00085 int c1; 00086 int c2; 00087 int c3; 00088 int d1; 00089 int d2; 00090 } work_t; 00091 00092 #ifdef IR_RAW_DATA_ANALYSIS 00093 typedef struct { 00094 State state; 00095 int timecount[1000]; // Hi,Lo count (1/1 [us]/count) 00096 int bitcount; 00097 } check_t; 00098 #endif //IR_RAW_DATA_ANALYSIS 00099 00100 InterruptIn evt; /**< Interrupt based input for input. */ 00101 Timer timer; /**< Timer for WDT. */ 00102 Ticker ticker; /**< Tciker for tick. */ 00103 Timeout timeout; /**< Timeout for tail. */ 00104 00105 data_t data; 00106 work_t work; 00107 #ifdef IR_RAW_DATA_ANALYSIS 00108 check_t check; 00109 #endif //IR_RAW_DATA_ANALYSIS 00110 00111 void init_state(void); 00112 00113 #ifdef ERRORWAIT 00114 void errorWait(void); 00115 #endif // ERRORWAIT 00116 00117 void isr_wdt(void); 00118 void isr_fall(void); 00119 void isr_rise(void); 00120 00121 /** 00122 * ISR timeout for tail detection. 00123 */ 00124 void isr_timeout(void); 00125 00126 }; 00127 00128 #endif 00129
Generated on Thu Jul 14 2022 02:07:30 by 1.7.2