RemotoIR Libraryに、IRC Helicopter Propo の受信処理と、受信パルス幅測定処理を追加したものです。
Dependents: SwiftPropoIR_TestProgram irRawDataDisplay spinner2 LPC1114_ir-spinne_main-propo
Fork of RemoteIR by
ReceiverIR.h@12:2379e13b8b34, 2013-06-23 (annotated)
- Committer:
- suupen
- Date:
- Sun Jun 23 07:23:56 2013 +0000
- Revision:
- 12:2379e13b8b34
- Parent:
- 11:268cc2ab63bd
- Child:
- 13:ec76e93a4d7c
IRC Helicopter "SWIFT" Propo recive data test program
Who changed what in which revision?
User | Revision | Line number | New 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 | 12:2379e13b8b34 | 13 | *-------------------------------------------------------- |
shintamainjp | 0:ec264f4ce158 | 14 | */ |
shintamainjp | 0:ec264f4ce158 | 15 | |
shintamainjp | 0:ec264f4ce158 | 16 | #ifndef _RECEIVER_IR_H_ |
shintamainjp | 0:ec264f4ce158 | 17 | #define _RECEIVER_IR_H_ |
shintamainjp | 0:ec264f4ce158 | 18 | |
shintamainjp | 0:ec264f4ce158 | 19 | #include <mbed.h> |
shintamainjp | 0:ec264f4ce158 | 20 | |
shintamainjp | 0:ec264f4ce158 | 21 | #include "RemoteIR.h" |
shintamainjp | 0:ec264f4ce158 | 22 | |
suupen | 12:2379e13b8b34 | 23 | //#define IR_RAW_DATA_ANALYSIS |
suupen | 12:2379e13b8b34 | 24 | |
shintamainjp | 0:ec264f4ce158 | 25 | /** |
shintamainjp | 0:ec264f4ce158 | 26 | * IR receiver class. |
shintamainjp | 0:ec264f4ce158 | 27 | */ |
shintamainjp | 0:ec264f4ce158 | 28 | class ReceiverIR { |
shintamainjp | 0:ec264f4ce158 | 29 | public: |
shintamainjp | 0:ec264f4ce158 | 30 | |
shintamainjp | 0:ec264f4ce158 | 31 | /** |
shintamainjp | 0:ec264f4ce158 | 32 | * Constructor. |
shintamainjp | 0:ec264f4ce158 | 33 | * |
shintamainjp | 0:ec264f4ce158 | 34 | * @param rxpin Pin for receive IR signal. |
shintamainjp | 0:ec264f4ce158 | 35 | */ |
shintamainjp | 0:ec264f4ce158 | 36 | explicit ReceiverIR(PinName rxpin); |
shintamainjp | 0:ec264f4ce158 | 37 | |
shintamainjp | 0:ec264f4ce158 | 38 | /** |
shintamainjp | 0:ec264f4ce158 | 39 | * Destructor. |
shintamainjp | 0:ec264f4ce158 | 40 | */ |
shintamainjp | 0:ec264f4ce158 | 41 | ~ReceiverIR(); |
shintamainjp | 0:ec264f4ce158 | 42 | |
shintamainjp | 0:ec264f4ce158 | 43 | /** |
shintamainjp | 0:ec264f4ce158 | 44 | * State. |
shintamainjp | 0:ec264f4ce158 | 45 | */ |
shintamainjp | 0:ec264f4ce158 | 46 | typedef enum { |
shintamainjp | 0:ec264f4ce158 | 47 | Idle, |
shintamainjp | 0:ec264f4ce158 | 48 | Receiving, |
shintamainjp | 0:ec264f4ce158 | 49 | Received |
shintamainjp | 0:ec264f4ce158 | 50 | } State; |
shintamainjp | 0:ec264f4ce158 | 51 | |
shintamainjp | 0:ec264f4ce158 | 52 | /** |
shintamainjp | 0:ec264f4ce158 | 53 | * Get state. |
shintamainjp | 0:ec264f4ce158 | 54 | * |
shintamainjp | 0:ec264f4ce158 | 55 | * @return Current state. |
shintamainjp | 0:ec264f4ce158 | 56 | */ |
shintamainjp | 0:ec264f4ce158 | 57 | State getState(); |
shintamainjp | 0:ec264f4ce158 | 58 | |
shintamainjp | 0:ec264f4ce158 | 59 | /** |
shintamainjp | 0:ec264f4ce158 | 60 | * Get data. |
shintamainjp | 0:ec264f4ce158 | 61 | * |
shintamainjp | 0:ec264f4ce158 | 62 | * @param format Pointer to format. |
shintamainjp | 8:46e34d6ddbe4 | 63 | * @param buf Buffer of a data. |
shintamainjp | 4:2304646f6ff5 | 64 | * @param bitlength Bit length of the buffer. |
shintamainjp | 0:ec264f4ce158 | 65 | * |
shintamainjp | 0:ec264f4ce158 | 66 | * @return Data bit length. |
shintamainjp | 0:ec264f4ce158 | 67 | */ |
shintamainjp | 4:2304646f6ff5 | 68 | int getData(RemoteIR::Format *format, uint8_t *buf, int bitlength); |
shintamainjp | 0:ec264f4ce158 | 69 | |
shintamainjp | 0:ec264f4ce158 | 70 | private: |
shintamainjp | 0:ec264f4ce158 | 71 | |
shintamainjp | 0:ec264f4ce158 | 72 | typedef struct { |
shintamainjp | 0:ec264f4ce158 | 73 | RemoteIR::Format format; |
shintamainjp | 0:ec264f4ce158 | 74 | int bitcount; |
shintamainjp | 0:ec264f4ce158 | 75 | uint8_t buffer[64]; |
shintamainjp | 0:ec264f4ce158 | 76 | } data_t; |
shintamainjp | 0:ec264f4ce158 | 77 | |
shintamainjp | 0:ec264f4ce158 | 78 | typedef struct { |
shintamainjp | 9:dcfdac59ef74 | 79 | State state; |
shintamainjp | 0:ec264f4ce158 | 80 | int c1; |
shintamainjp | 0:ec264f4ce158 | 81 | int c2; |
shintamainjp | 0:ec264f4ce158 | 82 | int c3; |
shintamainjp | 0:ec264f4ce158 | 83 | int d1; |
shintamainjp | 0:ec264f4ce158 | 84 | int d2; |
shintamainjp | 0:ec264f4ce158 | 85 | } work_t; |
suupen | 12:2379e13b8b34 | 86 | |
suupen | 12:2379e13b8b34 | 87 | #ifdef IR_RAW_DATA_ANALYSIS |
suupen | 12:2379e13b8b34 | 88 | typedef struct { |
suupen | 12:2379e13b8b34 | 89 | State state; |
suupen | 12:2379e13b8b34 | 90 | int timecount[1000]; // Hi,Lo count (1/1 [us]/count) |
suupen | 12:2379e13b8b34 | 91 | int bitcount; |
suupen | 12:2379e13b8b34 | 92 | } check_t; |
suupen | 12:2379e13b8b34 | 93 | #endif //IR_RAW_DATA_ANALYSIS |
shintamainjp | 0:ec264f4ce158 | 94 | |
shintamainjp | 0:ec264f4ce158 | 95 | InterruptIn evt; /**< Interrupt based input for input. */ |
shintamainjp | 0:ec264f4ce158 | 96 | Timer timer; /**< Timer for WDT. */ |
shintamainjp | 0:ec264f4ce158 | 97 | Ticker ticker; /**< Tciker for tick. */ |
shintamainjp | 0:ec264f4ce158 | 98 | Timeout timeout; /**< Timeout for tail. */ |
shintamainjp | 0:ec264f4ce158 | 99 | |
shintamainjp | 0:ec264f4ce158 | 100 | data_t data; |
shintamainjp | 0:ec264f4ce158 | 101 | work_t work; |
suupen | 12:2379e13b8b34 | 102 | #ifdef IR_RAW_DATA_ANALYSIS |
suupen | 12:2379e13b8b34 | 103 | check_t check; |
suupen | 12:2379e13b8b34 | 104 | #endif //IR_RAW_DATA_ANALYSIS |
suupen | 12:2379e13b8b34 | 105 | |
shintamainjp | 0:ec264f4ce158 | 106 | void init_state(void); |
shintamainjp | 0:ec264f4ce158 | 107 | |
shintamainjp | 0:ec264f4ce158 | 108 | void isr_wdt(void); |
shintamainjp | 0:ec264f4ce158 | 109 | void isr_fall(void); |
shintamainjp | 0:ec264f4ce158 | 110 | void isr_rise(void); |
shintamainjp | 0:ec264f4ce158 | 111 | |
shintamainjp | 0:ec264f4ce158 | 112 | /** |
shintamainjp | 0:ec264f4ce158 | 113 | * ISR timeout for tail detection. |
shintamainjp | 0:ec264f4ce158 | 114 | */ |
shintamainjp | 0:ec264f4ce158 | 115 | void isr_timeout(void); |
shintamainjp | 0:ec264f4ce158 | 116 | |
shintamainjp | 0:ec264f4ce158 | 117 | }; |
shintamainjp | 0:ec264f4ce158 | 118 | |
shintamainjp | 0:ec264f4ce158 | 119 | #endif |
suupen | 12:2379e13b8b34 | 120 |