MODSERIAL with support for more devices
Fork of MODSERIAL by
ISR_TX.cpp@46:6571cd7f896e, 2018-07-11 (annotated)
- Committer:
- fahadmirza
- Date:
- Wed Jul 11 08:17:03 2018 +0000
- Revision:
- 46:6571cd7f896e
- Parent:
- 28:76793a84f9e5
Added support for NUCLEO_L053R8
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AjK | 0:eb2522b41db8 | 1 | /* |
AjK | 0:eb2522b41db8 | 2 | Copyright (c) 2010 Andy Kirkham |
Sissors | 28:76793a84f9e5 | 3 | |
AjK | 0:eb2522b41db8 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
AjK | 0:eb2522b41db8 | 5 | of this software and associated documentation files (the "Software"), to deal |
AjK | 0:eb2522b41db8 | 6 | in the Software without restriction, including without limitation the rights |
AjK | 0:eb2522b41db8 | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
AjK | 0:eb2522b41db8 | 8 | copies of the Software, and to permit persons to whom the Software is |
AjK | 0:eb2522b41db8 | 9 | furnished to do so, subject to the following conditions: |
Sissors | 28:76793a84f9e5 | 10 | |
AjK | 0:eb2522b41db8 | 11 | The above copyright notice and this permission notice shall be included in |
AjK | 0:eb2522b41db8 | 12 | all copies or substantial portions of the Software. |
Sissors | 28:76793a84f9e5 | 13 | |
AjK | 0:eb2522b41db8 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
AjK | 0:eb2522b41db8 | 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
AjK | 0:eb2522b41db8 | 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
AjK | 0:eb2522b41db8 | 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
AjK | 0:eb2522b41db8 | 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
AjK | 0:eb2522b41db8 | 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
AjK | 0:eb2522b41db8 | 20 | THE SOFTWARE. |
AjK | 0:eb2522b41db8 | 21 | */ |
AjK | 0:eb2522b41db8 | 22 | |
AjK | 0:eb2522b41db8 | 23 | #include "MODSERIAL.h" |
AjK | 0:eb2522b41db8 | 24 | #include "MACROS.h" |
AjK | 0:eb2522b41db8 | 25 | |
Sissors | 28:76793a84f9e5 | 26 | namespace AjK |
AjK | 0:eb2522b41db8 | 27 | { |
Sissors | 28:76793a84f9e5 | 28 | |
Sissors | 28:76793a84f9e5 | 29 | void MODSERIAL::isr_tx(bool doCallback) |
Sissors | 28:76793a84f9e5 | 30 | { |
Sissors | 28:76793a84f9e5 | 31 | if (TX_IRQ_ENABLED || MODSERIAL_TX_BUFFER_FULL ) { |
Sissors | 28:76793a84f9e5 | 32 | if (! _base || buffer_size[TxIrq] == 0 || buffer[TxIrq] == (char *)NULL) { |
Sissors | 28:76793a84f9e5 | 33 | _isr[TxIrq].call(&this->callbackInfo); |
Sissors | 28:76793a84f9e5 | 34 | return; |
AjK | 0:eb2522b41db8 | 35 | } |
Sissors | 28:76793a84f9e5 | 36 | |
Sissors | 28:76793a84f9e5 | 37 | while (! MODSERIAL_TX_BUFFER_EMPTY && MODSERIAL_WRITABLE ) { |
Sissors | 28:76793a84f9e5 | 38 | MODSERIAL_WRITE_REG = txc = (uint8_t)(buffer[TxIrq][buffer_out[TxIrq]]); |
Sissors | 28:76793a84f9e5 | 39 | buffer_count[TxIrq]--; |
Sissors | 28:76793a84f9e5 | 40 | buffer_out[TxIrq]++; |
Sissors | 28:76793a84f9e5 | 41 | if (buffer_out[TxIrq] >= buffer_size[TxIrq]) { |
Sissors | 28:76793a84f9e5 | 42 | buffer_out[TxIrq] = 0; |
Sissors | 28:76793a84f9e5 | 43 | } |
Sissors | 28:76793a84f9e5 | 44 | if (doCallback) _isr[TxIrq].call(&this->callbackInfo); |
Sissors | 28:76793a84f9e5 | 45 | } |
Sissors | 28:76793a84f9e5 | 46 | |
Sissors | 28:76793a84f9e5 | 47 | if ( MODSERIAL_TX_BUFFER_EMPTY ) { |
Sissors | 28:76793a84f9e5 | 48 | DISABLE_TX_IRQ; |
Sissors | 28:76793a84f9e5 | 49 | _isr[TxEmpty].call(&this->callbackInfo); |
Sissors | 28:76793a84f9e5 | 50 | } |
AjK | 0:eb2522b41db8 | 51 | } |
Sissors | 28:76793a84f9e5 | 52 | } |
AjK | 0:eb2522b41db8 | 53 | }; // namespace AjK ends |
AjK | 0:eb2522b41db8 | 54 | |
Sissors | 28:76793a84f9e5 | 55 |