Added support for v4.2 boards
[SCSI2SD.git] / software / SCSI2SD / v4 / SCSI2SD.cydsn / Generated_Source / PSoC5 / CyFlash.h
1 /*******************************************************************************
2 * File Name: CyFlash.h
3 * Version 4.0
4 *
5 *  Description:
6 *   Provides the function definitions for the FLASH/EEPROM.
7 *
8 *  Note:
9 *   Documentation of the API's in this file is located in the
10 *   System Reference Guide provided with PSoC Creator.
11 *
12 ********************************************************************************
13 * Copyright 2008-2013, Cypress Semiconductor Corporation.  All rights reserved.
14 * You may use this file only in accordance with the license, terms, conditions,
15 * disclaimers, and limitations in the end user license agreement accompanying
16 * the software package with which this file was provided.
17 *******************************************************************************/
18
19 #if !defined(CY_BOOT_CYFLASH_H)
20 #define CY_BOOT_CYFLASH_H
21
22 #include "cydevice_trm.h"
23 #include "cytypes.h"
24 #include "CyLib.h"
25 #include "CySpc.h"
26
27 #define CY_FLASH_DIE_TEMP_DATA_SIZE      (2u)    /* Die temperature data size */
28
29 extern uint8 dieTemperature[CY_FLASH_DIE_TEMP_DATA_SIZE];
30
31
32 /***************************************
33 *    API Constants
34 ***************************************/
35
36 #define CY_FLASH_BASE               (CYDEV_FLASH_BASE)
37 #define CY_FLASH_SIZE               (CYDEV_FLS_SIZE)
38 #define CY_FLASH_SIZEOF_ARRAY       (CYDEV_FLS_SECTOR_SIZE)
39 #define CY_FLASH_SIZEOF_ROW         (CYDEV_FLS_ROW_SIZE)
40 #define CY_FLASH_SIZEOF_ECC_ROW     (CYDEV_ECC_ROW_SIZE)
41 #define CY_FLASH_NUMBER_ROWS        (CYDEV_FLS_SIZE / CYDEV_FLS_ROW_SIZE)
42 #define CY_FLASH_NUMBER_ARRAYS      (CYDEV_FLS_SIZE / CYDEV_FLS_SECTOR_SIZE)
43
44 #define CY_EEPROM_BASE              (CYDEV_EE_BASE)
45 #define CY_EEPROM_SIZE              (CYDEV_EE_SIZE)
46 #define CY_EEPROM_SIZEOF_ARRAY      (CYDEV_EEPROM_SECTOR_SIZE)
47 #define CY_EEPROM_SIZEOF_ROW        (CYDEV_EEPROM_ROW_SIZE)
48 #define CY_EEPROM_NUMBER_ROWS       (EEPROM_SIZE / CYDEV_EEPROM_ROW_SIZE)
49 #define CY_EEPROM_NUMBER_ARRAYS     (CYDEV_EE_SIZE / CY_EEPROM_SIZEOF_ARRAY)
50
51
52 #if !defined(CYDEV_FLS_BASE)
53     #define CYDEV_FLS_BASE    CYDEV_FLASH_BASE
54 #endif  /* !defined(CYDEV_FLS_BASE) */
55
56
57 /***************************************
58 *     Function Prototypes
59 ***************************************/
60
61 /* Flash Functions */
62 void     CyFlash_Start(void);
63 void     CyFlash_Stop(void);
64 cystatus CySetTemp(void);
65 cystatus CySetFlashEEBuffer(uint8 * buffer);
66 cystatus CyWriteRowFull(uint8 arrayId, uint16 rowNumber, const uint8 * rowData, uint16 rowSize) \
67             ;
68 cystatus CyWriteRowData(uint8 arrayId, uint16 rowAddress, const uint8 * rowData);
69
70 #if ((CYDEV_ECC_ENABLE == 0u) && (CYDEV_CONFIGURATION_ECC == 0u))
71     cystatus CyWriteRowConfig(uint8 arrayId, uint16 rowAddress, const uint8 * rowECC) \
72             ;
73 #endif  /* ((CYDEV_ECC_ENABLE == 0u) && (CYDEV_CONFIGURATION_ECC == 0u)) */
74
75 void CyFlash_SetWaitCycles(uint8 freq) ;
76
77 /* EEPROM Functions */
78 void CyEEPROM_Start(void) ;
79 void CyEEPROM_Stop(void) ;
80
81 void CyEEPROM_ReadReserve(void) ;
82 void CyEEPROM_ReadRelease(void) ;
83
84
85 /***************************************
86 *     Registers
87 ***************************************/
88 /* Active Power Mode Configuration Register 12 */
89 #define CY_FLASH_PM_ACT_EEFLASH_REG         (* (reg8 *) CYREG_PM_ACT_CFG12)
90 #define CY_FLASH_PM_ACT_EEFLASH_PTR         (  (reg8 *) CYREG_PM_ACT_CFG12)
91
92 /* Alternate Active Power Mode Configuration Register 12 */
93 #define CY_FLASH_PM_ALTACT_EEFLASH_REG      (* (reg8 *) CYREG_PM_STBY_CFG12)
94 #define CY_FLASH_PM_ALTACT_EEFLASH_PTR      (  (reg8 *) CYREG_PM_STBY_CFG12)
95
96
97 /* Cache Control Register */
98 #if (CY_PSOC3)
99
100     #define CY_FLASH_CONTROL_REG                (* (reg8 *) CYREG_CACHE_CR )
101     #define CY_FLASH_CONTROL_PTR                (  (reg8 *) CYREG_CACHE_CR )
102
103 #else
104
105     #define CY_FLASH_CONTROL_REG                (* (reg8 *) CYREG_CACHE_CC_CTL )
106     #define CY_FLASH_CONTROL_PTR                (  (reg8 *) CYREG_CACHE_CC_CTL )
107
108 #endif  /* (CY_PSOC3) */
109
110
111 /* EEPROM Status & Control Register */
112 #define CY_FLASH_EE_SCR_REG                     (* (reg8 *) CYREG_SPC_EE_SCR)
113 #define CY_FLASH_EE_SCR_PTR                     (  (reg8 *) CYREG_SPC_EE_SCR)
114
115
116
117 /***************************************
118 *     Register Constants
119 ***************************************/
120
121 /* Power Mode Masks */
122 #define CY_FLASH_PM_EE_MASK                 (0x10u)
123 #define CY_FLASH_PM_FLASH_MASK              (0x01u)
124
125 /* Frequency Constants */
126 #if (CY_PSOC3)
127
128     #define CY_FLASH_LESSER_OR_EQUAL_22MHz      (0x01u)
129     #define CY_FLASH_LESSER_OR_EQUAL_44MHz      (0x02u)
130     #define CY_FLASH_GREATER_44MHz              (0x03u)
131
132 #endif  /* (CY_PSOC3) */
133
134 #if (CY_PSOC5)
135
136     #define CY_FLASH_LESSER_OR_EQUAL_16MHz      (0x01u)
137     #define CY_FLASH_LESSER_OR_EQUAL_33MHz      (0x02u)
138     #define CY_FLASH_LESSER_OR_EQUAL_50MHz      (0x03u)
139     #define CY_FLASH_GREATER_51MHz              (0x00u)
140
141 #endif  /* (CY_PSOC5) */
142
143 #define CY_FLASH_CYCLES_MASK_SHIFT              (0x06u)
144 #define CY_FLASH_CYCLES_MASK                    ((uint8)(0x03u << (CY_FLASH_CYCLES_MASK_SHIFT)))
145 #define CY_FLASH_EE_STARTUP_DELAY               (5u)
146
147 #define CY_FLASH_EE_SCR_AHB_EE_REQ              (0x01u)
148 #define CY_FLASH_EE_SCR_AHB_EE_ACK              (0x02u)
149
150
151
152 /* Default values for getting temperature. */
153
154 #define CY_TEMP_NUMBER_OF_SAMPLES               (0x1u)
155 #define CY_TEMP_TIMER_PERIOD                    (0xFFFu)
156 #define CY_TEMP_CLK_DIV_SELECT                  (0x4u)
157 #define CY_TEMP_NUM_SAMPLES                     (1 << (CY_TEMP_NUMBER_OF_SAMPLES))
158 #define CY_SPC_CLK_PERIOD                       (120u)      /* nS */
159 #define CY_SYS_ns_PER_TICK                      (1000u)
160 #define CY_FRM_EXEC_TIME                        (1000u)     /* nS */
161
162 #define CY_GET_TEMP_TIME                        ((1 << (CY_TEMP_NUM_SAMPLES + 1)) * \
163                                                     (CY_SPC_CLK_PERIOD * CY_TEMP_CLK_DIV_SELECT) * \
164                                                     CY_TEMP_TIMER_PERIOD + CY_FRM_EXEC_TIME)
165
166 #define CY_TEMP_MAX_WAIT                        ((CY_GET_TEMP_TIME) / CY_SYS_ns_PER_TICK)    /* In system ticks. */
167
168
169 /*******************************************************************************
170 * Following code are OBSOLETE and must not be used starting from cy_boot 3.0
171 *******************************************************************************/
172 #define FLASH_SIZE                  (CY_FLASH_SIZE)
173 #define FLASH_SIZEOF_SECTOR         (CY_FLASH_SIZEOF_ARRAY)
174 #define FLASH_NUMBER_ROWS           (CY_FLASH_NUMBER_ROWS)
175 #define FLASH_NUMBER_SECTORS        (CY_FLASH_NUMBER_ARRAYS)
176 #define EEPROM_SIZE                 (CY_EEPROM_SIZE)
177 #define EEPROM_SIZEOF_SECTOR        (CY_EEPROM_SIZEOF_ARRAY)
178 #define EEPROM_NUMBER_ROWS          (CY_EEPROM_NUMBER_ROWS)
179 #define EEPROM_NUMBER_SECTORS       (CY_EEPROM_NUMBER_ARRAYS)
180 #define CY_EEPROM_NUMBER_SECTORS    (CY_EEPROM_NUMBER_ARRAYS)
181 #define CY_EEPROM_SIZEOF_SECTOR     (CY_EEPROM_SIZEOF_ARRAY)
182
183
184 /*******************************************************************************
185 * Following code are OBSOLETE and must not be used starting from cy_boot 3.30
186 *******************************************************************************/
187 #define FLASH_CYCLES_PTR            (CY_FLASH_CONTROL_PTR)
188
189 #define TEMP_NUMBER_OF_SAMPLES      (CY_TEMP_NUMBER_OF_SAMPLES)
190 #define TEMP_TIMER_PERIOD           (CY_TEMP_TIMER_PERIOD)
191 #define TEMP_CLK_DIV_SELECT         (CY_TEMP_CLK_DIV_SELECT)
192 #define NUM_SAMPLES                 (CY_TEMP_NUM_SAMPLES)
193 #define SPC_CLK_PERIOD              (CY_SPC_CLK_PERIOD)
194 #define FRM_EXEC_TIME               (CY_FRM_EXEC_TIME)
195 #define GET_TEMP_TIME               (CY_GET_TEMP_TIME)
196 #define TEMP_MAX_WAIT               (CY_TEMP_MAX_WAIT)
197
198 #define ECC_ADDR                    (0x80u)
199
200
201 #define PM_ACT_EE_PTR           (CY_FLASH_PM_ACT_EEFLASH_PTR)
202 #define PM_ACT_FLASH_PTR        (CY_FLASH_PM_ACT_EEFLASH_PTR)
203
204 #define PM_STBY_EE_PTR          (CY_FLASH_PM_ALTACT_EEFLASH_PTR)
205 #define PM_STBY_FLASH_PTR       (CY_FLASH_PM_ALTACT_EEFLASH_PTR)
206
207 #define PM_EE_MASK              (CY_FLASH_PM_EE_MASK)
208 #define PM_FLASH_MASK           (CY_FLASH_PM_FLASH_MASK)
209
210 #define FLASH_CYCLES_MASK_SHIFT     (CY_FLASH_CYCLES_MASK_SHIFT)
211 #define FLASH_CYCLES_MASK           (CY_FLASH_CYCLES_MASK)
212
213
214 #if (CY_PSOC3)
215
216     #define LESSER_OR_EQUAL_22MHz   (CY_FLASH_LESSER_OR_EQUAL_22MHz)
217     #define LESSER_OR_EQUAL_44MHz   (CY_FLASH_LESSER_OR_EQUAL_44MHz)
218     #define GREATER_44MHz           (CY_FLASH_GREATER_44MHz)
219
220 #endif  /* (CY_PSOC3) */
221
222 #if (CY_PSOC5)
223
224     #define LESSER_OR_EQUAL_16MHz   (CY_FLASH_LESSER_OR_EQUAL_16MHz)
225     #define LESSER_OR_EQUAL_33MHz   (CY_FLASH_LESSER_OR_EQUAL_33MHz)
226     #define LESSER_OR_EQUAL_50MHz   (CY_FLASH_LESSER_OR_EQUAL_50MHz)
227     #define LESSER_OR_EQUAL_67MHz   (CY_FLASH_LESSER_OR_EQUAL_67MHz)
228     #define GREATER_67MHz           (CY_FLASH_GREATER_67MHz)
229     #define GREATER_51MHz           (CY_FLASH_GREATER_51MHz)
230
231 #endif  /* (CY_PSOC5) */
232
233 #define AHUB_EE_REQ_ACK_PTR         (CY_FLASH_EE_SCR_PTR)
234
235
236 #endif  /* (CY_BOOT_CYFLASH_H) */
237
238
239 /* [] END OF FILE */