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
NECnfc_hal.cpp
00001 #include "NECnfc.h" 00002 00003 void NECnfc::setReset (bool flg) { 00004 if (_reset) { 00005 if (flg) { 00006 _reset->output(); 00007 _reset->write(0); 00008 } else { 00009 _reset->input(); 00010 _reset->mode(PullNone); 00011 } 00012 } 00013 } 00014 00015 void NECnfc::isrUart () { 00016 recvData(getUart()); 00017 } 00018 00019 int NECnfc::getUart () { 00020 return _nec.getc(); 00021 } 00022 00023 void NECnfc::putUart (char c) { 00024 _nec.putc(c); 00025 } 00026 00027 int NECnfc::lockUart (int ms) { 00028 return 0; 00029 } 00030 00031 void NECnfc::unlockUart () { 00032 } 00033 00034 void NECnfc::initUart (PinName reset, PinName wakeup, PinName mode, int baud) { 00035 if (baud) _nec.baud(baud); 00036 _nec.attach(this, &NECnfc::isrUart, Serial::RxIrq); 00037 00038 _reset = NULL; 00039 if (reset != NC) { 00040 _reset = new DigitalInOut(reset); 00041 } 00042 _wakeup = NULL; 00043 if (wakeup != NC) { 00044 _wakeup = new DigitalOut(wakeup); 00045 _wakeup->write(0); 00046 } 00047 _wmode = NULL; 00048 if (mode != NC) { 00049 _wmode = new DigitalIn(mode); 00050 _wmode->mode(PullUp); 00051 } 00052 } 00053 00054 int NECnfc::sleep (int wait) { 00055 00056 if (!_wakeup) return -1; 00057 00058 DBG("sleep\r\n"); 00059 _wakeup->write(1); 00060 if (wait && _wmode) { 00061 while (! _wmode->read()); 00062 } 00063 return 0; 00064 } 00065 00066 int NECnfc::wakeup (int wait) { 00067 00068 if (!_wakeup) return -1; 00069 00070 DBG("wakeup\r\n"); 00071 _wakeup->write(0); 00072 if (wait && _wmode) { 00073 while (_wmode->read()); 00074 } 00075 return 0; 00076 }
Generated on Wed Jul 13 2022 14:59:48 by
1.7.2