ChibiOS-Contrib/os/hal/include/hal_sram.h

172 lines
5.1 KiB
C
Raw Normal View History

2014-10-18 06:34:12 -07:00
/*
2014-12-06 09:15:59 -08:00
ChibiOS/HAL - Copyright (C) 2014 Uladzimir Pylinsky aka barthess
2014-10-18 06:34:12 -07:00
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
2016-10-17 07:23:16 -07:00
* @file hal_fsmc_sram.h
2014-10-18 06:34:12 -07:00
* @brief SRAM Driver subsystem low level driver header.
*
* @addtogroup SRAM
* @{
*/
2019-10-30 04:52:31 -07:00
#ifndef HAL_SRAM_H_
#define HAL_SRAM_H_
2014-10-18 06:34:12 -07:00
2019-10-30 04:52:31 -07:00
#if (HAL_USE_SRAM == TRUE) || defined(__DOXYGEN__)
2014-10-18 06:34:12 -07:00
/*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
/**
* @name Configuration options
* @{
*/
/**
* @brief SRAM driver enable switch.
* @details If set to @p TRUE the support for SRAM1 is included.
*/
2019-10-30 04:52:31 -07:00
#if !defined(STM32_SRAM_USE_SRAM1) || defined(__DOXYGEN__)
#define STM32_SRAM_USE_SRAM1 FALSE
2014-10-18 06:34:12 -07:00
#endif
/**
* @brief SRAM driver enable switch.
* @details If set to @p TRUE the support for SRAM2 is included.
*/
2019-10-30 04:52:31 -07:00
#if !defined(STM32_SRAM_USE_SRAM2) || defined(__DOXYGEN__)
#define STM32_SRAM_USE_SRAM2 FALSE
2014-10-18 06:34:12 -07:00
#endif
/**
* @brief SRAM driver enable switch.
* @details If set to @p TRUE the support for SRAM3 is included.
*/
2019-10-30 04:52:31 -07:00
#if !defined(STM32_SRAM_USE_SRAM3) || defined(__DOXYGEN__)
#define STM32_SRAM_USE_SRAM3 FALSE
2014-10-18 06:34:12 -07:00
#endif
/**
* @brief SRAM driver enable switch.
* @details If set to @p TRUE the support for SRAM4 is included.
*/
2019-10-30 04:52:31 -07:00
#if !defined(STM32_SRAM_USE_SRAM4) || defined(__DOXYGEN__)
#define STM32_SRAM_USE_SRAM4 FALSE
2014-10-18 06:34:12 -07:00
#endif
/** @} */
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
2019-10-30 04:52:31 -07:00
#if !STM32_SRAM_USE_SRAM1 && !STM32_SRAM_USE_SRAM2 && \
!STM32_SRAM_USE_SRAM3 && !STM32_SRAM_USE_SRAM4
2014-10-18 06:34:12 -07:00
#error "SRAM driver activated but no SRAM peripheral assigned"
#endif
2019-10-30 04:52:31 -07:00
#if (STM32_SRAM_USE_SRAM1 || STM32_SRAM_USE_SRAM2 || \
STM32_SRAM_USE_SRAM3 || STM32_SRAM_USE_SRAM4) && !STM32_HAS_FSMC
2014-10-18 06:34:12 -07:00
#error "FSMC not present in the selected device"
#endif
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
/**
* @brief Driver state machine possible states.
*/
typedef enum {
SRAM_UNINIT = 0, /**< Not initialized. */
SRAM_STOP = 1, /**< Stopped. */
SRAM_READY = 2, /**< Ready. */
} sramstate_t;
/**
* @brief Type of a structure representing an NAND driver.
*/
typedef struct SRAMDriver SRAMDriver;
/**
* @brief Driver configuration structure.
* @note It could be empty on some architectures.
* @note Some bits in BCR register will be forced by driver.
2014-10-18 06:34:12 -07:00
*/
typedef struct {
uint32_t bcr;
uint32_t btr;
uint32_t bwtr;
2014-10-18 06:34:12 -07:00
} SRAMConfig;
/**
* @brief Structure representing an NAND driver.
*/
struct SRAMDriver {
/**
* @brief Driver state.
*/
sramstate_t state;
/**
* @brief Pointer to the FSMC SRAM registers block.
*/
2019-10-30 04:52:31 -07:00
FSMC_SRAM_TypeDef *sram;
2014-10-18 06:34:12 -07:00
};
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
2019-10-30 04:52:31 -07:00
#if STM32_SRAM_USE_SRAM1 && !defined(__DOXYGEN__)
2014-10-18 06:34:12 -07:00
extern SRAMDriver SRAMD1;
#endif
2019-10-30 04:52:31 -07:00
#if STM32_SRAM_USE_SRAM2 && !defined(__DOXYGEN__)
2014-10-18 06:34:12 -07:00
extern SRAMDriver SRAMD2;
#endif
2019-10-30 04:52:31 -07:00
#if STM32_SRAM_USE_SRAM3 && !defined(__DOXYGEN__)
2014-10-18 06:34:12 -07:00
extern SRAMDriver SRAMD3;
#endif
2019-10-30 04:52:31 -07:00
#if STM32_SRAM_USE_SRAM4 && !defined(__DOXYGEN__)
2014-10-18 06:34:12 -07:00
extern SRAMDriver SRAMD4;
#endif
#ifdef __cplusplus
extern "C" {
#endif
2019-10-30 04:52:31 -07:00
void sramInit(void);
void sramObjectInit(SRAMDriver *sdramp);
void sramStart(SRAMDriver *sramp, const SRAMConfig *cfgp);
void sramStop(SRAMDriver *sramp);
2014-10-18 06:34:12 -07:00
#ifdef __cplusplus
}
#endif
2019-10-30 04:52:31 -07:00
#endif /* HAL_USE_SRAM */
2014-10-18 06:34:12 -07:00
2019-10-30 04:52:31 -07:00
#endif /* HAL_SRAM_H_ */
2014-10-18 06:34:12 -07:00
/** @} */