aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-06-19 16:47:09 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-06-19 16:47:09 +0000
commitde6bbbb9eff7592723d401c6340b9e4c78b24953 (patch)
tree7769b2a519686c3a817fbaa7658d7fbfd2f6e637 /os
parentcbfc9a5396c2924d6b8fa3c03e4ea8bbda386a15 (diff)
downloadChibiOS-de6bbbb9eff7592723d401c6340b9e4c78b24953.tar.gz
ChibiOS-de6bbbb9eff7592723d401c6340b9e4c78b24953.tar.bz2
ChibiOS-de6bbbb9eff7592723d401c6340b9e4c78b24953.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4307 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/platforms/STM32/can_lld.c10
-rw-r--r--os/hal/platforms/STM32/can_lld.h10
-rw-r--r--os/hal/platforms/STM32/stm32.h10
-rw-r--r--os/hal/platforms/STM32F0xx/hal_lld.h1
-rw-r--r--os/hal/platforms/STM32F1xx/hal_lld_f100.h2
-rw-r--r--os/hal/platforms/STM32F1xx/hal_lld_f103.h4
-rw-r--r--os/hal/platforms/STM32F1xx/hal_lld_f105_f107.h1
-rw-r--r--os/hal/platforms/STM32F2xx/hal_lld.h1
-rw-r--r--os/hal/platforms/STM32F2xx/platform.mk1
-rw-r--r--os/hal/platforms/STM32F2xx/stm32_rcc.h93
-rw-r--r--os/hal/platforms/STM32F4xx/hal_lld.h1
-rw-r--r--os/hal/platforms/STM32F4xx/platform.mk1
-rw-r--r--os/hal/platforms/STM32F4xx/stm32_rcc.h58
-rw-r--r--os/hal/platforms/STM32L1xx/hal_lld.h1
-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.dox30
-rw-r--r--os/various/devices_lib/accel/lis302dl.h (renamed from os/various/lis302dl.h)24
-rw-r--r--os/various/memstreams.c67
-rw-r--r--os/various/memstreams.h24
-rw-r--r--os/various/various.dox11
20 files changed, 316 insertions, 54 deletions
diff --git a/os/hal/platforms/STM32/can_lld.c b/os/hal/platforms/STM32/can_lld.c
index 3c577c346..a252d6889 100644
--- a/os/hal/platforms/STM32/can_lld.c
+++ b/os/hal/platforms/STM32/can_lld.c
@@ -184,9 +184,9 @@ void can_lld_start(CANDriver *canp) {
/* Clock activation.*/
#if STM32_CAN_USE_CAN1
if (&CAND1 == canp) {
- nvicEnableVector(USB_HP_CAN1_TX_IRQn,
+ nvicEnableVector(CAN1_TX_IRQn,
CORTEX_PRIORITY_MASK(STM32_CAN_CAN1_IRQ_PRIORITY));
- nvicEnableVector(USB_LP_CAN1_RX0_IRQn,
+ nvicEnableVector(CAN1_RX0_IRQn,
CORTEX_PRIORITY_MASK(STM32_CAN_CAN1_IRQ_PRIORITY));
nvicEnableVector(CAN1_RX1_IRQn,
CORTEX_PRIORITY_MASK(STM32_CAN_CAN1_IRQ_PRIORITY));
@@ -217,7 +217,7 @@ void can_lld_start(CANDriver *canp) {
canp->can->FFA1R = 0;
cfp = canp->can->sFilterRegister;
fmask = 1;
- for (i = 0; i < CAN_MAX_FILTERS; i++) {
+ for (i = 0; i < STM32_CAN_MAX_FILTERS; i++) {
if (i < canp->config->num) {
if (canp->config->filters[i].mode)
canp->can->FM1R |= fmask;
@@ -272,8 +272,8 @@ void can_lld_stop(CANDriver *canp) {
if (&CAND1 == canp) {
CAN1->MCR = 0x00010002; /* Register reset value. */
CAN1->IER = 0x00000000; /* All sources disabled. */
- nvicDisableVector(USB_HP_CAN1_TX_IRQn);
- nvicDisableVector(USB_LP_CAN1_RX0_IRQn);
+ nvicDisableVector(CAN1_TX_IRQn);
+ nvicDisableVector(CAN1_RX0_IRQn);
nvicDisableVector(CAN1_RX1_IRQn);
nvicDisableVector(CAN1_SCE_IRQn);
rccDisableCAN1(FALSE);
diff --git a/os/hal/platforms/STM32/can_lld.h b/os/hal/platforms/STM32/can_lld.h
index d9bf3bb39..273b95fa0 100644
--- a/os/hal/platforms/STM32/can_lld.h
+++ b/os/hal/platforms/STM32/can_lld.h
@@ -51,14 +51,9 @@
#define CAN_SUPPORTS_SLEEP TRUE
/**
- * @brief Minimum number of CAN filters.
+ * @name CAN registers helper macros
+ * @{
*/
-#if defined(STM32F10X_CL) || defined(__DOXYGEN__)
-#define CAN_MAX_FILTERS 28
-#else
-#define CAN_MAX_FILTERS 14
-#endif
-
#define CAN_BTR_BRP(n) (n) /**< @brief BRP field macro.*/
#define CAN_BTR_TS1(n) ((n) << 16) /**< @brief TS1 field macro.*/
#define CAN_BTR_TS2(n) ((n) << 20) /**< @brief TS2 field macro.*/
@@ -69,6 +64,7 @@
#define CAN_RTR_DATA 0 /**< @brief Data frame. */
#define CAN_RTR_REMOTE 1 /**< @brief Remote frame. */
+/** @} */
/*===========================================================================*/
/* Driver pre-compile time settings. */
diff --git a/os/hal/platforms/STM32/stm32.h b/os/hal/platforms/STM32/stm32.h
index 49c1c08bb..a872a2a00 100644
--- a/os/hal/platforms/STM32/stm32.h
+++ b/os/hal/platforms/STM32/stm32.h
@@ -54,13 +54,17 @@
defined(__DOXYGEN__)
#include "stm32f10x.h"
-#elif defined(STM32F2XX) || defined(__DOXYGEN__)
+/* Resolving naming anomalies related to the STM32F1xx sub-family.*/
+#define CAN1_TX_IRQn USB_HP_CAN1_TX_IRQn
+#define CAN1_RX0_IRQn USB_LP_CAN1_RX0_IRQn
+
+#elif defined(STM32F2XX)
#include "stm32f2xx.h"
-#elif defined(STM32F4XX) || defined(__DOXYGEN__)
+#elif defined(STM32F4XX)
#include "stm32f4xx.h"
-#elif defined(STM32L1XX_MD) || defined(__DOXYGEN__)
+#elif defined(STM32L1XX_MD)
#include "stm32l1xx.h"
#else
diff --git a/os/hal/platforms/STM32F0xx/hal_lld.h b/os/hal/platforms/STM32F0xx/hal_lld.h
index f5c32a82d..93403c91f 100644
--- a/os/hal/platforms/STM32F0xx/hal_lld.h
+++ b/os/hal/platforms/STM32F0xx/hal_lld.h
@@ -238,6 +238,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 FALSE
#define STM32_HAS_CAN2 FALSE
+#define STM32_CAN_MAX_FILTERS 0
/* DAC attributes.*/
#define STM32_HAS_DAC TRUE
diff --git a/os/hal/platforms/STM32F1xx/hal_lld_f100.h b/os/hal/platforms/STM32F1xx/hal_lld_f100.h
index 3237fd5d0..4cf678935 100644
--- a/os/hal/platforms/STM32F1xx/hal_lld_f100.h
+++ b/os/hal/platforms/STM32F1xx/hal_lld_f100.h
@@ -199,6 +199,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 FALSE
#define STM32_HAS_CAN2 FALSE
+#define STM32_CAN_MAX_FILTERS 0
/* DAC attributes.*/
#define STM32_HAS_DAC TRUE
@@ -342,6 +343,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 FALSE
#define STM32_HAS_CAN2 FALSE
+#define STM32_CAN_MAX_FILTERS 0
/* DAC attributes.*/
#define STM32_HAS_DAC TRUE
diff --git a/os/hal/platforms/STM32F1xx/hal_lld_f103.h b/os/hal/platforms/STM32F1xx/hal_lld_f103.h
index 02b08cb8f..7c58c502c 100644
--- a/os/hal/platforms/STM32F1xx/hal_lld_f103.h
+++ b/os/hal/platforms/STM32F1xx/hal_lld_f103.h
@@ -209,6 +209,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 TRUE
#define STM32_HAS_CAN2 FALSE
+#define STM32_CAN_MAX_FILTERS 14
/* DAC attributes.*/
#define STM32_HAS_DAC FALSE
@@ -352,6 +353,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 TRUE
#define STM32_HAS_CAN2 FALSE
+#define STM32_CAN_MAX_FILTERS 14
/* DAC attributes.*/
#define STM32_HAS_DAC FALSE
@@ -499,6 +501,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 TRUE
#define STM32_HAS_CAN2 FALSE
+#define STM32_CAN_MAX_FILTERS 14
/* DAC attributes.*/
#define STM32_HAS_DAC TRUE
@@ -646,6 +649,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 TRUE
#define STM32_HAS_CAN2 FALSE
+#define STM32_CAN_MAX_FILTERS 14
/* DAC attributes.*/
#define STM32_HAS_DAC TRUE
diff --git a/os/hal/platforms/STM32F1xx/hal_lld_f105_f107.h b/os/hal/platforms/STM32F1xx/hal_lld_f105_f107.h
index 139402bd4..5b641dfcf 100644
--- a/os/hal/platforms/STM32F1xx/hal_lld_f105_f107.h
+++ b/os/hal/platforms/STM32F1xx/hal_lld_f105_f107.h
@@ -226,6 +226,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 TRUE
#define STM32_HAS_CAN2 TRUE
+#define STM32_CAN_MAX_FILTERS 28
/* DAC attributes.*/
#define STM32_HAS_DAC TRUE
diff --git a/os/hal/platforms/STM32F2xx/hal_lld.h b/os/hal/platforms/STM32F2xx/hal_lld.h
index ee260fdbb..4bccae76b 100644
--- a/os/hal/platforms/STM32F2xx/hal_lld.h
+++ b/os/hal/platforms/STM32F2xx/hal_lld.h
@@ -287,6 +287,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 TRUE
#define STM32_HAS_CAN2 TRUE
+#define STM32_CAN_MAX_FILTERS 28
/* DAC attributes.*/
#define STM32_HAS_DAC TRUE
diff --git a/os/hal/platforms/STM32F2xx/platform.mk b/os/hal/platforms/STM32F2xx/platform.mk
index 92dca2228..b4793c02b 100644
--- a/os/hal/platforms/STM32F2xx/platform.mk
+++ b/os/hal/platforms/STM32F2xx/platform.mk
@@ -2,6 +2,7 @@
PLATFORMSRC = ${CHIBIOS}/os/hal/platforms/STM32F2xx/stm32_dma.c \
${CHIBIOS}/os/hal/platforms/STM32F2xx/hal_lld.c \
${CHIBIOS}/os/hal/platforms/STM32F2xx/adc_lld.c \
+ ${CHIBIOS}/os/hal/platforms/STM32/can_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/ext_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/gpt_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/i2c_lld.c \
diff --git a/os/hal/platforms/STM32F2xx/stm32_rcc.h b/os/hal/platforms/STM32F2xx/stm32_rcc.h
index 226164ba4..0bd3a6401 100644
--- a/os/hal/platforms/STM32F2xx/stm32_rcc.h
+++ b/os/hal/platforms/STM32F2xx/stm32_rcc.h
@@ -391,12 +391,11 @@
/** @} */
/**
- * @name PWR interface specific RCC operations
+ * @name PWR interface specific RCC operations
* @{
*/
/**
* @brief Enables the PWR interface clock.
- * @note The @p lp parameter is ignored in this family.
*
* @param[in] lp low power enable flag
*
@@ -406,7 +405,6 @@
/**
* @brief Disables PWR interface clock.
- * @note The @p lp parameter is ignored in this family.
*
* @param[in] lp low power enable flag
*
@@ -422,6 +420,62 @@
#define rccResetPWRInterface() rccResetAPB1(RCC_APB1RSTR_PWRRST)
/** @} */
+
+/**
+ * @name CAN peripherals specific RCC operations
+ * @{
+ */
+/**
+ * @brief Enables the CAN1 peripheral clock.
+ *
+ * @param[in] lp low power enable flag
+ *
+ * @api
+ */
+#define rccEnableCAN1(lp) rccEnableAPB1(RCC_APB1ENR_CAN1EN, lp)
+
+/**
+ * @brief Disables the CAN1 peripheral clock.
+ *
+ * @param[in] lp low power enable flag
+ *
+ * @api
+ */
+#define rccDisableCAN1(lp) rccDisableAPB1(RCC_APB1ENR_CAN1EN, lp)
+
+/**
+ * @brief Resets the CAN1 peripheral.
+ *
+ * @api
+ */
+#define rccResetCAN1() rccResetAPB1(RCC_APB1RSTR_CAN1RST)
+
+/**
+ * @brief Enables the CAN2 peripheral clock.
+ *
+ * @param[in] lp low power enable flag
+ *
+ * @api
+ */
+#define rccEnableCAN2(lp) rccEnableAPB1(RCC_APB1ENR_CAN2EN, lp)
+
+/**
+ * @brief Disables the CAN2 peripheral clock.
+ *
+ * @param[in] lp low power enable flag
+ *
+ * @api
+ */
+#define rccDisableCAN2(lp) rccDisableAPB1(RCC_APB1ENR_CAN2EN, lp)
+
+/**
+ * @brief Resets the CAN2 peripheral.
+ *
+ * @api
+ */
+#define rccResetCAN2() rccResetAPB1(RCC_APB1RSTR_CAN2RST)
+/** @} */
+
/**
* @name ETH peripheral specific RCC operations
* @{
@@ -569,6 +623,39 @@
/** @} */
/**
+ * @name SDIO peripheral specific RCC operations
+ * @{
+ */
+/**
+ * @brief Enables the SDIO peripheral clock.
+ * @note The @p lp parameter is ignored in this family.
+ *
+ * @param[in] lp low power enable flag
+ *
+ * @api
+ */
+#define rccEnableSDIO(lp) rccEnableAPB2(RCC_APB2ENR_SDIOEN, lp)
+
+/**
+ * @brief Disables the SDIO peripheral clock.
+ * @note The @p lp parameter is ignored in this family.
+ *
+ * @param[in] lp low power enable flag
+ *
+ * @api
+ */
+#define rccDisableSDIO(lp) rccDisableAPB2(RCC_APB2ENR_SDIOEN, lp)
+
+/**
+ * @brief Resets the SDIO peripheral.
+ * @note Not supported in this family, does nothing.
+ *
+ * @api
+ */
+#define rccResetSDIO() rccResetAPB2(RCC_APB2RSTR_SDIORST)
+/** @} */
+
+/**
* @name SPI peripherals specific RCC operations
* @{
*/
diff --git a/os/hal/platforms/STM32F4xx/hal_lld.h b/os/hal/platforms/STM32F4xx/hal_lld.h
index 8c5303350..a755f5aa5 100644
--- a/os/hal/platforms/STM32F4xx/hal_lld.h
+++ b/os/hal/platforms/STM32F4xx/hal_lld.h
@@ -286,6 +286,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 TRUE
#define STM32_HAS_CAN2 TRUE
+#define STM32_CAN_MAX_FILTERS 28
/* DAC attributes.*/
#define STM32_HAS_DAC TRUE
diff --git a/os/hal/platforms/STM32F4xx/platform.mk b/os/hal/platforms/STM32F4xx/platform.mk
index 5194488b8..5422ab5e6 100644
--- a/os/hal/platforms/STM32F4xx/platform.mk
+++ b/os/hal/platforms/STM32F4xx/platform.mk
@@ -2,6 +2,7 @@
PLATFORMSRC = ${CHIBIOS}/os/hal/platforms/STM32F4xx/stm32_dma.c \
${CHIBIOS}/os/hal/platforms/STM32F4xx/hal_lld.c \
${CHIBIOS}/os/hal/platforms/STM32F4xx/adc_lld.c \
+ ${CHIBIOS}/os/hal/platforms/STM32/can_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/ext_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/gpt_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/i2c_lld.c \
diff --git a/os/hal/platforms/STM32F4xx/stm32_rcc.h b/os/hal/platforms/STM32F4xx/stm32_rcc.h
index 9ccb4a960..367318e04 100644
--- a/os/hal/platforms/STM32F4xx/stm32_rcc.h
+++ b/os/hal/platforms/STM32F4xx/stm32_rcc.h
@@ -396,7 +396,6 @@
*/
/**
* @brief Enables the PWR interface clock.
- * @note The @p lp parameter is ignored in this family.
*
* @param[in] lp low power enable flag
*
@@ -406,7 +405,6 @@
/**
* @brief Disables PWR interface clock.
- * @note The @p lp parameter is ignored in this family.
*
* @param[in] lp low power enable flag
*
@@ -422,6 +420,62 @@
#define rccResetPWRInterface() rccResetAPB1(RCC_APB1RSTR_PWRRST)
/** @} */
+
+/**
+ * @name CAN peripherals specific RCC operations
+ * @{
+ */
+/**
+ * @brief Enables the CAN1 peripheral clock.
+ *
+ * @param[in] lp low power enable flag
+ *
+ * @api
+ */
+#define rccEnableCAN1(lp) rccEnableAPB1(RCC_APB1ENR_CAN1EN, lp)
+
+/**
+ * @brief Disables the CAN1 peripheral clock.
+ *
+ * @param[in] lp low power enable flag
+ *
+ * @api
+ */
+#define rccDisableCAN1(lp) rccDisableAPB1(RCC_APB1ENR_CAN1EN, lp)
+
+/**
+ * @brief Resets the CAN1 peripheral.
+ *
+ * @api
+ */
+#define rccResetCAN1() rccResetAPB1(RCC_APB1RSTR_CAN1RST)
+
+/**
+ * @brief Enables the CAN2 peripheral clock.
+ *
+ * @param[in] lp low power enable flag
+ *
+ * @api
+ */
+#define rccEnableCAN2(lp) rccEnableAPB1(RCC_APB1ENR_CAN2EN, lp)
+
+/**
+ * @brief Disables the CAN2 peripheral clock.
+ *
+ * @param[in] lp low power enable flag
+ *
+ * @api
+ */
+#define rccDisableCAN2(lp) rccDisableAPB1(RCC_APB1ENR_CAN2EN, lp)
+
+/**
+ * @brief Resets the CAN2 peripheral.
+ *
+ * @api
+ */
+#define rccResetCAN2() rccResetAPB1(RCC_APB1RSTR_CAN2RST)
+/** @} */
+
/**
* @name ETH peripheral specific RCC operations
* @{
diff --git a/os/hal/platforms/STM32L1xx/hal_lld.h b/os/hal/platforms/STM32L1xx/hal_lld.h
index e7c27ceb8..e41f922b6 100644
--- a/os/hal/platforms/STM32L1xx/hal_lld.h
+++ b/os/hal/platforms/STM32L1xx/hal_lld.h
@@ -186,6 +186,7 @@
/* CAN attributes.*/
#define STM32_HAS_CAN1 FALSE
#define STM32_HAS_CAN2 FALSE
+#define STM32_CAN_MAX_FILTERS 0
/* DAC attributes.*/
#define STM32_HAS_DAC TRUE
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
- */