diff options
Diffstat (limited to 'os/various')
-rw-r--r-- | os/various/devices_lib/accel/lis302dl.c (renamed from os/various/lis302dl.c) | 20 | ||||
-rw-r--r-- | os/various/devices_lib/accel/lis302dl.dox | 30 | ||||
-rw-r--r-- | os/various/devices_lib/accel/lis302dl.h (renamed from os/various/lis302dl.h) | 24 | ||||
-rw-r--r-- | os/various/memstreams.c | 67 | ||||
-rw-r--r-- | os/various/memstreams.h | 24 | ||||
-rw-r--r-- | os/various/various.dox | 11 |
6 files changed, 142 insertions, 34 deletions
diff --git a/os/various/lis302dl.c b/os/various/devices_lib/accel/lis302dl.c index 9cd0a0aec..6a4cb38a8 100644 --- a/os/various/lis302dl.c +++ b/os/various/devices_lib/accel/lis302dl.c @@ -30,9 +30,29 @@ #include "hal.h"
#include "lis302dl.h"
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
static uint8_t txbuf[2];
static uint8_t rxbuf[2];
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
/**
* @brief Reads a register value.
* @pre The SPI interface must be initialized and the driver started.
diff --git a/os/various/devices_lib/accel/lis302dl.dox b/os/various/devices_lib/accel/lis302dl.dox new file mode 100644 index 000000000..85745e4ae --- /dev/null +++ b/os/various/devices_lib/accel/lis302dl.dox @@ -0,0 +1,30 @@ +*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011,2012 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @defgroup lis302dl Interface module for LIS302DL MEMS
+ *
+ * @brief Interface module for LIS302DL MEMS.
+ * @details This module implements a generic interface for the LIS302DL
+ * STMicroelectronics MEMS device. The communication is performed
+ * through a standard SPI driver.
+ *
+ * @ingroup accel
+ */
diff --git a/os/various/lis302dl.h b/os/various/devices_lib/accel/lis302dl.h index 06e153205..4263c67e8 100644 --- a/os/various/lis302dl.h +++ b/os/various/devices_lib/accel/lis302dl.h @@ -29,6 +29,10 @@ #ifndef _LIS302DL_H_
#define _LIS302DL_H_
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
/**
* @name LIS302DL register names
* @{
@@ -59,6 +63,26 @@ #define LIS302DL_CLICK_WINDOW 0x3F
/** @} */
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/os/various/memstreams.c b/os/various/memstreams.c index 5eddeda9c..df17a4046 100644 --- a/os/various/memstreams.c +++ b/os/various/memstreams.c @@ -31,17 +31,22 @@ #include "ch.h"
#include "memstreams.h"
-/*
- * @brief Write virtual method implementation.
- *
- * @param[in] ip pointer to a @p MemoryStream object
- * @param[in] bp pointer to the data buffer
- * @param[in] n the maximum amount of data to be transferred
- * @return The number of bytes transferred. The return value can
- * be less than the specified number of bytes if the
- * stream reaches a physical end of file and cannot be
- * extended.
- */
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
static size_t writes(void *ip, const uint8_t *bp, size_t n) {
MemoryStream *msp = ip;
@@ -52,16 +57,6 @@ static size_t writes(void *ip, const uint8_t *bp, size_t n) { return n;
}
-/*
- * @brief Read virtual method implementation.
- *
- * @param[in] ip pointer to a @p MemoryStream object
- * @param[out] bp pointer to the data buffer
- * @param[in] n the maximum amount of data to be transferred
- * @return The number of bytes transferred. The return value can
- * be less than the specified number of bytes if the
- * stream reaches the end of the available data.
- */
static size_t reads(void *ip, uint8_t *bp, size_t n) {
MemoryStream *msp = ip;
@@ -72,7 +67,32 @@ static size_t reads(void *ip, uint8_t *bp, size_t n) { return n;
}
-static const struct MemStreamVMT vmt = {writes, reads};
+static msg_t put(void *ip, uint8_t b) {
+ MemoryStream *msp = ip;
+
+ if (msp->size - msp->eos <= 0)
+ return RDY_RESET;
+ *(msp->buffer + msp->eos) = b;
+ msp->eos += 1;
+ return RDY_OK;
+}
+
+static msg_t get(void *ip) {
+ uint8_t b;
+ MemoryStream *msp = ip;
+
+ if (msp->eos - msp->offset <= 0)
+ return RDY_RESET;
+ b = *(msp->buffer + msp->offset);
+ msp->offset += 1;
+ return b;
+}
+
+static const struct MemStreamVMT vmt = {writes, reads, put, get};
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
/**
* @brief Memory stream object initialization.
@@ -84,7 +104,8 @@ static const struct MemStreamVMT vmt = {writes, reads}; * put this to zero for RAM buffers or equal to @p size
* for ROM streams.
*/
-void msObjectInit(MemoryStream *msp, uint8_t *buffer, size_t size, size_t eos) {
+void msObjectInit(MemoryStream *msp, uint8_t *buffer,
+ size_t size, size_t eos) {
msp->vmt = &vmt;
msp->buffer = buffer;
diff --git a/os/various/memstreams.h b/os/various/memstreams.h index 083ab0771..57c69451f 100644 --- a/os/various/memstreams.h +++ b/os/various/memstreams.h @@ -29,6 +29,22 @@ #ifndef _MEMSTREAMS_H_
#define _MEMSTREAMS_H_
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
/**
* @brief @p RamStream specific data.
*/
@@ -61,6 +77,14 @@ typedef struct { _memory_stream_data
} MemoryStream;
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/os/various/various.dox b/os/various/various.dox index ac833a7e0..c69355b65 100644 --- a/os/various/various.dox +++ b/os/various/various.dox @@ -91,14 +91,3 @@ *
* @ingroup various
*/
-
-/**
- * @defgroup lis302dl Interface module for LIS302DL MEMS
- *
- * @brief Interface module for LIS302DL MEMS.
- * @details This module implements a generic interface for the LIS302DL
- * STMicroelectronics MEMS device. The communication is performed
- * through a standard SPI driver.
- *
- * @ingroup various
- */
|