suu pen
/
HonyBeePropoIR_TestProgram
IRC Helicopter "HonyBee" Propo decode test program
Embed:
(wiki syntax)
Show/hide line numbers
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 *-------------------------------------------------------- 00014 */ 00015 00016 #ifndef _RECEIVER_IR_H_ 00017 #define _RECEIVER_IR_H_ 00018 00019 #include <mbed.h> 00020 00021 #include "RemoteIR.h" 00022 00023 //#define IR_RAW_DATA_ANALYSIS 00024 00025 /** 00026 * IR receiver class. 00027 */ 00028 class ReceiverIR { 00029 public: 00030 00031 /** 00032 * Constructor. 00033 * 00034 * @param rxpin Pin for receive IR signal. 00035 */ 00036 explicit ReceiverIR(PinName rxpin); 00037 00038 /** 00039 * Destructor. 00040 */ 00041 ~ReceiverIR(); 00042 00043 /** 00044 * State. 00045 */ 00046 typedef enum { 00047 Idle, 00048 Receiving, 00049 Received 00050 } State; 00051 00052 /** 00053 * Get state. 00054 * 00055 * @return Current state. 00056 */ 00057 State getState(); 00058 00059 /** 00060 * Get data. 00061 * 00062 * @param format Pointer to format. 00063 * @param buf Buffer of a data. 00064 * @param bitlength Bit length of the buffer. 00065 * 00066 * @return Data bit length. 00067 */ 00068 int getData(RemoteIR::Format *format, uint8_t *buf, int bitlength); 00069 00070 private: 00071 00072 typedef struct { 00073 RemoteIR::Format format; 00074 int bitcount; 00075 uint8_t buffer[64]; 00076 } data_t; 00077 00078 typedef struct { 00079 State state; 00080 int c1; 00081 int c2; 00082 int c3; 00083 int d1; 00084 int d2; 00085 } work_t; 00086 00087 #ifdef IR_RAW_DATA_ANALYSIS 00088 typedef struct { 00089 State state; 00090 int timecount[1000]; // Hi,Lo count (1/1 [us]/count) 00091 int bitcount; 00092 } check_t; 00093 #endif //IR_RAW_DATA_ANALYSIS 00094 00095 InterruptIn evt; /**< Interrupt based input for input. */ 00096 Timer timer; /**< Timer for WDT. */ 00097 Ticker ticker; /**< Tciker for tick. */ 00098 Timeout timeout; /**< Timeout for tail. */ 00099 00100 data_t data; 00101 work_t work; 00102 #ifdef IR_RAW_DATA_ANALYSIS 00103 check_t check; 00104 #endif //IR_RAW_DATA_ANALYSIS 00105 00106 void init_state(void); 00107 00108 void isr_wdt(void); 00109 void isr_fall(void); 00110 void isr_rise(void); 00111 00112 /** 00113 * ISR timeout for tail detection. 00114 */ 00115 void isr_timeout(void); 00116 00117 }; 00118 00119 #endif 00120
Generated on Fri Jul 15 2022 02:33:45 by 1.7.2