Interplan IM920 library, 920MHz module
Dependents: IM920_sample IM920_SDlog IM920_sample IM920_sample3 ... more
IM920 ライブラリ
データモード、低速、長距離 の設定で通信するライブラリです。
920MHz無線モジュール
- mbedとモジュールとは、シリアル(TX,RX)、BUSY、RESET端子を接続します。
- モジュールはあらかじめ、コマンドでノード番号などを設定しておきます。
IM920_hal.cpp
- Committer:
- okini3939
- Date:
- 2015-01-08
- Revision:
- 3:db269462ad1c
- Parent:
- 0:d3ab05ed8142
File content as of revision 3:db269462ad1c:
#include "IM920.h" void IM920::setReset (bool flg) { if (_reset) { if (flg) { _reset->output(); _reset->write(0); } else { _reset->input(); _reset->mode(PullNone); } } } void IM920::isrUart () { recvData(getUart()); } int IM920::getUart () { return _im.getc(); } void IM920::putUart (char c) { _im.putc(c); } int IM920::lockUart (int ms) { Timer t; if (_busy && _busy->read()) { // CTS check t.start(); while (_busy->read()) { if (t.read_ms() >= ms) { DBG("cts timeout\r\n"); return -1; } } } return 0; } void IM920::unlockUart () { } void IM920::initUart (PinName busy, PinName reset, int baud) { _baud = baud; if (_baud) _im.baud(_baud); _im.attach(this, &IM920::isrUart, Serial::RxIrq); _busy = NULL; _reset = NULL; if (busy != NC) { _busy = new DigitalIn(busy); } if (reset != NC) { _reset = new DigitalInOut(reset); } }