diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-01-10 15:20:40 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-01-10 15:20:40 +0000 |
commit | 23626829b9463237559b0283bbb5327331b9e280 (patch) | |
tree | e35982eb2f61bdaca2e3372177c64770f55ad22d /ports | |
parent | 2730efd717f3a4bb736f49250769b119fb4cbfa3 (diff) | |
download | ChibiOS-23626829b9463237559b0283bbb5327331b9e280.tar.gz ChibiOS-23626829b9463237559b0283bbb5327331b9e280.tar.bz2 ChibiOS-23626829b9463237559b0283bbb5327331b9e280.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@610 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'ports')
-rw-r--r-- | ports/ARM7-AT91SAM7X/sam7x_emac.c | 10 | ||||
-rw-r--r-- | ports/ARM7-AT91SAM7X/sam7x_serial.c | 20 | ||||
-rw-r--r-- | ports/ARM7-LPC214x/lpc214x_serial.c | 35 |
3 files changed, 43 insertions, 22 deletions
diff --git a/ports/ARM7-AT91SAM7X/sam7x_emac.c b/ports/ARM7-AT91SAM7X/sam7x_emac.c index 9acfe530b..47de8650e 100644 --- a/ports/ARM7-AT91SAM7X/sam7x_emac.c +++ b/ports/ARM7-AT91SAM7X/sam7x_emac.c @@ -106,21 +106,25 @@ static void ServeInterrupt(void) { if ((isr & AT91C_EMAC_RCOMP) || (rsr & RSR_BITS)) {
if (rsr & AT91C_EMAC_REC) {
// received++;
+ chSysLockI();
chEvtBroadcastI(&EMACFrameReceived);
+ chSysUnlockI();
}
AT91C_BASE_EMAC->EMAC_RSR = RSR_BITS;
}
if ((isr & AT91C_EMAC_TCOMP) || (tsr & TSR_BITS)) {
- if (tsr & AT91C_EMAC_COMP)
+ if (tsr & AT91C_EMAC_COMP) {
+ chSysLockI();
chEvtBroadcastI(&EMACFrameTransmitted);
+ chSysUnlockI();
+ }
AT91C_BASE_EMAC->EMAC_TSR = TSR_BITS;
}
AT91C_BASE_AIC->AIC_EOICR = 0;
}
-__attribute__((naked))
-void EMACIrqHandler(void) {
+CH_IRQ_HANDLER void EMACIrqHandler(void) {
chSysIRQEnterI();
ServeInterrupt();
diff --git a/ports/ARM7-AT91SAM7X/sam7x_serial.c b/ports/ARM7-AT91SAM7X/sam7x_serial.c index 9534e287a..58a275439 100644 --- a/ports/ARM7-AT91SAM7X/sam7x_serial.c +++ b/ports/ARM7-AT91SAM7X/sam7x_serial.c @@ -42,18 +42,26 @@ static void SetError(AT91_REG csr, FullDuplexDriver *com) { sts |= SD_FRAMING_ERROR;
if (csr & AT91C_US_RXBRK)
sts |= SD_BREAK_DETECTED;
+ chSysLockI();
chFDDAddFlagsI(com, sts);
+ chSysUnlockI();
}
/*
* Serves the pending sources on the USART.
*/
+__attribute__((noinline))
static void ServeInterrupt(AT91PS_USART u, FullDuplexDriver *com) {
- if (u->US_CSR & AT91C_US_RXRDY)
+ if (u->US_CSR & AT91C_US_RXRDY) {
+ chSysLockI();
chFDDIncomingDataI(com, u->US_RHR);
+ chSysUnlockI();
+ }
if (u->US_CSR & AT91C_US_TXRDY) {
+ chSysLockI();
msg_t b = chFDDRequestDataI(com);
+ chSysUnlockI();
if (b < Q_OK)
u->US_IDR = AT91C_US_TXRDY;
else
@@ -66,23 +74,17 @@ static void ServeInterrupt(AT91PS_USART u, FullDuplexDriver *com) { AT91C_BASE_AIC->AIC_EOICR = 0;
}
-__attribute__((naked, weak))
-void USART0IrqHandler(void) {
+CH_IRQ_HANDLER void USART0IrqHandler(void) {
chSysIRQEnterI();
-
ServeInterrupt(AT91C_BASE_US0, &COM1);
-
chSysIRQExitI();
}
-__attribute__((naked, weak))
-void USART1IrqHandler(void) {
+CH_IRQ_HANDLER void USART1IrqHandler(void) {
chSysIRQEnterI();
-
ServeInterrupt(AT91C_BASE_US1, &COM2);
-
chSysIRQExitI();
}
diff --git a/ports/ARM7-LPC214x/lpc214x_serial.c b/ports/ARM7-LPC214x/lpc214x_serial.c index 88a142ed0..38eae3169 100644 --- a/ports/ARM7-LPC214x/lpc214x_serial.c +++ b/ports/ARM7-LPC214x/lpc214x_serial.c @@ -43,13 +43,16 @@ static void SetError(IOREG32 err, FullDuplexDriver *com) { sts |= SD_FRAMING_ERROR;
if (err & LSR_BREAK)
sts |= SD_BREAK_DETECTED;
+ chSysLockI();
chFDDAddFlagsI(com, sts);
+ chSysUnlockI();
}
/*
* Tries hard to clear all the pending interrupt sources, we dont want to
* go through the whole ISR and have another interrupt soon after.
*/
+__attribute__((noinline))
static void ServeInterrupt(UART *u, FullDuplexDriver *com) {
while (TRUE) {
@@ -62,26 +65,37 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) { break;
case IIR_SRC_TIMEOUT:
case IIR_SRC_RX:
- while (u->UART_LSR & LSR_RBR_FULL)
+ while (u->UART_LSR & LSR_RBR_FULL) {
+ chSysLockI();
if (chIQPutI(&com->sd_iqueue, u->UART_RBR) < Q_OK)
chFDDAddFlagsI(com, SD_OVERRUN_ERROR);
+ chSysUnlockI();
+ }
+ chSysLockI();
chEvtBroadcastI(&com->sd_ievent);
+ chSysUnlockI();
break;
case IIR_SRC_TX:
{
#ifdef FIFO_PRELOAD
int i = FIFO_PRELOAD;
do {
+ chSysLockI();
msg_t b = chOQGetI(&com->sd_oqueue);
+ chSysUnlockI();
if (b < Q_OK) {
u->UART_IER &= ~IER_THRE;
+ chSysLockI();
chEvtBroadcastI(&com->sd_oevent);
+ chSysUnlockI();
break;
}
u->UART_THR = b;
} while (--i);
#else
+ chSysLockI();
msg_t b = chFDDRequestDataI(com);
+ chSysUnlockI();
if (b < Q_OK)
u->UART_IER &= ~IER_THRE;
else
@@ -95,25 +109,19 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) { }
}
-__attribute__((naked, weak))
-void UART0IrqHandler(void) {
+CH_IRQ_HANDLER void UART0IrqHandler(void) {
chSysIRQEnterI();
-
ServeInterrupt(U0Base, &COM1);
VICVectAddr = 0;
-
chSysIRQExitI();
}
-__attribute__((naked, weak))
-void UART1IrqHandler(void) {
+CH_IRQ_HANDLER void UART1IrqHandler(void) {
chSysIRQEnterI();
-
ServeInterrupt(U1Base, &COM2);
VICVectAddr = 0;
-
chSysIRQExitI();
}
@@ -123,9 +131,13 @@ static void preload(UART *u, FullDuplexDriver *com) { if (u->UART_LSR & LSR_THRE) {
int i = FIFO_PRELOAD;
do {
+ chSysLockI();
msg_t b = chOQGetI(&com->sd_oqueue);
+ chSysUnlockI();
if (b < Q_OK) {
+ chSysLockI();
chEvtBroadcastI(&com->sd_oevent);
+ chSysUnlockI();
return;
}
u->UART_THR = b;
@@ -146,8 +158,11 @@ static void OutNotify1(void) { #else
UART *u = U0Base;
- if (u->UART_LSR & LSR_THRE)
+ if (u->UART_LSR & LSR_THRE) {
+ chSysLockI();
u->UART_THR = chOQGetI(&COM1.sd_oqueue);
+ chSysUnlockI();
+ }
u->UART_IER |= IER_THRE;
#endif
}
|