diff options
39 files changed, 181 insertions, 270 deletions
diff --git a/demos/ARM7-AT91SAM7S-FATFS-GCC/main.c b/demos/ARM7-AT91SAM7S-FATFS-GCC/main.c index faf8c5a8d..97898c9ce 100644 --- a/demos/ARM7-AT91SAM7S-FATFS-GCC/main.c +++ b/demos/ARM7-AT91SAM7S-FATFS-GCC/main.c @@ -59,9 +59,6 @@ static SPIConfig ls_spicfg = { (MIN_SPI_BITRATE << 8) | AT91C_SPI_NCPHA | AT91C_SPI_BITS_8
};
-/* MMC configuration (empty).*/
-static const MMCConfig mmc_cfg = {};
-
/* Card insertion verification.*/
static bool_t mmc_is_inserted(void) {
return !palReadPad(IOPORT1, PIOA_MMC_CP);
@@ -329,7 +326,7 @@ int main(void) { mmcObjectInit(&MMCD1, &SPID1,
&ls_spicfg, &hs_spicfg,
mmc_is_protected, mmc_is_inserted);
- mmcStart(&MMCD1, &mmc_cfg);
+ mmcStart(&MMCD1, NULL);
/*
* Creates the blinker threads.
diff --git a/demos/ARM7-AT91SAM7X-FATFS-GCC/main.c b/demos/ARM7-AT91SAM7X-FATFS-GCC/main.c index 3c3f2aae4..d7cd3f40e 100644 --- a/demos/ARM7-AT91SAM7X-FATFS-GCC/main.c +++ b/demos/ARM7-AT91SAM7X-FATFS-GCC/main.c @@ -59,9 +59,6 @@ static SPIConfig ls_spicfg = { (MIN_SPI_BITRATE << 8) | AT91C_SPI_NCPHA | AT91C_SPI_BITS_8
};
-/* MMC configuration (empty).*/
-static const MMCConfig mmc_cfg = {};
-
/* Card insertion verification.*/
static bool_t mmc_is_inserted(void) {
return !palReadPad(IOPORT2, PIOB_MMC_CP);
@@ -312,7 +309,7 @@ int main(void) { mmcObjectInit(&MMCD1, &SPID1,
&ls_spicfg, &hs_spicfg,
mmc_is_protected, mmc_is_inserted);
- mmcStart(&MMCD1, &mmc_cfg);
+ mmcStart(&MMCD1, NULL);
/*
* Creates the blinker threads.
diff --git a/demos/ARM7-LPC214x-FATFS-GCC/main.c b/demos/ARM7-LPC214x-FATFS-GCC/main.c index 44afc36fd..1868bac05 100644 --- a/demos/ARM7-LPC214x-FATFS-GCC/main.c +++ b/demos/ARM7-LPC214x-FATFS-GCC/main.c @@ -59,9 +59,6 @@ static SPIConfig ls_spicfg = { 254
};
-/* MMC configuration (empty).*/
-static const MMCConfig mmc_cfg = {};
-
/* Card insertion verification.*/
static bool_t mmc_is_inserted(void) {
return !palReadPad(IOPORT2, PB_CP1);
@@ -258,7 +255,7 @@ int main(void) { mmcObjectInit(&MMCD1, &SPID1,
&ls_spicfg, &hs_spicfg,
mmc_is_protected, mmc_is_inserted);
- mmcStart(&MMCD1, &mmc_cfg);
+ mmcStart(&MMCD1, NULL);
/*
* Creates the blinker threads.
diff --git a/demos/ARMCM3-STM32F103/mcuconf.h b/demos/ARMCM3-STM32F103/mcuconf.h index 4e640b93f..e5ccc2584 100644 --- a/demos/ARMCM3-STM32F103/mcuconf.h +++ b/demos/ARMCM3-STM32F103/mcuconf.h @@ -37,7 +37,7 @@ #define STM32_SW STM32_SW_PLL
#define STM32_PLLSRC STM32_PLLSRC_HSE
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
-#define STM32_PLLMUL_VALUE 9
+#define STM32_PLLMUL_VALUE 6
#define STM32_HPRE STM32_HPRE_DIV1
#define STM32_PPRE1 STM32_PPRE1_DIV2
#define STM32_PPRE2 STM32_PPRE2_DIV2
diff --git a/demos/Win32-MinGW/main.c b/demos/Win32-MinGW/main.c index 9ce9b284a..cbdfc100d 100644 --- a/demos/Win32-MinGW/main.c +++ b/demos/Win32-MinGW/main.c @@ -172,12 +172,12 @@ static void sd1_handler(eventid_t id) { sdflags_t flags;
(void)id;
- flags = sdGetAndClearFlags(&SD1);
- if ((flags & SD_CONNECTED) && (shelltp1 == NULL)) {
+ flags = chIOGetAndClearFlags(&SD1);
+ if ((flags & IO_CONNECTED) && (shelltp1 == NULL)) {
cputs("Init: connection on SD1");
shelltp1 = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO + 1);
}
- if (flags & SD_DISCONNECTED) {
+ if (flags & IO_DISCONNECTED) {
cputs("Init: disconnection on SD1");
chSysLock();
chIQResetI(&SD1.iqueue);
@@ -194,12 +194,12 @@ static void sd2_handler(eventid_t id) { sdflags_t flags;
(void)id;
- flags = sdGetAndClearFlags(&SD2);
- if ((flags & SD_CONNECTED) && (shelltp2 == NULL)) {
+ flags = chIOGetAndClearFlags(&SD2);
+ if ((flags & IO_CONNECTED) && (shelltp2 == NULL)) {
cputs("Init: connection on SD2");
shelltp2 = shellCreate(&shell_cfg2, SHELL_WA_SIZE, NORMALPRIO + 10);
}
- if (flags & SD_DISCONNECTED) {
+ if (flags & IO_DISCONNECTED) {
cputs("Init: disconnection on SD2");
chSysLock();
chIQResetI(&SD2.iqueue);
@@ -252,11 +252,11 @@ int main(void) { */
cputs("Shell service started on SD1, SD2");
cputs(" - Listening for connections on SD1");
- (void) sdGetAndClearFlags(&SD1);
- chEvtRegister(&SD1.sevent, &sd1fel, 1);
+ (void) chIOGetAndClearFlags(&SD1);
+ chEvtRegister(chIOGetEventSource(&SD1), &sd1fel, 1);
cputs(" - Listening for connections on SD2");
- (void) sdGetAndClearFlags(&SD2);
- chEvtRegister(&SD2.sevent, &sd2fel, 2);
+ (void) chIOGetAndClearFlags(&SD2);
+ chEvtRegister(chIOGetEventSource(&SD2), &sd2fel, 2);
/*
* Events servicing loop.
@@ -267,7 +267,7 @@ int main(void) { /*
* Clean simulator exit.
*/
- chEvtUnregister(&SD1.sevent, &sd1fel);
- chEvtUnregister(&SD2.sevent, &sd2fel);
+ chEvtUnregister(chIOGetEventSource(&SD1), &sd1fel);
+ chEvtUnregister(chIOGetEventSource(&SD2), &sd2fel);
return 0;
}
diff --git a/docs/reports/AT91SAM7X-48-ARM.txt b/docs/reports/AT91SAM7X-48-ARM.txt index 9a177cde4..3ea10a03a 100644 --- a/docs/reports/AT91SAM7X-48-ARM.txt +++ b/docs/reports/AT91SAM7X-48-ARM.txt @@ -5,7 +5,7 @@ Settings: MCK=48.054857, MC_FMR = AT91C_MC_FWS_1FWS (1 wait state) *** ChibiOS/RT test suite
***
-*** Kernel: 2.1.6unstable
+*** Kernel: 2.1.7unstable
*** GCC Version: 4.5.1
*** Architecture: ARM7
*** Core Variant: ARM7TDMI
@@ -122,7 +122,7 @@ Settings: MCK=48.054857, MC_FMR = AT91C_MC_FWS_1FWS (1 wait state) --- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.7 (Benchmark, mass reschedule, 5 threads)
---- Score : 27231 reschedules/S, 163386 ctxswc/S
+--- Score : 27232 reschedules/S, 163392 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Benchmark, round robin context switching)
diff --git a/docs/reports/LPC2148-48-ARM.txt b/docs/reports/LPC2148-48-ARM.txt index c179db3cf..f1ce426dd 100644 --- a/docs/reports/LPC2148-48-ARM.txt +++ b/docs/reports/LPC2148-48-ARM.txt @@ -5,7 +5,7 @@ Settings: CCLK=48, MAMCR=2, MAMTIM=3 (3 wait states) *** ChibiOS/RT test suite
***
-*** Kernel: 2.1.6unstable
+*** Kernel: 2.1.7unstable
*** GCC Version: 4.5.1
*** Architecture: ARM7
*** Core Variant: ARM7TDMI
diff --git a/docs/reports/STM32F103-48-GCC.txt b/docs/reports/STM32F103-48-GCC.txt index 7280a2ead..be8d0d274 100644 --- a/docs/reports/STM32F103-48-GCC.txt +++ b/docs/reports/STM32F103-48-GCC.txt @@ -5,7 +5,7 @@ Settings: SYSCLK=48, ACR=0x11 (1 wait state) *** ChibiOS/RT test suite
***
-*** Kernel: 2.1.5unstable
+*** Kernel: 2.1.7unstable
*** GCC Version: 4.5.1
*** Architecture: ARMv7-M
*** Core Variant: Cortex-M3
diff --git a/docs/reports/STM32F103-72-GCC.txt b/docs/reports/STM32F103-72-GCC.txt index e1f06d20a..0052c806a 100644 --- a/docs/reports/STM32F103-72-GCC.txt +++ b/docs/reports/STM32F103-72-GCC.txt @@ -5,7 +5,7 @@ Settings: SYSCLK=72, ACR=0x12 (2 wait states) *** ChibiOS/RT test suite
***
-*** Kernel: 2.1.6unstable
+*** Kernel: 2.1.7unstable
*** GCC Version: 4.5.1
*** Architecture: ARMv7-M
*** Core Variant: Cortex-M3
@@ -98,7 +98,7 @@ Settings: SYSCLK=72, ACR=0x12 (2 wait states) --- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.1 (Benchmark, messages #1)
---- Score : 248574 msgs/S, 497148 ctxswc/S
+--- Score : 248573 msgs/S, 497146 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Benchmark, messages #2)
@@ -126,7 +126,7 @@ Settings: SYSCLK=72, ACR=0x12 (2 wait states) --- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Benchmark, round robin context switching)
---- Score : 478128 ctxswc/S
+--- Score : 478116 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
diff --git a/docs/reports/STM8L152-16-Cosmic.txt b/docs/reports/STM8L152-16-Cosmic.txt index 7c82ce881..40ad21154 100644 --- a/docs/reports/STM8L152-16-Cosmic.txt +++ b/docs/reports/STM8L152-16-Cosmic.txt @@ -6,7 +6,7 @@ Compiler: Cosmic STM8 compiler 4.3.3.3. *** ChibiOS/RT test suite
***
-*** Kernel: 2.1.6unstable
+*** Kernel: 2.1.7unstable
*** Architecture: STM8
*** Platform: STM8L
*** Test Board: ST STM8L-Discovery
@@ -97,43 +97,43 @@ Compiler: Cosmic STM8 compiler 4.3.3.3. --- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.1 (Benchmark, messages #1)
---- Score : 35517 msgs/S, 71034 ctxswc/S
+--- Score : 35916 msgs/S, 71832 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Benchmark, messages #2)
---- Score : 28040 msgs/S, 56080 ctxswc/S
+--- Score : 28238 msgs/S, 56476 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.3 (Benchmark, messages #3)
---- Score : 28040 msgs/S, 56080 ctxswc/S
+--- Score : 28238 msgs/S, 56476 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.4 (Benchmark, context switch)
---- Score : 134880 ctxswc/S
+--- Score : 136456 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.5 (Benchmark, threads, full cycle)
---- Score : 20757 threads/S
+--- Score : 20730 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.6 (Benchmark, threads, create only)
---- Score : 32486 threads/S
+--- Score : 32552 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.7 (Benchmark, mass reschedule, 5 threads)
---- Score : 8461 reschedules/S, 50766 ctxswc/S
+--- Score : 8502 reschedules/S, 51012 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Benchmark, round robin context switching)
---- Score : 70640 ctxswc/S
+--- Score : 69940 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
---- Score : 76220 bytes/S
+--- Score : 76132 bytes/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.10 (Benchmark, virtual timers set/reset)
---- Score : 72812 timers/S
+--- Score : 72482 timers/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.11 (Benchmark, semaphores wait/signal)
@@ -141,7 +141,7 @@ Compiler: Cosmic STM8 compiler 4.3.3.3. --- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.12 (Benchmark, mutexes lock/unlock)
---- Score : 143340 lock+unlock/S
+--- Score : 141436 lock+unlock/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.13 (Benchmark, RAM footprint)
diff --git a/docs/reports/STM8S105-16-Cosmic.txt b/docs/reports/STM8S105-16-Cosmic.txt index 220994fef..1b57fb7e3 100644 --- a/docs/reports/STM8S105-16-Cosmic.txt +++ b/docs/reports/STM8S105-16-Cosmic.txt @@ -6,7 +6,7 @@ Compiler: Cosmic STM8 compiler 4.3.3.3. *** ChibiOS/RT test suite
***
-*** Kernel: 2.1.6unstable
+*** Kernel: 2.1.7unstable
*** Architecture: STM8
*** Platform: STM8S
*** Test Board: ST STM8S-Discovery
@@ -97,51 +97,51 @@ Compiler: Cosmic STM8 compiler 4.3.3.3. --- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.1 (Benchmark, messages #1)
---- Score : 35999 msgs/S, 71998 ctxswc/S
+--- Score : 35678 msgs/S, 71356 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Benchmark, messages #2)
---- Score : 28391 msgs/S, 56782 ctxswc/S
+--- Score : 28191 msgs/S, 56382 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.3 (Benchmark, messages #3)
---- Score : 28391 msgs/S, 56782 ctxswc/S
+--- Score : 28191 msgs/S, 56382 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.4 (Benchmark, context switch)
---- Score : 135888 ctxswc/S
+--- Score : 135456 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.5 (Benchmark, threads, full cycle)
---- Score : 20894 threads/S
+--- Score : 20813 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.6 (Benchmark, threads, create only)
---- Score : 32620 threads/S
+--- Score : 32554 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.7 (Benchmark, mass reschedule, 5 threads)
---- Score : 8484 reschedules/S, 50904 ctxswc/S
+--- Score : 8476 reschedules/S, 50856 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Benchmark, round robin context switching)
---- Score : 71040 ctxswc/S
+--- Score : 70336 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
---- Score : 76408 bytes/S
+--- Score : 75868 bytes/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.10 (Benchmark, virtual timers set/reset)
---- Score : 72602 timers/S
+--- Score : 72930 timers/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.11 (Benchmark, semaphores wait/signal)
---- Score : 172328 wait+signal/S
+--- Score : 170492 wait+signal/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.12 (Benchmark, mutexes lock/unlock)
---- Score : 142076 lock+unlock/S
+--- Score : 142080 lock+unlock/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.13 (Benchmark, RAM footprint)
diff --git a/os/hal/include/serial.h b/os/hal/include/serial.h index bbbd9eda5..d67c3079a 100644 --- a/os/hal/include/serial.h +++ b/os/hal/include/serial.h @@ -34,22 +34,16 @@ /* Driver constants. */
/*===========================================================================*/
-/** @brief No pending conditions.*/
-#define SD_NO_ERROR 0
-/** @brief Connection happened.*/
-#define SD_CONNECTED 1
-/** @brief Disconnection happened.*/
-#define SD_DISCONNECTED 2
/** @brief Parity error happened.*/
-#define SD_PARITY_ERROR 4
+#define SD_PARITY_ERROR 16
/** @brief Framing error happened.*/
-#define SD_FRAMING_ERROR 8
+#define SD_FRAMING_ERROR 32
/** @brief Overflow happened.*/
-#define SD_OVERRUN_ERROR 16
+#define SD_OVERRUN_ERROR 64
/** @brief Noise on the line.*/
-#define SD_NOISE_ERROR 32
+#define SD_NOISE_ERROR 128
/** @brief Break detected.*/
-#define SD_BREAK_DETECTED 64
+#define SD_BREAK_DETECTED 256
/*===========================================================================*/
/* Driver pre-compile time settings. */
@@ -311,8 +305,6 @@ extern "C" { void sdStop(SerialDriver *sdp);
void sdIncomingDataI(SerialDriver *sdp, uint8_t b);
msg_t sdRequestDataI(SerialDriver *sdp);
- void sdAddFlagsI(SerialDriver *sdp, sdflags_t mask);
- sdflags_t sdGetAndClearFlags(SerialDriver *sdp);
#ifdef __cplusplus
}
#endif
diff --git a/os/hal/platforms/AT91SAM7/serial_lld.c b/os/hal/platforms/AT91SAM7/serial_lld.c index 04e72a795..f34f2b6d8 100644 --- a/os/hal/platforms/AT91SAM7/serial_lld.c +++ b/os/hal/platforms/AT91SAM7/serial_lld.c @@ -136,7 +136,7 @@ static void usart_deinit(AT91PS_USART u) { * @param[in] sdp communication channel associated to the USART
*/
static void set_error(SerialDriver *sdp, AT91_REG csr) {
- sdflags_t sts = 0;
+ ioflags_t sts = 0;
if (csr & AT91C_US_OVRE)
sts |= SD_OVERRUN_ERROR;
@@ -147,7 +147,7 @@ static void set_error(SerialDriver *sdp, AT91_REG csr) { if (csr & AT91C_US_RXBRK)
sts |= SD_BREAK_DETECTED;
chSysLockFromIsr();
- sdAddFlagsI(sdp, sts);
+ chIOAddFlagsI(sdp, sts);
chSysUnlockFromIsr();
}
@@ -178,7 +178,7 @@ void sd_lld_serve_interrupt(SerialDriver *sdp) { chSysLockFromIsr();
b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) {
- chEvtBroadcastI(&sdp->oevent);
+ chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY);
u->US_IDR = AT91C_US_TXRDY;
}
else
diff --git a/os/hal/platforms/AT91SAM7/serial_lld.h b/os/hal/platforms/AT91SAM7/serial_lld.h index 027cf90cd..94aca128b 100644 --- a/os/hal/platforms/AT91SAM7/serial_lld.h +++ b/os/hal/platforms/AT91SAM7/serial_lld.h @@ -95,11 +95,6 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
- */
-typedef uint32_t sdflags_t;
-
-/**
* @brief AT91SAM7 Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
@@ -128,10 +123,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/platforms/AVR/serial_lld.c b/os/hal/platforms/AVR/serial_lld.c index a21e0e625..f78abac18 100644 --- a/os/hal/platforms/AVR/serial_lld.c +++ b/os/hal/platforms/AVR/serial_lld.c @@ -69,7 +69,7 @@ static const SerialConfig default_config = { /*===========================================================================*/
static void set_error(uint8_t sra, SerialDriver *sdp) {
- sdflags_t sts = 0;
+ ioflags_t sts = 0;
if (sra & (1 << DOR))
sts |= SD_OVERRUN_ERROR;
@@ -78,7 +78,7 @@ static void set_error(uint8_t sra, SerialDriver *sdp) { if (sra & (1 << FE))
sts |= SD_FRAMING_ERROR;
chSysLockFromIsr();
- sdAddFlagsI(sdp, sts);
+ chIOAddFlagsI(sdp, sts);
chSysUnlockFromIsr();
}
diff --git a/os/hal/platforms/AVR/serial_lld.h b/os/hal/platforms/AVR/serial_lld.h index 15d3352b1..4a2ff843a 100644 --- a/os/hal/platforms/AVR/serial_lld.h +++ b/os/hal/platforms/AVR/serial_lld.h @@ -65,11 +65,6 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
- */
-typedef uint8_t sdflags_t;
-
-/**
* @brief AVR Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
@@ -96,10 +91,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/platforms/LPC11xx/serial_lld.c b/os/hal/platforms/LPC11xx/serial_lld.c index 8c0853315..ecd080eaf 100644 --- a/os/hal/platforms/LPC11xx/serial_lld.c +++ b/os/hal/platforms/LPC11xx/serial_lld.c @@ -100,7 +100,7 @@ static void uart_deinit(LPC_UART_TypeDef *u) { * @param[in] err UART LSR register value
*/
static void set_error(SerialDriver *sdp, IOREG32 err) {
- sdflags_t sts = 0;
+ ioflags_t sts = 0;
if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR;
@@ -111,7 +111,7 @@ static void set_error(SerialDriver *sdp, IOREG32 err) { if (err & LSR_BREAK)
sts |= SD_BREAK_DETECTED;
chSysLockFromIsr();
- sdAddFlagsI(sdp, sts);
+ chIOAddFlagsI(sdp, sts);
chSysUnlockFromIsr();
}
@@ -138,12 +138,12 @@ static void serve_interrupt(SerialDriver *sdp) { case IIR_SRC_RX:
chSysLockFromIsr();
if (chIQIsEmptyI(&sdp->iqueue))
- chEvtBroadcastI(&sdp->ievent);
+ chIOAddFlagsI(sdp, IO_INPUT_AVAILABLE);
chSysUnlockFromIsr();
while (u->LSR & LSR_RBR_FULL) {
chSysLockFromIsr();
if (chIQPutI(&sdp->iqueue, u->RBR) < Q_OK)
- sdAddFlagsI(sdp, SD_OVERRUN_ERROR);
+ chIOAddFlagsI(sdp, SD_OVERRUN_ERROR);
chSysUnlockFromIsr();
}
break;
@@ -159,7 +159,7 @@ static void serve_interrupt(SerialDriver *sdp) { if (b < Q_OK) {
u->IER &= ~IER_THRE;
chSysLockFromIsr();
- chEvtBroadcastI(&sdp->oevent);
+ chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY);
chSysUnlockFromIsr();
break;
}
@@ -185,7 +185,7 @@ static void preload(SerialDriver *sdp) { do {
msg_t b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) {
- chEvtBroadcastI(&sdp->oevent);
+ chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY);
return;
}
u->THR = b;
diff --git a/os/hal/platforms/LPC11xx/serial_lld.h b/os/hal/platforms/LPC11xx/serial_lld.h index 37c2afbb7..a2e8acc4b 100644 --- a/os/hal/platforms/LPC11xx/serial_lld.h +++ b/os/hal/platforms/LPC11xx/serial_lld.h @@ -142,11 +142,6 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
- */
-typedef uint32_t sdflags_t;
-
-/**
* @brief LPC11xx Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
@@ -177,10 +172,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/platforms/LPC13xx/serial_lld.c b/os/hal/platforms/LPC13xx/serial_lld.c index 5dc014d5c..b0f53d97a 100644 --- a/os/hal/platforms/LPC13xx/serial_lld.c +++ b/os/hal/platforms/LPC13xx/serial_lld.c @@ -100,7 +100,7 @@ static void uart_deinit(LPC_UART_TypeDef *u) { * @param[in] err UART LSR register value
*/
static void set_error(SerialDriver *sdp, IOREG32 err) {
- sdflags_t sts = 0;
+ ioflags_t sts = 0;
if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR;
@@ -111,7 +111,7 @@ static void set_error(SerialDriver *sdp, IOREG32 err) { if (err & LSR_BREAK)
sts |= SD_BREAK_DETECTED;
chSysLockFromIsr();
- sdAddFlagsI(sdp, sts);
+ chIOAddFlagsI(sdp, sts);
chSysUnlockFromIsr();
}
@@ -138,12 +138,12 @@ static void serve_interrupt(SerialDriver *sdp) { case IIR_SRC_RX:
chSysLockFromIsr();
if (chIQIsEmptyI(&sdp->iqueue))
- chEvtBroadcastI(&sdp->ievent);
+ chIOAddFlagsI(sdp, IO_INPUT_AVAILABLE);
chSysUnlockFromIsr();
while (u->LSR & LSR_RBR_FULL) {
chSysLockFromIsr();
if (chIQPutI(&sdp->iqueue, u->RBR) < Q_OK)
- sdAddFlagsI(sdp, SD_OVERRUN_ERROR);
+ chIOAddFlagsI(sdp, SD_OVERRUN_ERROR);
chSysUnlockFromIsr();
}
break;
@@ -159,7 +159,7 @@ static void serve_interrupt(SerialDriver *sdp) { if (b < Q_OK) {
u->IER &= ~IER_THRE;
chSysLockFromIsr();
- chEvtBroadcastI(&sdp->oevent);
+ chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY);
chSysUnlockFromIsr();
break;
}
@@ -185,7 +185,7 @@ static void preload(SerialDriver *sdp) { do {
msg_t b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) {
- chEvtBroadcastI(&sdp->oevent);
+ chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY);
return;
}
u->THR = b;
diff --git a/os/hal/platforms/LPC13xx/serial_lld.h b/os/hal/platforms/LPC13xx/serial_lld.h index 7a7f88c54..3636f224a 100644 --- a/os/hal/platforms/LPC13xx/serial_lld.h +++ b/os/hal/platforms/LPC13xx/serial_lld.h @@ -142,11 +142,6 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
- */
-typedef uint32_t sdflags_t;
-
-/**
* @brief LPC13xx Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
@@ -177,10 +172,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/platforms/LPC214x/serial_lld.c b/os/hal/platforms/LPC214x/serial_lld.c index c28cd42c1..cc6280d79 100644 --- a/os/hal/platforms/LPC214x/serial_lld.c +++ b/os/hal/platforms/LPC214x/serial_lld.c @@ -105,7 +105,7 @@ static void uart_deinit(UART *u) { * @param[in] err UART LSR register value
*/
static void set_error(SerialDriver *sdp, IOREG32 err) {
- sdflags_t sts = 0;
+ ioflags_t sts = 0;
if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR;
@@ -116,7 +116,7 @@ static void set_error(SerialDriver *sdp, IOREG32 err) { if (err & LSR_BREAK)
sts |= SD_BREAK_DETECTED;
chSysLockFromIsr();
- sdAddFlagsI(sdp, sts);
+ chIOAddFlagsI(sdp, sts);
chSysUnlockFromIsr();
}
@@ -144,12 +144,12 @@ static void serve_interrupt(SerialDriver *sdp) { case IIR_SRC_RX:
chSysLockFromIsr();
if (chIQIsEmptyI(&sdp->iqueue))
- chEvtBroadcastI(&sdp->ievent);
+ chIOAddFlagsI(sdp, IO_INPUT_AVAILABLE);
chSysUnlockFromIsr();
while (u->UART_LSR & LSR_RBR_FULL) {
chSysLockFromIsr();
if (chIQPutI(&sdp->iqueue, u->UART_RBR) < Q_OK)
- sdAddFlagsI(sdp, SD_OVERRUN_ERROR);
+ chIOAddFlagsI(sdp, SD_OVERRUN_ERROR);
chSysUnlockFromIsr();
}
break;
@@ -165,7 +165,7 @@ static void serve_interrupt(SerialDriver *sdp) { if (b < Q_OK) {
u->UART_IER &= ~IER_THRE;
chSysLockFromIsr();
- chEvtBroadcastI(&sdp->oevent);
+ chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY);
chSysUnlockFromIsr();
break;
}
@@ -191,7 +191,7 @@ static void preload(SerialDriver *sdp) { do {
msg_t b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) {
- chEvtBroadcastI(&sdp->oevent);
+ chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY);
return;
}
u->UART_THR = b;
diff --git a/os/hal/platforms/LPC214x/serial_lld.h b/os/hal/platforms/LPC214x/serial_lld.h index 6398e9483..f14b9524b 100644 --- a/os/hal/platforms/LPC214x/serial_lld.h +++ b/os/hal/platforms/LPC214x/serial_lld.h @@ -131,10 +131,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/platforms/MSP430/serial_lld.c b/os/hal/platforms/MSP430/serial_lld.c index 633107412..c6000d7a8 100644 --- a/os/hal/platforms/MSP430/serial_lld.c +++ b/os/hal/platforms/MSP430/serial_lld.c @@ -61,7 +61,7 @@ static const SerialConfig default_config = { /*===========================================================================*/
static void set_error(SerialDriver *sdp, uint8_t urctl) {
- sdflags_t sts = 0;
+ ioflags_t sts = 0;
if (urctl & OE)
sts |= SD_OVERRUN_ERROR;
@@ -72,7 +72,7 @@ static void set_error(SerialDriver *sdp, uint8_t urctl) { if (urctl & BRK)
sts |= SD_BREAK_DETECTED;
chSysLockFromIsr();
- sdAddFlagsI(sdp, sts);
+ chIOAddFlagsI(sdp, sts);
chSysUnlockFromIsr();
}
diff --git a/os/hal/platforms/MSP430/serial_lld.h b/os/hal/platforms/MSP430/serial_lld.h index 4803ace6e..42788abcf 100644 --- a/os/hal/platforms/MSP430/serial_lld.h +++ b/os/hal/platforms/MSP430/serial_lld.h @@ -65,11 +65,6 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
- */
-typedef uint8_t sdflags_t;
-
-/**
* @brief MSP430 Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
@@ -100,10 +95,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/platforms/SPC56x/serial_lld.c b/os/hal/platforms/SPC56x/serial_lld.c index 8da5e4fcf..afb23086a 100644 --- a/os/hal/platforms/SPC56x/serial_lld.c +++ b/os/hal/platforms/SPC56x/serial_lld.c @@ -116,7 +116,7 @@ static void esci_deinit(volatile struct ESCI_tag *escip) { * @param[in] sr eSCI SR register value
*/
static void set_error(SerialDriver *sdp, uint32_t sr) {
- sdflags_t sts = 0;
+ ioflags_t sts = 0;
if (sr & 0x08000000)
sts |= SD_OVERRUN_ERROR;
@@ -129,7 +129,7 @@ static void set_error(SerialDriver *sdp, uint32_t sr) { /* if (sr & 0x00000000)
sts |= SD_BREAK_DETECTED;*/
chSysLockFromIsr();
- sdAddFlagsI(sdp, sts);
+ chIOAddFlagsI(sdp, sts);
chSysUnlockFromIsr();
}
@@ -155,7 +155,7 @@ static void serve_interrupt(SerialDriver *sdp) { chSysLockFromIsr();
b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) {
- chEvtBroadcastI(&sdp->oevent);
+ chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY);
escip->CR1.B.TIE = 0;
}
else {
diff --git a/os/hal/platforms/SPC56x/serial_lld.h b/os/hal/platforms/SPC56x/serial_lld.h index fdfe37c49..510e3298e 100644 --- a/os/hal/platforms/SPC56x/serial_lld.h +++ b/os/hal/platforms/SPC56x/serial_lld.h @@ -87,11 +87,6 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
- */
-typedef uint8_t sdflags_t;
-
-/**
* @brief Generic Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
@@ -121,10 +116,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/platforms/STM32/serial_lld.c b/os/hal/platforms/STM32/serial_lld.c index f68d54d50..84e42f44d 100644 --- a/os/hal/platforms/STM32/serial_lld.c +++ b/os/hal/platforms/STM32/serial_lld.c @@ -129,7 +129,7 @@ static void usart_deinit(USART_TypeDef *u) { * @param[in] sr USART SR register value
*/
static void set_error(SerialDriver *sdp, uint16_t sr) {
- sdflags_t sts = 0;
+ ioflags_t sts = 0;
if (sr & USART_SR_ORE)
sts |= SD_OVERRUN_ERROR;
@@ -142,7 +142,7 @@ static void set_error(SerialDriver *sdp, uint16_t sr) { if (sr & USART_SR_LBD)
sts |= SD_BREAK_DETECTED;
chSysLockFromIsr();
- sdAddFlagsI(sdp, sts);
+ chIOAddFlagsI(sdp, sts);
chSysUnlockFromIsr();
}
@@ -172,7 +172,7 @@ static void serve_interrupt(SerialDriver *sdp) { chSysLockFromIsr();
b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) {
- chEvtBroadcastI(&sdp->oevent);
+ chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY);
u->CR1 = cr1 & ~USART_CR1_TXEIE;
}
else
diff --git a/os/hal/platforms/STM32/serial_lld.h b/os/hal/platforms/STM32/serial_lld.h index 5d7d80c11..d16e1923d 100644 --- a/os/hal/platforms/STM32/serial_lld.h +++ b/os/hal/platforms/STM32/serial_lld.h @@ -153,11 +153,6 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
- */
-typedef uint32_t sdflags_t;
-
-/**
* @brief STM32 Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
@@ -195,10 +190,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/platforms/STM8L/serial_lld.c b/os/hal/platforms/STM8L/serial_lld.c index d5c102cfe..887dd4967 100644 --- a/os/hal/platforms/STM8L/serial_lld.c +++ b/os/hal/platforms/STM8L/serial_lld.c @@ -114,7 +114,7 @@ static void notify3(GenericQueue *qp) { * @notapi
*/
void sd_lld_set_error(SerialDriver *sdp, uint8_t sr) {
- sdflags_t sts = 0;
+ ioflags_t sts = 0;
if (sr & USART_SR_OR)
sts |= SD_OVERRUN_ERROR;
@@ -125,7 +125,7 @@ void sd_lld_set_error(SerialDriver *sdp, uint8_t sr) { if (sr & USART_SR_PE)
sts |= SD_PARITY_ERROR;
chSysLockFromIsr();
- sdAddFlagsI(sdp, sts);
+ chIOAddFlagsI(sdp, sts);
chSysUnlockFromIsr();
}
diff --git a/os/hal/platforms/STM8L/serial_lld.h b/os/hal/platforms/STM8L/serial_lld.h index d9fd75bf1..c4943433a 100644 --- a/os/hal/platforms/STM8L/serial_lld.h +++ b/os/hal/platforms/STM8L/serial_lld.h @@ -96,11 +96,6 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
- */
-typedef uint8_t sdflags_t;
-
-/**
* @brief Generic Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
@@ -130,10 +125,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/platforms/STM8S/serial_lld.c b/os/hal/platforms/STM8S/serial_lld.c index a152e81d3..d5bdb96f0 100644 --- a/os/hal/platforms/STM8S/serial_lld.c +++ b/os/hal/platforms/STM8S/serial_lld.c @@ -72,7 +72,7 @@ static ROMCONST SerialConfig default_config = { /*===========================================================================*/
static void set_error(SerialDriver *sdp, uint8_t sr) {
- sdflags_t sts = 0;
+ ioflags_t sts = 0;
/* Note, SR register bit definitions are equal for all UARTs so using
the UART1 definitions is fine.*/
@@ -85,7 +85,7 @@ static void set_error(SerialDriver *sdp, uint8_t sr) { if (sr & UART1_SR_PE)
sts |= SD_PARITY_ERROR;
chSysLockFromIsr();
- sdAddFlagsI(sdp, sts);
+ chIOAddFlagsI(sdp, sts);
chSysUnlockFromIsr();
}
diff --git a/os/hal/platforms/STM8S/serial_lld.h b/os/hal/platforms/STM8S/serial_lld.h index 29b44bfbc..96ac08896 100644 --- a/os/hal/platforms/STM8S/serial_lld.h +++ b/os/hal/platforms/STM8S/serial_lld.h @@ -88,11 +88,6 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
- */
-typedef uint8_t sdflags_t;
-
-/**
* @brief Generic Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
@@ -122,10 +117,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/platforms/Win32/serial_lld.c b/os/hal/platforms/Win32/serial_lld.c index 30e479055..bbfae160f 100644 --- a/os/hal/platforms/Win32/serial_lld.c +++ b/os/hal/platforms/Win32/serial_lld.c @@ -112,7 +112,7 @@ static bool_t connint(SerialDriver *sdp) { printf("%s: Unable to setup non blocking mode on data socket\n", sdp->com_name);
goto abort;
}
- sdAddFlagsI(sdp, SD_CONNECTED);
+ chIOAddFlagsI(sdp, IO_CONNECTED);
return TRUE;
}
return FALSE;
@@ -139,7 +139,7 @@ static bool_t inint(SerialDriver *sdp) { case 0:
closesocket(sdp->com_data);
sdp->com_data = INVALID_SOCKET;
- sdAddFlagsI(sdp, SD_DISCONNECTED);
+ chIOAddFlagsI(sdp, IO_DISCONNECTED);
return FALSE;
case SOCKET_ERROR:
if (WSAGetLastError() == WSAEWOULDBLOCK)
@@ -173,7 +173,7 @@ static bool_t outint(SerialDriver *sdp) { case 0:
closesocket(sdp->com_data);
sdp->com_data = INVALID_SOCKET;
- sdAddFlagsI(sdp, SD_DISCONNECTED);
+ chIOAddFlagsI(sdp, IO_DISCONNECTED);
return FALSE;
case SOCKET_ERROR:
if (WSAGetLastError() == WSAEWOULDBLOCK)
diff --git a/os/hal/platforms/Win32/serial_lld.h b/os/hal/platforms/Win32/serial_lld.h index 79a5994f2..5adf63998 100644 --- a/os/hal/platforms/Win32/serial_lld.h +++ b/os/hal/platforms/Win32/serial_lld.h @@ -110,10 +110,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/src/serial.c b/os/hal/src/serial.c index c769061bb..aafedcc6b 100644 --- a/os/hal/src/serial.c +++ b/os/hal/src/serial.c @@ -89,8 +89,14 @@ static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) { return chIQReadTimeout(&((SerialDriver *)ip)->iqueue, bp, n, time);
}
+static ioflags_t getflags(void *ip) {
+ _ch_get_and_clear_flags_impl(ip);
+}
+
static const struct SerialDriverVMT vmt = {
- writes, reads, putwouldblock, getwouldblock, putt, gett, writet, readt
+ writes, reads, putwouldblock, getwouldblock,
+ putt, gett, writet, readt,
+ getflags
};
/*===========================================================================*/
@@ -127,11 +133,9 @@ void sdInit(void) { void sdObjectInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify) {
sdp->vmt = &vmt;
- chEvtInit(&sdp->ievent);
- chEvtInit(&sdp->oevent);
- chEvtInit(&sdp->sevent);
+ chEvtInit(&sdp->event);
+ sdp->flags = IO_NO_ERROR;
sdp->state = SD_STOP;
- sdp->flags = SD_NO_ERROR;
chIQInit(&sdp->iqueue, sdp->ib, SERIAL_BUFFERS_SIZE, inotify);
chOQInit(&sdp->oqueue, sdp->ob, SERIAL_BUFFERS_SIZE, onotify);
}
@@ -205,9 +209,9 @@ void sdIncomingDataI(SerialDriver *sdp, uint8_t b) { chDbgCheck(sdp != NULL, "sdIncomingDataI");
if (chIQIsEmptyI(&sdp->iqueue))
- chEvtBroadcastI(&sdp->ievent);
+ chIOAddFlagsI(sdp, IO_INPUT_AVAILABLE);
if (chIQPutI(&sdp->iqueue, b) < Q_OK)
- sdAddFlagsI(sdp, SD_OVERRUN_ERROR);
+ chIOAddFlagsI(sdp, SD_OVERRUN_ERROR);
}
/**
@@ -232,49 +236,10 @@ msg_t sdRequestDataI(SerialDriver *sdp) { b = chOQGetI(&sdp->oqueue);
if (b < Q_OK)
- chEvtBroadcastI(&sdp->oevent);
+ chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY);
return b;
}
-/**
- * @brief Handles communication events/errors.
- * @details Must be called from the I/O interrupt service routine in order to
- * notify I/O conditions as errors, signals change etc.
- *
- * @param[in] sdp pointer to a @p SerialDriver structure
- * @param[in] mask condition flags to be added to the mask
- *
- * @iclass
- */
-void sdAddFlagsI(SerialDriver *sdp, sdflags_t mask) {
-
- chDbgCheck(sdp != NULL, "sdAddFlagsI");
-
- sdp->flags |= mask;
- chEvtBroadcastI(&sdp->sevent);
-}
-
-/**
- * @brief Returns and clears the errors mask associated to the driver.
- *
- * @param[in] sdp pointer to a @p SerialDriver structure
- * @return The condition flags modified since last time this
- * function was invoked.
- *
- * @api
- */
-sdflags_t sdGetAndClearFlags(SerialDriver *sdp) {
- sdflags_t mask;
-
- chDbgCheck(sdp != NULL, "sdGetAndClearFlags");
-
- chSysLock();
- mask = sdp->flags;
- sdp->flags = SD_NO_ERROR;
- chSysUnlock();
- return mask;
-}
-
#endif /* HAL_USE_SERIAL */
/** @} */
diff --git a/os/hal/templates/serial_lld.h b/os/hal/templates/serial_lld.h index f33c2062b..252f15fe5 100644 --- a/os/hal/templates/serial_lld.h +++ b/os/hal/templates/serial_lld.h @@ -73,10 +73,6 @@ typedef struct { InputQueue iqueue; \
/* Output queue.*/ \
OutputQueue oqueue; \
- /* Status Change @p EventSource.*/ \
- EventSource sevent; \
- /* I/O driver status flags.*/ \
- sdflags_t flags; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/kernel/include/chioch.h b/os/kernel/include/chioch.h index 3fff4b626..05a185a4d 100644 --- a/os/kernel/include/chioch.h +++ b/os/kernel/include/chioch.h @@ -228,21 +228,40 @@ typedef struct { ((ip)->vmt->readt(ip, bp, n, time))
#if CH_USE_EVENTS
+
+/** @brief No pending conditions.*/
+#define IO_NO_ERROR 0
+/** @brief Connection happened.*/
+#define IO_CONNECTED 1
+/** @brief Disconnection happened.*/
+#define IO_DISCONNECTED 2
+/** @brief Data available in the input queue.*/
+#define IO_INPUT_AVAILABLE 4
+/** @brief Output queue empty.*/
+#define IO_OUTPUT_EMPTY 8
+
+/**
+ * @brief Type of an I/O condition flags mask.
+ */
+typedef uint_fast16_t ioflags_t;
+
/**
* @brief @p BaseAsynchronousChannel specific methods.
*/
#define _base_asynchronous_channel_methods \
- _base_channel_methods
+ _base_channel_methods \
+ /* Channel read method with timeout specification.*/ \
+ ioflags_t (*getflags)(void *instance);
/**
* @brief @p BaseAsynchronousChannel specific data.
*/
#define _base_asynchronous_channel_data \
_base_channel_data \
- /* Data Available EventSource.*/ \
- EventSource ievent; \
- /* Data Transmitted EventSource.*/ \
- EventSource oevent;
+ /* I/O condition event source.*/ \
+ EventSource event; \
+ /* I/O condition flags.*/ \
+ ioflags_t flags;
/**
* @brief @p BaseAsynchronousChannel virtual methods table.
@@ -265,10 +284,8 @@ typedef struct { } BaseAsynchronousChannel;
/**
- * @brief Returns the write event source.
- * @details The write event source is broadcasted when the channel is ready
- * for write operations. This usually happens when the internal
- * output queue becomes empty.
+ * @brief Returns the I/O condition event source.
+ * @details The event source is broadcasted when an I/O condition happens.
*
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
* class
@@ -276,21 +293,54 @@ typedef struct { *
* @api
*/
-#define chIOGetWriteEventSource(ip) (&((ip)->vmt->oevent))
+#define chIOGetEventSource(ip) (&((ip)->event))
/**
- * @brief Returns the read event source.
- * @details The read event source is broadcasted when the channel is ready
- * for read operations. This usually happens when the internal
- * input queue becomes non-empty.
+ * @brief Adds condition flags to the channel's mask.
+ * @details This function is usually called from the I/O ISTs in order to
+ * notify I/O conditions such as data events, errors, signalů
+ * changes etc.
*
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
* class
- * @return A pointer to an @p EventSource object.
+ * @param[in] mask condition flags to be added to the mask
+ *
+ * @iclass
+ */
+#define chIOAddFlagsI(ip, mask) { \
+ (ip)->flags |= (mask); \
+ chEvtBroadcastI(&(ip)->event); \
+}
+
+/**
+ * @brief Returns and clears the errors mask associated to the channel.
+ *
+ * @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
+ * class
+ * @return The condition flags modified since last time this
+ * function was invoked.
*
* @api
*/
-#define chIOGetReadEventSource(ip) (&((ip)->vmt->ievent))
+#define chIOGetAndClearFlags(ip) ((ip)->vmt->getflags(ip))
+
+/**
+ * @brief Default implementation of the @p getflags virtual method.
+ *
+ * @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
+ * class
+ * @return The condition flags modified since last time this
+ * function was invoked.
+ *
+ * @notapi
+ */
+#define _ch_get_and_clear_flags_impl(ip) \
+ ioflags_t mask; \
+ chSysLock(); \
+ mask = ((BaseAsynchronousChannel *)(ip))->flags; \
+ ((BaseAsynchronousChannel *)(ip))->flags = IO_NO_ERROR; \
+ chSysUnlock(); \
+ return mask
#endif /* CH_USE_EVENTS */
diff --git a/readme.txt b/readme.txt index ae61387dc..f5e7fa2de 100644 --- a/readme.txt +++ b/readme.txt @@ -65,6 +65,8 @@ *****************************************************************************
*** 2.1.7 ***
+- FIX: Fixed error in chIOGetxxxxxEventSource() macros (bug 3153550)
+ (backported to 2.0.10)
- FIX: Fixed error in STM32 unbuffered UART driver (bug 3153437).
- FIX: Fixed wrong macro check in LPC214x driver (bug 3152510).
- FIX: Fixed switch condition error in STM32 PWM driver (bug 3152482)
@@ -81,6 +83,10 @@ - NEW: Added an USB clock configuration in the STM32 HAL driver (LD, MD, HD).
- NEW: New semaphore API chSemSetCounterI().
- NEW: New queue APIs chIQGetFullI() and chOQGetFullI().
+- CHANGE: Serial drivers now have a single event source instead of three,
+ the event source is located in the superclass, this allows to create
+ alternative implementations of the serial driver while keeping compatibility,
+ the change also allowed to save 8/4 RAM bytes per serial driver.
- CHANGE: Modified the ADC and CAN drivers to allow a NULL pointer for
the configuration structure if it is not required by the implementation.
- CHANGE: Modified the MMC_SPI driver to *require* a NULL as pointer to
@@ -57,16 +57,16 @@ N Evaluate if to add a synchronous API to the UART driver, eventually do so. them into board.c files, this will remove an ugly dependency.
* Realign the STM8 port to the new STM8L one as options, naming conventions
and general solutions.
-X Support for more compilers (IAR, Keil, ARMCMx only initially).
+* Support for more compilers (IAR, Keil, ARMCMx only initially).
X Support for not just Makefiles (Ride7, Crossworks etc).
+* IAR port for Cortex-Mx, add demos for all the supported families.
+* Keil port for Cortex-Mx, add demos for all the supported families.
+* Change the serial drivers to have a single event source instead of three.
+ Add Rx and Tx to the existing flags mechanism. Move up the flags handling in
+ the superclass.
? Make thread functions return void.
- Introduce a "THREAD" function prefix in order to hide compiler-specific
optimizations for thread functions.
-X IAR port for Cortex-Mx, add demos for all the supported families.
-X Keil port for Cortex-Mx, add demos for all the supported families.
-- Change the serial drivers to have a single event source instead of three.
- Add Rx and Tx to the existing flags mechanism. Move up the flags handling in
- the superclass.
X Except for the above, bug fixing only until the 2.2.0 release.
Within 2.3.x (hopefully)
|