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.
Dependents: NECnfc_sample Drone_air Drone_ground
Diff: NECnfc_hal.cpp
- Revision:
- 4:07e752ff8dce
- Child:
- 5:e5a358e9ed94
diff -r 71a16ce27889 -r 07e752ff8dce NECnfc_hal.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/NECnfc_hal.cpp Tue Sep 15 06:17:57 2015 +0000
@@ -0,0 +1,76 @@
+#include "NECnfc.h"
+
+void NECnfc::setReset (bool flg) {
+ if (_reset) {
+ if (flg) {
+ _reset->output();
+ _reset->write(0);
+ } else {
+ _reset->input();
+ _reset->mode(PullNone);
+ }
+ }
+}
+
+void NECnfc::isrUart () {
+ recvData(getUart());
+}
+
+int NECnfc::getUart () {
+ return _nec.getc();
+}
+
+void NECnfc::putUart (char c) {
+ _nec.putc(c);
+}
+
+int NECnfc::lockUart (int ms) {
+ return 0;
+}
+
+void NECnfc::unlockUart () {
+}
+
+void NECnfc::initUart (PinName reset, PinName wakeup, PinName mode, int baud) {
+ if (baud) _nec.baud(baud);
+ _nec.attach(this, &NECnfc::isrUart, Serial::RxIrq);
+
+ _reset = NULL;
+ if (reset != NC) {
+ _reset = new DigitalInOut(reset);
+ }
+ _wakeup = NULL;
+ if (wakeup != NC) {
+ _wakeup = new DigitalOut(wakeup);
+ _wakeup->write(0);
+ }
+ _wmode = NULL;
+ if (mode != NC) {
+ _wmode = new DigitalIn(mode);
+ _wmode->mode(PullUp);
+ }
+}
+
+int NECnfc::sleep (int wait) {
+
+ if (!_wakeup && !_wmode) return -1;
+
+ DBG("sleep\r\n");
+ _wakeup->write(1);
+ if (wait) {
+ while (! _wmode->read());
+ }
+ return 0;
+}
+
+int NECnfc::wakeup (int wait) {
+
+ if (!_wakeup && !_wmode) return -1;
+
+ DBG("wakeup\r\n");
+ _wakeup->write(0);
+ if (wait) {
+ while (_wmode->read());
+ }
+ return 0;
+}