This is the project for the Old Model Robots for OU's Dr. Davis's Configurable Robots Research. This is being published so future robots can be set up easily.

Dependencies:   FatFileSystem MCP3008 Motor PinDetect QTR_8A SRF05 SSD1308_128x64_I2C mbed

Committer:
DrewSchaef
Date:
Wed Nov 01 15:57:59 2017 +0000
Revision:
0:bcad524c1856
Published the project to allow access for future work on the Configurable Robots Research Project(s).

Who changed what in which revision?

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