aboutsummaryrefslogtreecommitdiffstats
path: root/ports
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-10-24 12:12:43 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-10-24 12:12:43 +0000
commit81a6458087801c73384f6d03eace650d0ea90828 (patch)
tree7dc32312846fa8666de8db976c1734c82204e00b /ports
parentc95d9e14831c7ebddfa17079fc6ae5217ed7242f (diff)
downloadChibiOS-81a6458087801c73384f6d03eace650d0ea90828.tar.gz
ChibiOS-81a6458087801c73384f6d03eace650d0ea90828.tar.bz2
ChibiOS-81a6458087801c73384f6d03eace650d0ea90828.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@62 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'ports')
-rw-r--r--ports/ARM7-LPC214x/GCC/lpc214x_serial.c44
-rw-r--r--ports/ARM7-LPC214x/GCC/lpc214x_serial.h17
2 files changed, 56 insertions, 5 deletions
diff --git a/ports/ARM7-LPC214x/GCC/lpc214x_serial.c b/ports/ARM7-LPC214x/GCC/lpc214x_serial.c
index e3f5e4040..71dbc0b7b 100644
--- a/ports/ARM7-LPC214x/GCC/lpc214x_serial.c
+++ b/ports/ARM7-LPC214x/GCC/lpc214x_serial.c
@@ -22,8 +22,6 @@
#include "lpc214x.h"
#include "lpc214x_serial.h"
-#define SERIAL_BUFFERS_SIZE 128
-
FullDuplexDriver COM1;
BYTE8 ib1[SERIAL_BUFFERS_SIZE];
BYTE8 ob1[SERIAL_BUFFERS_SIZE];
@@ -68,16 +66,28 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) {
break;
case IIR_SRC_TX:
{
+#ifdef FIFO_PRELOAD
+ int i = 0;
+ while (i < FIFO_PRELOAD) {
+ t_msg b = chFDDRequestDataI(com);
+ if (b < Q_OK) {
+ u->UART_IER &= ~IER_THRE;
+ break;
+ }
+ u->UART_THR = b;
+ i++;
+ }
+#else
t_msg b = chFDDRequestDataI(com);
if (b < Q_OK)
u->UART_IER &= ~IER_THRE;
else
u->UART_THR = b;
+#endif
}
default:
u->UART_THR;
u->UART_RBR;
- u->UART_IIR;
}
}
}
@@ -89,8 +99,20 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) {
static void OutNotify1(void) {
UART *u = U0Base;
- if (u->UART_LSR & LSR_THRE)
+ if (u->UART_LSR & LSR_THRE) {
+#ifdef FIFO_PRELOAD
+ int i = 0;
+ while (i < FIFO_PRELOAD) {
+ t_msg b = chOQGetI(&COM1.sd_oqueue);
+ if (b < Q_OK)
+ break;
+ u->UART_THR = b;
+ i++;
+ }
+#else
u->UART_THR = chOQGetI(&COM1.sd_oqueue);
+#endif
+ }
u->UART_IER |= IER_THRE;
}
@@ -101,8 +123,20 @@ static void OutNotify1(void) {
static void OutNotify2(void) {
UART *u = U1Base;
- if (u->UART_LSR & LSR_THRE)
+ if (u->UART_LSR & LSR_THRE) {
+#ifdef FIFO_PRELOAD
+ int i = 0;
+ while (i < FIFO_PRELOAD) {
+ t_msg b = chOQGetI(&COM2.sd_oqueue);
+ if (b < Q_OK)
+ break;
+ u->UART_THR = b;
+ i++;
+ }
+#else
u->UART_THR = chOQGetI(&COM2.sd_oqueue);
+#endif
+ }
u->UART_IER |= IER_THRE;
}
diff --git a/ports/ARM7-LPC214x/GCC/lpc214x_serial.h b/ports/ARM7-LPC214x/GCC/lpc214x_serial.h
index 1eaba687b..1ee910b4a 100644
--- a/ports/ARM7-LPC214x/GCC/lpc214x_serial.h
+++ b/ports/ARM7-LPC214x/GCC/lpc214x_serial.h
@@ -20,6 +20,23 @@
#ifndef _LPC214x_SERIAL_H_
#define _LPC214x_SERIAL_H_
+/*
+ * 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.
+ * NOTE: A greater value reduces the number of interrupts generated but can
+ * also increase the worst case interrupt response time.
+ * NOTE: You can undefine the following macro and revert to a simpler code
+ * that will generate an interrupt for each output byte,
+ */
+#define FIFO_PRELOAD 16
+
+/*
+ * Configuration parameter, you can change the depth of the queue buffers
+ * depending on the requirements of your application.
+ */
+#define SERIAL_BUFFERS_SIZE 128
+
void InitSerial(void);
void SetUARTI(UART *u, int speed, int lcr, int fcr);
void UART0IrqHandler(void);