Modified MODSERIAL library

Dependents:   BeaconAvoid

Committer:
mpanetta
Date:
Sun Sep 09 22:28:07 2012 +0000
Revision:
0:ef4645a79fca
[mbed] converted /BeaconAvoid/MODSERIAL

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mpanetta 0:ef4645a79fca 1 /*
mpanetta 0:ef4645a79fca 2 Copyright (c) 2010 Andy Kirkham
mpanetta 0:ef4645a79fca 3
mpanetta 0:ef4645a79fca 4 Permission is hereby granted, free of charge, to any person obtaining a copy
mpanetta 0:ef4645a79fca 5 of this software and associated documentation files (the "Software"), to deal
mpanetta 0:ef4645a79fca 6 in the Software without restriction, including without limitation the rights
mpanetta 0:ef4645a79fca 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
mpanetta 0:ef4645a79fca 8 copies of the Software, and to permit persons to whom the Software is
mpanetta 0:ef4645a79fca 9 furnished to do so, subject to the following conditions:
mpanetta 0:ef4645a79fca 10
mpanetta 0:ef4645a79fca 11 The above copyright notice and this permission notice shall be included in
mpanetta 0:ef4645a79fca 12 all copies or substantial portions of the Software.
mpanetta 0:ef4645a79fca 13
mpanetta 0:ef4645a79fca 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
mpanetta 0:ef4645a79fca 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
mpanetta 0:ef4645a79fca 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
mpanetta 0:ef4645a79fca 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
mpanetta 0:ef4645a79fca 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mpanetta 0:ef4645a79fca 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
mpanetta 0:ef4645a79fca 20 THE SOFTWARE.
mpanetta 0:ef4645a79fca 21 */
mpanetta 0:ef4645a79fca 22
mpanetta 0:ef4645a79fca 23 #include "MODSERIAL.h"
mpanetta 0:ef4645a79fca 24 #include "MACROS.h"
mpanetta 0:ef4645a79fca 25
mpanetta 0:ef4645a79fca 26 namespace AjK {
mpanetta 0:ef4645a79fca 27
mpanetta 0:ef4645a79fca 28 void
mpanetta 0:ef4645a79fca 29 MODSERIAL::flushBuffer(IrqType type)
mpanetta 0:ef4645a79fca 30 {
mpanetta 0:ef4645a79fca 31 uint32_t ier = _IER;
mpanetta 0:ef4645a79fca 32 switch(type) {
mpanetta 0:ef4645a79fca 33 case TxIrq: _IER &= ~(1UL << 1); break;
mpanetta 0:ef4645a79fca 34 case RxIrq: _IER &= ~(1UL << 0); break;
mpanetta 0:ef4645a79fca 35 }
mpanetta 0:ef4645a79fca 36 buffer_in[type] = 0;
mpanetta 0:ef4645a79fca 37 buffer_out[type] = 0;
mpanetta 0:ef4645a79fca 38 buffer_count[type] = 0;
mpanetta 0:ef4645a79fca 39 buffer_overflow[type] = 0;
mpanetta 0:ef4645a79fca 40 switch(type) {
mpanetta 0:ef4645a79fca 41 case TxIrq: _FCR = MODSERIAL_FIFO_TX_RESET; break;
mpanetta 0:ef4645a79fca 42 case RxIrq: _FCR = MODSERIAL_FIFO_RX_RESET; break;
mpanetta 0:ef4645a79fca 43 }
mpanetta 0:ef4645a79fca 44 _IER = ier;
mpanetta 0:ef4645a79fca 45 }
mpanetta 0:ef4645a79fca 46
mpanetta 0:ef4645a79fca 47 }; // namespace AjK ends