A simple 128x32 graphical LCD program to quickstart with LCD on ARM mbed IoT Starter Kit. This requires mbed Applciation Shield with FRDM-K64F platform.

Dependencies:   C12832

Committer:
tushki7
Date:
Sun Apr 12 15:45:52 2015 +0000
Revision:
1:eb68c94a8ee5
Parent:
0:60d829a0353a
A simple 128x32 LCD program with ARM mbed IoT Starter Kit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tushki7 0:60d829a0353a 1 /**
tushki7 0:60d829a0353a 2 ******************************************************************************
tushki7 0:60d829a0353a 3 * @file stm32f3xx_hal_nand.h
tushki7 0:60d829a0353a 4 * @author MCD Application Team
tushki7 0:60d829a0353a 5 * @version V1.1.0
tushki7 0:60d829a0353a 6 * @date 12-Sept-2014
tushki7 0:60d829a0353a 7 * @brief Header file of NAND HAL module.
tushki7 0:60d829a0353a 8 ******************************************************************************
tushki7 0:60d829a0353a 9 * @attention
tushki7 0:60d829a0353a 10 *
tushki7 0:60d829a0353a 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
tushki7 0:60d829a0353a 12 *
tushki7 0:60d829a0353a 13 * Redistribution and use in source and binary forms, with or without modification,
tushki7 0:60d829a0353a 14 * are permitted provided that the following conditions are met:
tushki7 0:60d829a0353a 15 * 1. Redistributions of source code must retain the above copyright notice,
tushki7 0:60d829a0353a 16 * this list of conditions and the following disclaimer.
tushki7 0:60d829a0353a 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
tushki7 0:60d829a0353a 18 * this list of conditions and the following disclaimer in the documentation
tushki7 0:60d829a0353a 19 * and/or other materials provided with the distribution.
tushki7 0:60d829a0353a 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
tushki7 0:60d829a0353a 21 * may be used to endorse or promote products derived from this software
tushki7 0:60d829a0353a 22 * without specific prior written permission.
tushki7 0:60d829a0353a 23 *
tushki7 0:60d829a0353a 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
tushki7 0:60d829a0353a 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
tushki7 0:60d829a0353a 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
tushki7 0:60d829a0353a 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
tushki7 0:60d829a0353a 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
tushki7 0:60d829a0353a 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
tushki7 0:60d829a0353a 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
tushki7 0:60d829a0353a 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
tushki7 0:60d829a0353a 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
tushki7 0:60d829a0353a 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
tushki7 0:60d829a0353a 34 *
tushki7 0:60d829a0353a 35 ******************************************************************************
tushki7 0:60d829a0353a 36 */
tushki7 0:60d829a0353a 37
tushki7 0:60d829a0353a 38 /* Define to prevent recursive inclusion -------------------------------------*/
tushki7 0:60d829a0353a 39 #ifndef __STM32F3xx_HAL_NAND_H
tushki7 0:60d829a0353a 40 #define __STM32F3xx_HAL_NAND_H
tushki7 0:60d829a0353a 41
tushki7 0:60d829a0353a 42 #ifdef __cplusplus
tushki7 0:60d829a0353a 43 extern "C" {
tushki7 0:60d829a0353a 44 #endif
tushki7 0:60d829a0353a 45
tushki7 0:60d829a0353a 46 /* Includes ------------------------------------------------------------------*/
tushki7 0:60d829a0353a 47 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx)
tushki7 0:60d829a0353a 48 #include "stm32f3xx_ll_fmc.h"
tushki7 0:60d829a0353a 49 #endif /* STM32F302xE || STM32F303xE || STM32F398xx */
tushki7 0:60d829a0353a 50
tushki7 0:60d829a0353a 51 /** @addtogroup STM32F3xx_HAL_Driver
tushki7 0:60d829a0353a 52 * @{
tushki7 0:60d829a0353a 53 */
tushki7 0:60d829a0353a 54
tushki7 0:60d829a0353a 55 /** @addtogroup NAND
tushki7 0:60d829a0353a 56 * @{
tushki7 0:60d829a0353a 57 */
tushki7 0:60d829a0353a 58
tushki7 0:60d829a0353a 59 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx)
tushki7 0:60d829a0353a 60
tushki7 0:60d829a0353a 61 /* Exported typedef ----------------------------------------------------------*/
tushki7 0:60d829a0353a 62 /* Exported types ------------------------------------------------------------*/
tushki7 0:60d829a0353a 63 /** @defgroup NAND_Exported_Types NAND Exported Types
tushki7 0:60d829a0353a 64 * @{
tushki7 0:60d829a0353a 65 */
tushki7 0:60d829a0353a 66
tushki7 0:60d829a0353a 67 /**
tushki7 0:60d829a0353a 68 * @brief HAL NAND State structures definition
tushki7 0:60d829a0353a 69 */
tushki7 0:60d829a0353a 70 typedef enum
tushki7 0:60d829a0353a 71 {
tushki7 0:60d829a0353a 72 HAL_NAND_STATE_RESET = 0x00, /*!< NAND not yet initialized or disabled */
tushki7 0:60d829a0353a 73 HAL_NAND_STATE_READY = 0x01, /*!< NAND initialized and ready for use */
tushki7 0:60d829a0353a 74 HAL_NAND_STATE_BUSY = 0x02, /*!< NAND internal process is ongoing */
tushki7 0:60d829a0353a 75 HAL_NAND_STATE_ERROR = 0x03 /*!< NAND error state */
tushki7 0:60d829a0353a 76 }HAL_NAND_StateTypeDef;
tushki7 0:60d829a0353a 77
tushki7 0:60d829a0353a 78 /**
tushki7 0:60d829a0353a 79 * @brief NAND Memory electronic signature Structure definition
tushki7 0:60d829a0353a 80 */
tushki7 0:60d829a0353a 81 typedef struct
tushki7 0:60d829a0353a 82 {
tushki7 0:60d829a0353a 83 /*<! NAND memory electronic signature maker and device IDs */
tushki7 0:60d829a0353a 84
tushki7 0:60d829a0353a 85 uint8_t Maker_Id;
tushki7 0:60d829a0353a 86
tushki7 0:60d829a0353a 87 uint8_t Device_Id;
tushki7 0:60d829a0353a 88
tushki7 0:60d829a0353a 89 uint8_t Third_Id;
tushki7 0:60d829a0353a 90
tushki7 0:60d829a0353a 91 uint8_t Fourth_Id;
tushki7 0:60d829a0353a 92 }NAND_IDTypeDef;
tushki7 0:60d829a0353a 93
tushki7 0:60d829a0353a 94 /**
tushki7 0:60d829a0353a 95 * @brief NAND Memory address Structure definition
tushki7 0:60d829a0353a 96 */
tushki7 0:60d829a0353a 97 typedef struct
tushki7 0:60d829a0353a 98 {
tushki7 0:60d829a0353a 99 uint16_t Page; /*!< NAND memory Page address */
tushki7 0:60d829a0353a 100
tushki7 0:60d829a0353a 101 uint16_t Zone; /*!< NAND memory Zone address */
tushki7 0:60d829a0353a 102
tushki7 0:60d829a0353a 103 uint16_t Block; /*!< NAND memory Block address */
tushki7 0:60d829a0353a 104
tushki7 0:60d829a0353a 105 }NAND_AddressTypedef;
tushki7 0:60d829a0353a 106
tushki7 0:60d829a0353a 107 /**
tushki7 0:60d829a0353a 108 * @brief NAND Memory info Structure definition
tushki7 0:60d829a0353a 109 */
tushki7 0:60d829a0353a 110 typedef struct
tushki7 0:60d829a0353a 111 {
tushki7 0:60d829a0353a 112 uint32_t PageSize; /*!< NAND memory page (without spare area) size measured in K. bytes */
tushki7 0:60d829a0353a 113
tushki7 0:60d829a0353a 114 uint32_t SpareAreaSize; /*!< NAND memory spare area size measured in K. bytes */
tushki7 0:60d829a0353a 115
tushki7 0:60d829a0353a 116 uint32_t BlockSize; /*!< NAND memory block size number of pages */
tushki7 0:60d829a0353a 117
tushki7 0:60d829a0353a 118 uint32_t BlockNbr; /*!< NAND memory number of blocks */
tushki7 0:60d829a0353a 119
tushki7 0:60d829a0353a 120 uint32_t ZoneSize; /*!< NAND memory zone size measured in number of blocks */
tushki7 0:60d829a0353a 121 }NAND_InfoTypeDef;
tushki7 0:60d829a0353a 122
tushki7 0:60d829a0353a 123 /**
tushki7 0:60d829a0353a 124 * @brief NAND handle Structure definition
tushki7 0:60d829a0353a 125 */
tushki7 0:60d829a0353a 126 typedef struct
tushki7 0:60d829a0353a 127 {
tushki7 0:60d829a0353a 128 FMC_NAND_TypeDef *Instance; /*!< Register base address */
tushki7 0:60d829a0353a 129
tushki7 0:60d829a0353a 130 FMC_NAND_InitTypeDef Init; /*!< NAND device control configuration parameters */
tushki7 0:60d829a0353a 131
tushki7 0:60d829a0353a 132 HAL_LockTypeDef Lock; /*!< NAND locking object */
tushki7 0:60d829a0353a 133
tushki7 0:60d829a0353a 134 __IO HAL_NAND_StateTypeDef State; /*!< NAND device access state */
tushki7 0:60d829a0353a 135
tushki7 0:60d829a0353a 136 NAND_InfoTypeDef Info; /*!< NAND characteristic information structure */
tushki7 0:60d829a0353a 137 }NAND_HandleTypeDef;
tushki7 0:60d829a0353a 138
tushki7 0:60d829a0353a 139 /**
tushki7 0:60d829a0353a 140 * @}
tushki7 0:60d829a0353a 141 */
tushki7 0:60d829a0353a 142
tushki7 0:60d829a0353a 143 /* Exported constants --------------------------------------------------------*/
tushki7 0:60d829a0353a 144 /** @defgroup NAND_Exported_Constants NAND Exported Constants
tushki7 0:60d829a0353a 145 * @{
tushki7 0:60d829a0353a 146 */
tushki7 0:60d829a0353a 147 #define NAND_DEVICE1 ((uint32_t)0x70000000)
tushki7 0:60d829a0353a 148 #define NAND_DEVICE2 ((uint32_t)0x80000000)
tushki7 0:60d829a0353a 149 #define NAND_WRITE_TIMEOUT ((uint32_t)0x01000000)
tushki7 0:60d829a0353a 150
tushki7 0:60d829a0353a 151 #define CMD_AREA ((uint32_t)(1<<16)) /* A16 = CLE high */
tushki7 0:60d829a0353a 152 #define ADDR_AREA ((uint32_t)(1<<17)) /* A17 = ALE high */
tushki7 0:60d829a0353a 153
tushki7 0:60d829a0353a 154 #define NAND_CMD_AREA_A ((uint8_t)0x00)
tushki7 0:60d829a0353a 155 #define NAND_CMD_AREA_B ((uint8_t)0x01)
tushki7 0:60d829a0353a 156 #define NAND_CMD_AREA_C ((uint8_t)0x50)
tushki7 0:60d829a0353a 157
tushki7 0:60d829a0353a 158 /* NAND memory status */
tushki7 0:60d829a0353a 159 #define NAND_VALID_ADDRESS ((uint32_t)0x00000100)
tushki7 0:60d829a0353a 160 #define NAND_INVALID_ADDRESS ((uint32_t)0x00000200)
tushki7 0:60d829a0353a 161 #define NAND_TIMEOUT_ERROR ((uint32_t)0x00000400)
tushki7 0:60d829a0353a 162 #define NAND_BUSY ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 163 #define NAND_ERROR ((uint32_t)0x00000001)
tushki7 0:60d829a0353a 164 #define NAND_READY ((uint32_t)0x00000040)
tushki7 0:60d829a0353a 165
tushki7 0:60d829a0353a 166 /**
tushki7 0:60d829a0353a 167 * @}
tushki7 0:60d829a0353a 168 */
tushki7 0:60d829a0353a 169
tushki7 0:60d829a0353a 170 /* Exported macro ------------------------------------------------------------*/
tushki7 0:60d829a0353a 171 /** @defgroup NAND_Exported_Macros NAND Exported Macros
tushki7 0:60d829a0353a 172 * @{
tushki7 0:60d829a0353a 173 */
tushki7 0:60d829a0353a 174
tushki7 0:60d829a0353a 175 /** @brief Reset NAND handle state
tushki7 0:60d829a0353a 176 * @param __HANDLE__: specifies the NAND handle.
tushki7 0:60d829a0353a 177 * @retval None
tushki7 0:60d829a0353a 178 */
tushki7 0:60d829a0353a 179 #define __HAL_NAND_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NAND_STATE_RESET)
tushki7 0:60d829a0353a 180
tushki7 0:60d829a0353a 181 /**
tushki7 0:60d829a0353a 182 * @brief NAND memory address computation.
tushki7 0:60d829a0353a 183 * @param __ADDRESS__: NAND memory address.
tushki7 0:60d829a0353a 184 * @param __HANDLE__ : NAND handle.
tushki7 0:60d829a0353a 185 * @retval NAND Raw address value
tushki7 0:60d829a0353a 186 */
tushki7 0:60d829a0353a 187 #define ARRAY_ADDRESS(__ADDRESS__ , __HANDLE__) ((__ADDRESS__)->Page + (((__ADDRESS__)->Block + (((__ADDRESS__)->Zone) * ((__HANDLE__)->Info.ZoneSize)))* ((__HANDLE__)->Info.BlockSize)))
tushki7 0:60d829a0353a 188
tushki7 0:60d829a0353a 189 /**
tushki7 0:60d829a0353a 190 * @brief NAND memory address cycling.
tushki7 0:60d829a0353a 191 * @param __ADDRESS__: NAND memory address.
tushki7 0:60d829a0353a 192 * @retval NAND address cycling value.
tushki7 0:60d829a0353a 193 */
tushki7 0:60d829a0353a 194 #define ADDR_1st_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__)& 0xFF) /* 1st addressing cycle */
tushki7 0:60d829a0353a 195 #define ADDR_2nd_CYCLE(__ADDRESS__) (uint8_t)(((__ADDRESS__)& 0xFF00) >> 8) /* 2nd addressing cycle */
tushki7 0:60d829a0353a 196 #define ADDR_3rd_CYCLE(__ADDRESS__) (uint8_t)(((__ADDRESS__)& 0xFF0000) >> 16) /* 3rd addressing cycle */
tushki7 0:60d829a0353a 197 #define ADDR_4th_CYCLE(__ADDRESS__) (uint8_t)(((__ADDRESS__)& 0xFF000000) >> 24) /* 4th addressing cycle */
tushki7 0:60d829a0353a 198 /**
tushki7 0:60d829a0353a 199 * @}
tushki7 0:60d829a0353a 200 */
tushki7 0:60d829a0353a 201
tushki7 0:60d829a0353a 202 /* Exported functions --------------------------------------------------------*/
tushki7 0:60d829a0353a 203 /** @addtogroup NAND_Exported_Functions NAND Exported Functions
tushki7 0:60d829a0353a 204 * @{
tushki7 0:60d829a0353a 205 */
tushki7 0:60d829a0353a 206
tushki7 0:60d829a0353a 207 /** @addtogroup NAND_Exported_Functions_Group1 Initialization and de-initialization functions
tushki7 0:60d829a0353a 208 * @{
tushki7 0:60d829a0353a 209 */
tushki7 0:60d829a0353a 210
tushki7 0:60d829a0353a 211 /* Initialization/de-initialization functions ********************************/
tushki7 0:60d829a0353a 212 HAL_StatusTypeDef HAL_NAND_Init(NAND_HandleTypeDef *hnand, FMC_NAND_PCC_TimingTypeDef *ComSpace_Timing, FMC_NAND_PCC_TimingTypeDef *AttSpace_Timing);
tushki7 0:60d829a0353a 213 HAL_StatusTypeDef HAL_NAND_DeInit(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 214 void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 215 void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 216 void HAL_NAND_IRQHandler(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 217 void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 218
tushki7 0:60d829a0353a 219 /**
tushki7 0:60d829a0353a 220 * @}
tushki7 0:60d829a0353a 221 */
tushki7 0:60d829a0353a 222
tushki7 0:60d829a0353a 223 /** @addtogroup NAND_Exported_Functions_Group2 Input and Output functions
tushki7 0:60d829a0353a 224 * @{
tushki7 0:60d829a0353a 225 */
tushki7 0:60d829a0353a 226
tushki7 0:60d829a0353a 227 /* IO operation functions ****************************************************/
tushki7 0:60d829a0353a 228 HAL_StatusTypeDef HAL_NAND_Read_ID(NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pNAND_ID);
tushki7 0:60d829a0353a 229 HAL_StatusTypeDef HAL_NAND_Reset(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 230 HAL_StatusTypeDef HAL_NAND_Read_Page(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumPageToRead);
tushki7 0:60d829a0353a 231 HAL_StatusTypeDef HAL_NAND_Write_Page(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumPageToWrite);
tushki7 0:60d829a0353a 232 HAL_StatusTypeDef HAL_NAND_Read_SpareArea(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumSpareAreaToRead);
tushki7 0:60d829a0353a 233 HAL_StatusTypeDef HAL_NAND_Write_SpareArea(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumSpareAreaTowrite);
tushki7 0:60d829a0353a 234 HAL_StatusTypeDef HAL_NAND_Erase_Block(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress);
tushki7 0:60d829a0353a 235 uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 236 uint32_t HAL_NAND_Address_Inc(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress);
tushki7 0:60d829a0353a 237
tushki7 0:60d829a0353a 238 /**
tushki7 0:60d829a0353a 239 * @}
tushki7 0:60d829a0353a 240 */
tushki7 0:60d829a0353a 241
tushki7 0:60d829a0353a 242 /** @addtogroup NAND_Exported_Functions_Group3 Peripheral Control functions
tushki7 0:60d829a0353a 243 * @{
tushki7 0:60d829a0353a 244 */
tushki7 0:60d829a0353a 245
tushki7 0:60d829a0353a 246 /* NAND Control functions ****************************************************/
tushki7 0:60d829a0353a 247 HAL_StatusTypeDef HAL_NAND_ECC_Enable(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 248 HAL_StatusTypeDef HAL_NAND_ECC_Disable(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 249 HAL_StatusTypeDef HAL_NAND_GetECC(NAND_HandleTypeDef *hnand, uint32_t *ECCval, uint32_t Timeout);
tushki7 0:60d829a0353a 250
tushki7 0:60d829a0353a 251 /**
tushki7 0:60d829a0353a 252 * @}
tushki7 0:60d829a0353a 253 */
tushki7 0:60d829a0353a 254
tushki7 0:60d829a0353a 255 /** @defgroup NAND_Exported_Functions_Group4 Peripheral State functions
tushki7 0:60d829a0353a 256 * @{
tushki7 0:60d829a0353a 257 */
tushki7 0:60d829a0353a 258
tushki7 0:60d829a0353a 259 /* NAND State functions *******************************************************/
tushki7 0:60d829a0353a 260 HAL_NAND_StateTypeDef HAL_NAND_GetState(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 261 uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand);
tushki7 0:60d829a0353a 262
tushki7 0:60d829a0353a 263 /**
tushki7 0:60d829a0353a 264 * @}
tushki7 0:60d829a0353a 265 */
tushki7 0:60d829a0353a 266
tushki7 0:60d829a0353a 267 /**
tushki7 0:60d829a0353a 268 * @}
tushki7 0:60d829a0353a 269 */
tushki7 0:60d829a0353a 270
tushki7 0:60d829a0353a 271 #endif /* STM32F302xE || STM32F303xE || STM32F398xx */
tushki7 0:60d829a0353a 272 /**
tushki7 0:60d829a0353a 273 * @}
tushki7 0:60d829a0353a 274 */
tushki7 0:60d829a0353a 275
tushki7 0:60d829a0353a 276 /**
tushki7 0:60d829a0353a 277 * @}
tushki7 0:60d829a0353a 278 */
tushki7 0:60d829a0353a 279
tushki7 0:60d829a0353a 280 #ifdef __cplusplus
tushki7 0:60d829a0353a 281 }
tushki7 0:60d829a0353a 282 #endif
tushki7 0:60d829a0353a 283
tushki7 0:60d829a0353a 284 #endif /* __STM32F3xx_HAL_NAND_H */
tushki7 0:60d829a0353a 285
tushki7 0:60d829a0353a 286 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/