diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-05-02 20:03:30 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-05-02 20:03:30 +0000 |
commit | 83cafc020df7f7a3b857a23aff93849eac694ea2 (patch) | |
tree | 9925b1007897dd29225fe2868cbd9eeecb4c1ec4 | |
parent | ae4f143cf638046e3e17c20b69a8551e3ce96de4 (diff) | |
download | ChibiOS-83cafc020df7f7a3b857a23aff93849eac694ea2.tar.gz ChibiOS-83cafc020df7f7a3b857a23aff93849eac694ea2.tar.bz2 ChibiOS-83cafc020df7f7a3b857a23aff93849eac694ea2.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@938 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | src/chserial.c | 17 | ||||
-rw-r--r-- | src/include/serial.h | 153 |
2 files changed, 70 insertions, 100 deletions
diff --git a/src/chserial.c b/src/chserial.c index 49046ee0a..4dac892f8 100644 --- a/src/chserial.c +++ b/src/chserial.c @@ -30,28 +30,27 @@ static msg_t put(void *instance, uint8_t b, systime_t timeout) {
- return chOQPutTimeout(&((FullDuplexDriver *)instance)->d3.oqueue, b, timeout);
+ return chOQPutTimeout(&((FullDuplexDriver *)instance)->d2.oqueue, b, timeout);
}
static msg_t get(void *instance, systime_t timeout) {
- return chIQGetTimeout(&((FullDuplexDriver *)instance)->d3.iqueue, timeout);
+ return chIQGetTimeout(&((FullDuplexDriver *)instance)->d2.iqueue, timeout);
}
static size_t write(void *instance, uint8_t *buffer, size_t n) {
- return chOQWrite(&((FullDuplexDriver *)instance)->d3.oqueue, buffer, n);
+ return chOQWrite(&((FullDuplexDriver *)instance)->d2.oqueue, buffer, n);
}
static size_t read(void *instance, uint8_t *buffer, size_t n) {
- return chIQRead(&((FullDuplexDriver *)instance)->d3.iqueue, buffer, n);
+ return chIQRead(&((FullDuplexDriver *)instance)->d2.iqueue, buffer, n);
}
static const struct FullDuplexDriverVMT vmt = {
{put, get},
{write, read},
- {},
{}
};
@@ -84,8 +83,8 @@ void chFDDInit(FullDuplexDriver *sd, chEvtInit(&sd->d1.oevent);
chEvtInit(&sd->d2.sevent);
sd->d2.flags = SD_NO_ERROR;
- chIQInit(&sd->d3.iqueue, ib, isize, inotify);
- chOQInit(&sd->d3.oqueue, ob, osize, onotify);
+ chIQInit(&sd->d2.iqueue, ib, isize, inotify);
+ chOQInit(&sd->d2.oqueue, ob, osize, onotify);
}
/**
@@ -98,7 +97,7 @@ void chFDDInit(FullDuplexDriver *sd, */
void chFDDIncomingDataI(FullDuplexDriver *sd, uint8_t b) {
- if (chIQPutI(&sd->d3.iqueue, b) < Q_OK)
+ if (chIQPutI(&sd->d2.iqueue, b) < Q_OK)
chFDDAddFlagsI(sd, SD_OVERRUN_ERROR);
else
chEvtBroadcastI(&sd->d1.ievent);
@@ -116,7 +115,7 @@ void chFDDIncomingDataI(FullDuplexDriver *sd, uint8_t b) { */
msg_t chFDDRequestDataI(FullDuplexDriver *sd) {
- msg_t b = chOQGetI(&sd->d3.oqueue);
+ msg_t b = chOQGetI(&sd->d2.oqueue);
if (b < Q_OK)
chEvtBroadcastI(&sd->d1.oevent);
return b;
diff --git a/src/include/serial.h b/src/include/serial.h index 6d91d0f15..9bb6c4f92 100644 --- a/src/include/serial.h +++ b/src/include/serial.h @@ -48,72 +48,6 @@ typedef uint8_t dflags_t;
/**
- * @brief @p GenericSerialDriver specific methods.
- */
-struct _generic_serial_driver_methods {
-};
-
-/**
- * @brief @p GenericSerialDriver specific data.
- */
-struct _generic_serial_driver_data {
- /**
- * Status Change @p EventSource. This event is generated when one or more
- * condition flags change.
- */
- EventSource sevent;
- /**
- * I/O driver status flags.
- */
- dflags_t flags;
-};
-
-/**
- * @brief @p GenericSerialDriver virtual methods table.
- */
-struct GenericSerialDriverVMT {
- /**
- * @p BaseChannel class inherited methods.
- */
- struct _base_channel_methods m0;
- /**
- * @p BaseAsynchronousChannel class inherited methods.
- */
- struct _base_asynchronous_channel_methods m1;
- /**
- * @p GenericSerialDriver specific methods.
- */
- struct _generic_serial_driver_methods m2;
-};
-
-/**
- * @extends BaseAsynchronousChannel
- *
- * @brief Generic serial driver class.
- * @details This class extends @p BaseAsynchronousChannel by adding handling for
- * serial error events.
- */
-typedef struct {
- /**
- * Virtual Methods Table.
- */
- const struct GenericSerialDriverVMT *vmt;
- /**
- * @p BaseChannel class inherited data.
- */
- struct _base_channel_data d0;
- /**
- * @p BaseAsynchronousChannel class inherited data.
- */
- struct _base_asynchronous_channel_data d1;
- /**
- * @p GenericSerialDriver specific data. - */
- struct _generic_serial_driver_data d2;
-} GenericSerialDriver;
-
-
-/**
* @brief @p FullDuplexDriver specific methods.
*/
struct _full_duplex_driver_methods {
@@ -133,6 +67,15 @@ struct _full_duplex_driver_data { * using the queues APIs.
*/
OutputQueue oqueue;
+ /**
+ * Status Change @p EventSource. This event is generated when one or more
+ * condition flags change.
+ */
+ EventSource sevent;
+ /**
+ * I/O driver status flags.
+ */
+ dflags_t flags;
};
/**
@@ -148,13 +91,9 @@ struct FullDuplexDriverVMT { */
struct _base_asynchronous_channel_methods m1;
/**
- * @p GenericSerialDriver specific methods.
- */
- struct _generic_serial_driver_methods m2;
- /**
* @p FullDuplexDriver specific methods.
*/
- struct _full_duplex_driver_methods m3;
+ struct _full_duplex_driver_methods m2;
};
/**
@@ -178,13 +117,9 @@ typedef struct { */
struct _base_asynchronous_channel_data d1;
/**
- * @p GenericSerialDriver inherited data.
- */
- struct _generic_serial_driver_data d2;
- /**
* @p FullDuplexDriver specific data.
*/
- struct _full_duplex_driver_data d3;
+ struct _full_duplex_driver_data d2;
} FullDuplexDriver;
#ifdef __cplusplus
@@ -201,25 +136,61 @@ extern "C" { }
#endif
-/** @see chIQRead()*/
-#define chFDDRead(sd, b, n) \
- chIQRead(&(sd)->sd_iqueue, b, n)
+/**
+ * @brief Direct blocking write to a @p FullDuplexDriver.
+ * @details This function bypasses the indirect access to the channel and
+ * writes directly on the output queue. This is faster but cannot
+ * be used to write to different channels implementations.
+ * @see chIOPut()
+ */
+#define chFDDPut(sd, b) chOQPut(&(sd)->d2.oqueue, b)
-/** @see chOQWrite()*/
-#define chFDDWrite(sd, b, n) \
- chOQWrite(&(sd)->sd_oqueue, b, n)
+/**
+ * @brief Direct blocking write on a @p FullDuplexDriver with timeout
+ * specification.
+ * @details This function bypasses the indirect access to the channel and
+ * writes directly on the output queue. This is faster but cannot
+ * be used to write to different channels implementations.
+ * @see chIOPutTimeout()
+ */
+#define chFDDPutTimeout(sd, b, t) chOQPutTimeout(&(sd)->d2.iqueue, b, t)
-/** @see chIQGet()*/
-#define chFDDGet(sd) \
- chIQGet(&(sd)->sd_iqueue)
+/**
+ * @brief Direct blocking read from a @p FullDuplexDriver.
+ * @details This function bypasses the indirect access to the channel and
+ * reads directly from the input queue. This is faster but cannot
+ * be used to read from different channels implementations.
+ * @see chIOGet()
+ */
+#define chFDDGet(sd) chIQGet(&(sd)->d2.iqueue)
-/** @see chIQGetTimeout()*/
-#define chFDDGetTimeout(sd, t) \
- chIQGetTimeout(&(sd)->sd_iqueue, t)
+/**
+ * @brief Direct blocking read from a @p FullDuplexDriver with timeout
+ * specification.
+ * @details This function bypasses the indirect access to the channel and
+ * reads directly from the input queue. This is faster but cannot
+ * be used to read from different channels implementations.
+ * @see chIOGetTimeout()
+ */
+#define chFDDGetTimeout(sd, t) chIQGetTimeout(&(sd)->d2.iqueue, t)
-/** @see chOQPut()*/
-#define chFDDPut(sd, b) \
- chOQPut(&(sd)->sd_oqueue, b)
+/**
+ * @brief Direct non-blocking write to a @p FullDuplexDriver.
+ * @details This function bypasses the indirect access to the channel and
+ * writes directly to the output queue. This is faster but cannot
+ * be used to write from different channels implementations.
+ * @see chIOWrite()
+ */
+#define chFDDWrite(sd, b, n) chOQWrite(&(sd)->d2.oqueue, b, n)
+
+/**
+ * @brief Direct non-blocking read on a @p FullDuplexDriver.
+ * @details This function bypasses the indirect access to the channel and
+ * reads directly from the input queue. This is faster but cannot
+ * be used to read from different channels implementations.
+ * @see chIORead()
+ */
+#define chFDDRead(sd, b, n) chIQRead(&(sd)->d2.iqueue, b, n)
#endif /* CH_USE_SERIAL_FULLDUPLEX */
|