DMX Library for STM devices
Dependents: DISCO-F746NG_DMX-Test
Fork of DMX by
Diff: DMX.cpp
- Revision:
- 5:72039cd4c874
- Parent:
- 4:dd0544c80096
- Child:
- 6:9e7b4eeac6ec
diff -r dd0544c80096 -r 72039cd4c874 DMX.cpp --- a/DMX.cpp Wed Nov 21 01:44:21 2012 +0000 +++ b/DMX.cpp Fri Jan 04 04:31:53 2013 +0000 @@ -4,14 +4,14 @@ * Released under the MIT License: http://mbed.org/license/mit */ -/** @file DMX.cpp +/** @file dmx.cpp * @brief DMX512 send/recv */ #include "mbed.h" #include "DMX.h" -DMX::DMX (PinName p_tx, PinName p_rx) : dmx(p_tx, p_rx) { +DMX::DMX (PinName p_tx, PinName p_rx) : _dmx(p_tx, p_rx) { int i; for (i = 0; i < DMX_SIZE; i ++) { @@ -24,6 +24,7 @@ is_recived = 0; is_sent = 0; +#if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) if (p_tx == p9) { uart_lcr = &LPC_UART3->LCR; uart_thr = &LPC_UART3->THR; @@ -51,10 +52,21 @@ uart_rbr = &LPC_UART2->RBR; NVIC_SetPriority(UART2_IRQn, 1); } +#elif defined(TARGET_LPC11U24) + if (p_tx == p9) { + uart_lcr = &LPC_USART->LCR; + uart_thr = &LPC_USART->THR; + } + if (p_rx == p10) { + uart_lsr = &LPC_USART->LSR; + uart_rbr = &LPC_USART->RBR; + NVIC_SetPriority(UART_IRQn, 1); + } +#endif - dmx.baud(250000); - dmx.format(8, Serial::None, 2); - dmx.attach(this, &DMX::int_rx, Serial::RxIrq); + _dmx.baud(250000); + _dmx.format(8, Serial::None, 2); + _dmx.attach(this, &DMX::int_rx, Serial::RxIrq); // timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BETWEEN); } @@ -91,11 +103,11 @@ timeout01.detach(); addr_tx = 0; mode_tx = DMX_MODE_DATA; - dmx.attach(this, &DMX::int_tx, Serial::TxIrq); + _dmx.attach(this, &DMX::int_tx, Serial::TxIrq); #ifdef DMX_UART_DIRECT *uart_thr = 0; #else - dmx.putc(0); + _dmx.putc(0); #endif break; } @@ -108,11 +120,11 @@ #ifdef DMX_UART_DIRECT *uart_thr = (uint8_t)data_tx[addr_tx]; #else - dmx.putc(data_tx[addr_tx]); + _dmx.putc(data_tx[addr_tx]); #endif addr_tx ++; } else { - dmx.attach(0, Serial::TxIrq); + _dmx.attach(0, Serial::TxIrq); mode_tx = DMX_MODE_BEGIN; is_sent = 1; timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BETWEEN); @@ -127,7 +139,7 @@ #ifdef DMX_UART_DIRECT dat = *uart_rbr; #else - dat = dmx.getc(); + dat = _dmx.getc(); #endif if (flg & ((1 << 7)|(1 << 3)|(1 << 4))) { @@ -172,7 +184,7 @@ } void DMX::stop () { - dmx.attach(0, Serial::TxIrq); + _dmx.attach(0, Serial::TxIrq); timeout01.detach(); mode_tx = DMX_MODE_STOP; }