Minor fork of Yoji KURODA's work to test a fix on a small error.
Fork of iSerial by
Revision 5:d83fc550ccbc, committed 2012-09-03
- Comitter:
- ykuroda
- Date:
- Mon Sep 03 11:18:05 2012 +0000
- Parent:
- 4:b38ef9675d39
- Child:
- 6:8d4b95b90c3b
- Commit message:
- Now support both LPC1768 and LPC11U24. But it can be used for USBTX/USBRX. Others are unchecked.;
Changed in this revision
iSerial.cpp | Show annotated file Show diff for this revision Revisions of this file |
iSerial.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/iSerial.cpp Mon Sep 03 09:15:34 2012 +0000 +++ b/iSerial.cpp Mon Sep 03 11:18:05 2012 +0000 @@ -10,19 +10,40 @@ #include "iSerial.h" - -#if defined(TARGET_LPC1768) +//DigitalOut led1(LED1); -// UART1 = p9, p10 - - #define UART_IRQn UART2_IRQn -#elif defined(TARGET_LPC11U24) +void +iSerial::enable_uart_irq(void) +{ + switch(tx){ + case USBTX: + #if defined(TARGET_LPC1768) + NVIC_EnableIRQ(UART2_IRQn); + #elif defined(TARGET_LPC11U24) + NVIC_EnableIRQ(UART_IRQn); + #endif +// led1 = !led1; + break; + + case p9: + #if defined(TARGET_LPC1768) + NVIC_EnableIRQ(UART1_IRQn); + #elif defined(TARGET_LPC11U24) + NVIC_EnableIRQ(UART_IRQn); + #endif + break; - #define UART_IRQn UART_IRQn - -#endif - + #if defined(TARGET_LPC1768) + case p13: + NVIC_EnableIRQ(UART3_IRQn); + break; + case p28: + NVIC_EnableIRQ(UART0_IRQn); + break; + #endif + } +} /* @@ -34,8 +55,7 @@ if(Serial::readable()){ rxbuf.save(Serial::getc()); } - - NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn); + enable_uart_irq(); } void @@ -46,16 +66,18 @@ Serial::putc( txbuf.read() ); } } - NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn); + enable_uart_irq(); } iSerial::iSerial(PinName _tx, PinName _rx, const char *_name, int _txbufsize, int _rxbufsize) : Serial(_tx, _rx, _name), + tx(_tx), + rx(_rx), txbufsize(_txbufsize), rxbufsize(_rxbufsize), txbuf(RingBuffer(txbufsize)), rxbuf(RingBuffer(rxbufsize)), - str(new char [txbufsize]) + str(new char [txbufsize]) { __disable_irq(); @@ -66,7 +88,7 @@ // baud(baudrate); __enable_irq(); - NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn); + enable_uart_irq(); } iSerial::~iSerial() @@ -100,7 +122,7 @@ } else { while(txbuf.full()); txbuf.save(ch); - NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn); + enable_uart_irq(); } } @@ -136,5 +158,3 @@ } - -
--- a/iSerial.h Mon Sep 03 09:15:34 2012 +0000 +++ b/iSerial.h Mon Sep 03 11:18:05 2012 +0000 @@ -16,6 +16,8 @@ class iSerial : public Serial { protected: + PinName tx; + PinName rx; const int txbufsize; const int rxbufsize; RingBuffer txbuf; @@ -24,6 +26,7 @@ void tx_handler(void); void rx_handler(void); + void enable_uart_irq(void); public: