aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-05-02 17:18:56 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-05-02 17:18:56 +0000
commitae4f143cf638046e3e17c20b69a8551e3ce96de4 (patch)
treea057d3296cc6e9e7202b433b91a5537821bf223c /src
parent81507dcbe7336d523b42afeeb422bd9c983dbf6f (diff)
downloadChibiOS-ae4f143cf638046e3e17c20b69a8551e3ce96de4.tar.gz
ChibiOS-ae4f143cf638046e3e17c20b69a8551e3ce96de4.tar.bz2
ChibiOS-ae4f143cf638046e3e17c20b69a8551e3ce96de4.zip
More madness.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@937 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src')
-rw-r--r--src/chserial.c29
-rw-r--r--src/include/channels.h56
-rw-r--r--src/include/serial.h13
3 files changed, 75 insertions, 23 deletions
diff --git a/src/chserial.c b/src/chserial.c
index b93a9973a..49046ee0a 100644
--- a/src/chserial.c
+++ b/src/chserial.c
@@ -27,6 +27,34 @@
#include <ch.h>
#if CH_USE_SERIAL_FULLDUPLEX
+
+static msg_t put(void *instance, uint8_t b, systime_t timeout) {
+
+ return chOQPutTimeout(&((FullDuplexDriver *)instance)->d3.oqueue, b, timeout);
+}
+
+static msg_t get(void *instance, systime_t timeout) {
+
+ return chIQGetTimeout(&((FullDuplexDriver *)instance)->d3.iqueue, timeout);
+}
+
+static size_t write(void *instance, uint8_t *buffer, size_t n) {
+
+ return chOQWrite(&((FullDuplexDriver *)instance)->d3.oqueue, buffer, n);
+}
+
+static size_t read(void *instance, uint8_t *buffer, size_t n) {
+
+ return chIQRead(&((FullDuplexDriver *)instance)->d3.iqueue, buffer, n);
+}
+
+static const struct FullDuplexDriverVMT vmt = {
+ {put, get},
+ {write, read},
+ {},
+ {}
+};
+
/**
* @brief Initializes a generic full duplex driver.
* @details The HW dependent part of the initialization has to be performed
@@ -51,6 +79,7 @@ void chFDDInit(FullDuplexDriver *sd,
chDbgCheck((sd != NULL) && (ib != NULL) && (ob != NULL) &&
(isize > 0) && (osize > 0), "chFDDInit");
+ sd->vmt = &vmt;
chEvtInit(&sd->d1.ievent);
chEvtInit(&sd->d1.oevent);
chEvtInit(&sd->d2.sevent);
diff --git a/src/include/channels.h b/src/include/channels.h
index 57eb55c4a..d3d1f5d47 100644
--- a/src/include/channels.h
+++ b/src/include/channels.h
@@ -28,7 +28,7 @@
#define _CHANNELS_H_
/**
- * @brief Base channels methods.
+ * @brief @p BaseChannel specific methods.
*/
struct _base_channel_methods {
/**
@@ -44,7 +44,7 @@ struct _base_channel_methods {
};
/**
- * @brief Base channels data.
+ * @brief @p BaseChannel specific data.
* @note It is empty because @p BaseChannel is only an interface without
* implementation.
*/
@@ -52,10 +52,13 @@ struct _base_channel_data {
};
/**
- * @brief Virtual methods table for base channels.
+ * @brief @p BaseChannel virtual methods table.
*/
-struct _base_channel_vmt {
- struct _base_channel_methods m0; /**< Class methods. */
+struct BaseChannelVMT {
+ /**
+ * @p BaseChannel class specific methods.
+ */
+ struct _base_channel_methods m0;
};
/**
@@ -63,8 +66,14 @@ struct _base_channel_vmt {
* @details This class represents a generic, byte-wide, I/O channel.
*/
typedef struct {
- struct _base_channel_vmt *vmt; /**< Virtual Methods Table. */
- struct _base_channel_data d0; /**< Class data. */
+ /**
+ * Virtual Methods Table.
+ */
+ const struct BaseChannelVMT *vmt;
+ /**
+ * @p BaseChannel class specific data.
+ */
+ struct _base_channel_data d0;
} BaseChannel;
/**
@@ -129,7 +138,7 @@ typedef struct {
#if CH_USE_EVENTS
/**
- * @brief Virtual methods table for base asynchronous channels.
+ * @brief @p BaseAsynchronousChannel specific methods.
*/
struct _base_asynchronous_channel_methods {
/**
@@ -145,7 +154,7 @@ struct _base_asynchronous_channel_methods {
};
/**
- * @brief Base asynchronous channels data.
+ * @brief @p BaseAsynchronousChannel specific data.
*/
struct _base_asynchronous_channel_data {
/**
@@ -161,11 +170,17 @@ struct _base_asynchronous_channel_data {
};
/**
- * @brief Virtual methods table for base asynchronous channels.
+ * @brief @p BaseAsynchronousChannel virtual methods table.
*/
-struct _base_asynchronous_channel_vmt {
- struct _base_channel_methods m0; /**< Super class methods. */
- struct _base_asynchronous_channel_methods m1; /**< Class methods. */
+struct BaseAsynchronousChannelVMT {
+ /**
+ * @p BaseChannel class inherited methods.
+ */
+ struct _base_channel_methods m0;
+ /**
+ * @p BaseAsynchronousChannel class specific methods.
+ */
+ struct _base_asynchronous_channel_methods m1;
};
/**
@@ -176,9 +191,18 @@ struct _base_asynchronous_channel_vmt {
* asynchronous I/O in an event-driven environment.
*/
typedef struct {
- struct _base_asynchronous_channel_vmt *vmt; /**< Virtual Methods Table. */
- struct _base_channel_data d0; /**< Super class data. */
- struct _base_asynchronous_channel_data d1; /**< Class data. */
+ /**
+ * Virtual Methods Table.
+ */
+ const struct BaseAsynchronousChannelVMT *vmt;
+ /**
+ * @p BaseChannel class inherited data.
+ */
+ struct _base_channel_data d0;
+ /**
+ * @p BaseAsynchronousChannel class specific data.
+ */
+ struct _base_asynchronous_channel_data d1;
} BaseAsynchronousChannel;
/**
diff --git a/src/include/serial.h b/src/include/serial.h
index 845c4bf9c..6d91d0f15 100644
--- a/src/include/serial.h
+++ b/src/include/serial.h
@@ -63,8 +63,7 @@ struct _generic_serial_driver_data {
*/
EventSource sevent;
/**
- * I/O driver status flags. This field should not be read directly but
- * the @p () function should be used instead.
+ * I/O driver status flags.
*/
dflags_t flags;
};
@@ -72,7 +71,7 @@ struct _generic_serial_driver_data {
/**
* @brief @p GenericSerialDriver virtual methods table.
*/
-struct _generic_serial_driver_vmt {
+struct GenericSerialDriverVMT {
/**
* @p BaseChannel class inherited methods.
*/
@@ -98,7 +97,7 @@ typedef struct {
/**
* Virtual Methods Table.
*/
- struct _generic_serial_driver_vmt *vmt;
+ const struct GenericSerialDriverVMT *vmt;
/**
* @p BaseChannel class inherited data.
*/
@@ -139,7 +138,7 @@ struct _full_duplex_driver_data {
/**
* @brief @p FullDuplexDriver virtual methods table.
*/
-struct _full_duplex_driver_vmt {
+struct FullDuplexDriverVMT {
/**
* @p BaseChannel class inherited methods.
*/
@@ -169,7 +168,7 @@ typedef struct {
/**
* Virtual Methods Table.
*/
- struct _full_duplex_driver_vmt *vmt;
+ const struct FullDuplexDriverVMT *vmt;
/**
* @p BaseChannel class inherited data.
*/
@@ -179,7 +178,7 @@ typedef struct {
*/
struct _base_asynchronous_channel_data d1;
/**
- * @p GenericSerialDriver specific data.
+ * @p GenericSerialDriver inherited data.
*/
struct _generic_serial_driver_data d2;
/**