MODSERIAL with support for more devices
Fork of MODSERIAL by
MACROS.h
- Committer:
- Sissors
- Date:
- 2013-07-11
- Revision:
- 27:9c93ce7cb9d8
- Parent:
- 20:59c74aaedda2
- Child:
- 28:76793a84f9e5
File content as of revision 27:9c93ce7cb9d8:
/* Copyright (c) 2010 Andy Kirkham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef MODSERIAL_MACROS_H #define MODSERIAL_MACROS_H #define MODSERIAL_TX_BUFFER_EMPTY (buffer_count[TxIrq]==0) #define MODSERIAL_RX_BUFFER_EMPTY (buffer_count[RxIrq]==0) #define MODSERIAL_TX_BUFFER_FULL (buffer_count[TxIrq]==buffer_size[TxIrq]) #define MODSERIAL_RX_BUFFER_FULL (buffer_count[RxIrq]==buffer_size[RxIrq]) #ifdef TARGET_LPC1768 #define MODSERIAL_IRQ_REG ((LPC_UART_TypeDef*)_base)->IER #define DISABLE_TX_IRQ MODSERIAL_IRQ_REG &= ~(1UL << 1) #define DISABLE_RX_IRQ MODSERIAL_IRQ_REG &= ~(1UL << 0) #define ENABLE_TX_IRQ MODSERIAL_IRQ_REG |= (1UL << 1) #define ENABLE_RX_IRQ MODSERIAL_IRQ_REG |= (1UL << 0) #define RESET_TX_FIFO ((LPC_UART_TypeDef*)_base)->FCR |= (1UL<<2) #define RESET_RX_FIFO ((LPC_UART_TypeDef*)_base)->FCR |= (1UL<<1) #define ENABLE_FIFO ((LPC_UART_TypeDef*)_base)->FCR = (1UL<<0) + (1UL<<1) + (1UL<<2) #define MODSERIAL_READ_REG ((LPC_UART_TypeDef*)_base)->RBR #define MODSERIAL_WRITE_REG ((LPC_UART_TypeDef*)_base)->THR #define MODSERIAL_READABLE ((((LPC_UART_TypeDef*)_base)->LSR & (1UL<<0)) != 0) #define MODSERIAL_WRITABLE ((((LPC_UART_TypeDef*)_base)->LSR & (1UL<<5)) != 0) #endif #ifdef TARGET_LPC11U24 #define MODSERIAL_IRQ_REG ((LPC_UART_TypeDef*)_base)->IER #define DISABLE_TX_IRQ MODSERIAL_IRQ_REG &= ~(1UL << 1) #define DISABLE_RX_IRQ MODSERIAL_IRQ_REG &= ~(1UL << 0) #define ENABLE_TX_IRQ MODSERIAL_IRQ_REG |= (1UL << 1) #define ENABLE_RX_IRQ MODSERIAL_IRQ_REG |= (1UL << 0) #define RESET_TX_FIFO ((LPC_UART_TypeDef*)_base)->FCR |= (1UL<<2) #define RESET_RX_FIFO ((LPC_UART_TypeDef*)_base)->FCR |= (1UL<<1) #define ENABLE_FIFO ((LPC_UART_TypeDef*)_base)->FCR = (1UL<<0) + (1UL<<1) + (1UL<<2) #define MODSERIAL_READ_REG ((LPC_UART_TypeDef*)_base)->RBR #define MODSERIAL_WRITE_REG ((LPC_UART_TypeDef*)_base)->THR #define MODSERIAL_READABLE ((((LPC_UART_TypeDef*)_base)->LSR & (1UL<<0)) != 0) #define MODSERIAL_WRITABLE ((((LPC_UART_TypeDef*)_base)->LSR & (1UL<<5)) != 0) #endif #ifdef TARGET_KL25Z #define MODSERIAL_IRQ_REG ((UART_Type*)_base)->C2 #define DISABLE_TX_IRQ MODSERIAL_IRQ_REG &= ~(1UL << UART_C2_TIE_SHIFT) #define DISABLE_RX_IRQ MODSERIAL_IRQ_REG &= ~(1UL << UART_C2_RIE_SHIFT) #define ENABLE_TX_IRQ MODSERIAL_IRQ_REG |= (1UL << UART_C2_TIE_SHIFT) #define ENABLE_RX_IRQ MODSERIAL_IRQ_REG |= (1UL << UART_C2_RIE_SHIFT) #define RESET_TX_FIFO while(0 == 1) #define RESET_RX_FIFO while(0 == 1) #define ENABLE_FIFO while(0 == 1) #define MODSERIAL_READ_REG ((UART_Type*)_base)->D #define MODSERIAL_WRITE_REG ((UART_Type*)_base)->D #define MODSERIAL_READABLE ((((UART_Type*)_base)->S1 & (1UL<<5)) != 0) #define MODSERIAL_WRITABLE ((((UART_Type*)_base)->S1 & (1UL<<7)) != 0) #endif #endif