aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-09-16 09:08:43 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-09-16 09:08:43 +0000
commitf90a0f37906a9363a6e702d8ac1c4c8257370efa (patch)
treedf0521c93a97691638a0227a17c64ddfc59d1080 /os/hal
parentdfb876b3a1263c627465dfc6e3b76d5bab6c052e (diff)
downloadChibiOS-f90a0f37906a9363a6e702d8ac1c4c8257370efa.tar.gz
ChibiOS-f90a0f37906a9363a6e702d8ac1c4c8257370efa.tar.bz2
ChibiOS-f90a0f37906a9363a6e702d8ac1c4c8257370efa.zip
Removed flags handling in BaseAsynchronousChannel. Modified serial drivers to use the new event flags.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4671 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/include/io_channel.h52
-rw-r--r--os/hal/platforms/AT91SAM7/serial_lld.c2
-rw-r--r--os/hal/platforms/AVR/serial_lld.c2
-rw-r--r--os/hal/platforms/LPC11Uxx/serial_lld.c2
-rw-r--r--os/hal/platforms/LPC11xx/serial_lld.c2
-rw-r--r--os/hal/platforms/LPC13xx/serial_lld.c2
-rw-r--r--os/hal/platforms/LPC214x/serial_lld.c2
-rw-r--r--os/hal/platforms/MSP430/serial_lld.c2
-rw-r--r--os/hal/platforms/SPC56x/serial_lld.c2
-rw-r--r--os/hal/platforms/STM32/serial_lld.c4
-rw-r--r--os/hal/platforms/STM8L/serial_lld.c2
-rw-r--r--os/hal/platforms/STM8S/serial_lld.c2
-rw-r--r--os/hal/src/serial.c8
-rw-r--r--os/hal/src/serial_usb.c9
14 files changed, 20 insertions, 73 deletions
diff --git a/os/hal/include/io_channel.h b/os/hal/include/io_channel.h
index 726a2040a..02e3fb2be 100644
--- a/os/hal/include/io_channel.h
+++ b/os/hal/include/io_channel.h
@@ -200,7 +200,7 @@ typedef struct {
#if CH_USE_EVENTS || defined(__DOXYGEN__)
/**
- * @name I/O status flags
+ * @name I/O status flags added to the event listener
* @{
*/
/** @brief No pending conditions.*/
@@ -218,17 +218,10 @@ typedef struct {
/** @} */
/**
- * @brief Type of an I/O condition flags mask.
- */
-typedef uint_fast16_t chnflags_t;
-
-/**
* @brief @p BaseAsynchronousChannel specific methods.
*/
#define _base_asynchronous_channel_methods \
_base_channel_methods \
- /* Channel read method with timeout specification.*/ \
- chnflags_t (*getflags)(void *instance);
/**
* @brief @p BaseAsynchronousChannel specific data.
@@ -236,9 +229,7 @@ typedef uint_fast16_t chnflags_t;
#define _base_asynchronous_channel_data \
_base_channel_data \
/* I/O condition event source.*/ \
- EventSource event; \
- /* I/O condition flags.*/ \
- chnflags_t flags;
+ EventSource event;
/**
* @extends BaseChannelVMT
@@ -279,53 +270,22 @@ typedef struct {
#define chnGetEventSource(ip) (&((ip)->event))
/**
- * @brief Adds status flags to the channel's mask.
+ * @brief Adds status flags to the listeners's flags mask.
* @details This function is usually called from the I/O ISRs 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
- * @param[in] mask condition flags to be added to the mask
+ * @param[in] flags condition flags to be added to the listener flags mask
*
* @iclass
*/
-#define chnAddFlagsI(ip, mask) { \
- (ip)->flags |= (mask); \
- chEvtBroadcastI(&(ip)->event); \
+#define chnAddFlagsI(ip, flags) { \
+ chEvtBroadcastFlagsI(&(ip)->event, flags); \
}
-
-/**
- * @brief Returns and clears the status flags 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 chnGetAndClearFlags(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 _chn_get_and_clear_flags_impl(ip) \
- chnflags_t mask; \
- chSysLock(); \
- mask = ((BaseAsynchronousChannel *)(ip))->flags; \
- ((BaseAsynchronousChannel *)(ip))->flags = CHN_NO_ERROR; \
- chSysUnlock(); \
- return mask
-
#endif /* CH_USE_EVENTS */
#endif /* _IO_CHANNEL_H_ */
diff --git a/os/hal/platforms/AT91SAM7/serial_lld.c b/os/hal/platforms/AT91SAM7/serial_lld.c
index 0e6aa1178..33917b38f 100644
--- a/os/hal/platforms/AT91SAM7/serial_lld.c
+++ b/os/hal/platforms/AT91SAM7/serial_lld.c
@@ -139,7 +139,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) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
if (csr & AT91C_US_OVRE)
sts |= SD_OVERRUN_ERROR;
diff --git a/os/hal/platforms/AVR/serial_lld.c b/os/hal/platforms/AVR/serial_lld.c
index c35cdca4b..ce7a928f0 100644
--- a/os/hal/platforms/AVR/serial_lld.c
+++ b/os/hal/platforms/AVR/serial_lld.c
@@ -70,7 +70,7 @@ static const SerialConfig default_config = {
/*===========================================================================*/
static void set_error(uint8_t sra, SerialDriver *sdp) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
uint8_t dor = 0;
uint8_t upe = 0;
uint8_t fe = 0;
diff --git a/os/hal/platforms/LPC11Uxx/serial_lld.c b/os/hal/platforms/LPC11Uxx/serial_lld.c
index 03bc9bbf9..d3faa7572 100644
--- a/os/hal/platforms/LPC11Uxx/serial_lld.c
+++ b/os/hal/platforms/LPC11Uxx/serial_lld.c
@@ -101,7 +101,7 @@ static void uart_deinit(LPC_USART_Type *u) {
* @param[in] err UART LSR register value
*/
static void set_error(SerialDriver *sdp, IOREG32 err) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR;
diff --git a/os/hal/platforms/LPC11xx/serial_lld.c b/os/hal/platforms/LPC11xx/serial_lld.c
index 10f7817b7..f0c5a9c1a 100644
--- a/os/hal/platforms/LPC11xx/serial_lld.c
+++ b/os/hal/platforms/LPC11xx/serial_lld.c
@@ -101,7 +101,7 @@ static void uart_deinit(LPC_UART_TypeDef *u) {
* @param[in] err UART LSR register value
*/
static void set_error(SerialDriver *sdp, IOREG32 err) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR;
diff --git a/os/hal/platforms/LPC13xx/serial_lld.c b/os/hal/platforms/LPC13xx/serial_lld.c
index f0c75d247..d5849cfd2 100644
--- a/os/hal/platforms/LPC13xx/serial_lld.c
+++ b/os/hal/platforms/LPC13xx/serial_lld.c
@@ -101,7 +101,7 @@ static void uart_deinit(LPC_UART_TypeDef *u) {
* @param[in] err UART LSR register value
*/
static void set_error(SerialDriver *sdp, IOREG32 err) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR;
diff --git a/os/hal/platforms/LPC214x/serial_lld.c b/os/hal/platforms/LPC214x/serial_lld.c
index ce207ff61..a25c9ebcc 100644
--- a/os/hal/platforms/LPC214x/serial_lld.c
+++ b/os/hal/platforms/LPC214x/serial_lld.c
@@ -106,7 +106,7 @@ static void uart_deinit(UART *u) {
* @param[in] err UART LSR register value
*/
static void set_error(SerialDriver *sdp, IOREG32 err) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR;
diff --git a/os/hal/platforms/MSP430/serial_lld.c b/os/hal/platforms/MSP430/serial_lld.c
index bdc3c580d..800243421 100644
--- a/os/hal/platforms/MSP430/serial_lld.c
+++ b/os/hal/platforms/MSP430/serial_lld.c
@@ -60,7 +60,7 @@ static const SerialConfig default_config = {
/*===========================================================================*/
static void set_error(SerialDriver *sdp, uint8_t urctl) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
if (urctl & OE)
sts |= SD_OVERRUN_ERROR;
diff --git a/os/hal/platforms/SPC56x/serial_lld.c b/os/hal/platforms/SPC56x/serial_lld.c
index 7effeeb60..e562b6c2d 100644
--- a/os/hal/platforms/SPC56x/serial_lld.c
+++ b/os/hal/platforms/SPC56x/serial_lld.c
@@ -117,7 +117,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) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
if (sr & 0x08000000)
sts |= SD_OVERRUN_ERROR;
diff --git a/os/hal/platforms/STM32/serial_lld.c b/os/hal/platforms/STM32/serial_lld.c
index eeabcae15..841b9b386 100644
--- a/os/hal/platforms/STM32/serial_lld.c
+++ b/os/hal/platforms/STM32/serial_lld.c
@@ -133,7 +133,7 @@ static void usart_deinit(USART_TypeDef *u) {
* @param[in] isr USART ISR register value
*/
static void set_error(SerialDriver *sdp, uint16_t isr) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
if (isr & USART_ISR_ORE)
sts |= SD_OVERRUN_ERROR;
@@ -252,7 +252,7 @@ static void usart_deinit(USART_TypeDef *u) {
* @param[in] sr USART SR register value
*/
static void set_error(SerialDriver *sdp, uint16_t sr) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
if (sr & USART_SR_ORE)
sts |= SD_OVERRUN_ERROR;
diff --git a/os/hal/platforms/STM8L/serial_lld.c b/os/hal/platforms/STM8L/serial_lld.c
index b91f44a21..4392ee94c 100644
--- a/os/hal/platforms/STM8L/serial_lld.c
+++ b/os/hal/platforms/STM8L/serial_lld.c
@@ -115,7 +115,7 @@ static void notify3(GenericQueue *qp) {
* @notapi
*/
void sd_lld_set_error(SerialDriver *sdp, uint8_t sr) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
if (sr & USART_SR_OR)
sts |= SD_OVERRUN_ERROR;
diff --git a/os/hal/platforms/STM8S/serial_lld.c b/os/hal/platforms/STM8S/serial_lld.c
index 610591cdf..6904ac6ab 100644
--- a/os/hal/platforms/STM8S/serial_lld.c
+++ b/os/hal/platforms/STM8S/serial_lld.c
@@ -73,7 +73,7 @@ static ROMCONST SerialConfig default_config = {
/*===========================================================================*/
static void set_error(SerialDriver *sdp, uint8_t sr) {
- chnflags_t sts = 0;
+ flagsmask_t sts = 0;
/* Note, SR register bit definitions are equal for all UARTs so using
the UART1 definitions is fine.*/
diff --git a/os/hal/src/serial.c b/os/hal/src/serial.c
index 2bf7f396b..999f4d6f9 100644
--- a/os/hal/src/serial.c
+++ b/os/hal/src/serial.c
@@ -94,14 +94,9 @@ static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
return chIQReadTimeout(&((SerialDriver *)ip)->iqueue, bp, n, time);
}
-static chnflags_t getflags(void *ip) {
- _chn_get_and_clear_flags_impl(ip);
-}
-
static const struct SerialDriverVMT vmt = {
write, read, put, get,
- putt, gett, writet, readt,
- getflags
+ putt, gett, writet, readt
};
/*===========================================================================*/
@@ -139,7 +134,6 @@ void sdObjectInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify) {
sdp->vmt = &vmt;
chEvtInit(&sdp->event);
- sdp->flags = CHN_NO_ERROR;
sdp->state = SD_STOP;
chIQInit(&sdp->iqueue, sdp->ib, SERIAL_BUFFERS_SIZE, inotify, sdp);
chOQInit(&sdp->oqueue, sdp->ob, SERIAL_BUFFERS_SIZE, onotify, sdp);
diff --git a/os/hal/src/serial_usb.c b/os/hal/src/serial_usb.c
index 9cef45524..05cb60c3f 100644
--- a/os/hal/src/serial_usb.c
+++ b/os/hal/src/serial_usb.c
@@ -103,14 +103,9 @@ static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
return chIQReadTimeout(&((SerialUSBDriver *)ip)->iqueue, bp, n, time);
}
-static chnflags_t getflags(void *ip) {
- _chn_get_and_clear_flags_impl(ip);
-}
-
static const struct SerialUSBDriverVMT vmt = {
write, read, put, get,
- putt, gett, writet, readt,
- getflags
+ putt, gett, writet, readt
};
/**
@@ -197,7 +192,6 @@ void sduObjectInit(SerialUSBDriver *sdup) {
sdup->vmt = &vmt;
chEvtInit(&sdup->event);
- sdup->flags = CHN_NO_ERROR;
sdup->state = SDU_STOP;
chIQInit(&sdup->iqueue, sdup->ib, SERIAL_USB_BUFFERS_SIZE, inotify, sdup);
chOQInit(&sdup->oqueue, sdup->ob, SERIAL_USB_BUFFERS_SIZE, onotify, sdup);
@@ -256,7 +250,6 @@ void sduStop(SerialUSBDriver *sdup) {
void sduConfigureHookI(USBDriver *usbp) {
SerialUSBDriver *sdup = usbp->param;
- sdup->flags = CHN_NO_ERROR;
chIQResetI(&sdup->iqueue);
chOQResetI(&sdup->oqueue);
chnAddFlagsI(sdup, CHN_CONNECTED);