1 /**************************************************************************//** 2 * @file spim_reg.h 3 * @version V1.00 4 * @brief SPIM register definition header file 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 * @copyright (C) 2017-2020 Nuvoton Technology Corp. All rights reserved. 8 *****************************************************************************/ 9 #ifndef __SPIM_REG_H__ 10 #define __SPIM_REG_H__ 11 12 #if defined ( __CC_ARM ) 13 #pragma anon_unions 14 #endif 15 16 /** 17 @addtogroup REGISTER Control Register 18 @{ 19 */ 20 21 /** 22 @addtogroup SPIM Serial Peripheral Interface Controller Master Mode (SPIM) 23 Memory Mapped Structure for SPIM Controller 24 @{ */ 25 26 typedef struct 27 { 28 29 30 /** 31 * @var SPIM_T::CTL0 32 * Offset: 0x00 Control and Status Register 0 33 * --------------------------------------------------------------------------------------------------- 34 * |Bits |Field |Descriptions 35 * | :----: | :----: | :---- | 36 * |[0] |CIPHOFF |Cipher Disable Control 37 * | | |0 = Cipher function Enabled. 38 * | | |1 = Cipher function Disabled. 39 * | | |Note1: If there is not any KEY1(SPIM_KEY1[31:0]) or KEY2(SPIM_KEY2[31:0]) (KEY1 is 0x0000_0000 or KEY2 is 0x0000_0000), the cipher function will be disabled automatically. 40 * | | |Note2: When CIPHOFF(SPIM_CTL0[0]) is 0, both of KEY1(SPIM_KEY1[31:0]) and KEY2(SPIM_KEY2[31:0]) do not equal to 0x0000_0000 (i.e. 41 * | | |KEY1 != 0x0000_0000 and KEY2 != 0x0000_0000), cipher encryption/decryption is enabled. 42 * | | |Note3 : When cipher encryption/decryption is enabled, please set DESELTIM (SPIM_DMMCTL[20:16]) >= 0x10. 43 * | | |When cipher encryption/decryption is disabled, please set DESELTIM(SPIM_DMMCTL[20:16]) >= 0x8. 44 * |[2] |BALEN |Balance the AHB Control Time Between Cipher Enable and Disable Control 45 * | | |When cipher is enabled, the AHB control signal will delay some time caused by the encoding or decoding calculation 46 * | | |Therefore, if set BALEN to 1, it will make the AHB signal processing time with cipher disabled be equal to that with cipher enabled. 47 * | | |Note: Only useful when cipher is disabled. 48 * |[5] |B4ADDREN |4-byte Address Mode Enable Control 49 * | | |0 = 4-byte address mode is disabled, and 3-byte address mode is enabled. 50 * | | |1 = 4-byte address mode is enabled. 51 * | | |Note: Used for DMA write mode, DMA read mode, and DMM mode. 52 * |[6] |IEN |Interrupt Enable Control 53 * | | |0 = SPIM Interrupt Disabled. 54 * | | |1 = SPIM Interrupt Enabled. 55 * |[7] |IF |Interrupt Flag 56 * | | |(1) Write Operation : 57 * | | |0 = No effect. 58 * | | |1 = Write 1 to clear. 59 * | | |(2) Read Operation : 60 * | | |0 = The transfer has not finished yet. 61 * | | |1 = The transfer has done. 62 * |[12:8] |DWIDTH |Transmit/Receive Bit Length 63 * | | |This specifies how many bits are transmitted/received in one transmit/receive transaction. 64 * | | |0x7 = 8 bits. 65 * | | |0xF = 16 bits. 66 * | | |0x17 = 24 bits. 67 * | | |0x1F = 32 bits. 68 * | | |Others = Incorrect transfer result. 69 * | | |Note1: Only used for normal I/O mode. 70 * | | |Note2: Only 8, 16, 24, and 32 bits are allowed. Other bit length will result in incorrect transfer. 71 * |[14:13] |BURSTNUM |Transmit/Receive Burst Number 72 * | | |This field specifies how many transmit/receive transactions should be executed continuously in one transfer. 73 * | | |0x0 = Only one transmit/receive transaction will be executed in one transfer. 74 * | | |0x1 = Two successive transmit/receive transactions will be executed in one transfer. 75 * | | |0x2 = Three successive transmit/receive transactions will be executed in one transfer. 76 * | | |0x3 = Four successive transmit/receive transactions will be executed in one transfer. 77 * | | |Note: Only used for normal I/O Mode. 78 * |[15] |QDIODIR |SPI Interface Direction Select for Quad/Dual Mode 79 * | | |0 = Interface signals are input. 80 * | | |1 = Interface signals are output. 81 * | | |Note: Only used for normal I/O mode. 82 * |[19:16] |SUSPITV |Suspend Interval 83 * | | |These four bits provide the configuration of suspend interval between two successive transmit/receive transactions in a transfer 84 * | | |The default value is 0x00 85 * | | |When BURSTNUM = 00, setting this field has no effect on transfer 86 * | | |The desired interval is obtained according to the following equation (from the last falling edge of current SPI clock to the first rising edge of next SPI clock): 87 * | | | (SUSPITV+2)*period of AHB clock 88 * | | | 0x0 = 2 AHB clock cycles. 89 * | | | 0x1 = 3 AHB clock cycles. 90 * | | | ...... 91 * | | | 0xE = 16 AHB clock cycles. 92 * | | | 0xF = 17 AHB clock cycles. 93 * | | | Note: Only used for normal I/O mode. 94 * |[21:20] |BITMODE |SPI Interface Bit Mode 95 * | | |0x0 = Standard mode. 96 * | | |0x1 = Dual mode. 97 * | | |0x2 = Quad mode. 98 * | | |0x3 = Reserved. 99 * | | |Note: Only used for normal I/O mode. 100 * |[23:22] |OPMODE |SPI Function Operation Mode 101 * | | |0x0 = Normal I/O mode. (Note1) (Note3) 102 * | | |0x1 = DMA write mode. (Note2) (Note3) 103 * | | |0x2 = DMA read mode. (Note3) 104 * | | |0x3 = Direct Memory Mapping mode (DMM mode) (Default). (Note4) 105 * | | |Note1 : After user uses Normal I/O mode of SPI flash controller to program the content of external SPI flash, please set CDINVAL(SPIM_CTL1[3]) to 0x1 (Set all cache data to be invalid). 106 * | | |Note2 : In DMA write mode, hardware will send just one page program command per operation 107 * | | |Users must take care of cross-page cases 108 * | | |After user uses DMA write mode of SPI flash controller to program the content of external SPI flash, please set CDINVAL(SPIM_CTL1[3]) to 0x1 (Set all cache data to be invalid). 109 * | | |Note3 : For external SPI flash with 32 MB, access address range of external SPI flash address is from 0x00000000 to 0x01FFFFFF when user uses Normal I/O mode, DMA write mode, and DMA read mode to write/read external SPI flash data 110 * | | |Please user check size of used SPI flash component to know access address range of external SPI flash. 111 * | | |Note4 : For external SPI flash with 32 MB, access address range of external SPI flash address is from 0x08000000 to 0x09FFFFFF when user uses Direct Memory mapping mode (DMM mode) to read external SPI flash data 112 * | | |Please user check size of used SPI flash component to know access address range of external SPI flash. 113 * |[31:24] |CMDCODE |Page Program Command Code (Note4) 114 * | | |(1) 0x02 = Page program (Used for DMA Write mode). 115 * | | |(2) 0x32 = Quad page program with TYPE_1 program flow (Used for DMA Write mode). (Note3) 116 * | | |(3) 0x38 = Quad page program with TYPE_2 program flow (Used for DMA Write mode). (Note3) 117 * | | |(4) 0x40 = Quad page program with TYPE_3 program flow (Used for DMA Write mode). (Note3) 118 * | | |The Others = Reserved. 119 * | | |Read Command Code : 120 * | | |(1) 0x03 = Standard Read (Used for DMA Read/DMM mode). 121 * | | |(2) 0x0B = Fast Read (Used for DMA Read/DMM mode). 122 * | | |The fast read command code "0x0B" is similar to command code of standard read "0x03" except it can operate at highest possible frequency 123 * | | |(Note2) 124 * | | |(3) 0x3B = Fast Read Dual Output (Used for DMA Read/DMM mode). 125 * | | |(4) 0xBB = Fast Read Dual I/O (Used for DMA Read/DMM mode). 126 * | | |The fast read dual I/O command code "0xBB" is similar to command code of fast read dual output "0x3B" but with capability to input the address bits two bits per clock 127 * | | |(Note2) 128 * | | |(5) 0xEB = Fast quad read (Used for DMA Read/DMM mode). 129 * | | |(6) 0xE7 = Word quad read (Used for DMA Read/DMM mode). 130 * | | |The command code of word quad read "0xE7" is similar to command code of fast quad read "0xEB" except that the lowest address bit must equal to 0 and the number of dummy cycles is less than fast quad read 131 * | | |(Note2) 132 * | | |(7) 0x0D = DTR/DDR Fast read (Used for DMA Read/DMM mode). 133 * | | |(8) 0xBD = DTR/DDR dual read (Used for DMA Read/DMM mode). 134 * | | |(9) 0xED = DTR/DDR quad read (Used for DMA Read/DMM mode). 135 * | | |The Others command codes are Reserved. 136 * | | |The DTR/DDR read commands "0x0D,0xBD,0xED" improves throughput by transferring address and data on both the falling and rising edge of SPI flash clock (SPIM_CLK) 137 * | | |It is similar to those commands "0x0B, 0xBB, 0xEB" but allows transfer of address and data on rising edge and falling edge of SPI flash output clock 138 * | | |(Note2) 139 * | | |Note1: Quad mode of SPI Flash must be enabled first by normal I/O mode before using quad page program/quad read commands. 140 * | | |Note2: See SPI flash specifications for support items. 141 * | | |Note3: For TYPE_1, TYPE_2, and TYPE_3 of page program command code, refer to Figure 7.19-3, Figure 7.19-4, and Figure 7.19-5. 142 * | | |Note4: Please disable "continuous read mode" and "burst wrap mode" before DMA write mode of SPI flash controller is used to program data of external SPI flash 143 * | | |After user uses DMA write mode of SPI flash controller to program the content of external SPI flash, please set CDINVAL(SPIM_CTL1[3]) to 0x1 (Set all cache data to be invalid). 144 * @var SPIM_T::CTL1 145 * Offset: 0x04 Control Register 1 146 * --------------------------------------------------------------------------------------------------- 147 * |Bits |Field |Descriptions 148 * | :----: | :----: | :---- | 149 * |[0] |SPIMEN |Go and Busy Status 150 * | | |(1) Write Operation : 151 * | | |0 = No effect. 152 * | | |1 = Start the transfer 153 * | | |This bit remains set during the transfer and is automatically cleared after transfer finished. 154 * | | |(2) Read Operation : 155 * | | |0 = The transfer has done. 156 * | | |1 = The transfer has not finished yet. 157 * | | |Note: All registers should be set before writing 1 to the SPIMEN bit 158 * | | |When a transfer is in progress, you should not write to any register of this peripheral. 159 * |[1] |CACHEOFF |Cache Memory Function Disable Control 160 * | | |0 = Cache memory function enable. (Default value) 161 * | | |1 = Cache memory function disable. 162 * | | |Note: When CCM mode is enabled, the cache function will be disable by hardware automatically 163 * | | |When CCM mode is disabled, the cache function can be enable or disable by user. 164 * |[2] |CCMEN |CCM (Core Coupled Memory) Mode Enable Control 165 * | | |0 = CCM mode disable. (Default value) 166 * | | |1 = CCM mode enable. 167 * | | |Note1: When CCM mode is enabled, the cache function will be disable by hardware automatically 168 * | | |When CCM mode is disabled, the cache function can be enabled or disabled by user. 169 * | | |Note2: When CCM mode is disabled, user accesses the core coupled memory by bus master 170 * | | |In this case, the SPI flash controller will send error response via HRESP bus signal to bus master. 171 * | | |Note3: When CCM mode needs to be enabled, user sets CCMEN to 1 and needs to read this register to show the current hardware status 172 * | | |When reading data of CCMEN is 1, MCU can start to read data from CCM memory space or write data to CCM memory space. 173 * |[3] |CDINVAL |Cache Data Invalid Enable Control 174 * | | |(1) Write Operation: 175 * | | |0 = No effect. 176 * | | |1 = Set all cache data to be invalid. This bit is cleared by hardware automatically. 177 * | | |(2) Read Operation : No effect 178 * | | |Note: When SPI flash memory is page erasing or whole flash erasing, please set CDINVAL to 0x1 179 * | | |After user uses normal I/O mode or DMA write mode of SPI flash controller to program or erase the content of external SPI flash, please set CDINVAL to 0x1. 180 * |[4] |SS |Slave Select Active Enable Control 181 * | | |0 = SPIM_SS is in active level. 182 * | | |1 = SPIM_SS is in inactive level (Default). 183 * | | |Note: This interface can only drive one device/slave at a given time 184 * | | |Therefore, the slave selects of the selected device must be set to its active level before starting any read or write transfer 185 * | | |Functional description of SSACTPOL(SPIM_CTL1[5]) and SS is shown in Table 2. 186 * |[5] |SSACTPOL |Slave Select Active Level 187 * | | |It defines the active level of device/slave select signal (SPIM_SS), and we show in Table 2. 188 * | | |0 = The SPIM_SS slave select signal is active low. 189 * | | |1 = The SPIM_SS slave select signal is active high. 190 * |[11:8] |IDLETIME |Idle Time Interval 191 * | | |In DMM mode, IDLETIME is set to control the minimum idle time between two SPI Flash accesses. 192 * | | |Minimum idle time = (IDLETIME + 1) * AHB clock cycle time. 193 * | | |Note1: Only used for DMM mode. 194 * | | |Note2 : AHB clock cycle time = 1/AHB clock frequency. 195 * |[31:16] |DIVIDER |Clock Divider Register 196 * | | |The value in this field is the frequency divider of the AHB clock (HCLK) to generate the serial SPI output clock "SCLK" on the output SPIM_CLK pin 197 * | | |The desired frequency is obtained according to the following equation: 198 * | | |Note1: When set DIVIDER to zero, the frequency of SPIM_CLK will be equal to the frequency of HCLK. 199 * | | |Note2: SCLK is serial SPI output clock. 200 * | | |Note3: Please check the specification of the used SPI flash component to decide the frequency of SPI flash clock. 201 * | | |Note4: For DTR/DDR read commands "0x0D, 0xBD, 0xED", the setting values of DIVIDER are only 1,2,4,8,16,32,..., where n = 0,1,2,3,4, ... 202 * @var SPIM_T::RXCLKDLY 203 * Offset: 0x0C RX Clock Delay Control Register 204 * --------------------------------------------------------------------------------------------------- 205 * |Bits |Field |Descriptions 206 * | :----: | :----: | :---- | 207 * |[7:0] |DWDELSEL |SPI flash deselect time interval of DMA write mode 208 * | | |For DMA write mode only 209 * | | |This register sets the deselect time interval of SPI flash (i.e. 210 * | | |time interval of inactive level of SPIM_SS) when SPI flash controller operates on DMA write mode 211 * | | |(Note1) 212 * | | |Deselect time interval of DMA write mode = (DWDELSEL + 1) * AHB clock cycle time (Note2). 213 * | | |Note1: Please user check the used external SPI flash component to set this register value 214 * | | |In general case, the deselect time interval of SPI flash is greater than 50 ns when SPI flash performs the program operation. 215 * | | |Note2: AHB clock cycle time = 1/AHB clock frequency. 216 * |[18:16] |RDDLYSEL |Sampling Clock Delay Selection for Received Data 217 * | | |For Normal I/O mode, DMA read mode, DMA write mode, and direct memory mapping mode 218 * | | |Determine the number of inserted delay cycles 219 * | | |Used to adjust the sampling clock of received data to latch the correct data. 220 * | | |0x0 : No delay. (Default Value) 221 * | | |0x1 : Delay 1 SPI flash clock. 222 * | | |0x2 : Delay 2 SPI flash clocks. 223 * | | |0x3 : Delay 3 SPI flash clocks. 224 * | | |... 225 * | | |0x7 : Delay 7 SPI flash clocks 226 * | | |Note : We can use manufacturer id or device id of external SPI flash component to determine the correct setting value of RDDLYSEL, and we give example as follows. 227 * | | |For example, manufacturer id and device id of external SPI flash for some vendor are 0xEF and 0x1234 separately 228 * | | |Firstly, we set RDDLYSEL to 0x0, and use read manufacturer id/device id command to read the manufacturer id of external SPI flash by using normal I/O mode (the manufacturer id is 0xEF (1110_1111) in this example). 229 * | | |If manufacturer id which reads from external SPI flash is 0xF7 (1111_0111), it denotes that manufacturer id is shifted the right by 1 bit and most significant bit (MSB) of manufacturer id is assigned to 1 230 * | | |According to manufacturer id reads from external SPI flash, we need to set RDDLYSEL to 0x1 to receive SPI flash data correctly. 231 * |[20] |RDEDGE |Sampling Clock Edge Selection for Received Data 232 * | | |For Normal I/O mode, DMA read mode, DMA write mode, and direct memory mapping mode 233 * | | |0 : Use SPI input clock rising edge to sample received data. (Default Value) 234 * | | |1 : Use SPI input clock falling edge to sample received data. 235 * @var SPIM_T::RX[4] 236 * Offset: 0x10 ~ 0x1C Data Receive Register 0 ~ 3 237 * --------------------------------------------------------------------------------------------------- 238 * |Bits |Field |Descriptions 239 * | :----: | :----: | :---- | 240 * |[31:0] |RXDAT |Data Receive Register 241 * | | |The Data Receive Registers hold the received data of the last executed transfer. 242 * | | |Number of valid RX registers is specified in SPIM_CTL0[BURSTNUM] 243 * | | |If BURSTNUM > 0, received data are held in the most significant RXDAT register first. 244 * | | |Number of valid-bit is specified in SPIM_CTL0[DWIDTH] 245 * | | |If DWIDTH is 16, 24, or 32, received data are held in the least significant byte of RXDAT register first. 246 * | | |In a byte, received data are held in the most significant bit of RXDAT register first. 247 * | | |Example 1: If SPIM_CTL0[BURSTNUM] = 0x3 and SPIM_CTL1[DWIDTH] = 0x17, received data will be held in the order SPIM_RX3[23:0], SPIM_RX2[23:0], SPIM_RX1[23:0], SPIM_RX0[23:0]. 248 * | | |Example 2: If SPIM_CTL0[BURSTNUM = 0x0 and SPIM_CTL0[DWIDTH] = 0x17, received data will be held in the order SPIM_RX0[7:0], SPIM_RX0[15:8], SPIM_RX0[23:16]. 249 * | | |Example 3: If SPIM_CTL0[BURSTNUM = 0x0 and SPIM_CTL0[DWIDTH] = 0x07, received data will be held in the order SPIM_RX0[7], SPIM_RX0[6], ..., 250 * | | |SPIM_RX0[0]. 251 * @var SPIM_T::TX[4] 252 * Offset: 0x20 ~ 0x2C Data Transmit Register 0 ~ 3 253 * --------------------------------------------------------------------------------------------------- 254 * |Bits |Field |Descriptions 255 * | :----: | :----: | :---- | 256 * |[31:0] |TXDAT |Data Transmit Register 257 * | | |The Data Transmit Registers hold the data to be transmitted in next transfer. 258 * | | |Number of valid TXDAT registers is specified in SPIM_CTL0[BURSTNUM] 259 * | | |If BURSTNUM > 0, data are transmitted in the most significant TXDAT register first. 260 * | | |Number of valid-bit is specified in SPIM_CTL0[DWIDTH] 261 * | | |If DWIDTH is 16, 24, or 32, data are transmitted in the least significant byte of TXDAT register first. 262 * | | |In a byte, data are transmitted in the most significant bit of TXDAT register first. 263 * | | |Example 1: If SPIM_CTL0[BURSTNUM] = 0x3 and SPIM_CTL1[DWIDTH] = 0x17, data will be transmitted in the order SPIM_TX3[23:0], SPIM_TX2[23:0], SPIM_TX1[23:0], SPIM_TX0[23:0] in next transfer. 264 * | | |Example 2: If SPIM_CTL0[BURSTNUM] = 0x0 and SPIM_CTL0[DWIDTH] = 0x17, data will be transmitted in the order SPIM_TX0[7:0], SPIM_TX0[15:8], SPIM_TX0[23:16] in next transfer. 265 * | | |Example 3: If SPIM_CTL0[BURSTNUM] = 0x0 and SPIM_CTL0[DWIDTH] = 0x07, data will be transmitted in the order SPIM_TX0[7], SPIM_TX0[6], ..., 266 * | | |SPIM_TX0[0] in next transfer. 267 * @var SPIM_T::SRAMADDR 268 * Offset: 0x30 SRAM Memory Address Register 269 * --------------------------------------------------------------------------------------------------- 270 * |Bits |Field |Descriptions 271 * | :----: | :----: | :---- | 272 * |[31:0] |ADDR |SRAM Memory Address 273 * | | |For DMA Read mode, this is the destination address for DMA transfer. 274 * | | |For DMA Write mode, this is the source address for DMA transfer. 275 * | | |Note: This address must be word-aligned. 276 * @var SPIM_T::DMACNT 277 * Offset: 0x34 DMA Transfer Byte Count Register 278 * --------------------------------------------------------------------------------------------------- 279 * |Bits |Field |Descriptions 280 * | :----: | :----: | :---- | 281 * |[23:0] |DMACNT |DMA Transfer Byte Count Register 282 * | | |It indicates the transfer length for DMA process. 283 * | | |Note1: The unit for counting is byte. 284 * | | |Note2: The number must be the multiple of 4. 285 * | | |Note3: Please check specification of used SPI flash to know maximum byte length of page program. 286 * @var SPIM_T::FADDR 287 * Offset: 0x38 SPI Flash Address Register 288 * --------------------------------------------------------------------------------------------------- 289 * |Bits |Field |Descriptions 290 * | :----: | :----: | :---- | 291 * |[31:0] |ADDR |SPI Flash Address Register 292 * | | |For DMA Read mode, this is the source address for DMA transfer. 293 * | | |For DMA Write mode, this is the destination address for DMA transfer. 294 * | | |Note 1 : This address must be word-aligned. 295 * | | |Note 2 : For external SPI flash with 32 MB, the value of this SPI flash address register "ADDR" is from 0x00000000 to 0x01FFFFFF when user uses DMA write mode and DMA read mode to write/read external SPI flash data 296 * | | |Please user check size of used SPI flash component to know access address range of external SPI flash. 297 * @var SPIM_T::KEY1 298 * Offset: 0x3C Cipher Key1 Register 299 * --------------------------------------------------------------------------------------------------- 300 * |Bits |Field |Descriptions 301 * | :----: | :----: | :---- | 302 * |[31:0] |KEY1 |Cipher Key1 Register 303 * | | |This is the KEY1 data for cipher function. 304 * | | |Note1: If there is not any KEY1(SPIM_KEY1[31:0]) or KEY2(SPIM_KEY2[31:0]) (KEY1 is 0x0000_0000 or KEY2 is 0x0000_0000), the cipher function will be disabled automatically. 305 * | | |Note2: When CIPHOFF(SPIM_CTL0[0]) is 0, both of KEY1(SPIM_KEY1[31:0]) and KEY2(SPIM_KEY2[31:0]) do not equal to 0x0000_0000 (i.e. 306 * | | |KEY1 != 0x0000_0000 and KEY2 != 0x0000_0000), cipher encryption/decryption is enabled. 307 * @var SPIM_T::KEY2 308 * Offset: 0x40 Cipher Key2 Register 309 * --------------------------------------------------------------------------------------------------- 310 * |Bits |Field |Descriptions 311 * | :----: | :----: | :---- | 312 * |[31:0] |KEY2 |Cipher Key2 Register 313 * | | |This is the KEY2 data for cipher function. 314 * | | |Note1: If there is not any KEY1(SPIM_KEY1[31:0]) or KEY2(SPIM_KEY2[31:0]) (KEY1 is 0x0000_0000 or KEY2 is 0x0000_0000), the cipher function will be disabled automatically. 315 * | | |Note2: When CIPHOFF(SPIM_CTL0[0]) is 0, both of KEY1(SPIM_KEY1[31:0]) and KEY2(SPIM_KEY2[31:0]) do not equal to 0x0000_0000 (i.e. 316 * | | |KEY1 != 0x0000_0000 and KEY2 != 0x0000_0000), cipher encryption/decryption is enabled. 317 * @var SPIM_T::DMMCTL 318 * Offset: 0x44 Direct Memory Mapping Mode Control Register 319 * --------------------------------------------------------------------------------------------------- 320 * |Bits |Field |Descriptions 321 * | :----: | :----: | :---- | 322 * |[15:8] |CRMDAT |Mode bits data for Continuous Read Mode (or performance enhance mode) (Default value = 0) 323 * | | |Only for direct memory mapping mode 324 * | | |Set the mode bits data for continuous read mode (or performance enhance mode). 325 * | | |When we set this mode bits currently (Note1) and set CREN(SPIM_DMMCTL[25]), this reduces the command phase by eight clocks and allows the read address to be immediately entered after SPIM_SS asserted to active 326 * | | |(Note1) 327 * | | |Note1 : Please check the used SPI flash specification to know the setting value of this mode bits data, and different SPI flash vendor may use different setting values. 328 * | | |Note2 : CRMDAT needs to used with CREN(SPIM_DMMCTL[25]). 329 * |[20:16] |DESELTIM |SPI Flash Deselect Time 330 * | | |Only for direct memory mapping mode 331 * | | |Set the minimum time width of SPI flash deselect time (i.e. 332 * | | |Minimum SPIM_SS deselect time), and we show in Figure 7.19-8. 333 * | | |(1) Cache function disable : 334 * | | |Minimum time width of SPIM_SS deselect time = (DESELTIM + 1) * AHB clock cycle time. 335 * | | |(2) Cache function enable : 336 * | | |Minimum time width of SPIM_SS deselect time = (DESELTIM + 4) * AHB clock cycle time. 337 * | | |Note1 : AHB clock cycle time = 1/AHB clock frequency. 338 * | | |Note2 : When cipher encryption/decryption is enabled, please set this register value >= 0x10 339 * | | |When cipher encryption/decryption is disabled, please set this register value >= 0x8. 340 * | | |Note3 : Please check the used SPI flash specification to know the setting value of this register, and different SPI flash vendor may use different setting values. 341 * |[24] |BWEN |16 bytes Burst Wrap Mode Enable Control Register (Default value = 0) 342 * | | |Only for WINBOND SPI flash, direct memory mapping mode, Cache enable, and read command code "0xEB, and 0xE7" 343 * | | |0 = Burst Wrap Mode Disable. (Default) 344 * | | |1 = Burst Wrap Mode Enable. 345 * | | |In direct memory mapping mode, both of quad read commands "0xEB" and "0xE7" support burst wrap mode for cache application and performance enhance 346 * | | |For cache application, the burst wrap mode can be used to fill the cache line quickly (In this SPI flash controller, we use cache data line with 16 bytes size) 347 * | | |For performance enhance with direct memory mapping mode and cache enable, when cache data is miss, the burst wrap mode can let MCU get the required SPI flash data quickly. 348 * |[25] |CREN |Continuous Read Mode Enable Control 349 * | | |Only for direct memory mapping mode, read command codes 0xBB, 0xEB, 0xE7, 0x0D, 0xBD, 0xED (Note2) 350 * | | |0 = Continuous Read Mode Disable. (Default) 351 * | | |1 = Continuous Read Mode Enable. 352 * | | |For read operations of SPI flash, commands of fast read quad I/O (0xEB), word read quad I/O (0xE7 in Winbond SPI flash), fast read dual I/O (0xBB), DTR/DDR fast read (0x0D), DTR/DDR fast read dual I/O (0xBD), and DTR/DDR fast read quad I/O (0xED) can further reduce command overhead through setting the "continuous read mode" bits (8 bits) after the input address data. 353 * | | |Note: When user uses function of continuous read mode and sets USETEN (SPIM_CTL2[16]) to 1, CRMDAT(SPIM_DMMCTL[15:8]) must be set by used SPI flash specifications 354 * | | |When user uses function of continuous read mode and sets USETEN(SPIM_CTL2[16]) to 0, CRMDAT(SPIM_DMMCTL[15:8]) is set by default value of WINBOND SPI flash. 355 * |[26] |UACTSCLK |User Sets SPI Flash Active SCLK Time 356 * | | |Only for direct memory mapping mode, DMA write mode, and DMA read mode 357 * | | |0 = According to DIVIDER(SPIM_CTL1[31:16]), ACTSCLKT(SPIM_DMMCTL[31:28]) is set by hardware automatically 358 * | | |(Default value) 359 * | | |1 = Set ACTSCLKT(SPIM_DMMCTL[31:28]) by user manually. 360 * | | |When user wants to set ACTSCLKT(SPIM_DMMCTL[31:28]) manually, please set UACTSCLK to 1. 361 * |[31:28] |ACTSCLKT |SPI Flash Active SCLK Time 362 * | | |Only for direct memory mapping mode, DMA write mode, and DMA read mode 363 * | | |This register sets time interval between SPIM SS active edge and the position edge of the first serial SPI output clock, and we show in Figure 7.19-8. 364 * | | |(1) ACTSCLKT = 0 (function disable) :. 365 * | | |Time interval = 1 AHB clock cycle time. 366 * | | |(2) ACTSCLKT != 0 (function enable) : 367 * | | |Time interval = (ACTSCLKT + 3) * AHB clock cycle time. 368 * | | |Note1 : AHB clock cycle time = 1/AHB clock frequency. 369 * | | |Note2 : SCLK is SPI output clock 370 * | | |Note3 : Please check the used SPI flash specification to know the setting value of this register, and different SPI flash vendor may use different setting values. 371 * @var SPIM_T::CTL2 372 * Offset: 0x48 Control Register 2 373 * --------------------------------------------------------------------------------------------------- 374 * |Bits |Field |Descriptions 375 * | :----: | :----: | :---- | 376 * |[16] |USETEN |User Set Value Enable Control 377 * | | |Only for direct memory mapping mode and DMA read mode with read commands 0x03,0x0B,0x3B,0xBB,0xEB,0xE7 378 * | | |0 = Hardware circuit of SPI flash controller will use the following default values of DCNUM(SPIM_CTL2[28:24]) and CRMDAT(SPIM_DMMCTL[15:8]) to configure SPI flash operations automatically. 379 * | | |Dummy cycle number (DCNUM) : 380 * | | |Dummy cycle number for read command 0x03 : 0x0 381 * | | |Dummy cycle number for read command 0x0B : 0x8 382 * | | |Dummy cycle number for read command 0x3B : 0x8 383 * | | |Dummy cycle number for read command 0xBB : 0x0 384 * | | |Dummy cycle number for read command 0xEB : 0x4 385 * | | |Dummy cycle number for read command 0xE7 : 0x2 386 * | | |Mode bits data for continuous read mode (CRMDAT) : 0x20 387 * | | |1 = If DCNUM(SPIM_CTL2[28:24]) and CRMDAT(SPIM_DMMCTL[15:8]) are not set as above default values, user must set USETEN to 0x1, DCNUM(SPIM_CTL2[28:24]) and CRMDAT(SPIM_DMMCTL[15:8]) to configure SPI flash operations manually. 388 * | | |For DTR/DDR command codes 0x0D, 0xBD, and 0xED, please set USETEN to 0x1. 389 * |[20] |DTRMPOFF |Mode Phase OFF for DTR/DDR Command Codes 0x0D, 0xBD, and 0xED 390 * | | |Only for direct memory mapping mode and DMA read mode (Note1) 391 * | | |0 = mode cycle number (or performance enhance cycle number) does not equal to 0x0 in DTR/DDR read command codes 0x0D, 0xBD, and 0xED. 392 * | | |1 = mode cycle number (or performance enhance cycle number) equals to 0x0 in DTR/DDR read command codes 0x0D, 0xBD, and 0xED. 393 * | | |Note1 : Please check the used SPI flash specification to know the mode cycle number (or performance enhance cycle number) for DTR/DDR command codes 0x0D, 0xBD, and 0xED. 394 * |[28:24] |DCNUM |Dummy Cycle Number 395 * | | |Only for direct memory mapping mode and DMA read mode (Note1) 396 * | | |Set number of dummy cycles 397 * | | |(1) For non-DTR/non-DDR command codes 0x03, 0x0B, 0x3B, 0xBB, 0xEB, and 0xE7 : 398 * | | |When read command code do not need any dummy cycles (i.e. 399 * | | |dummy cycle number = 0x0), user must set DCNUM to 0x0. 400 * | | |For command code 0xBB, if both mode cycle number (or performance enhance cycle number) and dummy cycle number do not equal to 0x0 simultaneously, user must set DCNUM to "mode cycle number + dummy cycle number" by used SPI flash specification. 401 * | | |For command code 0xBB, if there is only dummy cycle number (i.e. 402 * | | |dummy cycle number != 0x0 and mode cycle number = 0x0 (or performance enhance cycle number = 0x0)), user set DCNUM to dummy cycle number by used SPI flash specification. 403 * | | |For command codes 0x0B, 0x3B, 0xEB, and 0xE7, user only set DCNUM to dummy cycle number by used SPI flash specification. 404 * | | |(2) For DTR/DDR command codes 0x0D, 0xBD, and 0xED : 405 * | | |user sets DCNUM to dummy cycle number and DTRMPOFF(SPIM_CTL2[20]) by used SPI flash specification. 406 * | | |Note1 : Number of dummy cycles depends on the frequency of SPI output clock, SPI flash vendor, and read command types 407 * | | |Please check the used SPI flash specification to know the setting value of this number of dummy cycles. 408 */ 409 __IO uint32_t CTL0; /*!< [0x0000] Control and Status Register 0 */ 410 __IO uint32_t CTL1; /*!< [0x0004] Control Register 1 */ 411 /// @cond HIDDEN_SYMBOLS 412 __I uint32_t RESERVE0[1]; 413 /// @endcond //HIDDEN_SYMBOLS 414 __IO uint32_t RXCLKDLY; /*!< [0x000c] RX Clock Delay Control Register */ 415 __I uint32_t RX[4]; /*!< [0x0010] ~ [0x001C] Data Receive Register 0~3 */ 416 __IO uint32_t TX[4]; /*!< [0x0020] ~ [0x002C] Data Transmit Register 0~3 */ 417 __IO uint32_t SRAMADDR; /*!< [0x0030] SRAM Memory Address Register */ 418 __IO uint32_t DMACNT; /*!< [0x0034] DMA Transfer Byte Count Register */ 419 __IO uint32_t FADDR; /*!< [0x0038] SPI Flash Address Register */ 420 __O uint32_t KEY1; /*!< [0x003c] Cipher Key1 Register */ 421 __O uint32_t KEY2; /*!< [0x0040] Cipher Key2 Register */ 422 __IO uint32_t DMMCTL; /*!< [0x0044] Direct Memory Mapping Mode Control Register */ 423 __IO uint32_t CTL2; /*!< [0x0048] Control Register 2 */ 424 425 } SPIM_T; 426 427 /** 428 @addtogroup SPIM_CONST SPIM Bit Field Definition 429 Constant Definitions for SPIM Controller 430 @{ */ 431 432 #define SPIM_CTL0_CIPHOFF_Pos (0) /*!< SPIM_T::CTL0: CIPHOFF Position */ 433 #define SPIM_CTL0_CIPHOFF_Msk (0x1ul << SPIM_CTL0_CIPHOFF_Pos) /*!< SPIM_T::CTL0: CIPHOFF Mask */ 434 435 #define SPIM_CTL0_BALEN_Pos (2) /*!< SPIM_T::CTL0: BALEN Position */ 436 #define SPIM_CTL0_BALEN_Msk (0x1ul << SPIM_CTL0_BALEN_Pos) /*!< SPIM_T::CTL0: BALEN Mask */ 437 438 #define SPIM_CTL0_B4ADDREN_Pos (5) /*!< SPIM_T::CTL0: B4ADDREN Position */ 439 #define SPIM_CTL0_B4ADDREN_Msk (0x1ul << SPIM_CTL0_B4ADDREN_Pos) /*!< SPIM_T::CTL0: B4ADDREN Mask */ 440 441 #define SPIM_CTL0_IEN_Pos (6) /*!< SPIM_T::CTL0: IEN Position */ 442 #define SPIM_CTL0_IEN_Msk (0x1ul << SPIM_CTL0_IEN_Pos) /*!< SPIM_T::CTL0: IEN Mask */ 443 444 #define SPIM_CTL0_IF_Pos (7) /*!< SPIM_T::CTL0: IF Position */ 445 #define SPIM_CTL0_IF_Msk (0x1ul << SPIM_CTL0_IF_Pos) /*!< SPIM_T::CTL0: IF Mask */ 446 447 #define SPIM_CTL0_DWIDTH_Pos (8) /*!< SPIM_T::CTL0: DWIDTH Position */ 448 #define SPIM_CTL0_DWIDTH_Msk (0x1ful << SPIM_CTL0_DWIDTH_Pos) /*!< SPIM_T::CTL0: DWIDTH Mask */ 449 450 #define SPIM_CTL0_BURSTNUM_Pos (13) /*!< SPIM_T::CTL0: BURSTNUM Position */ 451 #define SPIM_CTL0_BURSTNUM_Msk (0x3ul << SPIM_CTL0_BURSTNUM_Pos) /*!< SPIM_T::CTL0: BURSTNUM Mask */ 452 453 #define SPIM_CTL0_QDIODIR_Pos (15) /*!< SPIM_T::CTL0: QDIODIR Position */ 454 #define SPIM_CTL0_QDIODIR_Msk (0x1ul << SPIM_CTL0_QDIODIR_Pos) /*!< SPIM_T::CTL0: QDIODIR Mask */ 455 456 #define SPIM_CTL0_SUSPITV_Pos (16) /*!< SPIM_T::CTL0: SUSPITV Position */ 457 #define SPIM_CTL0_SUSPITV_Msk (0xful << SPIM_CTL0_SUSPITV_Pos) /*!< SPIM_T::CTL0: SUSPITV Mask */ 458 459 #define SPIM_CTL0_BITMODE_Pos (20) /*!< SPIM_T::CTL0: BITMODE Position */ 460 #define SPIM_CTL0_BITMODE_Msk (0x3ul << SPIM_CTL0_BITMODE_Pos) /*!< SPIM_T::CTL0: BITMODE Mask */ 461 462 #define SPIM_CTL0_OPMODE_Pos (22) /*!< SPIM_T::CTL0: OPMODE Position */ 463 #define SPIM_CTL0_OPMODE_Msk (0x3ul << SPIM_CTL0_OPMODE_Pos) /*!< SPIM_T::CTL0: OPMODE Mask */ 464 465 #define SPIM_CTL0_CMDCODE_Pos (24) /*!< SPIM_T::CTL0: CMDCODE Position */ 466 #define SPIM_CTL0_CMDCODE_Msk (0xfful << SPIM_CTL0_CMDCODE_Pos) /*!< SPIM_T::CTL0: CMDCODE Mask */ 467 468 #define SPIM_CTL1_SPIMEN_Pos (0) /*!< SPIM_T::CTL1: SPIMEN Position */ 469 #define SPIM_CTL1_SPIMEN_Msk (0x1ul << SPIM_CTL1_SPIMEN_Pos) /*!< SPIM_T::CTL1: SPIMEN Mask */ 470 471 #define SPIM_CTL1_CACHEOFF_Pos (1) /*!< SPIM_T::CTL1: CACHEOFF Position */ 472 #define SPIM_CTL1_CACHEOFF_Msk (0x1ul << SPIM_CTL1_CACHEOFF_Pos) /*!< SPIM_T::CTL1: CACHEOFF Mask */ 473 474 #define SPIM_CTL1_CCMEN_Pos (2) /*!< SPIM_T::CTL1: CCMEN Position */ 475 #define SPIM_CTL1_CCMEN_Msk (0x1ul << SPIM_CTL1_CCMEN_Pos) /*!< SPIM_T::CTL1: CCMEN Mask */ 476 477 #define SPIM_CTL1_CDINVAL_Pos (3) /*!< SPIM_T::CTL1: CDINVAL Position */ 478 #define SPIM_CTL1_CDINVAL_Msk (0x1ul << SPIM_CTL1_CDINVAL_Pos) /*!< SPIM_T::CTL1: CDINVAL Mask */ 479 480 #define SPIM_CTL1_SS_Pos (4) /*!< SPIM_T::CTL1: SS Position */ 481 #define SPIM_CTL1_SS_Msk (0x1ul << SPIM_CTL1_SS_Pos) /*!< SPIM_T::CTL1: SS Mask */ 482 483 #define SPIM_CTL1_SSACTPOL_Pos (5) /*!< SPIM_T::CTL1: SSACTPOL Position */ 484 #define SPIM_CTL1_SSACTPOL_Msk (0x1ul << SPIM_CTL1_SSACTPOL_Pos) /*!< SPIM_T::CTL1: SSACTPOL Mask */ 485 486 #define SPIM_CTL1_IDLETIME_Pos (8) /*!< SPIM_T::CTL1: IDLETIME Position */ 487 #define SPIM_CTL1_IDLETIME_Msk (0xful << SPIM_CTL1_IDLETIME_Pos) /*!< SPIM_T::CTL1: IDLETIME Mask */ 488 489 #define SPIM_CTL1_DIVIDER_Pos (16) /*!< SPIM_T::CTL1: DIVIDER Position */ 490 #define SPIM_CTL1_DIVIDER_Msk (0xfffful << SPIM_CTL1_DIVIDER_Pos) /*!< SPIM_T::CTL1: DIVIDER Mask */ 491 492 #define SPIM_RXCLKDLY_DWDELSEL_Pos (0) /*!< SPIM_T::RXCLKDLY: DWDELSEL Position */ 493 #define SPIM_RXCLKDLY_DWDELSEL_Msk (0xfful << SPIM_RXCLKDLY_DWDELSEL_Pos) /*!< SPIM_T::RXCLKDLY: DWDELSEL Mask */ 494 495 #define SPIM_RXCLKDLY_RDDLYSEL_Pos (16) /*!< SPIM_T::RXCLKDLY: RDDLYSEL Position */ 496 #define SPIM_RXCLKDLY_RDDLYSEL_Msk (0x7ul << SPIM_RXCLKDLY_RDDLYSEL_Pos) /*!< SPIM_T::RXCLKDLY: RDDLYSEL Mask */ 497 498 #define SPIM_RXCLKDLY_RDEDGE_Pos (20) /*!< SPIM_T::RXCLKDLY: RDEDGE Position */ 499 #define SPIM_RXCLKDLY_RDEDGE_Msk (0x1ul << SPIM_RXCLKDLY_RDEDGE_Pos) /*!< SPIM_T::RXCLKDLY: RDEDGE Mask */ 500 501 #define SPIM_RX_RXDAT_Pos (0) /*!< SPIM_T::RX[4]: RXDAT Position */ 502 #define SPIM_RX_RXDAT_Msk (0xfffffffful << SPIM_RX_RXDAT_Pos) /*!< SPIM_T::RX[4]: RXDAT Mask */ 503 504 #define SPIM_TX_TXDAT_Pos (0) /*!< SPIM_T::TX[4]: TXDAT Position */ 505 #define SPIM_TX_TXDAT_Msk (0xfffffffful << SPIM_TX_TXDAT_Pos) /*!< SPIM_T::TX[4]: TXDAT Mask */ 506 507 #define SPIM_SRAMADDR_ADDR_Pos (0) /*!< SPIM_T::SRAMADDR: ADDR Position */ 508 #define SPIM_SRAMADDR_ADDR_Msk (0xfffffffful << SPIM_SRAMADDR_ADDR_Pos) /*!< SPIM_T::SRAMADDR: ADDR Mask */ 509 510 #define SPIM_DMACNT_DMACNT_Pos (0) /*!< SPIM_T::DMACNT: DMACNT Position */ 511 #define SPIM_DMACNT_DMACNT_Msk (0xfffffful << SPIM_DMACNT_DMACNT_Pos) /*!< SPIM_T::DMACNT: DMACNT Mask */ 512 513 #define SPIM_FADDR_ADDR_Pos (0) /*!< SPIM_T::FADDR: ADDR Position */ 514 #define SPIM_FADDR_ADDR_Msk (0xfffffffful << SPIM_FADDR_ADDR_Pos) /*!< SPIM_T::FADDR: ADDR Mask */ 515 516 #define SPIM_KEY1_KEY1_Pos (0) /*!< SPIM_T::KEY1: KEY1 Position */ 517 #define SPIM_KEY1_KEY1_Msk (0xfffffffful << SPIM_KEY1_KEY1_Pos) /*!< SPIM_T::KEY1: KEY1 Mask */ 518 519 #define SPIM_KEY2_KEY2_Pos (0) /*!< SPIM_T::KEY2: KEY2 Position */ 520 #define SPIM_KEY2_KEY2_Msk (0xfffffffful << SPIM_KEY2_KEY2_Pos) /*!< SPIM_T::KEY2: KEY2 Mask */ 521 522 #define SPIM_DMMCTL_CRMDAT_Pos (8) /*!< SPIM_T::DMMCTL: CRMDAT Position */ 523 #define SPIM_DMMCTL_CRMDAT_Msk (0xfful << SPIM_DMMCTL_CRMDAT_Pos) /*!< SPIM_T::DMMCTL: CRMDAT Mask */ 524 525 #define SPIM_DMMCTL_DESELTIM_Pos (16) /*!< SPIM_T::DMMCTL: DESELTIM Position */ 526 #define SPIM_DMMCTL_DESELTIM_Msk (0x1ful << SPIM_DMMCTL_DESELTIM_Pos) /*!< SPIM_T::DMMCTL: DESELTIM Mask */ 527 528 #define SPIM_DMMCTL_BWEN_Pos (24) /*!< SPIM_T::DMMCTL: BWEN Position */ 529 #define SPIM_DMMCTL_BWEN_Msk (0x1ul << SPIM_DMMCTL_BWEN_Pos) /*!< SPIM_T::DMMCTL: BWEN Mask */ 530 531 #define SPIM_DMMCTL_CREN_Pos (25) /*!< SPIM_T::DMMCTL: CREN Position */ 532 #define SPIM_DMMCTL_CREN_Msk (0x1ul << SPIM_DMMCTL_CREN_Pos) /*!< SPIM_T::DMMCTL: CREN Mask */ 533 534 #define SPIM_DMMCTL_UACTSCLK_Pos (26) /*!< SPIM_T::DMMCTL: UACTSCLK Position */ 535 #define SPIM_DMMCTL_UACTSCLK_Msk (0x1ul << SPIM_DMMCTL_UACTSCLK_Pos) /*!< SPIM_T::DMMCTL: UACTSCLK Mask */ 536 537 #define SPIM_DMMCTL_ACTSCLKT_Pos (28) /*!< SPIM_T::DMMCTL: ACTSCLKT Position */ 538 #define SPIM_DMMCTL_ACTSCLKT_Msk (0xful << SPIM_DMMCTL_ACTSCLKT_Pos) /*!< SPIM_T::DMMCTL: ACTSCLKT Mask */ 539 540 #define SPIM_CTL2_USETEN_Pos (16) /*!< SPIM_T::CTL2: USETEN Position */ 541 #define SPIM_CTL2_USETEN_Msk (0x1ul << SPIM_CTL2_USETEN_Pos) /*!< SPIM_T::CTL2: USETEN Mask */ 542 543 #define SPIM_CTL2_DTRMPOFF_Pos (20) /*!< SPIM_T::CTL2: DTRMPOFF Position */ 544 #define SPIM_CTL2_DTRMPOFF_Msk (0x1ul << SPIM_CTL2_DTRMPOFF_Pos) /*!< SPIM_T::CTL2: DTRMPOFF Mask */ 545 546 #define SPIM_CTL2_DCNUM_Pos (24) /*!< SPIM_T::CTL2: DCNUM Position */ 547 #define SPIM_CTL2_DCNUM_Msk (0x1ful << SPIM_CTL2_DCNUM_Pos) /*!< SPIM_T::CTL2: DCNUM Mask */ 548 549 /**@}*/ /* SPIM_CONST */ 550 /**@}*/ /* end of SPIM register group */ 551 /**@}*/ /* end of REGISTER group */ 552 553 #if defined ( __CC_ARM ) 554 #pragma no_anon_unions 555 #endif 556 557 #endif /* __SPIM_REG_H__ */ 558