From 16178e1c45a76544d34ce63db37932838353637c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 28 Nov 2009 12:25:35 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1333 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 208 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 os/hal/include/mmc_spi.h (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h new file mode 100644 index 000000000..e77dbe7dc --- /dev/null +++ b/os/hal/include/mmc_spi.h @@ -0,0 +1,208 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2007 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 . +*/ + +/** + * @file mmc_spi.h + * @brief MMC over SPI driver header. + * @addtogroup MMC_SPI + * @{ + */ + +#ifndef _MMC_SPI_H_ +#define _MMC_SPI_H_ + +#if CH_HAL_USE_MMC_SPI + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/** + * @brief Block size for MMC transfers. + */ +#if !defined(MMC_SECTOR_SIZE) || defined(__DOXYGEN__) +#define MMC_SECTOR_SIZE 512 +#endif + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + * This option is recommended also if the SPI driver does not + * use a DMA channel and heavily loads the CPU. + */ +#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) +#define MMC_NICE_WAITING TRUE +#endif + +/** + * @brief Number of positive insertion queries before generating the + * insertion event. + */ +#if !defined(MMC_POLLING_INTERVAL) || defined(__DOXYGEN__) +#define MMC_POLLING_INTERVAL 10 +#endif + +/** + * @brief Interval, in milliseconds, between insertion queries. + */ +#if !defined(MMC_POLLING_DELAY) || defined(__DOXYGEN__) +#define MMC_POLLING_DELAY 10 +#endif + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +#define MMC_CMD0_RETRY 10 +#define MMC_CMD1_RETRY 100 +#define MMC_WAIT_DATA 10000 + +#define MMC_CMDGOIDLE 0 +#define MMC_CMDINIT 1 +#define MMC_CMDREADCSD 9 +#define MMC_CMDSTOP 12 +#define MMC_CMDSETBLOCKLEN 16 +#define MMC_CMDREAD 17 +#define MMC_CMDREADMULTIPLE 18 +#define MMC_CMDWRITE 24 +#define MMC_CMDWRITEMULTIPLE 25 + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Driver state machine possible states. + */ +typedef enum { + MMC_UNINIT = 0, /**< @brief Not initialized. */ + MMC_STOP = 1, /**< @brief Stopped. */ + MMC_WAIT = 2, /**< @brief Waiting card. */ + MMC_INSERTED = 3, /**< @brief Card inserted. */ + MMC_READY = 4, /**< @brief Card ready. */ + MMC_READING = 5, /**< @brief Reading. */ + MMC_WRITING = 6 /**< @brief Writing. */ +} mmcstate_t; + +/** + * @brief Function used to query some hardware status bits. + * + * @return The status. + */ +typedef bool_t (*mmcquery_t)(void); + +/** + * @brief Driver configuration structure. + */ +typedef struct { + +} MMCConfig; + +/** + * @brief Structure representing a MMC driver. + */ +typedef struct { + /** + * @brief Driver state. + */ + mmcstate_t mmc_state; + /** + * @brief Current configuration data. + */ + const MMCConfig *mmc_config; + /** + * @brief SPI driver associated to this MMC driver. + */ + SPIDriver *mmc_spip; + /** + * @brief SPI low speed configuration used during initialization. + */ + const SPIConfig *mmc_lscfg; + /** + * @brief SPI high speed configuration used during transfers. + */ + const SPIConfig *mmc_hscfg; + /** + * @brief Write protect status query function. + */ + mmcquery_t mmc_is_protected; + /** + * @brief Insertion status query function. + */ + mmcquery_t mmc_is_inserted; + /** + * @brief Card insertion event source. + */ + EventSource mmc_inserted_event; + /** + * @brief Card removal event source. + */ + EventSource mmc_removed_event; + /** + * @brief MMC insertion polling timer. + */ + VirtualTimer mmc_vt; + /** + * @brief Insertion counter. + */ + uint_fast8_t mmc_cnt; +} MMCDriver; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +/** + * @brief Returns the driver state. + */ +#define mmcGetDriverState(mmcp) ((mmcp)->mmc_state) + +/** + * @brief Returns the write protect status. + */ +#define mmcIsWriteProtected(mmcp) ((mmcp)->mmc_is_protected()) + +#ifdef __cplusplus +extern "C" { +#endif + void mmcInit(void); + void mmcObjectInit(MMCDriver *mmcp, SPIDriver *spip, + const SPIConfig *lscfg, const SPIConfig *hscfg, + mmcquery_t is_protected, mmcquery_t is_inserted); + void mmcStart(MMCDriver *mmcp, const MMCConfig *config); + void mmcStop(MMCDriver *mmcp); + bool_t mmcConnect(MMCDriver *mmcp); + bool_t mmcDisconnect(MMCDriver *mmcp); + bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk); + bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer); + bool_t mmcStopSequentialRead(MMCDriver *mmcp); + bool_t mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk); + bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer); + bool_t mmcStopSequentialWrite(MMCDriver *mmcp); +#ifdef __cplusplus +} +#endif + +#endif /* CH_HAL_USE_MMC_SPI */ + +#endif /* _MMC_SPI_H_ */ + +/** @} */ -- cgit v1.2.3 From 0d0e4d619185ad86270ca5c0212c314f7f4529d5 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 29 Nov 2009 08:25:31 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1342 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 208 ----------------------------------------------- 1 file changed, 208 deletions(-) delete mode 100644 os/hal/include/mmc_spi.h (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h deleted file mode 100644 index e77dbe7dc..000000000 --- a/os/hal/include/mmc_spi.h +++ /dev/null @@ -1,208 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2007 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 . -*/ - -/** - * @file mmc_spi.h - * @brief MMC over SPI driver header. - * @addtogroup MMC_SPI - * @{ - */ - -#ifndef _MMC_SPI_H_ -#define _MMC_SPI_H_ - -#if CH_HAL_USE_MMC_SPI - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/** - * @brief Block size for MMC transfers. - */ -#if !defined(MMC_SECTOR_SIZE) || defined(__DOXYGEN__) -#define MMC_SECTOR_SIZE 512 -#endif - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - * This option is recommended also if the SPI driver does not - * use a DMA channel and heavily loads the CPU. - */ -#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) -#define MMC_NICE_WAITING TRUE -#endif - -/** - * @brief Number of positive insertion queries before generating the - * insertion event. - */ -#if !defined(MMC_POLLING_INTERVAL) || defined(__DOXYGEN__) -#define MMC_POLLING_INTERVAL 10 -#endif - -/** - * @brief Interval, in milliseconds, between insertion queries. - */ -#if !defined(MMC_POLLING_DELAY) || defined(__DOXYGEN__) -#define MMC_POLLING_DELAY 10 -#endif - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -#define MMC_CMD0_RETRY 10 -#define MMC_CMD1_RETRY 100 -#define MMC_WAIT_DATA 10000 - -#define MMC_CMDGOIDLE 0 -#define MMC_CMDINIT 1 -#define MMC_CMDREADCSD 9 -#define MMC_CMDSTOP 12 -#define MMC_CMDSETBLOCKLEN 16 -#define MMC_CMDREAD 17 -#define MMC_CMDREADMULTIPLE 18 -#define MMC_CMDWRITE 24 -#define MMC_CMDWRITEMULTIPLE 25 - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/** - * @brief Driver state machine possible states. - */ -typedef enum { - MMC_UNINIT = 0, /**< @brief Not initialized. */ - MMC_STOP = 1, /**< @brief Stopped. */ - MMC_WAIT = 2, /**< @brief Waiting card. */ - MMC_INSERTED = 3, /**< @brief Card inserted. */ - MMC_READY = 4, /**< @brief Card ready. */ - MMC_READING = 5, /**< @brief Reading. */ - MMC_WRITING = 6 /**< @brief Writing. */ -} mmcstate_t; - -/** - * @brief Function used to query some hardware status bits. - * - * @return The status. - */ -typedef bool_t (*mmcquery_t)(void); - -/** - * @brief Driver configuration structure. - */ -typedef struct { - -} MMCConfig; - -/** - * @brief Structure representing a MMC driver. - */ -typedef struct { - /** - * @brief Driver state. - */ - mmcstate_t mmc_state; - /** - * @brief Current configuration data. - */ - const MMCConfig *mmc_config; - /** - * @brief SPI driver associated to this MMC driver. - */ - SPIDriver *mmc_spip; - /** - * @brief SPI low speed configuration used during initialization. - */ - const SPIConfig *mmc_lscfg; - /** - * @brief SPI high speed configuration used during transfers. - */ - const SPIConfig *mmc_hscfg; - /** - * @brief Write protect status query function. - */ - mmcquery_t mmc_is_protected; - /** - * @brief Insertion status query function. - */ - mmcquery_t mmc_is_inserted; - /** - * @brief Card insertion event source. - */ - EventSource mmc_inserted_event; - /** - * @brief Card removal event source. - */ - EventSource mmc_removed_event; - /** - * @brief MMC insertion polling timer. - */ - VirtualTimer mmc_vt; - /** - * @brief Insertion counter. - */ - uint_fast8_t mmc_cnt; -} MMCDriver; - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -/** - * @brief Returns the driver state. - */ -#define mmcGetDriverState(mmcp) ((mmcp)->mmc_state) - -/** - * @brief Returns the write protect status. - */ -#define mmcIsWriteProtected(mmcp) ((mmcp)->mmc_is_protected()) - -#ifdef __cplusplus -extern "C" { -#endif - void mmcInit(void); - void mmcObjectInit(MMCDriver *mmcp, SPIDriver *spip, - const SPIConfig *lscfg, const SPIConfig *hscfg, - mmcquery_t is_protected, mmcquery_t is_inserted); - void mmcStart(MMCDriver *mmcp, const MMCConfig *config); - void mmcStop(MMCDriver *mmcp); - bool_t mmcConnect(MMCDriver *mmcp); - bool_t mmcDisconnect(MMCDriver *mmcp); - bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk); - bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer); - bool_t mmcStopSequentialRead(MMCDriver *mmcp); - bool_t mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk); - bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer); - bool_t mmcStopSequentialWrite(MMCDriver *mmcp); -#ifdef __cplusplus -} -#endif - -#endif /* CH_HAL_USE_MMC_SPI */ - -#endif /* _MMC_SPI_H_ */ - -/** @} */ -- cgit v1.2.3 From d4c616e6eeb0587ca450c75b1086efa77ac690e5 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 29 Nov 2009 08:50:13 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1351 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 208 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 os/hal/include/mmc_spi.h (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h new file mode 100644 index 000000000..e77dbe7dc --- /dev/null +++ b/os/hal/include/mmc_spi.h @@ -0,0 +1,208 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2007 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 . +*/ + +/** + * @file mmc_spi.h + * @brief MMC over SPI driver header. + * @addtogroup MMC_SPI + * @{ + */ + +#ifndef _MMC_SPI_H_ +#define _MMC_SPI_H_ + +#if CH_HAL_USE_MMC_SPI + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/** + * @brief Block size for MMC transfers. + */ +#if !defined(MMC_SECTOR_SIZE) || defined(__DOXYGEN__) +#define MMC_SECTOR_SIZE 512 +#endif + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + * This option is recommended also if the SPI driver does not + * use a DMA channel and heavily loads the CPU. + */ +#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) +#define MMC_NICE_WAITING TRUE +#endif + +/** + * @brief Number of positive insertion queries before generating the + * insertion event. + */ +#if !defined(MMC_POLLING_INTERVAL) || defined(__DOXYGEN__) +#define MMC_POLLING_INTERVAL 10 +#endif + +/** + * @brief Interval, in milliseconds, between insertion queries. + */ +#if !defined(MMC_POLLING_DELAY) || defined(__DOXYGEN__) +#define MMC_POLLING_DELAY 10 +#endif + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +#define MMC_CMD0_RETRY 10 +#define MMC_CMD1_RETRY 100 +#define MMC_WAIT_DATA 10000 + +#define MMC_CMDGOIDLE 0 +#define MMC_CMDINIT 1 +#define MMC_CMDREADCSD 9 +#define MMC_CMDSTOP 12 +#define MMC_CMDSETBLOCKLEN 16 +#define MMC_CMDREAD 17 +#define MMC_CMDREADMULTIPLE 18 +#define MMC_CMDWRITE 24 +#define MMC_CMDWRITEMULTIPLE 25 + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Driver state machine possible states. + */ +typedef enum { + MMC_UNINIT = 0, /**< @brief Not initialized. */ + MMC_STOP = 1, /**< @brief Stopped. */ + MMC_WAIT = 2, /**< @brief Waiting card. */ + MMC_INSERTED = 3, /**< @brief Card inserted. */ + MMC_READY = 4, /**< @brief Card ready. */ + MMC_READING = 5, /**< @brief Reading. */ + MMC_WRITING = 6 /**< @brief Writing. */ +} mmcstate_t; + +/** + * @brief Function used to query some hardware status bits. + * + * @return The status. + */ +typedef bool_t (*mmcquery_t)(void); + +/** + * @brief Driver configuration structure. + */ +typedef struct { + +} MMCConfig; + +/** + * @brief Structure representing a MMC driver. + */ +typedef struct { + /** + * @brief Driver state. + */ + mmcstate_t mmc_state; + /** + * @brief Current configuration data. + */ + const MMCConfig *mmc_config; + /** + * @brief SPI driver associated to this MMC driver. + */ + SPIDriver *mmc_spip; + /** + * @brief SPI low speed configuration used during initialization. + */ + const SPIConfig *mmc_lscfg; + /** + * @brief SPI high speed configuration used during transfers. + */ + const SPIConfig *mmc_hscfg; + /** + * @brief Write protect status query function. + */ + mmcquery_t mmc_is_protected; + /** + * @brief Insertion status query function. + */ + mmcquery_t mmc_is_inserted; + /** + * @brief Card insertion event source. + */ + EventSource mmc_inserted_event; + /** + * @brief Card removal event source. + */ + EventSource mmc_removed_event; + /** + * @brief MMC insertion polling timer. + */ + VirtualTimer mmc_vt; + /** + * @brief Insertion counter. + */ + uint_fast8_t mmc_cnt; +} MMCDriver; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +/** + * @brief Returns the driver state. + */ +#define mmcGetDriverState(mmcp) ((mmcp)->mmc_state) + +/** + * @brief Returns the write protect status. + */ +#define mmcIsWriteProtected(mmcp) ((mmcp)->mmc_is_protected()) + +#ifdef __cplusplus +extern "C" { +#endif + void mmcInit(void); + void mmcObjectInit(MMCDriver *mmcp, SPIDriver *spip, + const SPIConfig *lscfg, const SPIConfig *hscfg, + mmcquery_t is_protected, mmcquery_t is_inserted); + void mmcStart(MMCDriver *mmcp, const MMCConfig *config); + void mmcStop(MMCDriver *mmcp); + bool_t mmcConnect(MMCDriver *mmcp); + bool_t mmcDisconnect(MMCDriver *mmcp); + bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk); + bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer); + bool_t mmcStopSequentialRead(MMCDriver *mmcp); + bool_t mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk); + bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer); + bool_t mmcStopSequentialWrite(MMCDriver *mmcp); +#ifdef __cplusplus +} +#endif + +#endif /* CH_HAL_USE_MMC_SPI */ + +#endif /* _MMC_SPI_H_ */ + +/** @} */ -- cgit v1.2.3 From f90ae4d17df24cd6477f2557bc86ef9433e93414 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 29 Nov 2009 10:37:31 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1354 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index e77dbe7dc..4a6886933 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -27,7 +27,7 @@ #ifndef _MMC_SPI_H_ #define _MMC_SPI_H_ -#if CH_HAL_USE_MMC_SPI +#if CH_HAL_USE_MMC_SPI || defined(__DOXYGEN__) /*===========================================================================*/ /* Driver pre-compile time settings. */ -- cgit v1.2.3 From 0b8fd860fa71b35bfe0a242471d3bc4b56c93089 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 7 Dec 2009 16:13:01 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1381 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 4a6886933..2a9fd0c53 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -29,6 +29,10 @@ #if CH_HAL_USE_MMC_SPI || defined(__DOXYGEN__) +#if !CH_USE_EVENTS +#error "MMC_SPI driver requires CH_USE_EVENTS" +#endif + /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ -- cgit v1.2.3 From fe24da9fcca4967e58b25a2698c46717995de0ad Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 29 Dec 2009 11:12:05 +0000 Subject: Reorganized sections in HAL files. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1473 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 2a9fd0c53..da2ed573c 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -29,9 +29,23 @@ #if CH_HAL_USE_MMC_SPI || defined(__DOXYGEN__) -#if !CH_USE_EVENTS -#error "MMC_SPI driver requires CH_USE_EVENTS" -#endif +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +#define MMC_CMD0_RETRY 10 +#define MMC_CMD1_RETRY 100 +#define MMC_WAIT_DATA 10000 + +#define MMC_CMDGOIDLE 0 +#define MMC_CMDINIT 1 +#define MMC_CMDREADCSD 9 +#define MMC_CMDSTOP 12 +#define MMC_CMDSETBLOCKLEN 16 +#define MMC_CMDREAD 17 +#define MMC_CMDREADMULTIPLE 18 +#define MMC_CMDWRITE 24 +#define MMC_CMDWRITEMULTIPLE 25 /*===========================================================================*/ /* Driver pre-compile time settings. */ @@ -72,22 +86,12 @@ #endif /*===========================================================================*/ -/* Driver constants. */ +/* Derived constants and error checks. */ /*===========================================================================*/ -#define MMC_CMD0_RETRY 10 -#define MMC_CMD1_RETRY 100 -#define MMC_WAIT_DATA 10000 - -#define MMC_CMDGOIDLE 0 -#define MMC_CMDINIT 1 -#define MMC_CMDREADCSD 9 -#define MMC_CMDSTOP 12 -#define MMC_CMDSETBLOCKLEN 16 -#define MMC_CMDREAD 17 -#define MMC_CMDREADMULTIPLE 18 -#define MMC_CMDWRITE 24 -#define MMC_CMDWRITEMULTIPLE 25 +#if !CH_USE_EVENTS +#error "MMC_SPI driver requires CH_USE_EVENTS" +#endif /*===========================================================================*/ /* Driver data structures and types. */ @@ -171,7 +175,7 @@ typedef struct { } MMCDriver; /*===========================================================================*/ -/* External declarations. */ +/* Driver macros. */ /*===========================================================================*/ /** @@ -184,6 +188,10 @@ typedef struct { */ #define mmcIsWriteProtected(mmcp) ((mmcp)->mmc_is_protected()) +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + #ifdef __cplusplus extern "C" { #endif -- cgit v1.2.3 From bd96aadd957fab46d4173cd74b31c5da44d20899 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 5 Jan 2010 17:40:46 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1502 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index da2ed573c..2be2673fb 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -89,8 +89,8 @@ /* Derived constants and error checks. */ /*===========================================================================*/ -#if !CH_USE_EVENTS -#error "MMC_SPI driver requires CH_USE_EVENTS" +#if !CH_HAL_USE_SPI || !CH_USE_EVENTS +#error "MMC_SPI driver requires CH_HAL_USE_SPI and CH_USE_EVENTS" #endif /*===========================================================================*/ -- cgit v1.2.3 From e3c7dc319ff582f9eb4a593950ac7bedb1d38b77 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 6 Feb 2010 16:17:30 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1571 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 2be2673fb..e4c3ee157 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -18,8 +18,9 @@ */ /** - * @file mmc_spi.h - * @brief MMC over SPI driver header. + * @file mmc_spi.h + * @brief MMC over SPI driver header. + * * @addtogroup MMC_SPI * @{ */ @@ -52,14 +53,14 @@ /*===========================================================================*/ /** - * @brief Block size for MMC transfers. + * @brief Block size for MMC transfers. */ #if !defined(MMC_SECTOR_SIZE) || defined(__DOXYGEN__) #define MMC_SECTOR_SIZE 512 #endif /** - * @brief Delays insertions. + * @brief Delays insertions. * @details If enabled this options inserts delays into the MMC waiting * routines releasing some extra CPU time for the threads with * lower priority, this may slow down the driver a bit however. @@ -71,15 +72,15 @@ #endif /** - * @brief Number of positive insertion queries before generating the - * insertion event. + * @brief Number of positive insertion queries before generating the + * insertion event. */ #if !defined(MMC_POLLING_INTERVAL) || defined(__DOXYGEN__) #define MMC_POLLING_INTERVAL 10 #endif /** - * @brief Interval, in milliseconds, between insertion queries. + * @brief Interval, in milliseconds, between insertion queries. */ #if !defined(MMC_POLLING_DELAY) || defined(__DOXYGEN__) #define MMC_POLLING_DELAY 10 @@ -98,7 +99,7 @@ /*===========================================================================*/ /** - * @brief Driver state machine possible states. + * @brief Driver state machine possible states. */ typedef enum { MMC_UNINIT = 0, /**< @brief Not initialized. */ @@ -111,21 +112,21 @@ typedef enum { } mmcstate_t; /** - * @brief Function used to query some hardware status bits. + * @brief Function used to query some hardware status bits. * - * @return The status. + * @return The status. */ typedef bool_t (*mmcquery_t)(void); /** - * @brief Driver configuration structure. + * @brief Driver configuration structure. */ typedef struct { } MMCConfig; /** - * @brief Structure representing a MMC driver. + * @brief Structure representing a MMC driver. */ typedef struct { /** @@ -179,12 +180,12 @@ typedef struct { /*===========================================================================*/ /** - * @brief Returns the driver state. + * @brief Returns the driver state. */ #define mmcGetDriverState(mmcp) ((mmcp)->mmc_state) /** - * @brief Returns the write protect status. + * @brief Returns the write protect status. */ #define mmcIsWriteProtected(mmcp) ((mmcp)->mmc_is_protected()) -- cgit v1.2.3 From 157b6f9695e7f72f2d54b231c19cb4045710ed01 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 21 Feb 2010 07:24:53 +0000 Subject: Updated license dates. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1646 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index e4c3ee157..cc698c3de 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -65,7 +65,7 @@ * routines releasing some extra CPU time for the threads with * lower priority, this may slow down the driver a bit however. * This option is recommended also if the SPI driver does not - * use a DMA channel and heavily loads the CPU. + * use a DMA channel and heavily loads the CPU. */ #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) #define MMC_NICE_WAITING TRUE @@ -73,14 +73,14 @@ /** * @brief Number of positive insertion queries before generating the - * insertion event. + * insertion event. */ #if !defined(MMC_POLLING_INTERVAL) || defined(__DOXYGEN__) #define MMC_POLLING_INTERVAL 10 #endif /** - * @brief Interval, in milliseconds, between insertion queries. + * @brief Interval, in milliseconds, between insertion queries. */ #if !defined(MMC_POLLING_DELAY) || defined(__DOXYGEN__) #define MMC_POLLING_DELAY 10 @@ -138,19 +138,19 @@ typedef struct { */ const MMCConfig *mmc_config; /** - * @brief SPI driver associated to this MMC driver. + * @brief SPI driver associated to this MMC driver. */ SPIDriver *mmc_spip; /** - * @brief SPI low speed configuration used during initialization. + * @brief SPI low speed configuration used during initialization. */ const SPIConfig *mmc_lscfg; /** - * @brief SPI high speed configuration used during transfers. + * @brief SPI high speed configuration used during transfers. */ const SPIConfig *mmc_hscfg; /** - * @brief Write protect status query function. + * @brief Write protect status query function. */ mmcquery_t mmc_is_protected; /** @@ -158,19 +158,19 @@ typedef struct { */ mmcquery_t mmc_is_inserted; /** - * @brief Card insertion event source. + * @brief Card insertion event source. */ EventSource mmc_inserted_event; /** - * @brief Card removal event source. + * @brief Card removal event source. */ EventSource mmc_removed_event; /** - * @brief MMC insertion polling timer. + * @brief MMC insertion polling timer. */ VirtualTimer mmc_vt; /** - * @brief Insertion counter. + * @brief Insertion counter. */ uint_fast8_t mmc_cnt; } MMCDriver; @@ -180,12 +180,12 @@ typedef struct { /*===========================================================================*/ /** - * @brief Returns the driver state. + * @brief Returns the driver state. */ #define mmcGetDriverState(mmcp) ((mmcp)->mmc_state) /** - * @brief Returns the write protect status. + * @brief Returns the write protect status. */ #define mmcIsWriteProtected(mmcp) ((mmcp)->mmc_is_protected()) -- cgit v1.2.3 From 2891f7d645c4be187ac96ee4011207531d25c34a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 4 Oct 2010 17:16:18 +0000 Subject: Documentation improvements, fixed a small error in the STM32 serial driver. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2234 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index cc698c3de..6af424d29 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -181,11 +181,23 @@ typedef struct { /** * @brief Returns the driver state. + * + * @param[in] mmcp pointer to the @p MMCDriver object + * @return The driver state. + * + * @api */ #define mmcGetDriverState(mmcp) ((mmcp)->mmc_state) /** * @brief Returns the write protect status. + * + * @param[in] mmcp pointer to the @p MMCDriver object + * @return The card state. + * @retval FALSE card not inserted. + * @retval TRUE card inserted. + * + * @api */ #define mmcIsWriteProtected(mmcp) ((mmcp)->mmc_is_protected()) -- cgit v1.2.3 From 19ee10d24417ce8db6d28cf2e57755450bdf42d8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 9 Oct 2010 07:58:41 +0000 Subject: Defaulted serial buffer sizes to 16 bytes. Improvements to the documentation. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2239 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 6af424d29..c5732887d 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -34,19 +34,19 @@ /* Driver constants. */ /*===========================================================================*/ -#define MMC_CMD0_RETRY 10 -#define MMC_CMD1_RETRY 100 -#define MMC_WAIT_DATA 10000 - -#define MMC_CMDGOIDLE 0 -#define MMC_CMDINIT 1 -#define MMC_CMDREADCSD 9 -#define MMC_CMDSTOP 12 -#define MMC_CMDSETBLOCKLEN 16 -#define MMC_CMDREAD 17 -#define MMC_CMDREADMULTIPLE 18 -#define MMC_CMDWRITE 24 -#define MMC_CMDWRITEMULTIPLE 25 +#define MMC_CMD0_RETRY 10 +#define MMC_CMD1_RETRY 100 +#define MMC_WAIT_DATA 10000 + +#define MMC_CMDGOIDLE 0 +#define MMC_CMDINIT 1 +#define MMC_CMDREADCSD 9 +#define MMC_CMDSTOP 12 +#define MMC_CMDSETBLOCKLEN 16 +#define MMC_CMDREAD 17 +#define MMC_CMDREADMULTIPLE 18 +#define MMC_CMDWRITE 24 +#define MMC_CMDWRITEMULTIPLE 25 /*===========================================================================*/ /* Driver pre-compile time settings. */ @@ -56,7 +56,7 @@ * @brief Block size for MMC transfers. */ #if !defined(MMC_SECTOR_SIZE) || defined(__DOXYGEN__) -#define MMC_SECTOR_SIZE 512 +#define MMC_SECTOR_SIZE 512 #endif /** @@ -68,7 +68,7 @@ * use a DMA channel and heavily loads the CPU. */ #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) -#define MMC_NICE_WAITING TRUE +#define MMC_NICE_WAITING TRUE #endif /** @@ -76,14 +76,14 @@ * insertion event. */ #if !defined(MMC_POLLING_INTERVAL) || defined(__DOXYGEN__) -#define MMC_POLLING_INTERVAL 10 +#define MMC_POLLING_INTERVAL 10 #endif /** * @brief Interval, in milliseconds, between insertion queries. */ #if !defined(MMC_POLLING_DELAY) || defined(__DOXYGEN__) -#define MMC_POLLING_DELAY 10 +#define MMC_POLLING_DELAY 10 #endif /*===========================================================================*/ -- cgit v1.2.3 From 4f1b492119f90b34fdbc13e88d892612c21cb08e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 31 Oct 2010 13:06:42 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2313 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index c5732887d..582ed1653 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -102,13 +102,13 @@ * @brief Driver state machine possible states. */ typedef enum { - MMC_UNINIT = 0, /**< @brief Not initialized. */ - MMC_STOP = 1, /**< @brief Stopped. */ - MMC_WAIT = 2, /**< @brief Waiting card. */ - MMC_INSERTED = 3, /**< @brief Card inserted. */ - MMC_READY = 4, /**< @brief Card ready. */ - MMC_READING = 5, /**< @brief Reading. */ - MMC_WRITING = 6 /**< @brief Writing. */ + MMC_UNINIT = 0, /**< Not initialized. */ + MMC_STOP = 1, /**< Stopped. */ + MMC_WAIT = 2, /**< Waiting card. */ + MMC_INSERTED = 3, /**< Card inserted. */ + MMC_READY = 4, /**< Card ready. */ + MMC_READING = 5, /**< Reading. */ + MMC_WRITING = 6 /**< Writing. */ } mmcstate_t; /** -- cgit v1.2.3 From d8be44136c1e6d02ee105ac0791f9e6732551fec Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 1 Nov 2010 17:29:56 +0000 Subject: Fixed bug 3100946, renamed HAL switches removing the CH_ part. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2326 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 582ed1653..f413e3c15 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -28,7 +28,7 @@ #ifndef _MMC_SPI_H_ #define _MMC_SPI_H_ -#if CH_HAL_USE_MMC_SPI || defined(__DOXYGEN__) +#if HAL_USE_MMC_SPI || defined(__DOXYGEN__) /*===========================================================================*/ /* Driver constants. */ @@ -90,8 +90,8 @@ /* Derived constants and error checks. */ /*===========================================================================*/ -#if !CH_HAL_USE_SPI || !CH_USE_EVENTS -#error "MMC_SPI driver requires CH_HAL_USE_SPI and CH_USE_EVENTS" +#if !HAL_USE_SPI || !CH_USE_EVENTS +#error "MMC_SPI driver requires HAL_USE_SPI and CH_USE_EVENTS" #endif /*===========================================================================*/ @@ -226,7 +226,7 @@ extern "C" { } #endif -#endif /* CH_HAL_USE_MMC_SPI */ +#endif /* HAL_USE_MMC_SPI */ #endif /* _MMC_SPI_H_ */ -- cgit v1.2.3 From 0f395838d3782f0865ead3dacc7c5acb5cfc73f0 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 21 Dec 2010 18:25:56 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2516 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index f413e3c15..241fae54a 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -120,9 +120,10 @@ typedef bool_t (*mmcquery_t)(void); /** * @brief Driver configuration structure. + * @note Not required in the current implementation. */ typedef struct { - + uint8_t dummy; } MMCConfig; /** -- cgit v1.2.3 From 18fb8f676f0f650d83f69bc29ab45b04b73e86c1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 8 Mar 2011 10:09:57 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2808 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 241fae54a..9f717ed39 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -18,7 +18,7 @@ */ /** - * @file mmc_spi.h + * @file spi.h * @brief MMC over SPI driver header. * * @addtogroup MMC_SPI @@ -133,47 +133,47 @@ typedef struct { /** * @brief Driver state. */ - mmcstate_t mmc_state; + mmcstate_t state; /** * @brief Current configuration data. */ - const MMCConfig *mmc_config; + const MMCConfig *config; /** * @brief SPI driver associated to this MMC driver. */ - SPIDriver *mmc_spip; + SPIDriver *spip; /** * @brief SPI low speed configuration used during initialization. */ - const SPIConfig *mmc_lscfg; + const SPIConfig *lscfg; /** * @brief SPI high speed configuration used during transfers. */ - const SPIConfig *mmc_hscfg; + const SPIConfig *hscfg; /** * @brief Write protect status query function. */ - mmcquery_t mmc_is_protected; + mmcquery_t is_protected; /** * @brief Insertion status query function. */ - mmcquery_t mmc_is_inserted; + mmcquery_t is_inserted; /** * @brief Card insertion event source. */ - EventSource mmc_inserted_event; + EventSource inserted_event; /** * @brief Card removal event source. */ - EventSource mmc_removed_event; + EventSource removed_event; /** * @brief MMC insertion polling timer. */ - VirtualTimer mmc_vt; + VirtualTimer vt; /** * @brief Insertion counter. */ - uint_fast8_t mmc_cnt; + uint_fast8_t cnt; } MMCDriver; /*===========================================================================*/ @@ -188,7 +188,7 @@ typedef struct { * * @api */ -#define mmcGetDriverState(mmcp) ((mmcp)->mmc_state) +#define mmcGetDriverState(mmcp) ((mmcp)->state) /** * @brief Returns the write protect status. @@ -200,7 +200,7 @@ typedef struct { * * @api */ -#define mmcIsWriteProtected(mmcp) ((mmcp)->mmc_is_protected()) +#define mmcIsWriteProtected(mmcp) ((mmcp)->is_protected()) /*===========================================================================*/ /* External declarations. */ -- cgit v1.2.3 From e7e79a6ccb4f3e320b2b8b7bad1b14d65218641d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 18 Mar 2011 18:38:08 +0000 Subject: License updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2827 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 9f717ed39..6940ca479 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -1,5 +1,6 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 718dc5084f7719f91eaacfc99e8c7de654eb2ad8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 23 Aug 2011 13:36:25 +0000 Subject: HAL documentation improvements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3252 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 6940ca479..f51bd6765 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -53,6 +53,10 @@ /* Driver pre-compile time settings. */ /*===========================================================================*/ +/** + * @name MMC_SPI configuration options + * @{ + */ /** * @brief Block size for MMC transfers. */ @@ -86,6 +90,7 @@ #if !defined(MMC_POLLING_DELAY) || defined(__DOXYGEN__) #define MMC_POLLING_DELAY 10 #endif +/** @} */ /*===========================================================================*/ /* Derived constants and error checks. */ @@ -181,6 +186,10 @@ typedef struct { /* Driver macros. */ /*===========================================================================*/ +/** + * @name Macro Functions + * @{ + */ /** * @brief Returns the driver state. * @@ -202,6 +211,7 @@ typedef struct { * @api */ #define mmcIsWriteProtected(mmcp) ((mmcp)->is_protected()) +/** @} */ /*===========================================================================*/ /* External declarations. */ -- cgit v1.2.3 From 62b090c673675b2f519aced5f466a72e432b1417 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 5 Jan 2012 16:01:52 +0000 Subject: Improvements to the MMC over SPI driver. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3741 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index f51bd6765..42bcb2f84 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -19,7 +19,7 @@ */ /** - * @file spi.h + * @file mmc_spi.h * @brief MMC over SPI driver header. * * @addtogroup MMC_SPI @@ -37,10 +37,12 @@ #define MMC_CMD0_RETRY 10 #define MMC_CMD1_RETRY 100 +#define MMC_ACMD41_RETRY 100 #define MMC_WAIT_DATA 10000 #define MMC_CMDGOIDLE 0 #define MMC_CMDINIT 1 +#define MMC_CMDINTERFACE_CONDITION 8 #define MMC_CMDREADCSD 9 #define MMC_CMDSTOP 12 #define MMC_CMDSETBLOCKLEN 16 @@ -48,6 +50,9 @@ #define MMC_CMDREADMULTIPLE 18 #define MMC_CMDWRITE 24 #define MMC_CMDWRITEMULTIPLE 25 +#define MMC_CMDAPP 55 +#define MMC_CMDREADOCR 58 +#define MMC_ACMDOPCONDITION 41 /*===========================================================================*/ /* Driver pre-compile time settings. */ @@ -180,6 +185,10 @@ typedef struct { * @brief Insertion counter. */ uint_fast8_t cnt; + /*** + * @brief Addresses use blocks instead of bytes. + */ + bool_t block_addresses; } MMCDriver; /*===========================================================================*/ -- cgit v1.2.3 From de5dcbba856524599a8f06d3a9bdbf1b01db44c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Jan 2012 14:29:42 +0000 Subject: License text updated with new year. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3846 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 42bcb2f84..1d624aeff 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011 Giovanni Di Sirio. + 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 7f87eee586adf22f28b1687ef92051065a0a5ee5 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 9 May 2012 17:00:03 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4178 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 1d624aeff..fd2850576 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -40,20 +40,6 @@ #define MMC_ACMD41_RETRY 100 #define MMC_WAIT_DATA 10000 -#define MMC_CMDGOIDLE 0 -#define MMC_CMDINIT 1 -#define MMC_CMDINTERFACE_CONDITION 8 -#define MMC_CMDREADCSD 9 -#define MMC_CMDSTOP 12 -#define MMC_CMDSETBLOCKLEN 16 -#define MMC_CMDREAD 17 -#define MMC_CMDREADMULTIPLE 18 -#define MMC_CMDWRITE 24 -#define MMC_CMDWRITEMULTIPLE 25 -#define MMC_CMDAPP 55 -#define MMC_CMDREADOCR 58 -#define MMC_ACMDOPCONDITION 41 - /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ @@ -62,13 +48,6 @@ * @name MMC_SPI configuration options * @{ */ -/** - * @brief Block size for MMC transfers. - */ -#if !defined(MMC_SECTOR_SIZE) || defined(__DOXYGEN__) -#define MMC_SECTOR_SIZE 512 -#endif - /** * @brief Delays insertions. * @details If enabled this options inserts delays into the MMC waiting @@ -138,9 +117,15 @@ typedef struct { } MMCConfig; /** - * @brief Structure representing a MMC driver. + * @extends MMCSDBlockDevice + * + * @brief Structure representing a MMC/SD over SPI driver. */ typedef struct { + /** + * @brief Virtual Methods Table. + */ + const struct MMCSDBlockDeviceVMT *vmt; /** * @brief Driver state. */ @@ -243,6 +228,8 @@ extern "C" { bool_t mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk); bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer); bool_t mmcStopSequentialWrite(MMCDriver *mmcp); + bool_t mmcSync(MMCDriver *mmcp); + bool_t mmcGetInfo(MMCDriver *mmcp, BlockDeviceInfo *bdip); #ifdef __cplusplus } #endif -- cgit v1.2.3 From 6a8a643ab00e5964a3fb77e5b2394561bb797e55 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 9 May 2012 18:44:47 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4179 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index fd2850576..760ab3ad1 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -101,13 +101,6 @@ typedef enum { MMC_WRITING = 6 /**< Writing. */ } mmcstate_t; -/** - * @brief Function used to query some hardware status bits. - * - * @return The status. - */ -typedef bool_t (*mmcquery_t)(void); - /** * @brief Driver configuration structure. * @note Not required in the current implementation. @@ -146,14 +139,6 @@ typedef struct { * @brief SPI high speed configuration used during transfers. */ const SPIConfig *hscfg; - /** - * @brief Write protect status query function. - */ - mmcquery_t is_protected; - /** - * @brief Insertion status query function. - */ - mmcquery_t is_inserted; /** * @brief Card insertion event source. */ @@ -204,7 +189,7 @@ typedef struct { * * @api */ -#define mmcIsWriteProtected(mmcp) ((mmcp)->is_protected()) +#define mmcIsWriteProtected(mmcp) mmc_lld_is_write_protected(mmcp) /** @} */ /*===========================================================================*/ @@ -216,8 +201,7 @@ extern "C" { #endif void mmcInit(void); void mmcObjectInit(MMCDriver *mmcp, SPIDriver *spip, - const SPIConfig *lscfg, const SPIConfig *hscfg, - mmcquery_t is_protected, mmcquery_t is_inserted); + const SPIConfig *lscfg, const SPIConfig *hscfg); void mmcStart(MMCDriver *mmcp, const MMCConfig *config); void mmcStop(MMCDriver *mmcp); bool_t mmcConnect(MMCDriver *mmcp); @@ -230,6 +214,8 @@ extern "C" { bool_t mmcStopSequentialWrite(MMCDriver *mmcp); bool_t mmcSync(MMCDriver *mmcp); bool_t mmcGetInfo(MMCDriver *mmcp, BlockDeviceInfo *bdip); + bool_t mmc_lld_is_card_inserted(MMCDriver *mmcp); + bool_t mmc_lld_is_write_protected(MMCDriver *mmcp); #ifdef __cplusplus } #endif -- cgit v1.2.3 From 97dce7b94464b891a25170e6556daac5bb30f7ef Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 10 May 2012 12:26:24 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4180 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 760ab3ad1..a5812e399 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -102,11 +102,21 @@ typedef enum { } mmcstate_t; /** - * @brief Driver configuration structure. - * @note Not required in the current implementation. + * @brief MMC/SD over SPI driver configuration structure. */ typedef struct { - uint8_t dummy; + /** + * @brief SPI driver associated to this MMC driver. + */ + SPIDriver *spip; + /** + * @brief SPI low speed configuration used during initialization. + */ + const SPIConfig *lscfg; + /** + * @brief SPI high speed configuration used during transfers. + */ + const SPIConfig *hscfg; } MMCConfig; /** @@ -127,18 +137,6 @@ typedef struct { * @brief Current configuration data. */ const MMCConfig *config; - /** - * @brief SPI driver associated to this MMC driver. - */ - SPIDriver *spip; - /** - * @brief SPI low speed configuration used during initialization. - */ - const SPIConfig *lscfg; - /** - * @brief SPI high speed configuration used during transfers. - */ - const SPIConfig *hscfg; /** * @brief Card insertion event source. */ @@ -200,8 +198,7 @@ typedef struct { extern "C" { #endif void mmcInit(void); - void mmcObjectInit(MMCDriver *mmcp, SPIDriver *spip, - const SPIConfig *lscfg, const SPIConfig *hscfg); + void mmcObjectInit(MMCDriver *mmcp); void mmcStart(MMCDriver *mmcp, const MMCConfig *config); void mmcStop(MMCDriver *mmcp); bool_t mmcConnect(MMCDriver *mmcp); -- cgit v1.2.3 From eba4b7056128ae85402984fb03882a5a9eb88213 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 10 May 2012 15:07:40 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4182 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index a5812e399..a1a33c72d 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -157,6 +157,10 @@ typedef struct { * @brief Addresses use blocks instead of bytes. */ bool_t block_addresses; + /** + * @brief Total number of blocks in card. + */ + uint32_t capacity; } MMCDriver; /*===========================================================================*/ -- cgit v1.2.3 From 661cf8e8dc3793c0f716e783018514b9bd4e5551 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 22 May 2012 19:45:00 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4230 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index a1a33c72d..307ffd3ca 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -157,6 +157,14 @@ typedef struct { * @brief Addresses use blocks instead of bytes. */ bool_t block_addresses; + /** + * @brief Card CID. + */ + uint32_t cid[4]; + /** + * @brief Card CSD. + */ + uint32_t csd[4]; /** * @brief Total number of blocks in card. */ @@ -215,6 +223,7 @@ extern "C" { bool_t mmcStopSequentialWrite(MMCDriver *mmcp); bool_t mmcSync(MMCDriver *mmcp); bool_t mmcGetInfo(MMCDriver *mmcp, BlockDeviceInfo *bdip); + bool_t mmcErase(MMCDriver *mmcp, uint32_t startblk, uint32_t endblk); bool_t mmc_lld_is_card_inserted(MMCDriver *mmcp); bool_t mmc_lld_is_write_protected(MMCDriver *mmcp); #ifdef __cplusplus -- cgit v1.2.3 From 2b1173e29246cbc82f45490d0b1b1443d7bf897a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 14 Jun 2012 16:45:57 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4276 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 307ffd3ca..a008292f5 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -119,6 +119,21 @@ typedef struct { const SPIConfig *hscfg; } MMCConfig; +/** + * @brief @p MMCDriver specific methods. + */ +#define _mmc_driver_methods \ + _mmcsd_block_device_methods + +/** + * @extends MMCSDBlockDeviceVMT + * + * @brief @p MMCDriver virtual methods table. + */ +struct MMCDriverVMT { + _mmc_driver_methods +}; + /** * @extends MMCSDBlockDevice * @@ -128,7 +143,8 @@ typedef struct { /** * @brief Virtual Methods Table. */ - const struct MMCSDBlockDeviceVMT *vmt; + const struct MMCDriverVMT *vmt; + _mmcsd_block_device_data /** * @brief Driver state. */ @@ -157,18 +173,6 @@ typedef struct { * @brief Addresses use blocks instead of bytes. */ bool_t block_addresses; - /** - * @brief Card CID. - */ - uint32_t cid[4]; - /** - * @brief Card CSD. - */ - uint32_t csd[4]; - /** - * @brief Total number of blocks in card. - */ - uint32_t capacity; } MMCDriver; /*===========================================================================*/ -- cgit v1.2.3 From 80443125b286868f18342a9e6884a65b3218bf99 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 25 Jun 2012 16:53:21 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4347 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 62 +++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 38 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index a008292f5..cff70876b 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -59,21 +59,6 @@ #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) #define MMC_NICE_WAITING TRUE #endif - -/** - * @brief Number of positive insertion queries before generating the - * insertion event. - */ -#if !defined(MMC_POLLING_INTERVAL) || defined(__DOXYGEN__) -#define MMC_POLLING_INTERVAL 10 -#endif - -/** - * @brief Interval, in milliseconds, between insertion queries. - */ -#if !defined(MMC_POLLING_DELAY) || defined(__DOXYGEN__) -#define MMC_POLLING_DELAY 10 -#endif /** @} */ /*===========================================================================*/ @@ -92,13 +77,14 @@ * @brief Driver state machine possible states. */ typedef enum { - MMC_UNINIT = 0, /**< Not initialized. */ - MMC_STOP = 1, /**< Stopped. */ - MMC_WAIT = 2, /**< Waiting card. */ - MMC_INSERTED = 3, /**< Card inserted. */ - MMC_READY = 4, /**< Card ready. */ - MMC_READING = 5, /**< Reading. */ - MMC_WRITING = 6 /**< Writing. */ + MMC_UNINIT = 0, /**< Not initialized. */ + MMC_STOP = 1, /**< Stopped. */ + MMC_READY = 2, /**< Ready. */ + MMC_CONNECTING = 3, /**< Card connection in progress. */ + MMC_DISCONNECTING = 4, /**< Card disconnection in progress. */ + MMC_ACTIVE = 5, /**< Cart initialized. */ + MMC_READING = 6, /**< Read operation in progress. */ + MMC_WRITING = 7, /**< Write operation in progress. */ } mmcstate_t; /** @@ -153,22 +139,6 @@ typedef struct { * @brief Current configuration data. */ const MMCConfig *config; - /** - * @brief Card insertion event source. - */ - EventSource inserted_event; - /** - * @brief Card removal event source. - */ - EventSource removed_event; - /** - * @brief MMC insertion polling timer. - */ - VirtualTimer vt; - /** - * @brief Insertion counter. - */ - uint_fast8_t cnt; /*** * @brief Addresses use blocks instead of bytes. */ @@ -193,6 +163,22 @@ typedef struct { */ #define mmcGetDriverState(mmcp) ((mmcp)->state) +/** + * @brief Returns the card insertion status. + * @note This macro wraps a low level function named + * @p sdc_lld_is_card_inserted(), this function must be + * provided by the application because it is not part of the + * SDC driver. + * + * @param[in] mmcp pointer to the @p MMCDriver object + * @return The card state. + * @retval FALSE card not inserted. + * @retval TRUE card inserted. + * + * @api + */ +#define mmcIsCardInserted(mmcp) mmc_lld_is_card_inserted(mmcp) + /** * @brief Returns the write protect status. * -- cgit v1.2.3 From 853b0fd51c80d9b8640639321a950f16800d57d4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 26 Jun 2012 18:02:43 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4348 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index cff70876b..b03732992 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -73,20 +73,6 @@ /* Driver data structures and types. */ /*===========================================================================*/ -/** - * @brief Driver state machine possible states. - */ -typedef enum { - MMC_UNINIT = 0, /**< Not initialized. */ - MMC_STOP = 1, /**< Stopped. */ - MMC_READY = 2, /**< Ready. */ - MMC_CONNECTING = 3, /**< Card connection in progress. */ - MMC_DISCONNECTING = 4, /**< Card disconnection in progress. */ - MMC_ACTIVE = 5, /**< Cart initialized. */ - MMC_READING = 6, /**< Read operation in progress. */ - MMC_WRITING = 7, /**< Write operation in progress. */ -} mmcstate_t; - /** * @brief MMC/SD over SPI driver configuration structure. */ @@ -131,10 +117,6 @@ typedef struct { */ const struct MMCDriverVMT *vmt; _mmcsd_block_device_data - /** - * @brief Driver state. - */ - mmcstate_t state; /** * @brief Current configuration data. */ @@ -153,16 +135,6 @@ typedef struct { * @name Macro Functions * @{ */ -/** - * @brief Returns the driver state. - * - * @param[in] mmcp pointer to the @p MMCDriver object - * @return The driver state. - * - * @api - */ -#define mmcGetDriverState(mmcp) ((mmcp)->state) - /** * @brief Returns the card insertion status. * @note This macro wraps a low level function named -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index b03732992..0663818df 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 3adcb46879db0ebabf5d5575dcc724e8483c9079 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 7 Apr 2013 07:45:17 +0000 Subject: Added a compile time chech to the MMC_SPI driver. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5553 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/mmc_spi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/hal/include/mmc_spi.h') diff --git a/os/hal/include/mmc_spi.h b/os/hal/include/mmc_spi.h index 0663818df..5732570b6 100644 --- a/os/hal/include/mmc_spi.h +++ b/os/hal/include/mmc_spi.h @@ -65,8 +65,8 @@ /* Derived constants and error checks. */ /*===========================================================================*/ -#if !HAL_USE_SPI || !CH_USE_EVENTS -#error "MMC_SPI driver requires HAL_USE_SPI and CH_USE_EVENTS" +#if !HAL_USE_SPI || !SPI_USE_WAIT || !CH_USE_EVENTS +#error "MMC_SPI driver requires HAL_USE_SPI, SPI_USE_WAIT and CH_USE_EVENTS" #endif /*===========================================================================*/ -- cgit v1.2.3