More madness.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@937 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
81507dcbe7
commit
ae4f143cf6
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue