ロボカップジュニアサッカー IRM2121を用いた専用パルスボールを検知するためのライブラリ

Dependents:   BallCheck_IRM2121_InterrputInAdd CatPot_SensorRight

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IRM2121.h Source File

IRM2121.h

00001 
00002     
00003  #ifndef MBED_IRM_H
00004  #define MBED_IRM_H
00005 
00006 #include "mbed.h"
00007 #include "interruptin_mod.h"
00008 /** IRM2121  class, based on an InterruptIn pin, and a timer
00009  *  use RoboCup Junior Soccer to find PULSE BALL.
00010  
00011  
00012  * Example:
00013  * @code
00014  * // Set interrupt and read sensor.
00015  * #include "mbed.h"
00016  * #include "IRM2121.h"
00017  * IRM2121 IR(p21);
00018  * 
00019  * int main() {
00020  *     int length;
00021  
00022  *     while(1) {
00023  *  
00024  *        IR.Set();    
00025  *        wait_ms(20); //check _Busy 1 &_Valid 0 ....config just wait time.
00026  *        length = IR.Read();
00027  *     }
00028  * }
00029  * @endcode
00030  */
00031 class IRM2121 {
00032   public:
00033     /** Create a IRM2121 object connected to the specified InterruptIn pin
00034     *
00035     * @param IRM_PIN InterruptIn pin to connect to 
00036     */
00037     IRM2121(PinName IRM_PIN);
00038     
00039     
00040      /** Set a IRM2121 Interrupt Pin 
00041       *
00042       * @param none
00043       */
00044     void Set(void);
00045     
00046     /** Read the result 
00047       *
00048       * @param none
00049       */
00050     unsigned long Read(void);
00051     
00052     /**
00053       * Check two flags( _Valid, _Busy )
00054       *
00055       * @param none
00056       */
00057     void ReturnVB(bool *valid, bool *busy);
00058     
00059     
00060   private:
00061     
00062     interruptin_mod    _event;
00063     Timer              _timer;
00064 
00065     bool _Flag;
00066     bool _Valid;
00067     bool _Busy;
00068     unsigned long _Time;
00069       
00070     void _Start(void);
00071     void _Stop (void);
00072     
00073   };
00074   
00075   #endif