Fork of the MODSERIAL library by Erik Olieman.
Fork of MODSERIAL by
Revision 23:5c45c21f36b7, committed 2012-07-25
- Comitter:
- AjK
- Date:
- Wed Jul 25 22:27:49 2012 +0000
- Parent:
- 22:c11ea36f17f9
- Child:
- 24:fca9bb26ca15
- Child:
- 30:9c456e647a8f
- Commit message:
- Add support for LPC11U24
Changed in this revision
--- a/ChangeLog.c Thu Apr 19 20:47:46 2012 +0000 +++ b/ChangeLog.c Wed Jul 25 22:27:49 2012 +0000 @@ -1,5 +1,9 @@ /* $Id:$ +1.23 25th July 2012 + + * LPC1768 code as was. This release includes "alpha" support for the LPC11U24 + 1.22 19th April 2012 * http://mbed.org/forum/bugs-suggestions/topic/2936/
--- a/INIT.cpp Thu Apr 19 20:47:46 2012 +0000 +++ b/INIT.cpp Wed Jul 25 22:27:49 2012 +0000 @@ -26,12 +26,17 @@ namespace AjK { void -MODSERIAL::init(int txSize, int rxSize) +MODSERIAL::init( int txSize, int rxSize ) { disableIrq(); callbackInfo.setSerial(this); + +#ifdef __LPC11UXX_H__ + + _base = LPC_USART; +#else switch(_uidx) { case 0: _base = LPC_UART0; break; case 1: _base = LPC_UART1; break; @@ -39,6 +44,7 @@ case 3: _base = LPC_UART3; break; default : _base = NULL; break; } +#endif dmaSendChannel = -1; moddma_p = (void *)NULL;
--- a/MODSERIAL.cpp Thu Apr 19 20:47:46 2012 +0000 +++ b/MODSERIAL.cpp Wed Jul 25 22:27:49 2012 +0000 @@ -31,82 +31,91 @@ namespace AjK { -MODSERIAL::MODSERIAL(PinName tx, PinName rx, const char *name) : Serial(tx, rx, name) +MODSERIAL::MODSERIAL( PinName tx, PinName rx, const char *name ) : Serial( tx, rx, name ) { - init(MODSERIAL_DEFAULT_TX_BUFFER_SIZE, MODSERIAL_DEFAULT_RX_BUFFER_SIZE); + init( MODSERIAL_DEFAULT_TX_BUFFER_SIZE, MODSERIAL_DEFAULT_RX_BUFFER_SIZE ); } -MODSERIAL::MODSERIAL(PinName tx, PinName rx, int bufferSize, const char *name) : Serial(tx, rx, name) +MODSERIAL::MODSERIAL( PinName tx, PinName rx, int bufferSize, const char *name ) : Serial( tx, rx, name ) { - init(bufferSize, bufferSize); + init( bufferSize, bufferSize ); } -MODSERIAL::MODSERIAL(PinName tx, PinName rx, int txSize, int rxSize, const char *name) : Serial(tx, rx, name) +MODSERIAL::MODSERIAL( PinName tx, PinName rx, int txSize, int rxSize, const char *name ) : Serial( tx, rx, name ) { - init(txSize, rxSize); + init( txSize, rxSize ); } MODSERIAL::~MODSERIAL() { disableIrq(); - if (buffer[0] != NULL) free((char *)buffer[0]); - if (buffer[1] != NULL) free((char *)buffer[1]); + if ( buffer[0] != NULL) free((char *)buffer[0] ); + if ( buffer[1] != NULL) free((char *)buffer[1] ); } bool -MODSERIAL::txBufferFull(void) +MODSERIAL::txBufferFull( void ) { return MODSERIAL_TX_BUFFER_FULL; } bool -MODSERIAL::rxBufferFull(void) +MODSERIAL::rxBufferFull( void ) { return MODSERIAL_RX_BUFFER_FULL; } bool -MODSERIAL::txBufferEmpty(void) +MODSERIAL::txBufferEmpty( void ) { return MODSERIAL_TX_BUFFER_EMPTY; } bool -MODSERIAL::rxBufferEmpty(void) +MODSERIAL::rxBufferEmpty( void ) { return MODSERIAL_RX_BUFFER_EMPTY; } bool -MODSERIAL::txIsBusy(void) +MODSERIAL::txIsBusy( void ) { - return (_LSR & (3UL << 5) == 0) ? true : false; + return ( _LSR & ( 3UL << 5 ) == 0 ) ? true : false; } void -MODSERIAL::disableIrq(void) +MODSERIAL::disableIrq( void ) { + +#ifdef __LPC11UXX_H__ + NVIC_DisableIRQ( UART_IRQn ); +#else switch(_uidx) { - case 0: NVIC_DisableIRQ(UART0_IRQn); break; - case 1: NVIC_DisableIRQ(UART1_IRQn); break; - case 2: NVIC_DisableIRQ(UART2_IRQn); break; - case 3: NVIC_DisableIRQ(UART3_IRQn); break; + case 0: NVIC_DisableIRQ( UART0_IRQn ); break; + case 1: NVIC_DisableIRQ( UART1_IRQn ); break; + case 2: NVIC_DisableIRQ( UART2_IRQn ); break; + case 3: NVIC_DisableIRQ( UART3_IRQn ); break; } +#endif } void MODSERIAL::enableIrq(void) { - switch(_uidx) { - case 0: NVIC_EnableIRQ(UART0_IRQn); break; - case 1: NVIC_EnableIRQ(UART1_IRQn); break; - case 2: NVIC_EnableIRQ(UART2_IRQn); break; - case 3: NVIC_EnableIRQ(UART3_IRQn); break; +#ifdef __LPC11UXX_H__ + NVIC_EnableIRQ( UART_IRQn ); +#else + switch( _uidx ) { + case 0: NVIC_EnableIRQ( UART0_IRQn ); break; + case 1: NVIC_EnableIRQ( UART1_IRQn ); break; + case 2: NVIC_EnableIRQ( UART2_IRQn ); break; + case 3: NVIC_EnableIRQ( UART3_IRQn ); break; } +#endif } int -MODSERIAL::rxDiscardLastChar(void) +MODSERIAL::rxDiscardLastChar( void ) { // This function can only be called indirectly from // an rxCallback function. Therefore, we know we