RoemoteIR
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 #ifndef _RECEIVER_IR_H_ 00009 #define _RECEIVER_IR_H_ 00010 00011 #include <mbed.h> 00012 00013 #include "RemoteIR.h" 00014 00015 /** 00016 * IR receiver class. 00017 */ 00018 class ReceiverIR { 00019 public: 00020 00021 /** 00022 * Constructor. 00023 * 00024 * @param rxpin Pin for receive IR signal. 00025 */ 00026 explicit ReceiverIR(PinName rxpin); 00027 00028 /** 00029 * Destructor. 00030 */ 00031 ~ReceiverIR(); 00032 00033 /** 00034 * State. 00035 */ 00036 typedef enum { 00037 Idle, 00038 Receiving, 00039 Received 00040 } State; 00041 00042 /** 00043 * Get state. 00044 * 00045 * @return Current state. 00046 */ 00047 State getState(); 00048 00049 /** 00050 * Get data. 00051 * 00052 * @param format Pointer to format. 00053 * @param buf Buffer of a data. 00054 * @param bitlength Bit length of the buffer. 00055 * 00056 * @return Data bit length. 00057 */ 00058 int getData(RemoteIR::Format *format, uint8_t *buf, int bitlength); 00059 00060 typedef struct { // 구조체 00061 RemoteIR::Format format; 00062 int bitcount; 00063 uint8_t buffer[64]; 00064 } data_t; 00065 00066 data_t data; 00067 int code; 00068 00069 private: 00070 00071 typedef struct { // 구조체 00072 State state; 00073 int c1; 00074 int c2; 00075 int c3; 00076 int d1; 00077 int d2; 00078 } work_t; 00079 00080 00081 InterruptIn evt; /**< Interrupt based input for input. */ 00082 Timer timer; /**< Timer for WDT. */ 00083 Ticker ticker; /**< Tciker for tick. */ 00084 Timeout timeout; /**< Timeout for tail. */ 00085 00086 work_t work; 00087 00088 void init_state(void); 00089 00090 void isr_wdt(void); 00091 void isr_fall(void); 00092 void isr_rise(void); 00093 00094 /** 00095 * ISR timeout for tail detection. 00096 */ 00097 void isr_timeout(void); 00098 00099 }; 00100 00101 #endif
Generated on Mon Jul 18 2022 16:50:02 by 1.7.2