NEC Near Field Communication RF module library for mbed H001-000003-001 (950MHz), H001-000013-001 (920MHz), TY24FM-E2024 (2.4GHz)
Dependents: NECnfc_sample Drone_air Drone_ground
NEC Near Field Communication RF module library
NEC製の近距離無線モジュール用のライブラリです。
NECnfc_hal.cpp
- Committer:
- okini3939
- Date:
- 2015-10-19
- Revision:
- 5:e5a358e9ed94
- Parent:
- 4:07e752ff8dce
File content as of revision 5:e5a358e9ed94:
#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) return -1; DBG("sleep\r\n"); _wakeup->write(1); if (wait && _wmode) { while (! _wmode->read()); } return 0; } int NECnfc::wakeup (int wait) { if (!_wakeup) return -1; DBG("wakeup\r\n"); _wakeup->write(0); if (wait && _wmode) { while (_wmode->read()); } return 0; }