MODSERIAL with support for more devices. Added support for LPC4330
Dependents: HC05_AT_mode GPS_U-blox_NEO-6M_Test_Code GPS_U-blox_NEO-6M_Code UbloxGPSWithThread ... more
Fork of MODSERIAL by
Revision 36:4213f9a7c3ad, committed 2014-08-12
- Comitter:
- edodm85
- Date:
- Tue Aug 12 16:05:10 2014 +0000
- Parent:
- 35:180e968a751e
- Commit message:
- Added support for LPC4330
Changed in this revision
diff -r 180e968a751e -r 4213f9a7c3ad Device/MODSERIAL_LPC4330.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Device/MODSERIAL_LPC4330.cpp Tue Aug 12 16:05:10 2014 +0000 @@ -0,0 +1,24 @@ +#ifdef TARGET_LPC4330_M4 +#include "MODSERIAL.h" + + +void MODSERIAL::setBase(void ) { +switch( _serial.index ) { + case 0: _base = LPC_USART0; _IRQ = USART0_IRQn; break; + case 1: _base = LPC_UART1; _IRQ = UART1_IRQn; break; + case 2: _base = LPC_USART2; _IRQ = USART2_IRQn; break; + case 3: _base = LPC_USART3; _IRQ = USART3_IRQn; break; + default: _base = NULL; _IRQ = (IRQn_Type)NULL; break; + } +} + +void MODSERIAL::initDevice(void) { + ((LPC_USART_T*)_base)->FCR = (1UL<<0) + (1UL<<1) + (1UL<<2); + } + +bool MODSERIAL::txIsBusy( void ) +{ + return ( (((LPC_USART_T*)_base)->LSR & ( 1UL << 6 )) == 0 ) ? true : false; +} + +#endif
diff -r 180e968a751e -r 4213f9a7c3ad Device/MODSERIAL_LPC4330.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Device/MODSERIAL_LPC4330.h Tue Aug 12 16:05:10 2014 +0000 @@ -0,0 +1,20 @@ +#if defined(TARGET_LPC4330_M4) + +#define MODSERIAL_IRQ_REG ((LPC_USART_T*)_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_USART_T*)_base)->FCR |= (1UL<<2) +#define RESET_RX_FIFO ((LPC_USART_T*)_base)->FCR |= (1UL<<1) + +#define MODSERIAL_READ_REG ((LPC_USART_T*)_base)->RBR +#define MODSERIAL_WRITE_REG ((LPC_USART_T*)_base)->THR +#define MODSERIAL_READABLE ((((LPC_USART_T*)_base)->LSR & (1UL<<0)) != 0) +#define MODSERIAL_WRITABLE ((((LPC_USART_T*)_base)->LSR & (1UL<<5)) != 0) + +#define RX_IRQ_ENABLED true +#define TX_IRQ_ENABLED true + +#endif \ No newline at end of file
diff -r 180e968a751e -r 4213f9a7c3ad MACROS.h --- a/MACROS.h Mon May 12 13:20:20 2014 +0000 +++ b/MACROS.h Tue Aug 12 16:05:10 2014 +0000 @@ -24,6 +24,7 @@ #define MODSERIAL_MACROS_H #include "MODSERIAL_LPC1768.h" +#include "MODSERIAL_LPC4330.h" #include "MODSERIAL_LPC11U24.h" #include "MODSERIAL_KL25Z.h" #include "MODSERIAL_KL05Z.h"