aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include/serial.h
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-01-01 13:41:31 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-01-01 13:41:31 +0000
commitf8c40043e469d81f2a9f380d6723b92c79bd30bc (patch)
tree3611911703c617241bb91c00c48163f147e3b123 /os/hal/include/serial.h
parent320a3f140e693a0d8647fd05ec6d2d4cb10c523a (diff)
downloadChibiOS-f8c40043e469d81f2a9f380d6723b92c79bd30bc.tar.gz
ChibiOS-f8c40043e469d81f2a9f380d6723b92c79bd30bc.tar.bz2
ChibiOS-f8c40043e469d81f2a9f380d6723b92c79bd30bc.zip
Serial driver enhancements for STM32 and AT91SAM7.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1485 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include/serial.h')
-rw-r--r--os/hal/include/serial.h61
1 files changed, 41 insertions, 20 deletions
diff --git a/os/hal/include/serial.h b/os/hal/include/serial.h
index 6f80985ab..9a2c8ec78 100644
--- a/os/hal/include/serial.h
+++ b/os/hal/include/serial.h
@@ -33,25 +33,37 @@
/* Driver constants. */
/*===========================================================================*/
-/** No pending conditions.*/
+/** @brief No pending conditions.*/
#define SD_NO_ERROR 0
-/** Connection happened.*/
+/** @brief Connection happened.*/
#define SD_CONNECTED 1
-/** Disconnection happened.*/
+/** @brief Disconnection happened.*/
#define SD_DISCONNECTED 2
-/** Parity error happened.*/
+/** @brief Parity error happened.*/
#define SD_PARITY_ERROR 4
-/** Framing error happened.*/
+/** @brief Framing error happened.*/
#define SD_FRAMING_ERROR 8
-/** Overflow happened.*/
+/** @brief Overflow happened.*/
#define SD_OVERRUN_ERROR 16
-/** Break detected.*/
-#define SD_BREAK_DETECTED 32
+/** @brief Noise on the line.*/
+#define SD_NOISE_ERROR 32
+/** @brief Break detected.*/
+#define SD_BREAK_DETECTED 64
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
+/**
+ * @brief Serial buffers size.
+ * @details Configuration parameter, you can change the depth of the queue
+ * buffers depending on the requirements of your application.
+ * @note The default is 64 bytes for both the transmission and receive buffers.
+ */
+#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
+#define SERIAL_BUFFERS_SIZE 128
+#endif
+
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
@@ -61,6 +73,15 @@
/*===========================================================================*/
/**
+ * @brief Driver state machine possible states.
+ */
+typedef enum {
+ SD_UNINIT = 0, /**< @brief Not initialized. */
+ SD_STOP = 1, /**< @brief Stopped. */
+ SD_READY = 2 /**< @brief Ready. */
+} sdstate_t;
+
+/**
* @brief Structure representing a serial driver.
*/
typedef struct _SerialDriver SerialDriver;
@@ -106,15 +127,15 @@ struct _SerialDriver {
/**
* @p BaseChannel class inherited data.
*/
- struct _base_channel_data d0;
+ struct _base_channel_data bc;
/**
* @p BaseAsynchronousChannel class inherited data.
*/
- struct _base_asynchronous_channel_data d1;
+ struct _base_asynchronous_channel_data bac;
/**
* @p SerialDriver specific data.
*/
- struct _serial_driver_data d2;
+ struct _serial_driver_data sd;
};
/*===========================================================================*/
@@ -128,7 +149,7 @@ struct _SerialDriver {
* be used to check different channels implementations.
* @see chIOPutWouldBlock()
*/
-#define sdPutWouldBlock(sdp) chOQIsFull(&(sdp)->d2.oqueue)
+#define sdPutWouldBlock(sdp) chOQIsFull(&(sdp)->sd.oqueue)
/**
* @brief Direct input check on a @p SerialDriver.
@@ -137,7 +158,7 @@ struct _SerialDriver {
* be used to check different channels implementations.
* @see chIOGetWouldBlock()
*/
-#define sdGetWouldBlock(sdp) chIQIsEmpty(&(sdp)->d2.iqueue)
+#define sdGetWouldBlock(sdp) chIQIsEmpty(&(sdp)->sd.iqueue)
/**
* @brief Direct blocking write to a @p SerialDriver.
@@ -146,7 +167,7 @@ struct _SerialDriver {
* be used to write to different channels implementations.
* @see chIOPut()
*/
-#define sdPut(sdp, b) chOQPut(&(sdp)->d2.oqueue, b)
+#define sdPut(sdp, b) chOQPut(&(sdp)->sd.oqueue, b)
/**
* @brief Direct blocking write on a @p SerialDriver with timeout
@@ -156,7 +177,7 @@ struct _SerialDriver {
* be used to write to different channels implementations.
* @see chIOPutTimeout()
*/
-#define sdPutTimeout(sdp, b, t) chOQPutTimeout(&(sdp)->d2.iqueue, b, t)
+#define sdPutTimeout(sdp, b, t) chOQPutTimeout(&(sdp)->sd.iqueue, b, t)
/**
* @brief Direct blocking read from a @p SerialDriver.
@@ -165,7 +186,7 @@ struct _SerialDriver {
* be used to read from different channels implementations.
* @see chIOGet()
*/
-#define sdGet(sdp) chIQGet(&(sdp)->d2.iqueue)
+#define sdGet(sdp) chIQGet(&(sdp)->sd.iqueue)
/**
* @brief Direct blocking read from a @p SerialDriver with timeout
@@ -175,7 +196,7 @@ struct _SerialDriver {
* be used to read from different channels implementations.
* @see chIOGetTimeout()
*/
-#define sdGetTimeout(sdp, t) chIQGetTimeout(&(sdp)->d2.iqueue, t)
+#define sdGetTimeout(sdp, t) chIQGetTimeout(&(sdp)->sd.iqueue, t)
/**
* @brief Direct non-blocking write to a @p SerialDriver.
@@ -184,7 +205,7 @@ struct _SerialDriver {
* be used to write from different channels implementations.
* @see chIOWrite()
*/
-#define sdWrite(sdp, b, n) chOQWrite(&(sdp)->d2.oqueue, b, n)
+#define sdWrite(sdp, b, n) chOQWrite(&(sdp)->sd.oqueue, b, n)
/**
* @brief Direct non-blocking read on a @p SerialDriver.
@@ -193,7 +214,7 @@ struct _SerialDriver {
* be used to read from different channels implementations.
* @see chIORead()
*/
-#define sdRead(sdp, b, n) chIQRead(&(sdp)->d2.iqueue, b, n)
+#define sdRead(sdp, b, n) chIQRead(&(sdp)->sd.iqueue, b, n)
/*===========================================================================*/
/* External declarations. */
@@ -204,7 +225,7 @@ extern "C" {
#endif
void sdInit(void);
void sdObjectInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify);
- void sdStart(SerialDriver *sdp, const SerialDriverConfig *config);
+ void sdStart(SerialDriver *sdp, const SerialConfig *config);
void sdStop(SerialDriver *sdp);
void sdIncomingDataI(SerialDriver *sdp, uint8_t b);
msg_t sdRequestDataI(SerialDriver *sdp);