This library can be used in mbed driver or mbed OS2. So If you want to use WizFi310 on mbed OS5, You have to use another WizFi310 library(wizfi310-driver). That is git repository for wizfi310-driver. - https://github.com/ARMmbed/wizfi310-driver

Dependents:   KT_IoTMakers_WizFi310_Example WizFi310_STATION_HelloWorld WizFi310_DNS_TCP_HelloWorld WizFi310_Ubidots ... more

This library can be used in mbed driver or mbed OS2. So If you want to use WizFi310 on mbed OS5, You have to use another WizFi310 library(wizfi310-driver).

That is git repository for wizfi310-driver. - https://github.com/ARMmbed/wizfi310-driver

Committer:
jehoon
Date:
Wed Oct 05 09:40:30 2016 +0000
Revision:
0:df571f8f8c03
Child:
5:72212beb817c
This is a WizFi310 Library. It supports new mbed5 features including NetworkInterfaceAPI.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jehoon 0:df571f8f8c03 1 /*
jehoon 0:df571f8f8c03 2 * Copyright (C) 2013 gsfan, MIT License
jehoon 0:df571f8f8c03 3 *
jehoon 0:df571f8f8c03 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
jehoon 0:df571f8f8c03 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
jehoon 0:df571f8f8c03 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
jehoon 0:df571f8f8c03 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
jehoon 0:df571f8f8c03 8 * furnished to do so, subject to the following conditions:
jehoon 0:df571f8f8c03 9 *
jehoon 0:df571f8f8c03 10 * The above copyright notice and this permission notice shall be included in all copies or
jehoon 0:df571f8f8c03 11 * substantial portions of the Software.
jehoon 0:df571f8f8c03 12 *
jehoon 0:df571f8f8c03 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
jehoon 0:df571f8f8c03 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
jehoon 0:df571f8f8c03 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
jehoon 0:df571f8f8c03 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
jehoon 0:df571f8f8c03 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
jehoon 0:df571f8f8c03 18 */
jehoon 0:df571f8f8c03 19 /* Copyright (C) 2014 Wiznet, MIT License
jehoon 0:df571f8f8c03 20 * port to the Wiznet Module WizFi310
jehoon 0:df571f8f8c03 21 */
jehoon 0:df571f8f8c03 22
jehoon 0:df571f8f8c03 23 #include "WizFi310.h"
jehoon 0:df571f8f8c03 24
jehoon 0:df571f8f8c03 25 void WizFi310::setReset(bool flg)
jehoon 0:df571f8f8c03 26 {
jehoon 0:df571f8f8c03 27 if( flg )
jehoon 0:df571f8f8c03 28 {
jehoon 0:df571f8f8c03 29 // low
jehoon 0:df571f8f8c03 30 _reset.output();
jehoon 0:df571f8f8c03 31 _reset = 0;
jehoon 0:df571f8f8c03 32 }
jehoon 0:df571f8f8c03 33 else
jehoon 0:df571f8f8c03 34 {
jehoon 0:df571f8f8c03 35 // high z
jehoon 0:df571f8f8c03 36 _reset.input();
jehoon 0:df571f8f8c03 37 _reset.mode(PullNone);
jehoon 0:df571f8f8c03 38 }
jehoon 0:df571f8f8c03 39 }
jehoon 0:df571f8f8c03 40
jehoon 0:df571f8f8c03 41 void WizFi310::isrUart()
jehoon 0:df571f8f8c03 42 {
jehoon 0:df571f8f8c03 43 char c;
jehoon 0:df571f8f8c03 44
jehoon 0:df571f8f8c03 45 c = getUart();
jehoon 0:df571f8f8c03 46
jehoon 0:df571f8f8c03 47 recvData(c);
jehoon 0:df571f8f8c03 48 //S_UartPutc(c);
jehoon 0:df571f8f8c03 49 }
jehoon 0:df571f8f8c03 50
jehoon 0:df571f8f8c03 51 int WizFi310::getUart()
jehoon 0:df571f8f8c03 52 {
jehoon 0:df571f8f8c03 53 return _wizfi.getc();
jehoon 0:df571f8f8c03 54 }
jehoon 0:df571f8f8c03 55
jehoon 0:df571f8f8c03 56 void WizFi310::putUart (char c)
jehoon 0:df571f8f8c03 57 {
jehoon 0:df571f8f8c03 58 _wizfi.putc(c);
jehoon 0:df571f8f8c03 59 }
jehoon 0:df571f8f8c03 60
jehoon 0:df571f8f8c03 61 void WizFi310::setRts (bool flg)
jehoon 0:df571f8f8c03 62 {
jehoon 0:df571f8f8c03 63 if (flg)
jehoon 0:df571f8f8c03 64 {
jehoon 0:df571f8f8c03 65 if(_flow == 2)
jehoon 0:df571f8f8c03 66 {
jehoon 0:df571f8f8c03 67 if(_rts)
jehoon 0:df571f8f8c03 68 {
jehoon 0:df571f8f8c03 69 _rts->write(0); // low
jehoon 0:df571f8f8c03 70 }
jehoon 0:df571f8f8c03 71 }
jehoon 0:df571f8f8c03 72 }
jehoon 0:df571f8f8c03 73 else
jehoon 0:df571f8f8c03 74 {
jehoon 0:df571f8f8c03 75 if(_flow == 2)
jehoon 0:df571f8f8c03 76 {
jehoon 0:df571f8f8c03 77 if(_rts)
jehoon 0:df571f8f8c03 78 {
jehoon 0:df571f8f8c03 79 _rts->write(1); // high
jehoon 0:df571f8f8c03 80 }
jehoon 0:df571f8f8c03 81 }
jehoon 0:df571f8f8c03 82 }
jehoon 0:df571f8f8c03 83 }
jehoon 0:df571f8f8c03 84
jehoon 0:df571f8f8c03 85 int WizFi310::lockUart (int ms)
jehoon 0:df571f8f8c03 86 {
jehoon 0:df571f8f8c03 87 Timer t;
jehoon 0:df571f8f8c03 88
jehoon 0:df571f8f8c03 89 if(_state.mode != MODE_COMMAND)
jehoon 0:df571f8f8c03 90 {
jehoon 0:df571f8f8c03 91 t.start();
jehoon 0:df571f8f8c03 92 while(_state.mode != MODE_COMMAND)
jehoon 0:df571f8f8c03 93 {
jehoon 0:df571f8f8c03 94 if(t.read_ms() >= ms)
jehoon 0:df571f8f8c03 95 {
jehoon 0:df571f8f8c03 96 WIZ_WARN("lock timeout (%d)\r\n", _state.mode);
jehoon 0:df571f8f8c03 97 return -1;
jehoon 0:df571f8f8c03 98 }
jehoon 0:df571f8f8c03 99 }
jehoon 0:df571f8f8c03 100 }
jehoon 0:df571f8f8c03 101
jehoon 0:df571f8f8c03 102 #ifdef CFG_ENABLE_RTOS
jehoon 0:df571f8f8c03 103 if (_mutexUart.lock(ms) != osOK) return -1;
jehoon 0:df571f8f8c03 104 #endif
jehoon 0:df571f8f8c03 105
jehoon 0:df571f8f8c03 106 if(_flow == 2)
jehoon 0:df571f8f8c03 107 {
jehoon 0:df571f8f8c03 108 if(_cts && _cts->read())
jehoon 0:df571f8f8c03 109 {
jehoon 0:df571f8f8c03 110 // CTS check
jehoon 0:df571f8f8c03 111 t.start();
jehoon 0:df571f8f8c03 112 while (_cts->read())
jehoon 0:df571f8f8c03 113 {
jehoon 0:df571f8f8c03 114 if(t.read_ms() >= ms)
jehoon 0:df571f8f8c03 115 {
jehoon 0:df571f8f8c03 116 WIZ_DBG("cts timeout\r\n");
jehoon 0:df571f8f8c03 117 return -1;
jehoon 0:df571f8f8c03 118 }
jehoon 0:df571f8f8c03 119 }
jehoon 0:df571f8f8c03 120 }
jehoon 0:df571f8f8c03 121 }
jehoon 0:df571f8f8c03 122
jehoon 0:df571f8f8c03 123 setRts(false); // blcok
jehoon 0:df571f8f8c03 124 return 0;
jehoon 0:df571f8f8c03 125 }
jehoon 0:df571f8f8c03 126
jehoon 0:df571f8f8c03 127 void WizFi310::unlockUart()
jehoon 0:df571f8f8c03 128 {
jehoon 0:df571f8f8c03 129 setRts(true); // release
jehoon 0:df571f8f8c03 130 #ifdef CFG_ENABLE_RTOS
jehoon 0:df571f8f8c03 131 _mutexUart.unlock();
jehoon 0:df571f8f8c03 132 #endif
jehoon 0:df571f8f8c03 133 }
jehoon 0:df571f8f8c03 134
jehoon 0:df571f8f8c03 135 void WizFi310::initUart (PinName cts, PinName rts, PinName alarm, int baud)
jehoon 0:df571f8f8c03 136 {
jehoon 0:df571f8f8c03 137 _baud = baud;
jehoon 0:df571f8f8c03 138 if (_baud) _wizfi.baud(_baud);
jehoon 0:df571f8f8c03 139
jehoon 0:df571f8f8c03 140 _wizfi.attach(this, &WizFi310::isrUart, Serial::RxIrq);
jehoon 0:df571f8f8c03 141
jehoon 0:df571f8f8c03 142 _cts = NULL;
jehoon 0:df571f8f8c03 143 _rts = NULL;
jehoon 0:df571f8f8c03 144 _flow = 0;
jehoon 0:df571f8f8c03 145
jehoon 0:df571f8f8c03 146 if(cts != NC)
jehoon 0:df571f8f8c03 147 {
jehoon 0:df571f8f8c03 148 _cts = new DigitalIn(cts);
jehoon 0:df571f8f8c03 149 }
jehoon 0:df571f8f8c03 150 if(rts != NC)
jehoon 0:df571f8f8c03 151 {
jehoon 0:df571f8f8c03 152 _rts = new DigitalOut(rts);
jehoon 0:df571f8f8c03 153 _flow = 2;
jehoon 0:df571f8f8c03 154 }
jehoon 0:df571f8f8c03 155 }