An initial port to the FRDM-K46Z based on the the following: https://developer.mbed.org/users/okini3939/notebook/dmx512/
Fork of DMX by
Need to update the UART references to the K46Z. The KE02 Sub-Family Reference Manual provides us with the required information.
The modifications are wrapped with the target for the K46: For example, defined(TARGET_KL46Z)
Diff: DMX.cpp
- Revision:
- 8:d4a45bba41d2
- Parent:
- 7:16d6874076dd
- Child:
- 9:e687f321c428
diff -r 16d6874076dd -r d4a45bba41d2 DMX.cpp --- a/DMX.cpp Sun Jan 13 01:35:53 2013 +0000 +++ b/DMX.cpp Mon Mar 11 04:02:26 2013 +0000 @@ -25,41 +25,21 @@ is_sent = 0; #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) - if (p_tx == p9) { - uart_lcr = &LPC_UART3->LCR; - uart_thr = &LPC_UART3->THR; - } else - if (p_tx == p13) { - uart_lcr = &LPC_UART1->LCR; - uart_thr = &LPC_UART1->THR; - } else - if (p_tx == p28) { - uart_lcr = &LPC_UART2->LCR; - uart_thr = &LPC_UART2->THR; - } if (p_rx == p10) { - uart_lsr = &LPC_UART3->LSR; - uart_rbr = &LPC_UART3->RBR; + _uart = LPC_UART3; NVIC_SetPriority(UART3_IRQn, 1); } else if (p_rx == p14) { - uart_lsr = &LPC_UART1->LSR; - uart_rbr = &LPC_UART1->RBR; + _uart = (LPC_UART_TypeDef*)LPC_UART1; NVIC_SetPriority(UART1_IRQn, 1); } else if (p_rx == p27) { - uart_lsr = &LPC_UART2->LSR; - uart_rbr = &LPC_UART2->RBR; + _uart = LPC_UART2; 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; + _uart = LPC_USART; NVIC_SetPriority(UART_IRQn, 1); } #endif @@ -99,7 +79,7 @@ case DMX_MODE_BEGIN: // Break Time timeout01.detach(); - *uart_lcr |= (1 << 6); + _uart->LCR |= (1 << 6); mode_tx = DMX_MODE_BREAK; timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BREAK); break; @@ -107,7 +87,7 @@ case DMX_MODE_BREAK: // Mark After Break timeout01.detach(); - *uart_lcr &= ~(1 << 6); + _uart->LCR &= ~(1 << 6); mode_tx = DMX_MODE_MAB; timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_MAB); break; @@ -119,7 +99,7 @@ mode_tx = DMX_MODE_DATA; _dmx.attach(this, &DMX::int_tx, Serial::TxIrq); #ifdef DMX_UART_DIRECT - *uart_thr = 0; + _uart->THR = 0; #else _dmx.putc(0); #endif @@ -132,7 +112,7 @@ if (mode_tx == DMX_MODE_DATA) { if (addr_tx < DMX_SIZE) { #ifdef DMX_UART_DIRECT - *uart_thr = (uint8_t)data_tx[addr_tx]; + _uart->THR = (uint8_t)data_tx[addr_tx]; #else _dmx.putc(data_tx[addr_tx]); #endif @@ -149,16 +129,16 @@ void DMX::int_rx () { int flg, dat; - flg = *uart_lsr; + flg = _uart->LSR; #ifdef DMX_UART_DIRECT - dat = *uart_rbr; + dat = _uart->RBR; #else dat = _dmx.getc(); #endif if (flg & ((1 << 7)|(1 << 3)|(1 << 4))) { // Break Time - if (addr_rx > 0) { + if (addr_rx >= 24) { is_recived = 1; } mode_rx = DMX_MODE_BREAK;