From ae4f143cf638046e3e17c20b69a8551e3ce96de4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 May 2009 17:18:56 +0000 Subject: More madness. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@937 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chserial.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/chserial.c') 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 #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); -- cgit v1.2.3