Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: irRecv.cpp
- Revision:
- 3:17440cf7ab90
- Parent:
- 0:70c8e56bac45
- Child:
- 4:5e46ae042bc7
--- a/irRecv.cpp Sat Jan 23 15:36:14 2016 +0900
+++ b/irRecv.cpp Sat Jan 23 15:09:34 2016 +0000
@@ -91,56 +91,30 @@
}
//+=============================================================================
-IRrecv::IRrecv (int recvpin)
+IRrecv::IRrecv (PinName recvpin) : _recvpin(recvpin)
{
- irparams.recvpin = recvpin;
- irparams.blinkflag = 0;
+ _recvpin.mode(PullNone);
}
-IRrecv::IRrecv (int recvpin, int blinkpin)
-{
- irparams.recvpin = recvpin;
- irparams.blinkpin = blinkpin;
- pinMode(blinkpin, OUTPUT);
- irparams.blinkflag = 0;
-}
-
-
-
//+=============================================================================
-// initialization
+// enable IR receive
//
void IRrecv::enableIRIn ( )
{
- cli();
- // Setup pulse clock timer interrupt
- // Prescale /8 (16M/8 = 0.5 microseconds per tick)
- // Therefore, the timer interval can range from 0.5 to 128 microseconds
- // Depending on the reset value (255 to 0)
- TIMER_CONFIG_NORMAL();
-
- // Timer2 Overflow Interrupt Enable
- TIMER_ENABLE_INTR;
-
- TIMER_RESET;
-
- sei(); // enable interrupts
+ _ticker.detach();
+ _ticker.attach_us(this, &IRrecv::timer_isr, USECPERTICK);
// Initialize state machine variables
irparams.rcvstate = STATE_IDLE;
irparams.rawlen = 0;
-
- // Set pin modes
- pinMode(irparams.recvpin, INPUT);
}
//+=============================================================================
-// Enable/disable blinking of pin 13 on IR processing
+// disable IR receive
//
-void IRrecv::blink13 (int blinkflag)
+void IRrecv::disableIRIn ( )
{
- irparams.blinkflag = blinkflag;
- if (blinkflag) pinMode(BLINKLED, OUTPUT) ;
+ _ticker.detach();
}
//+=============================================================================
@@ -150,6 +124,7 @@
{
return (irparams.rcvstate == STATE_IDLE || irparams.rcvstate == STATE_STOP) ? true : false;
}
+
//+=============================================================================
// Restart the ISR state machine
//