2 ******************************************************************************
3 * @file stm32f1xx_hal_pccard.h
4 * @author MCD Application Team
7 * @brief Header file of PCCARD HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F1xx_HAL_PCCARD_H
40 #define __STM32F1xx_HAL_PCCARD_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f1xx_ll_fsmc.h"
49 /** @addtogroup STM32F1xx_HAL_Driver
53 #if defined (STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG)
54 /** @addtogroup PCCARD
58 /** @addtogroup PCCARD_Private_Constants
62 #define PCCARD_DEVICE_ADDRESS FSMC_BANK4
63 #define PCCARD_ATTRIBUTE_SPACE_ADDRESS ((uint32_t)(FSMC_BANK4 + 0x08000000U)) /* Attribute space size to @0x9BFF FFFF */
64 #define PCCARD_COMMON_SPACE_ADDRESS PCCARD_DEVICE_ADDRESS /* Common space size to @0x93FF FFFF */
65 #define PCCARD_IO_SPACE_ADDRESS ((uint32_t)(FSMC_BANK4 + 0x0C000000U)) /* IO space size to @0x9FFF FFFF */
66 #define PCCARD_IO_SPACE_PRIMARY_ADDR ((uint32_t)(FSMC_BANK4 + 0x0C0001F0U)) /* IO space size to @0x9FFF FFFF */
68 /* Compact Flash-ATA registers description */
69 #define ATA_DATA ((uint8_t)0x00) /* Data register */
70 #define ATA_SECTOR_COUNT ((uint8_t)0x02) /* Sector Count register */
71 #define ATA_SECTOR_NUMBER ((uint8_t)0x03) /* Sector Number register */
72 #define ATA_CYLINDER_LOW ((uint8_t)0x04) /* Cylinder low register */
73 #define ATA_CYLINDER_HIGH ((uint8_t)0x05) /* Cylinder high register */
74 #define ATA_CARD_HEAD ((uint8_t)0x06) /* Card/Head register */
75 #define ATA_STATUS_CMD ((uint8_t)0x07) /* Status(read)/Command(write) register */
76 #define ATA_STATUS_CMD_ALTERNATE ((uint8_t)0x0E) /* Alternate Status(read)/Command(write) register */
77 #define ATA_COMMON_DATA_AREA ((uint16_t)0x0400) /* Start of data area (for Common access only!) */
78 #define ATA_CARD_CONFIGURATION ((uint16_t)0x0202) /* Card Configuration and Status Register */
80 /* Compact Flash-ATA commands */
81 #define ATA_READ_SECTOR_CMD ((uint8_t)0x20)
82 #define ATA_WRITE_SECTOR_CMD ((uint8_t)0x30)
83 #define ATA_ERASE_SECTOR_CMD ((uint8_t)0xC0)
84 #define ATA_IDENTIFY_CMD ((uint8_t)0xEC)
86 /* Compact Flash status */
87 #define PCCARD_TIMEOUT_ERROR ((uint8_t)0x60)
88 #define PCCARD_BUSY ((uint8_t)0x80)
89 #define PCCARD_PROGR ((uint8_t)0x01)
90 #define PCCARD_READY ((uint8_t)0x40)
92 #define PCCARD_SECTOR_SIZE 255U /* In half words */
95 /* Compact Flash redefinition */
96 #define HAL_CF_Read_ID HAL_PCCARD_Read_ID
97 #define HAL_CF_Write_Sector HAL_PCCARD_Write_Sector
98 #define HAL_CF_Read_Sector HAL_PCCARD_Read_Sector
99 #define HAL_CF_Erase_Sector HAL_PCCARD_Erase_Sector
100 #define HAL_CF_Reset HAL_PCCARD_Reset
102 #define HAL_CF_GetStatus HAL_PCCARD_GetStatus
103 #define HAL_CF_ReadStatus HAL_PCCARD_ReadStatus
105 #define CF_SUCCESS HAL_PCCARD_STATUS_SUCCESS
106 #define CF_ONGOING HAL_PCCARD_STATUS_ONGOING
107 #define CF_ERROR HAL_PCCARD_STATUS_ERROR
108 #define CF_TIMEOUT HAL_PCCARD_STATUS_TIMEOUT
109 #define CF_StatusTypedef HAL_PCCARD_StatusTypeDef
111 #define CF_DEVICE_ADDRESS PCCARD_DEVICE_ADDRESS
112 #define CF_ATTRIBUTE_SPACE_ADDRESS PCCARD_ATTRIBUTE_SPACE_ADDRESS
113 #define CF_COMMON_SPACE_ADDRESS PCCARD_COMMON_SPACE_ADDRESS
114 #define CF_IO_SPACE_ADDRESS PCCARD_IO_SPACE_ADDRESS
115 #define CF_IO_SPACE_PRIMARY_ADDR PCCARD_IO_SPACE_PRIMARY_ADDR
117 #define CF_TIMEOUT_ERROR PCCARD_TIMEOUT_ERROR
118 #define CF_BUSY PCCARD_BUSY
119 #define CF_PROGR PCCARD_PROGR
120 #define CF_READY PCCARD_READY
122 #define CF_SECTOR_SIZE PCCARD_SECTOR_SIZE
128 /* Exported typedef ----------------------------------------------------------*/
129 /** @defgroup PCCARD_Exported_Types PCCARD Exported Types
134 * @brief HAL PCCARD State structures definition
138 HAL_PCCARD_STATE_RESET
= 0x00U
, /*!< PCCARD peripheral not yet initialized or disabled */
139 HAL_PCCARD_STATE_READY
= 0x01U
, /*!< PCCARD peripheral ready */
140 HAL_PCCARD_STATE_BUSY
= 0x02U
, /*!< PCCARD peripheral busy */
141 HAL_PCCARD_STATE_ERROR
= 0x04U
/*!< PCCARD peripheral error */
142 }HAL_PCCARD_StateTypeDef
;
146 HAL_PCCARD_STATUS_SUCCESS
= 0U,
147 HAL_PCCARD_STATUS_ONGOING
,
148 HAL_PCCARD_STATUS_ERROR
,
149 HAL_PCCARD_STATUS_TIMEOUT
150 }HAL_PCCARD_StatusTypeDef
;
153 * @brief FSMC_PCCARD handle Structure definition
157 FSMC_PCCARD_TypeDef
*Instance
; /*!< Register base address for PCCARD device */
159 FSMC_PCCARD_InitTypeDef Init
; /*!< PCCARD device control configuration parameters */
161 __IO HAL_PCCARD_StateTypeDef State
; /*!< PCCARD device access state */
163 HAL_LockTypeDef Lock
; /*!< PCCARD Lock */
165 }PCCARD_HandleTypeDef
;
170 /* Exported constants --------------------------------------------------------*/
171 /* Exported macro ------------------------------------------------------------*/
172 /** @defgroup PCCARD_Exported_Macros PCCARD Exported Macros
176 /** @brief Reset PCCARD handle state
177 * @param __HANDLE__: specifies the PCCARD handle.
180 #define __HAL_PCCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_PCCARD_STATE_RESET)
185 /* Exported functions --------------------------------------------------------*/
186 /** @addtogroup PCCARD_Exported_Functions PCCARD Exported Functions
190 /** @addtogroup PCCARD_Exported_Functions_Group1 Initialization and de-initialization functions
193 /* Initialization/de-initialization functions **********************************/
194 HAL_StatusTypeDef
HAL_PCCARD_Init(PCCARD_HandleTypeDef
*hpccard
, FSMC_NAND_PCC_TimingTypeDef
*ComSpaceTiming
, FSMC_NAND_PCC_TimingTypeDef
*AttSpaceTiming
, FSMC_NAND_PCC_TimingTypeDef
*IOSpaceTiming
);
195 HAL_StatusTypeDef
HAL_PCCARD_DeInit(PCCARD_HandleTypeDef
*hpccard
);
196 void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef
*hpccard
);
197 void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef
*hpccard
);
202 /** @addtogroup PCCARD_Exported_Functions_Group2 Input Output and memory functions
205 /* IO operation functions *****************************************************/
206 HAL_StatusTypeDef
HAL_PCCARD_Read_ID(PCCARD_HandleTypeDef
*hpccard
, uint8_t CompactFlash_ID
[], uint8_t *pStatus
);
207 HAL_StatusTypeDef
HAL_PCCARD_Write_Sector(PCCARD_HandleTypeDef
*hpccard
, uint16_t *pBuffer
, uint16_t SectorAddress
, uint8_t *pStatus
);
208 HAL_StatusTypeDef
HAL_PCCARD_Read_Sector(PCCARD_HandleTypeDef
*hpccard
, uint16_t *pBuffer
, uint16_t SectorAddress
, uint8_t *pStatus
);
209 HAL_StatusTypeDef
HAL_PCCARD_Erase_Sector(PCCARD_HandleTypeDef
*hpccard
, uint16_t SectorAddress
, uint8_t *pStatus
);
210 HAL_StatusTypeDef
HAL_PCCARD_Reset(PCCARD_HandleTypeDef
*hpccard
);
211 void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef
*hpccard
);
212 void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef
*hpccard
);
218 /** @defgroup PCCARD_Exported_Functions_Group3 Peripheral State functions
221 /* PCCARD State functions *******************************************************/
222 HAL_PCCARD_StateTypeDef
HAL_PCCARD_GetState(PCCARD_HandleTypeDef
*hpccard
);
223 HAL_PCCARD_StatusTypeDef
HAL_PCCARD_GetStatus(PCCARD_HandleTypeDef
*hpccard
);
224 HAL_PCCARD_StatusTypeDef
HAL_PCCARD_ReadStatus(PCCARD_HandleTypeDef
*hpccard
);
237 #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */
246 #endif /* __STM32F1xx_HAL_PCCARD_H */
248 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/