Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Committer:
AntonLS
Date:
Mon Apr 13 17:41:48 2015 +0000
Revision:
3:388e441be8df
Parent:
0:28ca4562fe1a
Child:
5:1b9734e68327
Ready for HW FC test.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AntonLS 0:28ca4562fe1a 1 /* Universal Socket Modem Interface Library
AntonLS 0:28ca4562fe1a 2 * Copyright (c) 2013 Multi-Tech Systems
AntonLS 0:28ca4562fe1a 3 *
AntonLS 0:28ca4562fe1a 4 * Licensed under the Apache License, Version 2.0 (the "License");
AntonLS 0:28ca4562fe1a 5 * you may not use this file except in compliance with the License.
AntonLS 0:28ca4562fe1a 6 * You may obtain a copy of the License at
AntonLS 0:28ca4562fe1a 7 *
AntonLS 0:28ca4562fe1a 8 * http://www.apache.org/licenses/LICENSE-2.0
AntonLS 0:28ca4562fe1a 9 *
AntonLS 0:28ca4562fe1a 10 * Unless required by applicable law or agreed to in writing, software
AntonLS 0:28ca4562fe1a 11 * distributed under the License is distributed on an "AS IS" BASIS,
AntonLS 0:28ca4562fe1a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AntonLS 0:28ca4562fe1a 13 * See the License for the specific language governing permissions and
AntonLS 0:28ca4562fe1a 14 * limitations under the License.
AntonLS 0:28ca4562fe1a 15 */
AntonLS 0:28ca4562fe1a 16
AntonLS 0:28ca4562fe1a 17 #include "MTSSerial.h"
AntonLS 0:28ca4562fe1a 18
AntonLS 3:388e441be8df 19 // Added new RTS CTS args. ALS 20150413
AntonLS 3:388e441be8df 20
AntonLS 0:28ca4562fe1a 21 using namespace mts;
AntonLS 0:28ca4562fe1a 22
AntonLS 3:388e441be8df 23 MTSSerial::MTSSerial( PinName TXD, PinName RXD, int txBufferSize, int rxBufferSize,
AntonLS 3:388e441be8df 24 PinName RTS, PinName CTS )
AntonLS 0:28ca4562fe1a 25 : MTSBufferedIO(txBufferSize, rxBufferSize)
AntonLS 3:388e441be8df 26 , serial( TXD, RXD, NULL, RTS, CTS )
AntonLS 0:28ca4562fe1a 27 {
AntonLS 0:28ca4562fe1a 28 serial.attach(this, &MTSSerial::handleRead, Serial::RxIrq);
AntonLS 0:28ca4562fe1a 29 //serial.attach(this, &MTSSerial::handleWrite, Serial::TxIrq);
AntonLS 0:28ca4562fe1a 30 }
AntonLS 0:28ca4562fe1a 31
AntonLS 0:28ca4562fe1a 32 MTSSerial::~MTSSerial()
AntonLS 0:28ca4562fe1a 33 {
AntonLS 0:28ca4562fe1a 34
AntonLS 0:28ca4562fe1a 35 }
AntonLS 0:28ca4562fe1a 36
AntonLS 0:28ca4562fe1a 37 void MTSSerial::baud(int baudrate)
AntonLS 0:28ca4562fe1a 38 {
AntonLS 0:28ca4562fe1a 39 serial.baud(baudrate);
AntonLS 0:28ca4562fe1a 40 }
AntonLS 0:28ca4562fe1a 41
AntonLS 0:28ca4562fe1a 42 void MTSSerial::format(int bits, SerialBase::Parity parity, int stop_bits)
AntonLS 0:28ca4562fe1a 43 {
AntonLS 0:28ca4562fe1a 44 serial.format(bits, parity, stop_bits);
AntonLS 0:28ca4562fe1a 45 }
AntonLS 0:28ca4562fe1a 46
AntonLS 0:28ca4562fe1a 47 void MTSSerial::handleRead()
AntonLS 0:28ca4562fe1a 48 {
AntonLS 0:28ca4562fe1a 49 char byte = serial.getc();
AntonLS 0:28ca4562fe1a 50 if(rxBuffer.write(byte) != 1) {
AntonLS 0:28ca4562fe1a 51 printf("[ERROR] Serial Rx Byte Dropped [%c][0x%02X]\r\n", byte, byte);
AntonLS 0:28ca4562fe1a 52 }
AntonLS 0:28ca4562fe1a 53 }
AntonLS 0:28ca4562fe1a 54
AntonLS 0:28ca4562fe1a 55 // Currently uses Non-Irq based blocking write calls
AntonLS 0:28ca4562fe1a 56 void MTSSerial::handleWrite()
AntonLS 0:28ca4562fe1a 57 {
AntonLS 0:28ca4562fe1a 58 while(txBuffer.size() != 0) {
AntonLS 0:28ca4562fe1a 59 if (serial.writeable()) {
AntonLS 0:28ca4562fe1a 60 char byte;
AntonLS 0:28ca4562fe1a 61 if(txBuffer.read(byte) == 1) {
AntonLS 0:28ca4562fe1a 62 serial.attach(NULL, Serial::RxIrq);
AntonLS 0:28ca4562fe1a 63 serial.putc(byte);
AntonLS 0:28ca4562fe1a 64 serial.attach(this, &MTSSerial::handleRead, Serial::RxIrq);
AntonLS 0:28ca4562fe1a 65 }
AntonLS 0:28ca4562fe1a 66 } else {
AntonLS 0:28ca4562fe1a 67 return;
AntonLS 0:28ca4562fe1a 68 }
AntonLS 0:28ca4562fe1a 69 }
AntonLS 0:28ca4562fe1a 70 }
AntonLS 0:28ca4562fe1a 71
AntonLS 0:28ca4562fe1a 72