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.
Fork of RemoteIR by
Diff: TransmitterIR.cpp
- Revision:
- 9:dcfdac59ef74
- Parent:
- 3:dfed23b157e6
- Child:
- 10:c54fb1204d1e
--- a/TransmitterIR.cpp Sat Aug 21 13:28:50 2010 +0000
+++ b/TransmitterIR.cpp Fri Sep 17 20:22:38 2010 +0000
@@ -1,5 +1,5 @@
/**
- * IR transmitter (Version 0.0.3)
+ * IR transmitter (Version 0.0.4)
*
* Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
* http://shinta.main.jp/
@@ -7,8 +7,8 @@
#include "TransmitterIR.h"
-#define IRQ_ENABLE() sem.release(); __enable_irq()
-#define IRQ_DISABLE() sem.take(); __disable_irq()
+#define LOCK() sem.take()
+#define UNLOCK() sem.release()
TransmitterIR::TransmitterIR(PinName txpin) : tx(txpin) {
tx.write(0.0);
@@ -28,17 +28,17 @@
}
TransmitterIR::State TransmitterIR::getState(void) {
- IRQ_DISABLE();
+ LOCK();
State s = work.state;
- IRQ_ENABLE();
+ UNLOCK();
wait_ms(10);
return s;
}
int TransmitterIR::setData(RemoteIR::Format format, uint8_t *buf, int bitlength) {
- IRQ_DISABLE();
+ LOCK();
if (work.state != Idle) {
- IRQ_ENABLE();
+ UNLOCK();
return -1;
}
@@ -70,12 +70,12 @@
break;
}
- IRQ_ENABLE();
+ UNLOCK();
return bitlength;
}
void TransmitterIR::tick(void) {
- IRQ_DISABLE();
+ LOCK();
switch (work.state) {
case Idle:
work.bitcount = 0;
@@ -275,5 +275,5 @@
default:
break;
}
- IRQ_ENABLE();
+ UNLOCK();
}
