MODSERIAL with support for more devices
Fork of MODSERIAL by
Diff: INIT.cpp
- Revision:
- 8:775f860e94d3
- Parent:
- 4:28de979b77cf
- Child:
- 9:b3cdae80e7a9
--- a/INIT.cpp Mon Nov 22 09:19:50 2010 +0000 +++ b/INIT.cpp Mon Nov 22 09:58:34 2010 +0000 @@ -40,7 +40,7 @@ if (_base != NULL) { buffer_size[RxIrq] = rxSize; - buffer[RxIrq] = (char *)malloc(buffer_size[RxIrq]); + buffer[RxIrq] = rxSize > 0 ? (char *)malloc(buffer_size[RxIrq]) : (char *)NULL; buffer_in[RxIrq] = 0; buffer_out[RxIrq] = 0; buffer_count[RxIrq] = 0; @@ -48,7 +48,7 @@ Serial::attach(this, &MODSERIAL::isr_rx, Serial::RxIrq); buffer_size[TxIrq] = txSize; - buffer[TxIrq] = (char *)malloc(buffer_size[TxIrq]); + buffer[TxIrq] = txSize > 0 ? (char *)malloc(buffer_size[TxIrq]) : (char *)NULL; buffer_in[TxIrq] = 0; buffer_out[TxIrq] = 0; buffer_count[TxIrq] = 0; @@ -59,14 +59,6 @@ error("MODSERIAL must have a defined UART to function."); } - if (!txBufferSane()) { - error("Failed to allocate memory for TX buffer"); - } - - if (!rxBufferSane()) { - error("Failed to allocate memory for RX buffer"); - } - _FCR = MODSERIAL_FIFO_ENABLE | MODSERIAL_FIFO_RX_RESET | MODSERIAL_FIFO_TX_RESET; enableIrq();