Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of IR_remote 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 #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 private: 00061 00062 typedef struct { 00063 RemoteIR::Format format; 00064 int bitcount; 00065 uint8_t buffer[64]; 00066 } data_t; 00067 00068 typedef struct { 00069 State state; 00070 int c1; 00071 int c2; 00072 int c3; 00073 int d1; 00074 int d2; 00075 } work_t; 00076 00077 InterruptIn evt; /**< Interrupt based input for input. */ 00078 Timer timer; /**< Timer for WDT. */ 00079 Ticker ticker; /**< Tciker for tick. */ 00080 Timeout timeout; /**< Timeout for tail. */ 00081 00082 data_t data; 00083 work_t work; 00084 00085 void init_state(void); 00086 00087 void isr_wdt(void); 00088 void isr_fall(void); 00089 void isr_rise(void); 00090 00091 /** 00092 * ISR timeout for tail detection. 00093 */ 00094 void isr_timeout(void); 00095 00096 }; 00097 00098 #endif
Generated on Thu Jul 21 2022 09:28:40 by
1.7.2
