aboutsummaryrefslogtreecommitdiffstats
path: root/os/io/serial.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-08-19 13:11:25 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-08-19 13:11:25 +0000
commit45a6b7dc5a1758cb2bc49b0d76effa381043d297 (patch)
tree2e9f38ca4e3eed5f7d1c3b0c1271564c4f5655f0 /os/io/serial.c
parent0a59caa507fd9aed69345ba2c915dfa8f7c2395c (diff)
downloadChibiOS-45a6b7dc5a1758cb2bc49b0d76effa381043d297.tar.gz
ChibiOS-45a6b7dc5a1758cb2bc49b0d76effa381043d297.tar.bz2
ChibiOS-45a6b7dc5a1758cb2bc49b0d76effa381043d297.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1082 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/io/serial.c')
-rw-r--r--os/io/serial.c62
1 files changed, 33 insertions, 29 deletions
diff --git a/os/io/serial.c b/os/io/serial.c
index abc099eea..05d258841 100644
--- a/os/io/serial.c
+++ b/os/io/serial.c
@@ -61,36 +61,10 @@ static size_t read(void *ip, uint8_t *buffer, size_t n) {
return chIQRead(&((SerialDriver *)ip)->d2.iqueue, buffer, n);
}
-static void start(void *ip, const SerialDriverConfig *config) {
- SerialDriver *sdp = (SerialDriver *)ip;
-
- chSysLock();
- sd_lld_start(sdp, config);
- chSysUnlock();
-}
-
-/**
- * @brief Stops the driver.
- * @Details Any thread waiting on the driver's queues will be awakened with
- * the message @p Q_RESET.
- *
- * @param sd The @p SerialDriver to be stopped.
- */
-static void stop(void *ip) {
- SerialDriver *sdp = (SerialDriver *)ip;
-
- chSysLock();
- sd_lld_stop(sdp);
- chOQResetI(&sdp->d2.oqueue);
- chIQResetI(&sdp->d2.iqueue);
- chSchRescheduleS();
- chSysUnlock();
-}
-
static const struct SerialDriverVMT vmt = {
{putwouldblock, getwouldblock, put, get},
{write, read},
- {start, stop}
+ {}
};
/**
@@ -112,8 +86,6 @@ static const struct SerialDriverVMT vmt = {
*/
void sdInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify) {
- chDbgCheck(sdp != NULL, "sdInit");
-
sdp->vmt = &vmt;
chEvtInit(&sdp->d1.ievent);
chEvtInit(&sdp->d1.oevent);
@@ -124,6 +96,38 @@ void sdInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify) {
}
/**
+ * @brief Configures and starts the driver.
+ *
+ * @param[in] ip pointer to a @p SerialDriver or derived class
+ * @param[in] config the architecture-dependent serial driver configuration.
+ * If this parameter is set to @p NULL then a default
+ * configuration is used.
+ */
+void sdStart(SerialDriver *sdp, const SerialDriverConfig *config) {
+
+ chSysLock();
+ sd_lld_start(sdp, config);
+ chSysUnlock();
+}
+
+/**
+ * @brief Stops the driver.
+ * @Details Any thread waiting on the driver's queues will be awakened with
+ * the message @p Q_RESET.
+ *
+ * @param[in] ip pointer to a @p SerialDriver or derived class
+ */
+void sdStop(SerialDriver *sdp) {
+
+ chSysLock();
+ sd_lld_stop(sdp);
+ chOQResetI(&sdp->d2.oqueue);
+ chIQResetI(&sdp->d2.iqueue);
+ chSchRescheduleS();
+ chSysUnlock();
+}
+
+/**
* @brief Handles incoming data.
* @details This function must be called from the input interrupt service
* routine in order to enqueue incoming data and generate the