V1/Toolbox.NETMF.Hardware.InfraredRX/InfraredReceiverBase.cs
/// <summary>
/// The port interrupt's handler, called on any falling edge
/// </summary>
/// <param name="data1"></param>
/// <param name="data2"></param>
/// <param name="time"></param>
The port interrupt's handler, called on any falling edge
The port interrupt ' s handler called on any falling edge
void TriggerOnInterrupt(
            uint data1,
            uint data2,
            DateTime time)
        {
            long ticks = time.Ticks;
            switch (this.Status)
            {
                case InfraredReceiverBase.StatusIdle:
                    this.Status = InfraredReceiverBase.StatusRunning;
                    this._sampleCount = 0;
                    this._timer.Change(
                        this.MessageTimeout,
                        Timeout.Infinite);
                    break;
                case InfraredReceiverBase.StatusRunning:
                    if (this._sampleCount <= this.MaxBufferSize)
                    {
                        this._samples[this._sampleCount++] = (int)(ticks - this._oldTicks);
                    }
                    else
                    {
                        this._triggerPort.DisableInterrupt();
                        this.Status = InfraredReceiverBase.StatusError;
                    }
                    break;
            }
            this._oldTicks = ticks;
        }
void TriggerOnInterrupt ( uint data1 , uint data2 , DateTime time ) { long ticks = time . Ticks ; switch ( this . Status ) { case InfraredReceiverBase . StatusIdle : this . Status = InfraredReceiverBase . StatusRunning ; this . _sampleCount = 0 ; this . _timer . Change ( this . MessageTimeout , Timeout . Infinite ) ; break ; case InfraredReceiverBase . StatusRunning : if ( this . _sampleCount <= this . MaxBufferSize ) { this . _samples [ this . _sampleCount ++ ] = ( int ) ( ticks - this . _oldTicks ) ; } else { this . _triggerPort . DisableInterrupt ( ) ; this . Status = InfraredReceiverBase . StatusError ; } break ; } this . _oldTicks = ticks ; }
The port interrupt's handler, called on any falling edge
The port interrupt ' s handler called on any falling edge
//cache the current ticks-count //here is the very first edge, so switch the machine to the //"running" state //starts the timer //place the sampled delta-ticks in the current buffer's cells //no more rooms to hold new data: switch to the "error" state
data1
uint
None
data2
uint
None
time
DateTime
None