Projet AutoStart pour projecteur LG

Dependencies:   mbed

Committer:
nnguyen
Date:
Mon Jul 03 16:17:40 2017 +0000
Revision:
0:f09b7c760de7
AutoStart

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nnguyen 0:f09b7c760de7 1 /**
nnguyen 0:f09b7c760de7 2 * IR receiver (Version 0.0.4)
nnguyen 0:f09b7c760de7 3 *
nnguyen 0:f09b7c760de7 4 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
nnguyen 0:f09b7c760de7 5 * http://shinta.main.jp/
nnguyen 0:f09b7c760de7 6 */
nnguyen 0:f09b7c760de7 7
nnguyen 0:f09b7c760de7 8 #ifndef _RECEIVER_IR_H_
nnguyen 0:f09b7c760de7 9 #define _RECEIVER_IR_H_
nnguyen 0:f09b7c760de7 10
nnguyen 0:f09b7c760de7 11 #include <mbed.h>
nnguyen 0:f09b7c760de7 12
nnguyen 0:f09b7c760de7 13 #include "RemoteIR.h"
nnguyen 0:f09b7c760de7 14
nnguyen 0:f09b7c760de7 15 /**
nnguyen 0:f09b7c760de7 16 * IR receiver class.
nnguyen 0:f09b7c760de7 17 */
nnguyen 0:f09b7c760de7 18 class ReceiverIR {
nnguyen 0:f09b7c760de7 19 public:
nnguyen 0:f09b7c760de7 20
nnguyen 0:f09b7c760de7 21 /**
nnguyen 0:f09b7c760de7 22 * Constructor.
nnguyen 0:f09b7c760de7 23 *
nnguyen 0:f09b7c760de7 24 * @param rxpin Pin for receive IR signal.
nnguyen 0:f09b7c760de7 25 */
nnguyen 0:f09b7c760de7 26 explicit ReceiverIR(PinName rxpin);
nnguyen 0:f09b7c760de7 27
nnguyen 0:f09b7c760de7 28 /**
nnguyen 0:f09b7c760de7 29 * Destructor.
nnguyen 0:f09b7c760de7 30 */
nnguyen 0:f09b7c760de7 31 ~ReceiverIR();
nnguyen 0:f09b7c760de7 32
nnguyen 0:f09b7c760de7 33 /**
nnguyen 0:f09b7c760de7 34 * State.
nnguyen 0:f09b7c760de7 35 */
nnguyen 0:f09b7c760de7 36 typedef enum {
nnguyen 0:f09b7c760de7 37 Idle,
nnguyen 0:f09b7c760de7 38 Receiving,
nnguyen 0:f09b7c760de7 39 Received
nnguyen 0:f09b7c760de7 40 } State;
nnguyen 0:f09b7c760de7 41
nnguyen 0:f09b7c760de7 42 /**
nnguyen 0:f09b7c760de7 43 * Get state.
nnguyen 0:f09b7c760de7 44 *
nnguyen 0:f09b7c760de7 45 * @return Current state.
nnguyen 0:f09b7c760de7 46 */
nnguyen 0:f09b7c760de7 47 State getState();
nnguyen 0:f09b7c760de7 48
nnguyen 0:f09b7c760de7 49 /**
nnguyen 0:f09b7c760de7 50 * Get data.
nnguyen 0:f09b7c760de7 51 *
nnguyen 0:f09b7c760de7 52 * @param format Pointer to format.
nnguyen 0:f09b7c760de7 53 * @param buf Buffer of a data.
nnguyen 0:f09b7c760de7 54 * @param bitlength Bit length of the buffer.
nnguyen 0:f09b7c760de7 55 *
nnguyen 0:f09b7c760de7 56 * @return Data bit length.
nnguyen 0:f09b7c760de7 57 */
nnguyen 0:f09b7c760de7 58 int getData(RemoteIR::Format *format, uint8_t *buf, int bitlength);
nnguyen 0:f09b7c760de7 59
nnguyen 0:f09b7c760de7 60 private:
nnguyen 0:f09b7c760de7 61
nnguyen 0:f09b7c760de7 62 typedef struct {
nnguyen 0:f09b7c760de7 63 RemoteIR::Format format;
nnguyen 0:f09b7c760de7 64 int bitcount;
nnguyen 0:f09b7c760de7 65 uint8_t buffer[64];
nnguyen 0:f09b7c760de7 66 } data_t;
nnguyen 0:f09b7c760de7 67
nnguyen 0:f09b7c760de7 68 typedef struct {
nnguyen 0:f09b7c760de7 69 State state;
nnguyen 0:f09b7c760de7 70 int c1;
nnguyen 0:f09b7c760de7 71 int c2;
nnguyen 0:f09b7c760de7 72 int c3;
nnguyen 0:f09b7c760de7 73 int d1;
nnguyen 0:f09b7c760de7 74 int d2;
nnguyen 0:f09b7c760de7 75 } work_t;
nnguyen 0:f09b7c760de7 76
nnguyen 0:f09b7c760de7 77 InterruptIn evt; /**< Interrupt based input for input. */
nnguyen 0:f09b7c760de7 78 Timer timer; /**< Timer for WDT. */
nnguyen 0:f09b7c760de7 79 Ticker ticker; /**< Tciker for tick. */
nnguyen 0:f09b7c760de7 80 Timeout timeout; /**< Timeout for tail. */
nnguyen 0:f09b7c760de7 81
nnguyen 0:f09b7c760de7 82 data_t data;
nnguyen 0:f09b7c760de7 83 work_t work;
nnguyen 0:f09b7c760de7 84
nnguyen 0:f09b7c760de7 85 void init_state(void);
nnguyen 0:f09b7c760de7 86
nnguyen 0:f09b7c760de7 87 void isr_wdt(void);
nnguyen 0:f09b7c760de7 88 void isr_fall(void);
nnguyen 0:f09b7c760de7 89 void isr_rise(void);
nnguyen 0:f09b7c760de7 90
nnguyen 0:f09b7c760de7 91 /**
nnguyen 0:f09b7c760de7 92 * ISR timeout for tail detection.
nnguyen 0:f09b7c760de7 93 */
nnguyen 0:f09b7c760de7 94 void isr_timeout(void);
nnguyen 0:f09b7c760de7 95
nnguyen 0:f09b7c760de7 96 };
nnguyen 0:f09b7c760de7 97
nnguyen 0:f09b7c760de7 98 #endif