diff options
Diffstat (limited to 'os')
-rw-r--r-- | os/hal/platforms/LPC214x/serial_lld.c | 52 | ||||
-rw-r--r-- | os/hal/platforms/LPC214x/serial_lld.h | 9 | ||||
-rw-r--r-- | os/hal/platforms/Linux/console.c | 10 | ||||
-rw-r--r-- | os/hal/platforms/MSP430/serial_lld.c | 16 | ||||
-rw-r--r-- | os/hal/platforms/Win32/console.c | 10 |
5 files changed, 48 insertions, 49 deletions
diff --git a/os/hal/platforms/LPC214x/serial_lld.c b/os/hal/platforms/LPC214x/serial_lld.c index cfc742736..9c76d8e7f 100644 --- a/os/hal/platforms/LPC214x/serial_lld.c +++ b/os/hal/platforms/LPC214x/serial_lld.c @@ -152,7 +152,6 @@ static void serve_interrupt(SerialDriver *sdp) { break;
case IIR_SRC_TX:
{
-#if LPC214x_UART_FIFO_PRELOAD > 0
int i = LPC214x_UART_FIFO_PRELOAD;
do {
msg_t b;
@@ -169,15 +168,6 @@ static void serve_interrupt(SerialDriver *sdp) { }
u->UART_THR = b;
} while (--i);
-#else
- chSysLockFromIsr();
- msg_t b = sdRequestDataI(sdp);
- chSysUnlockFromIsr();
- if (b < Q_OK)
- u->UART_IER &= ~IER_THRE;
- else
- u->UART_THR = b;
-#endif
}
break;
default:
@@ -187,20 +177,18 @@ static void serve_interrupt(SerialDriver *sdp) { }
}
-#if LPC214x_UART_FIFO_PRELOAD > 0
+/**
+ * @brief Attempts a TX FIFO preload. + */
static void preload(SerialDriver *sdp) {
UART *u = sdp->sd.uart;
if (u->UART_LSR & LSR_THRE) {
int i = LPC214x_UART_FIFO_PRELOAD;
do {
- chSysLockFromIsr();
msg_t b = chOQGetI(&sdp->sd.oqueue);
- chSysUnlockFromIsr();
if (b < Q_OK) {
- chSysLockFromIsr();
chEvtBroadcastI(&sdp->bac.oevent);
- chSysUnlockFromIsr();
return;
}
u->UART_THR = b;
@@ -208,38 +196,25 @@ static void preload(SerialDriver *sdp) { }
u->UART_IER |= IER_THRE;
}
-#endif
+/**
+ * @brief Driver SD1 output notification. + */
#if USE_LPC214x_UART0 || defined(__DOXYGEN__)
static void notify1(void) {
-#if LPC214x_UART_FIFO_PRELOAD > 0
preload(&SD1);
-#else
- UART *u = U0Base;
-
- if (u->UART_LSR & LSR_THRE) {
- chSysLockFromIsr();
- u->UART_THR = chOQGetI(&SD1.sd.oqueue);
- chSysUnlockFromIsr();
- }
- u->UART_IER |= IER_THRE;
-#endif
}
#endif
+
+/**
+ * @brief Driver SD2 output notification.
+ */
#if USE_LPC214x_UART1 || defined(__DOXYGEN__)
static void notify2(void) {
-#if LPC214x_UART_FIFO_PRELOAD > 0
preload(&SD2);
-#else
- UART *u = U1Base;
-
- if (u->UART_LSR & LSR_THRE)
- u->UART_THR = chOQGetI(&SD2.sd.oqueue);
- u->UART_IER |= IER_THRE;
-#endif
}
#endif
@@ -247,6 +222,9 @@ static void notify2(void) { /* Driver interrupt handlers. */
/*===========================================================================*/
+/**
+ * @brief UART0 IRQ handler. + */
#if USE_LPC214x_UART0 || defined(__DOXYGEN__)
CH_IRQ_HANDLER(UART0IrqHandler) {
@@ -259,6 +237,10 @@ CH_IRQ_HANDLER(UART0IrqHandler) { }
#endif
+
+/**
+ * @brief UART1 IRQ handler.
+ */
#if USE_LPC214x_UART1 || defined(__DOXYGEN__)
CH_IRQ_HANDLER(UART1IrqHandler) {
diff --git a/os/hal/platforms/LPC214x/serial_lld.h b/os/hal/platforms/LPC214x/serial_lld.h index 034a707fb..67e7e27d0 100644 --- a/os/hal/platforms/LPC214x/serial_lld.h +++ b/os/hal/platforms/LPC214x/serial_lld.h @@ -59,13 +59,10 @@ * @brief FIFO preload parameter.
* @details Configuration parameter, this values defines how many bytes are
* preloaded in the HW transmit FIFO for each interrupt, the maximum value is
- * 16 the minimum is 2, the value 0 disables the feature.
+ * 16 the minimum is 1.
* @note An high value reduces the number of interrupts generated but can
* also increase the worst case interrupt response time because the
* preload loops.
- * @note The value zero disables the feature and reverts to a simpler code
- * that will generate an interrupt for each output byte but is much
- * smaller and simpler.
*/
#if !defined(UART_FIFO_PRELOAD) || defined(__DOXYGEN__)
#define LPC214x_UART_FIFO_PRELOAD 16
@@ -89,6 +86,10 @@ /* Derived constants and error checks. */
/*===========================================================================*/
+#if (LPC214x_UART_FIFO_PRELOAD < 1) || (LPC214x_UART_FIFO_PRELOAD > 16)
+#error "invalid LPC214x_UART_FIFO_PRELOAD setting"
+#endif
+
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
diff --git a/os/hal/platforms/Linux/console.c b/os/hal/platforms/Linux/console.c index 0c47ff491..7c6bd705d 100644 --- a/os/hal/platforms/Linux/console.c +++ b/os/hal/platforms/Linux/console.c @@ -47,9 +47,12 @@ BaseChannel CD1; static size_t writes(void *ip, const uint8_t *bp, size_t n) {
+ size_t ret;
(void)ip;
- return fwrite(bp, 1, n, stdout);
+ ret = fwrite(bp, 1, n, stdout);
+ fflush(stdout);
+ return ret;
}
static size_t reads(void *ip, uint8_t *bp, size_t n) {
@@ -87,10 +90,13 @@ static msg_t gett(void *ip, systime_t time) { }
static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) {
+ size_t ret;
(void)ip;
(void)time;
- return fwrite(bp, 1, n, stdout);
+ ret = fwrite(bp, 1, n, stdout);
+ fflush(stdout);
+ return ret;
}
static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
diff --git a/os/hal/platforms/MSP430/serial_lld.c b/os/hal/platforms/MSP430/serial_lld.c index fd9dc19bf..acc8a8357 100644 --- a/os/hal/platforms/MSP430/serial_lld.c +++ b/os/hal/platforms/MSP430/serial_lld.c @@ -79,10 +79,11 @@ static void set_error(SerialDriver *sdp, uint8_t urctl) { static void notify1(void) {
if (!(U0IE & UTXIE0)) {
- chSysLockFromIsr();
- U0TXBUF = (uint8_t)sdRequestDataI(&SD1);
- chSysUnlockFromIsr();
- U0IE |= UTXIE0;
+ msg_t b = sdRequestDataI(&SD1);
+ if (b != Q_EMPTY) {
+ U0IE |= UTXIE0;
+ U0TXBUF = (uint8_t)b;
+ }
}
}
@@ -122,8 +123,11 @@ static void usart0_deinit(void) { static void notify2(void) {
if (!(U1IE & UTXIE1)) {
- U1TXBUF = (uint8_t)sdRequestDataI(&SD2);
- U1IE |= UTXIE1;
+ msg_t b = sdRequestDataI(&SD2);
+ if (b != Q_EMPTY) {
+ U1IE |= UTXIE1;
+ U1TXBUF = (uint8_t)b;
+ }
}
}
diff --git a/os/hal/platforms/Win32/console.c b/os/hal/platforms/Win32/console.c index 0c47ff491..7c6bd705d 100644 --- a/os/hal/platforms/Win32/console.c +++ b/os/hal/platforms/Win32/console.c @@ -47,9 +47,12 @@ BaseChannel CD1; static size_t writes(void *ip, const uint8_t *bp, size_t n) {
+ size_t ret;
(void)ip;
- return fwrite(bp, 1, n, stdout);
+ ret = fwrite(bp, 1, n, stdout);
+ fflush(stdout);
+ return ret;
}
static size_t reads(void *ip, uint8_t *bp, size_t n) {
@@ -87,10 +90,13 @@ static msg_t gett(void *ip, systime_t time) { }
static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) {
+ size_t ret;
(void)ip;
(void)time;
- return fwrite(bp, 1, n, stdout);
+ ret = fwrite(bp, 1, n, stdout);
+ fflush(stdout);
+ return ret;
}
static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
|