MODSERIAL with support for more devices

Dependents:   1D-Pong BMT-K9_encoder BMT-K9-Regelaar programma_filter ... more

Check the cookbook page for more information: https://mbed.org/cookbook/MODSERIAL

Did you add a device? Please send a pull request so we can keep everything in one library instead of many copies. In that case also send a PM, since currently mbed does not inform of new pull requests. I will then also add you to the developers of this library so you can do other changes directly.

Committer:
AjK
Date:
Tue Apr 26 08:12:45 2011 +0000
Revision:
20:59c74aaedda2
Parent:
12:8c7394e2ae7f
Child:
27:9c93ce7cb9d8
1.20 See ChangeLog.c

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AjK 12:8c7394e2ae7f 1 /*
AjK 12:8c7394e2ae7f 2 Copyright (c) 2010 Andy Kirkham
AjK 12:8c7394e2ae7f 3
AjK 12:8c7394e2ae7f 4 Permission is hereby granted, free of charge, to any person obtaining a copy
AjK 12:8c7394e2ae7f 5 of this software and associated documentation files (the "Software"), to deal
AjK 12:8c7394e2ae7f 6 in the Software without restriction, including without limitation the rights
AjK 12:8c7394e2ae7f 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
AjK 12:8c7394e2ae7f 8 copies of the Software, and to permit persons to whom the Software is
AjK 12:8c7394e2ae7f 9 furnished to do so, subject to the following conditions:
AjK 12:8c7394e2ae7f 10
AjK 12:8c7394e2ae7f 11 The above copyright notice and this permission notice shall be included in
AjK 12:8c7394e2ae7f 12 all copies or substantial portions of the Software.
AjK 12:8c7394e2ae7f 13
AjK 12:8c7394e2ae7f 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
AjK 12:8c7394e2ae7f 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
AjK 12:8c7394e2ae7f 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AjK 12:8c7394e2ae7f 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
AjK 12:8c7394e2ae7f 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AjK 12:8c7394e2ae7f 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
AjK 12:8c7394e2ae7f 20 THE SOFTWARE.
AjK 12:8c7394e2ae7f 21 */
AjK 12:8c7394e2ae7f 22
AjK 12:8c7394e2ae7f 23 #ifndef MODSERIAL_MACROS_H
AjK 12:8c7394e2ae7f 24 #define MODSERIAL_MACROS_H
AjK 12:8c7394e2ae7f 25
AjK 12:8c7394e2ae7f 26 #define MODSERIAL_RBR 0x00
AjK 12:8c7394e2ae7f 27 #define MODSERIAL_THR 0x00
AjK 12:8c7394e2ae7f 28 #define MODSERIAL_DLL 0x00
AjK 12:8c7394e2ae7f 29 #define MODSERIAL_IER 0x04
AjK 12:8c7394e2ae7f 30 #define MODSERIAL_DML 0x04
AjK 12:8c7394e2ae7f 31 #define MODSERIAL_IIR 0x08
AjK 12:8c7394e2ae7f 32 #define MODSERIAL_FCR 0x08
AjK 12:8c7394e2ae7f 33 #define MODSERIAL_LCR 0x0C
AjK 12:8c7394e2ae7f 34 #define MODSERIAL_LSR 0x14
AjK 12:8c7394e2ae7f 35 #define MODSERIAL_SCR 0x1C
AjK 12:8c7394e2ae7f 36 #define MODSERIAL_ACR 0x20
AjK 12:8c7394e2ae7f 37 #define MODSERIAL_ICR 0x24
AjK 12:8c7394e2ae7f 38 #define MODSERIAL_FDR 0x28
AjK 12:8c7394e2ae7f 39 #define MODSERIAL_TER 0x30
AjK 12:8c7394e2ae7f 40
AjK 12:8c7394e2ae7f 41 #define MODSERIAL_LSR_RDR (1UL << 0)
AjK 12:8c7394e2ae7f 42 #define MODSERIAL_LSR_OE (1UL << 1)
AjK 12:8c7394e2ae7f 43 #define MODSERIAL_LSR_PE (1UL << 2)
AjK 12:8c7394e2ae7f 44 #define MODSERIAL_LSR_FE (1UL << 3)
AjK 12:8c7394e2ae7f 45 #define MODSERIAL_LSR_BR (1UL << 4)
AjK 12:8c7394e2ae7f 46 #define MODSERIAL_LSR_THRE (1UL << 5)
AjK 12:8c7394e2ae7f 47 #define MODSERIAL_LSR_TEMT (1UL << 6)
AjK 12:8c7394e2ae7f 48 #define MODSERIAL_LSR_RXFE (1UL << 7)
AjK 12:8c7394e2ae7f 49
AjK 12:8c7394e2ae7f 50 #define MODSERIAL_FIFO_ENABLE 1
AjK 12:8c7394e2ae7f 51 #define MODSERIAL_FIFO_RX_RESET 2
AjK 12:8c7394e2ae7f 52 #define MODSERIAL_FIFO_TX_RESET 4
AjK 12:8c7394e2ae7f 53
AjK 12:8c7394e2ae7f 54 #define _RBR *((char *)_base+MODSERIAL_RBR)
AjK 12:8c7394e2ae7f 55 #define _THR *((char *)_base+MODSERIAL_THR)
AjK 12:8c7394e2ae7f 56 #define _IIR *((char *)_base+MODSERIAL_IIR)
AjK 12:8c7394e2ae7f 57 #define _IER *((char *)_base+MODSERIAL_IER)
AjK 12:8c7394e2ae7f 58 #define _LSR *((char *)_base+MODSERIAL_LSR)
AjK 12:8c7394e2ae7f 59 #define _FCR *((char *)_base+MODSERIAL_FCR)
AjK 12:8c7394e2ae7f 60
AjK 12:8c7394e2ae7f 61 #define MODSERIAL_TX_BUFFER_EMPTY (buffer_count[TxIrq]==0)
AjK 12:8c7394e2ae7f 62 #define MODSERIAL_RX_BUFFER_EMPTY (buffer_count[RxIrq]==0)
AjK 12:8c7394e2ae7f 63 #define MODSERIAL_TX_BUFFER_FULL (buffer_count[TxIrq]==buffer_size[TxIrq])
AjK 12:8c7394e2ae7f 64 #define MODSERIAL_RX_BUFFER_FULL (buffer_count[RxIrq]==buffer_size[RxIrq])
AjK 12:8c7394e2ae7f 65
AjK 20:59c74aaedda2 66 #define MODSERIAL_THR_HAS_SPACE ((int)_LSR&MODSERIAL_LSR_THRE)
AjK 20:59c74aaedda2 67 #define MODSERIAL_TEMT_IS_EMPTY ((int)_LSR&MODSERIAL_LSR_TEMT)
AjK 20:59c74aaedda2 68 #define MODSERIAL_RBR_HAS_DATA ((int)_LSR&MODSERIAL_LSR_RDR)
AjK 12:8c7394e2ae7f 69
AjK 12:8c7394e2ae7f 70 #endif