RemotoIR Libraryに、IRC Helicopter Propo の受信処理と、受信パルス幅測定処理を追加したものです。

Dependents:   SwiftPropoIR_TestProgram irRawDataDisplay spinner2 LPC1114_ir-spinne_main-propo

Fork of RemoteIR by Shinichiro Nakamura

Committer:
suupen
Date:
Sat Aug 03 01:44:43 2013 +0000
Revision:
13:ec76e93a4d7c
Parent:
12:2379e13b8b34
????????????????????????????????(100ms??)???????????????????????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shintamainjp 0:ec264f4ce158 1 /**
shintamainjp 9:dcfdac59ef74 2 * IR receiver (Version 0.0.4)
shintamainjp 0:ec264f4ce158 3 *
shintamainjp 0:ec264f4ce158 4 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
shintamainjp 0:ec264f4ce158 5 * http://shinta.main.jp/
suupen 12:2379e13b8b34 6 *
suupen 12:2379e13b8b34 7 * -------------------------------------------------------
suupen 12:2379e13b8b34 8 * 130616 suupen
suupen 12:2379e13b8b34 9 * IRC Helicopter "SWIFT" Propo support
suupen 12:2379e13b8b34 10 * Conditional compilation
suupen 12:2379e13b8b34 11 * "SWIFT_PROTCOL"
suupen 12:2379e13b8b34 12 * "IR_RAW_DATA_ANALYSIS"
suupen 13:ec76e93a4d7c 13 * "ERRORWAIT" : recive error no fuuki taisaku
suupen 12:2379e13b8b34 14 *--------------------------------------------------------
shintamainjp 0:ec264f4ce158 15 */
shintamainjp 0:ec264f4ce158 16
shintamainjp 0:ec264f4ce158 17 #ifndef _RECEIVER_IR_H_
shintamainjp 0:ec264f4ce158 18 #define _RECEIVER_IR_H_
shintamainjp 0:ec264f4ce158 19
shintamainjp 0:ec264f4ce158 20 #include <mbed.h>
shintamainjp 0:ec264f4ce158 21
shintamainjp 0:ec264f4ce158 22 #include "RemoteIR.h"
shintamainjp 0:ec264f4ce158 23
suupen 12:2379e13b8b34 24 //#define IR_RAW_DATA_ANALYSIS
suupen 13:ec76e93a4d7c 25 #define ERRORWAIT
suupen 12:2379e13b8b34 26
shintamainjp 0:ec264f4ce158 27 /**
shintamainjp 0:ec264f4ce158 28 * IR receiver class.
shintamainjp 0:ec264f4ce158 29 */
shintamainjp 0:ec264f4ce158 30 class ReceiverIR {
shintamainjp 0:ec264f4ce158 31 public:
shintamainjp 0:ec264f4ce158 32
shintamainjp 0:ec264f4ce158 33 /**
shintamainjp 0:ec264f4ce158 34 * Constructor.
shintamainjp 0:ec264f4ce158 35 *
shintamainjp 0:ec264f4ce158 36 * @param rxpin Pin for receive IR signal.
shintamainjp 0:ec264f4ce158 37 */
shintamainjp 0:ec264f4ce158 38 explicit ReceiverIR(PinName rxpin);
shintamainjp 0:ec264f4ce158 39
shintamainjp 0:ec264f4ce158 40 /**
shintamainjp 0:ec264f4ce158 41 * Destructor.
shintamainjp 0:ec264f4ce158 42 */
shintamainjp 0:ec264f4ce158 43 ~ReceiverIR();
shintamainjp 0:ec264f4ce158 44
shintamainjp 0:ec264f4ce158 45 /**
shintamainjp 0:ec264f4ce158 46 * State.
shintamainjp 0:ec264f4ce158 47 */
shintamainjp 0:ec264f4ce158 48 typedef enum {
shintamainjp 0:ec264f4ce158 49 Idle,
shintamainjp 0:ec264f4ce158 50 Receiving,
suupen 13:ec76e93a4d7c 51 Received,
suupen 13:ec76e93a4d7c 52 #ifdef ERRORWAIT
suupen 13:ec76e93a4d7c 53 ErrorWait,
suupen 13:ec76e93a4d7c 54 #endif // ERRORWAIT
shintamainjp 0:ec264f4ce158 55 } State;
shintamainjp 0:ec264f4ce158 56
shintamainjp 0:ec264f4ce158 57 /**
shintamainjp 0:ec264f4ce158 58 * Get state.
shintamainjp 0:ec264f4ce158 59 *
shintamainjp 0:ec264f4ce158 60 * @return Current state.
shintamainjp 0:ec264f4ce158 61 */
shintamainjp 0:ec264f4ce158 62 State getState();
shintamainjp 0:ec264f4ce158 63
shintamainjp 0:ec264f4ce158 64 /**
shintamainjp 0:ec264f4ce158 65 * Get data.
shintamainjp 0:ec264f4ce158 66 *
shintamainjp 0:ec264f4ce158 67 * @param format Pointer to format.
shintamainjp 8:46e34d6ddbe4 68 * @param buf Buffer of a data.
shintamainjp 4:2304646f6ff5 69 * @param bitlength Bit length of the buffer.
shintamainjp 0:ec264f4ce158 70 *
shintamainjp 0:ec264f4ce158 71 * @return Data bit length.
shintamainjp 0:ec264f4ce158 72 */
shintamainjp 4:2304646f6ff5 73 int getData(RemoteIR::Format *format, uint8_t *buf, int bitlength);
shintamainjp 0:ec264f4ce158 74
shintamainjp 0:ec264f4ce158 75 private:
shintamainjp 0:ec264f4ce158 76
shintamainjp 0:ec264f4ce158 77 typedef struct {
shintamainjp 0:ec264f4ce158 78 RemoteIR::Format format;
shintamainjp 0:ec264f4ce158 79 int bitcount;
shintamainjp 0:ec264f4ce158 80 uint8_t buffer[64];
shintamainjp 0:ec264f4ce158 81 } data_t;
shintamainjp 0:ec264f4ce158 82
shintamainjp 0:ec264f4ce158 83 typedef struct {
shintamainjp 9:dcfdac59ef74 84 State state;
shintamainjp 0:ec264f4ce158 85 int c1;
shintamainjp 0:ec264f4ce158 86 int c2;
shintamainjp 0:ec264f4ce158 87 int c3;
shintamainjp 0:ec264f4ce158 88 int d1;
shintamainjp 0:ec264f4ce158 89 int d2;
shintamainjp 0:ec264f4ce158 90 } work_t;
suupen 12:2379e13b8b34 91
suupen 12:2379e13b8b34 92 #ifdef IR_RAW_DATA_ANALYSIS
suupen 12:2379e13b8b34 93 typedef struct {
suupen 12:2379e13b8b34 94 State state;
suupen 12:2379e13b8b34 95 int timecount[1000]; // Hi,Lo count (1/1 [us]/count)
suupen 12:2379e13b8b34 96 int bitcount;
suupen 12:2379e13b8b34 97 } check_t;
suupen 12:2379e13b8b34 98 #endif //IR_RAW_DATA_ANALYSIS
shintamainjp 0:ec264f4ce158 99
shintamainjp 0:ec264f4ce158 100 InterruptIn evt; /**< Interrupt based input for input. */
shintamainjp 0:ec264f4ce158 101 Timer timer; /**< Timer for WDT. */
shintamainjp 0:ec264f4ce158 102 Ticker ticker; /**< Tciker for tick. */
shintamainjp 0:ec264f4ce158 103 Timeout timeout; /**< Timeout for tail. */
shintamainjp 0:ec264f4ce158 104
shintamainjp 0:ec264f4ce158 105 data_t data;
shintamainjp 0:ec264f4ce158 106 work_t work;
suupen 12:2379e13b8b34 107 #ifdef IR_RAW_DATA_ANALYSIS
suupen 12:2379e13b8b34 108 check_t check;
suupen 12:2379e13b8b34 109 #endif //IR_RAW_DATA_ANALYSIS
suupen 12:2379e13b8b34 110
shintamainjp 0:ec264f4ce158 111 void init_state(void);
shintamainjp 0:ec264f4ce158 112
suupen 13:ec76e93a4d7c 113 #ifdef ERRORWAIT
suupen 13:ec76e93a4d7c 114 void errorWait(void);
suupen 13:ec76e93a4d7c 115 #endif // ERRORWAIT
suupen 13:ec76e93a4d7c 116
shintamainjp 0:ec264f4ce158 117 void isr_wdt(void);
shintamainjp 0:ec264f4ce158 118 void isr_fall(void);
shintamainjp 0:ec264f4ce158 119 void isr_rise(void);
shintamainjp 0:ec264f4ce158 120
shintamainjp 0:ec264f4ce158 121 /**
shintamainjp 0:ec264f4ce158 122 * ISR timeout for tail detection.
shintamainjp 0:ec264f4ce158 123 */
shintamainjp 0:ec264f4ce158 124 void isr_timeout(void);
shintamainjp 0:ec264f4ce158 125
shintamainjp 0:ec264f4ce158 126 };
shintamainjp 0:ec264f4ce158 127
shintamainjp 0:ec264f4ce158 128 #endif
suupen 12:2379e13b8b34 129