1 /**
2  * \file
3  *
4  * \brief Component description for SPI
5  *
6  * Copyright (c) 2016 Atmel Corporation,
7  *                    a wholly owned subsidiary of Microchip Technology Inc.
8  *
9  * \asf_license_start
10  *
11  * \page License
12  *
13  * Licensed under the Apache License, Version 2.0 (the "License");
14  * you may not use this file except in compliance with the License.
15  * You may obtain a copy of the Licence at
16  *
17  *     http://www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  *
25  * \asf_license_stop
26  *
27  */
28 
29 #ifndef _SAM4L_SPI_COMPONENT_
30 #define _SAM4L_SPI_COMPONENT_
31 
32 /* ========================================================================== */
33 /**  SOFTWARE API DEFINITION FOR SPI */
34 /* ========================================================================== */
35 /** \addtogroup SAM4L_SPI Serial Peripheral Interface */
36 /*@{*/
37 
38 #define SPI_I7602
39 #define REV_SPI                     0x211
40 
41 /* -------- SPI_CR : (SPI Offset: 0x00) ( /W 32) Control Register -------- */
42 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
43 typedef union {
44   struct {
45     uint32_t SPIEN:1;          /*!< bit:      0  SPI Enable                         */
46     uint32_t SPIDIS:1;         /*!< bit:      1  SPI Disable                        */
47     uint32_t :5;               /*!< bit:  2.. 6  Reserved                           */
48     uint32_t SWRST:1;          /*!< bit:      7  SPI Software Reset                 */
49     uint32_t FLUSHFIFO:1;      /*!< bit:      8  Flush FIFO command                 */
50     uint32_t :15;              /*!< bit:  9..23  Reserved                           */
51     uint32_t LASTXFER:1;       /*!< bit:     24  Last Transfer                      */
52     uint32_t :7;               /*!< bit: 25..31  Reserved                           */
53   } bit;                       /*!< Structure used for bit  access                  */
54   uint32_t reg;                /*!< Type      used for register access              */
55 } SPI_CR_Type;
56 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
57 
58 #define SPI_CR_OFFSET               0x00         /**< \brief (SPI_CR offset) Control Register */
59 #define SPI_CR_RESETVALUE           _U_(0x00000000); /**< \brief (SPI_CR reset_value) Control Register */
60 
61 #define SPI_CR_SPIEN_Pos            0            /**< \brief (SPI_CR) SPI Enable */
62 #define SPI_CR_SPIEN                (_U_(0x1) << SPI_CR_SPIEN_Pos)
63 #define   SPI_CR_SPIEN_0_Val              _U_(0x0)   /**< \brief (SPI_CR) No effect. */
64 #define   SPI_CR_SPIEN_1_Val              _U_(0x1)   /**< \brief (SPI_CR) Enables the SPI to transfer and receive data. */
65 #define SPI_CR_SPIEN_0              (SPI_CR_SPIEN_0_Val            << SPI_CR_SPIEN_Pos)
66 #define SPI_CR_SPIEN_1              (SPI_CR_SPIEN_1_Val            << SPI_CR_SPIEN_Pos)
67 #define SPI_CR_SPIDIS_Pos           1            /**< \brief (SPI_CR) SPI Disable */
68 #define SPI_CR_SPIDIS               (_U_(0x1) << SPI_CR_SPIDIS_Pos)
69 #define   SPI_CR_SPIDIS_0_Val             _U_(0x0)   /**< \brief (SPI_CR) No effect. */
70 #define   SPI_CR_SPIDIS_1_Val             _U_(0x1)   /**< \brief (SPI_CR) Disables the SPI.All pins are set in input mode and no data is received or transmitted.If a transfer is in progress, the transfer is finished before the SPI is disabled.If both SPIEN and SPIDIS are equal to one when the control register is written, the SPI is disabled. */
71 #define SPI_CR_SPIDIS_0             (SPI_CR_SPIDIS_0_Val           << SPI_CR_SPIDIS_Pos)
72 #define SPI_CR_SPIDIS_1             (SPI_CR_SPIDIS_1_Val           << SPI_CR_SPIDIS_Pos)
73 #define SPI_CR_SWRST_Pos            7            /**< \brief (SPI_CR) SPI Software Reset */
74 #define SPI_CR_SWRST                (_U_(0x1) << SPI_CR_SWRST_Pos)
75 #define   SPI_CR_SWRST_0_Val              _U_(0x0)   /**< \brief (SPI_CR) No effect. */
76 #define   SPI_CR_SWRST_1_Val              _U_(0x1)   /**< \brief (SPI_CR) Reset the SPI. A software-triggered hardware reset of the SPI interface is performed. */
77 #define SPI_CR_SWRST_0              (SPI_CR_SWRST_0_Val            << SPI_CR_SWRST_Pos)
78 #define SPI_CR_SWRST_1              (SPI_CR_SWRST_1_Val            << SPI_CR_SWRST_Pos)
79 #define SPI_CR_FLUSHFIFO_Pos        8            /**< \brief (SPI_CR) Flush FIFO command */
80 #define SPI_CR_FLUSHFIFO            (_U_(0x1) << SPI_CR_FLUSHFIFO_Pos)
81 #define SPI_CR_LASTXFER_Pos         24           /**< \brief (SPI_CR) Last Transfer */
82 #define SPI_CR_LASTXFER             (_U_(0x1) << SPI_CR_LASTXFER_Pos)
83 #define   SPI_CR_LASTXFER_0_Val           _U_(0x0)   /**< \brief (SPI_CR) No effect. */
84 #define   SPI_CR_LASTXFER_1_Val           _U_(0x1)   /**< \brief (SPI_CR) The current NPCS will be deasserted after the character written in TD has been transferred. When CSAAT is set, thisallows to close the communication with the current serial peripheral by raising the corresponding NPCS line as soon as TDtransfer has completed. */
85 #define SPI_CR_LASTXFER_0           (SPI_CR_LASTXFER_0_Val         << SPI_CR_LASTXFER_Pos)
86 #define SPI_CR_LASTXFER_1           (SPI_CR_LASTXFER_1_Val         << SPI_CR_LASTXFER_Pos)
87 #define SPI_CR_MASK                 _U_(0x01000183) /**< \brief (SPI_CR) MASK Register */
88 
89 /* -------- SPI_MR : (SPI Offset: 0x04) (R/W 32) Mode Register -------- */
90 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
91 typedef union {
92   struct {
93     uint32_t MSTR:1;           /*!< bit:      0  Master/Slave Mode                  */
94     uint32_t PS:1;             /*!< bit:      1  Peripheral Select                  */
95     uint32_t PCSDEC:1;         /*!< bit:      2  Chip Select Decode                 */
96     uint32_t :1;               /*!< bit:      3  Reserved                           */
97     uint32_t MODFDIS:1;        /*!< bit:      4  Mode Fault Detection               */
98     uint32_t WDRBT:1;          /*!< bit:      5  wait data read before transfer     */
99     uint32_t RXFIFOEN:1;       /*!< bit:      6  FIFO in Reception Enable           */
100     uint32_t LLB:1;            /*!< bit:      7  Local Loopback Enable              */
101     uint32_t :8;               /*!< bit:  8..15  Reserved                           */
102     uint32_t PCS:4;            /*!< bit: 16..19  Peripheral Chip Select             */
103     uint32_t :4;               /*!< bit: 20..23  Reserved                           */
104     uint32_t DLYBCS:8;         /*!< bit: 24..31  Delay Between Chip Selects         */
105   } bit;                       /*!< Structure used for bit  access                  */
106   uint32_t reg;                /*!< Type      used for register access              */
107 } SPI_MR_Type;
108 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
109 
110 #define SPI_MR_OFFSET               0x04         /**< \brief (SPI_MR offset) Mode Register */
111 #define SPI_MR_RESETVALUE           _U_(0x00000000); /**< \brief (SPI_MR reset_value) Mode Register */
112 
113 #define SPI_MR_MSTR_Pos             0            /**< \brief (SPI_MR) Master/Slave Mode */
114 #define SPI_MR_MSTR                 (_U_(0x1) << SPI_MR_MSTR_Pos)
115 #define   SPI_MR_MSTR_0_Val               _U_(0x0)   /**< \brief (SPI_MR) SPI is in Slave mode. */
116 #define   SPI_MR_MSTR_1_Val               _U_(0x1)   /**< \brief (SPI_MR) SPI is in Master mode. */
117 #define SPI_MR_MSTR_0               (SPI_MR_MSTR_0_Val             << SPI_MR_MSTR_Pos)
118 #define SPI_MR_MSTR_1               (SPI_MR_MSTR_1_Val             << SPI_MR_MSTR_Pos)
119 #define SPI_MR_PS_Pos               1            /**< \brief (SPI_MR) Peripheral Select */
120 #define SPI_MR_PS                   (_U_(0x1) << SPI_MR_PS_Pos)
121 #define   SPI_MR_PS_0_Val                 _U_(0x0)   /**< \brief (SPI_MR) Fixed Peripheral Select. */
122 #define   SPI_MR_PS_1_Val                 _U_(0x1)   /**< \brief (SPI_MR) Variable Peripheral Select. */
123 #define SPI_MR_PS_0                 (SPI_MR_PS_0_Val               << SPI_MR_PS_Pos)
124 #define SPI_MR_PS_1                 (SPI_MR_PS_1_Val               << SPI_MR_PS_Pos)
125 #define SPI_MR_PCSDEC_Pos           2            /**< \brief (SPI_MR) Chip Select Decode */
126 #define SPI_MR_PCSDEC               (_U_(0x1) << SPI_MR_PCSDEC_Pos)
127 #define   SPI_MR_PCSDEC_0_Val             _U_(0x0)   /**< \brief (SPI_MR) The chip selects are directly connected to a peripheral device. */
128 #define   SPI_MR_PCSDEC_1_Val             _U_(0x1)   /**< \brief (SPI_MR) The four chip select lines are connected to a 4- to 16-bit decoder.When PCSDEC equals one, up to 15 Chip Select signals can be generated with the four lines using an external 4- to 16-bitdecoder. The Chip Select Registers define the characteristics of the 16 chip selects according to the following rules:CSR0 defines peripheral chip select signals 0 to 3.CSR1 defines peripheral chip select signals 4 to 7.CSR2 defines peripheral chip select signals 8 to 11.CSR3 defines peripheral chip select signals 12 to 15. */
129 #define SPI_MR_PCSDEC_0             (SPI_MR_PCSDEC_0_Val           << SPI_MR_PCSDEC_Pos)
130 #define SPI_MR_PCSDEC_1             (SPI_MR_PCSDEC_1_Val           << SPI_MR_PCSDEC_Pos)
131 #define SPI_MR_MODFDIS_Pos          4            /**< \brief (SPI_MR) Mode Fault Detection */
132 #define SPI_MR_MODFDIS              (_U_(0x1) << SPI_MR_MODFDIS_Pos)
133 #define   SPI_MR_MODFDIS_0_Val            _U_(0x0)   /**< \brief (SPI_MR) Mode fault detection is enabled. */
134 #define   SPI_MR_MODFDIS_1_Val            _U_(0x1)   /**< \brief (SPI_MR) Mode fault detection is disabled. */
135 #define SPI_MR_MODFDIS_0            (SPI_MR_MODFDIS_0_Val          << SPI_MR_MODFDIS_Pos)
136 #define SPI_MR_MODFDIS_1            (SPI_MR_MODFDIS_1_Val          << SPI_MR_MODFDIS_Pos)
137 #define SPI_MR_WDRBT_Pos            5            /**< \brief (SPI_MR) wait data read before transfer */
138 #define SPI_MR_WDRBT                (_U_(0x1) << SPI_MR_WDRBT_Pos)
139 #define SPI_MR_RXFIFOEN_Pos         6            /**< \brief (SPI_MR) FIFO in Reception Enable */
140 #define SPI_MR_RXFIFOEN             (_U_(0x1) << SPI_MR_RXFIFOEN_Pos)
141 #define SPI_MR_LLB_Pos              7            /**< \brief (SPI_MR) Local Loopback Enable */
142 #define SPI_MR_LLB                  (_U_(0x1) << SPI_MR_LLB_Pos)
143 #define   SPI_MR_LLB_0_Val                _U_(0x0)   /**< \brief (SPI_MR) Local loopback path disabled. */
144 #define   SPI_MR_LLB_1_Val                _U_(0x1)   /**< \brief (SPI_MR) Local loopback path enabled.LLB controls the local loopback on the data serializer for testing in Master Mode only. */
145 #define SPI_MR_LLB_0                (SPI_MR_LLB_0_Val              << SPI_MR_LLB_Pos)
146 #define SPI_MR_LLB_1                (SPI_MR_LLB_1_Val              << SPI_MR_LLB_Pos)
147 #define SPI_MR_PCS_Pos              16           /**< \brief (SPI_MR) Peripheral Chip Select */
148 #define SPI_MR_PCS_Msk              (_U_(0xF) << SPI_MR_PCS_Pos)
149 #define SPI_MR_PCS(value)           (SPI_MR_PCS_Msk & ((value) << SPI_MR_PCS_Pos))
150 #define SPI_MR_DLYBCS_Pos           24           /**< \brief (SPI_MR) Delay Between Chip Selects */
151 #define SPI_MR_DLYBCS_Msk           (_U_(0xFF) << SPI_MR_DLYBCS_Pos)
152 #define SPI_MR_DLYBCS(value)        (SPI_MR_DLYBCS_Msk & ((value) << SPI_MR_DLYBCS_Pos))
153 #define SPI_MR_MASK                 _U_(0xFF0F00F7) /**< \brief (SPI_MR) MASK Register */
154 
155 /* -------- SPI_RDR : (SPI Offset: 0x08) (R/  32) Receive Data Register -------- */
156 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
157 typedef union {
158   struct {
159     uint32_t RD:16;            /*!< bit:  0..15  Receive Data                       */
160     uint32_t PCS:4;            /*!< bit: 16..19  Peripheral Chip Select             */
161     uint32_t :12;              /*!< bit: 20..31  Reserved                           */
162   } bit;                       /*!< Structure used for bit  access                  */
163   uint32_t reg;                /*!< Type      used for register access              */
164 } SPI_RDR_Type;
165 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
166 
167 #define SPI_RDR_OFFSET              0x08         /**< \brief (SPI_RDR offset) Receive Data Register */
168 #define SPI_RDR_RESETVALUE          _U_(0x00000000); /**< \brief (SPI_RDR reset_value) Receive Data Register */
169 
170 #define SPI_RDR_RD_Pos              0            /**< \brief (SPI_RDR) Receive Data */
171 #define SPI_RDR_RD_Msk              (_U_(0xFFFF) << SPI_RDR_RD_Pos)
172 #define SPI_RDR_RD(value)           (SPI_RDR_RD_Msk & ((value) << SPI_RDR_RD_Pos))
173 #define SPI_RDR_PCS_Pos             16           /**< \brief (SPI_RDR) Peripheral Chip Select */
174 #define SPI_RDR_PCS_Msk             (_U_(0xF) << SPI_RDR_PCS_Pos)
175 #define SPI_RDR_PCS(value)          (SPI_RDR_PCS_Msk & ((value) << SPI_RDR_PCS_Pos))
176 #define SPI_RDR_MASK                _U_(0x000FFFFF) /**< \brief (SPI_RDR) MASK Register */
177 
178 /* -------- SPI_TDR : (SPI Offset: 0x0C) ( /W 32) Transmit Data Register -------- */
179 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
180 typedef union {
181   struct {
182     uint32_t TD:16;            /*!< bit:  0..15  Transmit Data                      */
183     uint32_t PCS:4;            /*!< bit: 16..19  Peripheral Chip Select             */
184     uint32_t :4;               /*!< bit: 20..23  Reserved                           */
185     uint32_t LASTXFER:1;       /*!< bit:     24  Last Transfer                      */
186     uint32_t :7;               /*!< bit: 25..31  Reserved                           */
187   } bit;                       /*!< Structure used for bit  access                  */
188   uint32_t reg;                /*!< Type      used for register access              */
189 } SPI_TDR_Type;
190 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
191 
192 #define SPI_TDR_OFFSET              0x0C         /**< \brief (SPI_TDR offset) Transmit Data Register */
193 #define SPI_TDR_RESETVALUE          _U_(0x00000000); /**< \brief (SPI_TDR reset_value) Transmit Data Register */
194 
195 #define SPI_TDR_TD_Pos              0            /**< \brief (SPI_TDR) Transmit Data */
196 #define SPI_TDR_TD_Msk              (_U_(0xFFFF) << SPI_TDR_TD_Pos)
197 #define SPI_TDR_TD(value)           (SPI_TDR_TD_Msk & ((value) << SPI_TDR_TD_Pos))
198 #define SPI_TDR_PCS_Pos             16           /**< \brief (SPI_TDR) Peripheral Chip Select */
199 #define SPI_TDR_PCS_Msk             (_U_(0xF) << SPI_TDR_PCS_Pos)
200 #define SPI_TDR_PCS(value)          (SPI_TDR_PCS_Msk & ((value) << SPI_TDR_PCS_Pos))
201 #define SPI_TDR_LASTXFER_Pos        24           /**< \brief (SPI_TDR) Last Transfer */
202 #define SPI_TDR_LASTXFER            (_U_(0x1) << SPI_TDR_LASTXFER_Pos)
203 #define   SPI_TDR_LASTXFER_0_Val          _U_(0x0)   /**< \brief (SPI_TDR) No effect. */
204 #define   SPI_TDR_LASTXFER_1_Val          _U_(0x1)   /**< \brief (SPI_TDR) The current NPCS will be deasserted after the character written in TD has been transferred. When CSAAT is set, thisallows to close the communication with the current serial peripheral by raising the corresponding NPCS line as soon as TDtransfer has completed. */
205 #define SPI_TDR_LASTXFER_0          (SPI_TDR_LASTXFER_0_Val        << SPI_TDR_LASTXFER_Pos)
206 #define SPI_TDR_LASTXFER_1          (SPI_TDR_LASTXFER_1_Val        << SPI_TDR_LASTXFER_Pos)
207 #define SPI_TDR_MASK                _U_(0x010FFFFF) /**< \brief (SPI_TDR) MASK Register */
208 
209 /* -------- SPI_SR : (SPI Offset: 0x10) (R/  32) Status Register -------- */
210 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
211 typedef union {
212   struct {
213     uint32_t RDRF:1;           /*!< bit:      0  Receive Data Register Full         */
214     uint32_t TDRE:1;           /*!< bit:      1  Transmit Data Register Empty       */
215     uint32_t MODF:1;           /*!< bit:      2  Mode Fault Error                   */
216     uint32_t OVRES:1;          /*!< bit:      3  Overrun Error Status               */
217     uint32_t ENDRX:1;          /*!< bit:      4  End of RX buffer                   */
218     uint32_t ENDTX:1;          /*!< bit:      5  End of TX buffer                   */
219     uint32_t RXBUFF:1;         /*!< bit:      6  RX Buffer Full                     */
220     uint32_t TXBUFE:1;         /*!< bit:      7  TX Buffer Empty                    */
221     uint32_t NSSR:1;           /*!< bit:      8  NSS Rising                         */
222     uint32_t TXEMPTY:1;        /*!< bit:      9  Transmission Registers Empty       */
223     uint32_t UNDES:1;          /*!< bit:     10  Underrun Error Status (Slave Mode Only) */
224     uint32_t :5;               /*!< bit: 11..15  Reserved                           */
225     uint32_t SPIENS:1;         /*!< bit:     16  SPI Enable Status                  */
226     uint32_t :15;              /*!< bit: 17..31  Reserved                           */
227   } bit;                       /*!< Structure used for bit  access                  */
228   uint32_t reg;                /*!< Type      used for register access              */
229 } SPI_SR_Type;
230 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
231 
232 #define SPI_SR_OFFSET               0x10         /**< \brief (SPI_SR offset) Status Register */
233 #define SPI_SR_RESETVALUE           _U_(0x000000F0); /**< \brief (SPI_SR reset_value) Status Register */
234 
235 #define SPI_SR_RDRF_Pos             0            /**< \brief (SPI_SR) Receive Data Register Full */
236 #define SPI_SR_RDRF                 (_U_(0x1) << SPI_SR_RDRF_Pos)
237 #define   SPI_SR_RDRF_0_Val               _U_(0x0)   /**< \brief (SPI_SR) No data has been received since the last read of RDR */
238 #define   SPI_SR_RDRF_1_Val               _U_(0x1)   /**< \brief (SPI_SR) Data has been received and the received data has been transferred from the serializer to RDR since the last readof RDR. */
239 #define SPI_SR_RDRF_0               (SPI_SR_RDRF_0_Val             << SPI_SR_RDRF_Pos)
240 #define SPI_SR_RDRF_1               (SPI_SR_RDRF_1_Val             << SPI_SR_RDRF_Pos)
241 #define SPI_SR_TDRE_Pos             1            /**< \brief (SPI_SR) Transmit Data Register Empty */
242 #define SPI_SR_TDRE                 (_U_(0x1) << SPI_SR_TDRE_Pos)
243 #define   SPI_SR_TDRE_0_Val               _U_(0x0)   /**< \brief (SPI_SR) Data has been written to TDR and not yet transferred to the serializer. */
244 #define   SPI_SR_TDRE_1_Val               _U_(0x1)   /**< \brief (SPI_SR) The last data written in the Transmit Data Register has been transferred to the serializer.TDRE equals zero when the SPI is disabled or at reset. The SPI enable command sets this bit to one. */
245 #define SPI_SR_TDRE_0               (SPI_SR_TDRE_0_Val             << SPI_SR_TDRE_Pos)
246 #define SPI_SR_TDRE_1               (SPI_SR_TDRE_1_Val             << SPI_SR_TDRE_Pos)
247 #define SPI_SR_MODF_Pos             2            /**< \brief (SPI_SR) Mode Fault Error */
248 #define SPI_SR_MODF                 (_U_(0x1) << SPI_SR_MODF_Pos)
249 #define   SPI_SR_MODF_0_Val               _U_(0x0)   /**< \brief (SPI_SR) No Mode Fault has been detected since the last read of SR. */
250 #define   SPI_SR_MODF_1_Val               _U_(0x1)   /**< \brief (SPI_SR) A Mode Fault occurred since the last read of the SR. */
251 #define SPI_SR_MODF_0               (SPI_SR_MODF_0_Val             << SPI_SR_MODF_Pos)
252 #define SPI_SR_MODF_1               (SPI_SR_MODF_1_Val             << SPI_SR_MODF_Pos)
253 #define SPI_SR_OVRES_Pos            3            /**< \brief (SPI_SR) Overrun Error Status */
254 #define SPI_SR_OVRES                (_U_(0x1) << SPI_SR_OVRES_Pos)
255 #define   SPI_SR_OVRES_0_Val              _U_(0x0)   /**< \brief (SPI_SR) No overrun has been detected since the last read of SR. */
256 #define   SPI_SR_OVRES_1_Val              _U_(0x1)   /**< \brief (SPI_SR) An overrun has occurred since the last read of SR. */
257 #define SPI_SR_OVRES_0              (SPI_SR_OVRES_0_Val            << SPI_SR_OVRES_Pos)
258 #define SPI_SR_OVRES_1              (SPI_SR_OVRES_1_Val            << SPI_SR_OVRES_Pos)
259 #define SPI_SR_ENDRX_Pos            4            /**< \brief (SPI_SR) End of RX buffer */
260 #define SPI_SR_ENDRX                (_U_(0x1) << SPI_SR_ENDRX_Pos)
261 #define   SPI_SR_ENDRX_0_Val              _U_(0x0)   /**< \brief (SPI_SR) The Receive Counter Register has not reached 0 since the last write in RCR or RNCR. */
262 #define   SPI_SR_ENDRX_1_Val              _U_(0x1)   /**< \brief (SPI_SR) The Receive Counter Register has reached 0 since the last write in RCR or RNCR. */
263 #define SPI_SR_ENDRX_0              (SPI_SR_ENDRX_0_Val            << SPI_SR_ENDRX_Pos)
264 #define SPI_SR_ENDRX_1              (SPI_SR_ENDRX_1_Val            << SPI_SR_ENDRX_Pos)
265 #define SPI_SR_ENDTX_Pos            5            /**< \brief (SPI_SR) End of TX buffer */
266 #define SPI_SR_ENDTX                (_U_(0x1) << SPI_SR_ENDTX_Pos)
267 #define   SPI_SR_ENDTX_0_Val              _U_(0x0)   /**< \brief (SPI_SR) The Transmit Counter Register has not reached 0 since the last write in TCR or TNCR. */
268 #define   SPI_SR_ENDTX_1_Val              _U_(0x1)   /**< \brief (SPI_SR) The Transmit Counter Register has reached 0 since the last write in TCR or TNCR. */
269 #define SPI_SR_ENDTX_0              (SPI_SR_ENDTX_0_Val            << SPI_SR_ENDTX_Pos)
270 #define SPI_SR_ENDTX_1              (SPI_SR_ENDTX_1_Val            << SPI_SR_ENDTX_Pos)
271 #define SPI_SR_RXBUFF_Pos           6            /**< \brief (SPI_SR) RX Buffer Full */
272 #define SPI_SR_RXBUFF               (_U_(0x1) << SPI_SR_RXBUFF_Pos)
273 #define   SPI_SR_RXBUFF_0_Val             _U_(0x0)   /**< \brief (SPI_SR) RCR or RNCR has a value other than 0. */
274 #define   SPI_SR_RXBUFF_1_Val             _U_(0x1)   /**< \brief (SPI_SR) Both RCR and RNCR has a value of 0. */
275 #define SPI_SR_RXBUFF_0             (SPI_SR_RXBUFF_0_Val           << SPI_SR_RXBUFF_Pos)
276 #define SPI_SR_RXBUFF_1             (SPI_SR_RXBUFF_1_Val           << SPI_SR_RXBUFF_Pos)
277 #define SPI_SR_TXBUFE_Pos           7            /**< \brief (SPI_SR) TX Buffer Empty */
278 #define SPI_SR_TXBUFE               (_U_(0x1) << SPI_SR_TXBUFE_Pos)
279 #define   SPI_SR_TXBUFE_0_Val             _U_(0x0)   /**< \brief (SPI_SR) TCR or TNCR has a value other than 0. */
280 #define   SPI_SR_TXBUFE_1_Val             _U_(0x1)   /**< \brief (SPI_SR) Both TCR and TNCR has a value of 0. */
281 #define SPI_SR_TXBUFE_0             (SPI_SR_TXBUFE_0_Val           << SPI_SR_TXBUFE_Pos)
282 #define SPI_SR_TXBUFE_1             (SPI_SR_TXBUFE_1_Val           << SPI_SR_TXBUFE_Pos)
283 #define SPI_SR_NSSR_Pos             8            /**< \brief (SPI_SR) NSS Rising */
284 #define SPI_SR_NSSR                 (_U_(0x1) << SPI_SR_NSSR_Pos)
285 #define   SPI_SR_NSSR_0_Val               _U_(0x0)   /**< \brief (SPI_SR) No rising edge detected on NSS pin since last read. */
286 #define   SPI_SR_NSSR_1_Val               _U_(0x1)   /**< \brief (SPI_SR) A rising edge occurred on NSS pin since last read. */
287 #define SPI_SR_NSSR_0               (SPI_SR_NSSR_0_Val             << SPI_SR_NSSR_Pos)
288 #define SPI_SR_NSSR_1               (SPI_SR_NSSR_1_Val             << SPI_SR_NSSR_Pos)
289 #define SPI_SR_TXEMPTY_Pos          9            /**< \brief (SPI_SR) Transmission Registers Empty */
290 #define SPI_SR_TXEMPTY              (_U_(0x1) << SPI_SR_TXEMPTY_Pos)
291 #define   SPI_SR_TXEMPTY_0_Val            _U_(0x0)   /**< \brief (SPI_SR) As soon as data is written in TDR. */
292 #define   SPI_SR_TXEMPTY_1_Val            _U_(0x1)   /**< \brief (SPI_SR) TDR and internal shifter are empty. If a transfer delay has been defined, TXEMPTY is set after the completion ofsuch delay. */
293 #define SPI_SR_TXEMPTY_0            (SPI_SR_TXEMPTY_0_Val          << SPI_SR_TXEMPTY_Pos)
294 #define SPI_SR_TXEMPTY_1            (SPI_SR_TXEMPTY_1_Val          << SPI_SR_TXEMPTY_Pos)
295 #define SPI_SR_UNDES_Pos            10           /**< \brief (SPI_SR) Underrun Error Status (Slave Mode Only) */
296 #define SPI_SR_UNDES                (_U_(0x1) << SPI_SR_UNDES_Pos)
297 #define SPI_SR_SPIENS_Pos           16           /**< \brief (SPI_SR) SPI Enable Status */
298 #define SPI_SR_SPIENS               (_U_(0x1) << SPI_SR_SPIENS_Pos)
299 #define   SPI_SR_SPIENS_0_Val             _U_(0x0)   /**< \brief (SPI_SR) SPI is disabled. */
300 #define   SPI_SR_SPIENS_1_Val             _U_(0x1)   /**< \brief (SPI_SR) SPI is enabled. */
301 #define SPI_SR_SPIENS_0             (SPI_SR_SPIENS_0_Val           << SPI_SR_SPIENS_Pos)
302 #define SPI_SR_SPIENS_1             (SPI_SR_SPIENS_1_Val           << SPI_SR_SPIENS_Pos)
303 #define SPI_SR_MASK                 _U_(0x000107FF) /**< \brief (SPI_SR) MASK Register */
304 
305 /* -------- SPI_IER : (SPI Offset: 0x14) ( /W 32) Interrupt Enable Register -------- */
306 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
307 typedef union {
308   struct {
309     uint32_t RDRF:1;           /*!< bit:      0  Receive Data Register Full Interrupt Enable */
310     uint32_t TDRE:1;           /*!< bit:      1  Transmit Data Register Empty Interrupt Enable */
311     uint32_t MODF:1;           /*!< bit:      2  Mode Fault Error Interrupt Enable  */
312     uint32_t OVRES:1;          /*!< bit:      3  Overrun Error Interrupt Enable     */
313     uint32_t ENDRX:1;          /*!< bit:      4  End of Receive Buffer Interrupt Enable */
314     uint32_t ENDTX:1;          /*!< bit:      5  End of Transmit Buffer Interrupt Enable */
315     uint32_t RXBUFF:1;         /*!< bit:      6  Receive Buffer Full Interrupt Enable */
316     uint32_t TXBUFE:1;         /*!< bit:      7  Transmit Buffer Empty Interrupt Enable */
317     uint32_t NSSR:1;           /*!< bit:      8  NSS Rising Interrupt Enable        */
318     uint32_t TXEMPTY:1;        /*!< bit:      9  Transmission Registers Empty Enable */
319     uint32_t UNDES:1;          /*!< bit:     10  Underrun Error Interrupt Enable    */
320     uint32_t :21;              /*!< bit: 11..31  Reserved                           */
321   } bit;                       /*!< Structure used for bit  access                  */
322   uint32_t reg;                /*!< Type      used for register access              */
323 } SPI_IER_Type;
324 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
325 
326 #define SPI_IER_OFFSET              0x14         /**< \brief (SPI_IER offset) Interrupt Enable Register */
327 #define SPI_IER_RESETVALUE          _U_(0x00000000); /**< \brief (SPI_IER reset_value) Interrupt Enable Register */
328 
329 #define SPI_IER_RDRF_Pos            0            /**< \brief (SPI_IER) Receive Data Register Full Interrupt Enable */
330 #define SPI_IER_RDRF                (_U_(0x1) << SPI_IER_RDRF_Pos)
331 #define   SPI_IER_RDRF_0_Val              _U_(0x0)   /**< \brief (SPI_IER) No effect. */
332 #define   SPI_IER_RDRF_1_Val              _U_(0x1)   /**< \brief (SPI_IER) Enables the corresponding interrupt. */
333 #define SPI_IER_RDRF_0              (SPI_IER_RDRF_0_Val            << SPI_IER_RDRF_Pos)
334 #define SPI_IER_RDRF_1              (SPI_IER_RDRF_1_Val            << SPI_IER_RDRF_Pos)
335 #define SPI_IER_TDRE_Pos            1            /**< \brief (SPI_IER) Transmit Data Register Empty Interrupt Enable */
336 #define SPI_IER_TDRE                (_U_(0x1) << SPI_IER_TDRE_Pos)
337 #define   SPI_IER_TDRE_0_Val              _U_(0x0)   /**< \brief (SPI_IER) No effect. */
338 #define   SPI_IER_TDRE_1_Val              _U_(0x1)   /**< \brief (SPI_IER) Enables the corresponding interrupt. */
339 #define SPI_IER_TDRE_0              (SPI_IER_TDRE_0_Val            << SPI_IER_TDRE_Pos)
340 #define SPI_IER_TDRE_1              (SPI_IER_TDRE_1_Val            << SPI_IER_TDRE_Pos)
341 #define SPI_IER_MODF_Pos            2            /**< \brief (SPI_IER) Mode Fault Error Interrupt Enable */
342 #define SPI_IER_MODF                (_U_(0x1) << SPI_IER_MODF_Pos)
343 #define   SPI_IER_MODF_0_Val              _U_(0x0)   /**< \brief (SPI_IER) No effect. */
344 #define   SPI_IER_MODF_1_Val              _U_(0x1)   /**< \brief (SPI_IER) Enables the corresponding interrupt. */
345 #define SPI_IER_MODF_0              (SPI_IER_MODF_0_Val            << SPI_IER_MODF_Pos)
346 #define SPI_IER_MODF_1              (SPI_IER_MODF_1_Val            << SPI_IER_MODF_Pos)
347 #define SPI_IER_OVRES_Pos           3            /**< \brief (SPI_IER) Overrun Error Interrupt Enable */
348 #define SPI_IER_OVRES               (_U_(0x1) << SPI_IER_OVRES_Pos)
349 #define   SPI_IER_OVRES_0_Val             _U_(0x0)   /**< \brief (SPI_IER) No effect. */
350 #define   SPI_IER_OVRES_1_Val             _U_(0x1)   /**< \brief (SPI_IER) Enables the corresponding interrupt. */
351 #define SPI_IER_OVRES_0             (SPI_IER_OVRES_0_Val           << SPI_IER_OVRES_Pos)
352 #define SPI_IER_OVRES_1             (SPI_IER_OVRES_1_Val           << SPI_IER_OVRES_Pos)
353 #define SPI_IER_ENDRX_Pos           4            /**< \brief (SPI_IER) End of Receive Buffer Interrupt Enable */
354 #define SPI_IER_ENDRX               (_U_(0x1) << SPI_IER_ENDRX_Pos)
355 #define   SPI_IER_ENDRX_0_Val             _U_(0x0)   /**< \brief (SPI_IER) No effect. */
356 #define   SPI_IER_ENDRX_1_Val             _U_(0x1)   /**< \brief (SPI_IER) Enables the corresponding interrupt. */
357 #define SPI_IER_ENDRX_0             (SPI_IER_ENDRX_0_Val           << SPI_IER_ENDRX_Pos)
358 #define SPI_IER_ENDRX_1             (SPI_IER_ENDRX_1_Val           << SPI_IER_ENDRX_Pos)
359 #define SPI_IER_ENDTX_Pos           5            /**< \brief (SPI_IER) End of Transmit Buffer Interrupt Enable */
360 #define SPI_IER_ENDTX               (_U_(0x1) << SPI_IER_ENDTX_Pos)
361 #define   SPI_IER_ENDTX_0_Val             _U_(0x0)   /**< \brief (SPI_IER) No effect. */
362 #define   SPI_IER_ENDTX_1_Val             _U_(0x1)   /**< \brief (SPI_IER) Enables the corresponding interrupt. */
363 #define SPI_IER_ENDTX_0             (SPI_IER_ENDTX_0_Val           << SPI_IER_ENDTX_Pos)
364 #define SPI_IER_ENDTX_1             (SPI_IER_ENDTX_1_Val           << SPI_IER_ENDTX_Pos)
365 #define SPI_IER_RXBUFF_Pos          6            /**< \brief (SPI_IER) Receive Buffer Full Interrupt Enable */
366 #define SPI_IER_RXBUFF              (_U_(0x1) << SPI_IER_RXBUFF_Pos)
367 #define   SPI_IER_RXBUFF_0_Val            _U_(0x0)   /**< \brief (SPI_IER) No effect. */
368 #define   SPI_IER_RXBUFF_1_Val            _U_(0x1)   /**< \brief (SPI_IER) Enables the corresponding interrupt. */
369 #define SPI_IER_RXBUFF_0            (SPI_IER_RXBUFF_0_Val          << SPI_IER_RXBUFF_Pos)
370 #define SPI_IER_RXBUFF_1            (SPI_IER_RXBUFF_1_Val          << SPI_IER_RXBUFF_Pos)
371 #define SPI_IER_TXBUFE_Pos          7            /**< \brief (SPI_IER) Transmit Buffer Empty Interrupt Enable */
372 #define SPI_IER_TXBUFE              (_U_(0x1) << SPI_IER_TXBUFE_Pos)
373 #define   SPI_IER_TXBUFE_0_Val            _U_(0x0)   /**< \brief (SPI_IER) No effect. */
374 #define   SPI_IER_TXBUFE_1_Val            _U_(0x1)   /**< \brief (SPI_IER) Enables the corresponding interrupt. */
375 #define SPI_IER_TXBUFE_0            (SPI_IER_TXBUFE_0_Val          << SPI_IER_TXBUFE_Pos)
376 #define SPI_IER_TXBUFE_1            (SPI_IER_TXBUFE_1_Val          << SPI_IER_TXBUFE_Pos)
377 #define SPI_IER_NSSR_Pos            8            /**< \brief (SPI_IER) NSS Rising Interrupt Enable */
378 #define SPI_IER_NSSR                (_U_(0x1) << SPI_IER_NSSR_Pos)
379 #define   SPI_IER_NSSR_0_Val              _U_(0x0)   /**< \brief (SPI_IER) No effect. */
380 #define   SPI_IER_NSSR_1_Val              _U_(0x1)   /**< \brief (SPI_IER) Enables the corresponding interrupt. */
381 #define SPI_IER_NSSR_0              (SPI_IER_NSSR_0_Val            << SPI_IER_NSSR_Pos)
382 #define SPI_IER_NSSR_1              (SPI_IER_NSSR_1_Val            << SPI_IER_NSSR_Pos)
383 #define SPI_IER_TXEMPTY_Pos         9            /**< \brief (SPI_IER) Transmission Registers Empty Enable */
384 #define SPI_IER_TXEMPTY             (_U_(0x1) << SPI_IER_TXEMPTY_Pos)
385 #define   SPI_IER_TXEMPTY_0_Val           _U_(0x0)   /**< \brief (SPI_IER) No effect. */
386 #define   SPI_IER_TXEMPTY_1_Val           _U_(0x1)   /**< \brief (SPI_IER) Enables the corresponding interrupt. */
387 #define SPI_IER_TXEMPTY_0           (SPI_IER_TXEMPTY_0_Val         << SPI_IER_TXEMPTY_Pos)
388 #define SPI_IER_TXEMPTY_1           (SPI_IER_TXEMPTY_1_Val         << SPI_IER_TXEMPTY_Pos)
389 #define SPI_IER_UNDES_Pos           10           /**< \brief (SPI_IER) Underrun Error Interrupt Enable */
390 #define SPI_IER_UNDES               (_U_(0x1) << SPI_IER_UNDES_Pos)
391 #define SPI_IER_MASK                _U_(0x000007FF) /**< \brief (SPI_IER) MASK Register */
392 
393 /* -------- SPI_IDR : (SPI Offset: 0x18) ( /W 32) Interrupt Disable Register -------- */
394 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
395 typedef union {
396   struct {
397     uint32_t RDRF:1;           /*!< bit:      0  Receive Data Register Full Interrupt Disable */
398     uint32_t TDRE:1;           /*!< bit:      1  Transmit Data Register Empty Interrupt Disable */
399     uint32_t MODF:1;           /*!< bit:      2  Mode Fault Error Interrupt Disable */
400     uint32_t OVRES:1;          /*!< bit:      3  Overrun Error Interrupt Disable    */
401     uint32_t ENDRX:1;          /*!< bit:      4  End of Receive Buffer Interrupt Disable */
402     uint32_t ENDTX:1;          /*!< bit:      5  End of Transmit Buffer Interrupt Disable */
403     uint32_t RXBUFF:1;         /*!< bit:      6  Receive Buffer Full Interrupt Disable */
404     uint32_t TXBUFE:1;         /*!< bit:      7  Transmit Buffer Empty Interrupt Disable */
405     uint32_t NSSR:1;           /*!< bit:      8  NSS Rising Interrupt Disable       */
406     uint32_t TXEMPTY:1;        /*!< bit:      9  Transmission Registers Empty Disable */
407     uint32_t UNDES:1;          /*!< bit:     10  Underrun Error Interrupt Disable   */
408     uint32_t :21;              /*!< bit: 11..31  Reserved                           */
409   } bit;                       /*!< Structure used for bit  access                  */
410   uint32_t reg;                /*!< Type      used for register access              */
411 } SPI_IDR_Type;
412 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
413 
414 #define SPI_IDR_OFFSET              0x18         /**< \brief (SPI_IDR offset) Interrupt Disable Register */
415 #define SPI_IDR_RESETVALUE          _U_(0x00000000); /**< \brief (SPI_IDR reset_value) Interrupt Disable Register */
416 
417 #define SPI_IDR_RDRF_Pos            0            /**< \brief (SPI_IDR) Receive Data Register Full Interrupt Disable */
418 #define SPI_IDR_RDRF                (_U_(0x1) << SPI_IDR_RDRF_Pos)
419 #define   SPI_IDR_RDRF_0_Val              _U_(0x0)   /**< \brief (SPI_IDR) No effect. */
420 #define   SPI_IDR_RDRF_1_Val              _U_(0x1)   /**< \brief (SPI_IDR) Disables the corresponding interrupt. */
421 #define SPI_IDR_RDRF_0              (SPI_IDR_RDRF_0_Val            << SPI_IDR_RDRF_Pos)
422 #define SPI_IDR_RDRF_1              (SPI_IDR_RDRF_1_Val            << SPI_IDR_RDRF_Pos)
423 #define SPI_IDR_TDRE_Pos            1            /**< \brief (SPI_IDR) Transmit Data Register Empty Interrupt Disable */
424 #define SPI_IDR_TDRE                (_U_(0x1) << SPI_IDR_TDRE_Pos)
425 #define   SPI_IDR_TDRE_0_Val              _U_(0x0)   /**< \brief (SPI_IDR) No effect. */
426 #define   SPI_IDR_TDRE_1_Val              _U_(0x1)   /**< \brief (SPI_IDR) Disables the corresponding interrupt. */
427 #define SPI_IDR_TDRE_0              (SPI_IDR_TDRE_0_Val            << SPI_IDR_TDRE_Pos)
428 #define SPI_IDR_TDRE_1              (SPI_IDR_TDRE_1_Val            << SPI_IDR_TDRE_Pos)
429 #define SPI_IDR_MODF_Pos            2            /**< \brief (SPI_IDR) Mode Fault Error Interrupt Disable */
430 #define SPI_IDR_MODF                (_U_(0x1) << SPI_IDR_MODF_Pos)
431 #define   SPI_IDR_MODF_0_Val              _U_(0x0)   /**< \brief (SPI_IDR) No effect. */
432 #define   SPI_IDR_MODF_1_Val              _U_(0x1)   /**< \brief (SPI_IDR) Disables the corresponding interrupt. */
433 #define SPI_IDR_MODF_0              (SPI_IDR_MODF_0_Val            << SPI_IDR_MODF_Pos)
434 #define SPI_IDR_MODF_1              (SPI_IDR_MODF_1_Val            << SPI_IDR_MODF_Pos)
435 #define SPI_IDR_OVRES_Pos           3            /**< \brief (SPI_IDR) Overrun Error Interrupt Disable */
436 #define SPI_IDR_OVRES               (_U_(0x1) << SPI_IDR_OVRES_Pos)
437 #define   SPI_IDR_OVRES_0_Val             _U_(0x0)   /**< \brief (SPI_IDR) No effect. */
438 #define   SPI_IDR_OVRES_1_Val             _U_(0x1)   /**< \brief (SPI_IDR) Disables the corresponding interrupt. */
439 #define SPI_IDR_OVRES_0             (SPI_IDR_OVRES_0_Val           << SPI_IDR_OVRES_Pos)
440 #define SPI_IDR_OVRES_1             (SPI_IDR_OVRES_1_Val           << SPI_IDR_OVRES_Pos)
441 #define SPI_IDR_ENDRX_Pos           4            /**< \brief (SPI_IDR) End of Receive Buffer Interrupt Disable */
442 #define SPI_IDR_ENDRX               (_U_(0x1) << SPI_IDR_ENDRX_Pos)
443 #define   SPI_IDR_ENDRX_0_Val             _U_(0x0)   /**< \brief (SPI_IDR) No effect. */
444 #define   SPI_IDR_ENDRX_1_Val             _U_(0x1)   /**< \brief (SPI_IDR) Disables the corresponding interrupt. */
445 #define SPI_IDR_ENDRX_0             (SPI_IDR_ENDRX_0_Val           << SPI_IDR_ENDRX_Pos)
446 #define SPI_IDR_ENDRX_1             (SPI_IDR_ENDRX_1_Val           << SPI_IDR_ENDRX_Pos)
447 #define SPI_IDR_ENDTX_Pos           5            /**< \brief (SPI_IDR) End of Transmit Buffer Interrupt Disable */
448 #define SPI_IDR_ENDTX               (_U_(0x1) << SPI_IDR_ENDTX_Pos)
449 #define   SPI_IDR_ENDTX_0_Val             _U_(0x0)   /**< \brief (SPI_IDR) No effect. */
450 #define   SPI_IDR_ENDTX_1_Val             _U_(0x1)   /**< \brief (SPI_IDR) Disables the corresponding interrupt. */
451 #define SPI_IDR_ENDTX_0             (SPI_IDR_ENDTX_0_Val           << SPI_IDR_ENDTX_Pos)
452 #define SPI_IDR_ENDTX_1             (SPI_IDR_ENDTX_1_Val           << SPI_IDR_ENDTX_Pos)
453 #define SPI_IDR_RXBUFF_Pos          6            /**< \brief (SPI_IDR) Receive Buffer Full Interrupt Disable */
454 #define SPI_IDR_RXBUFF              (_U_(0x1) << SPI_IDR_RXBUFF_Pos)
455 #define   SPI_IDR_RXBUFF_0_Val            _U_(0x0)   /**< \brief (SPI_IDR) No effect. */
456 #define   SPI_IDR_RXBUFF_1_Val            _U_(0x1)   /**< \brief (SPI_IDR) Disables the corresponding interrupt. */
457 #define SPI_IDR_RXBUFF_0            (SPI_IDR_RXBUFF_0_Val          << SPI_IDR_RXBUFF_Pos)
458 #define SPI_IDR_RXBUFF_1            (SPI_IDR_RXBUFF_1_Val          << SPI_IDR_RXBUFF_Pos)
459 #define SPI_IDR_TXBUFE_Pos          7            /**< \brief (SPI_IDR) Transmit Buffer Empty Interrupt Disable */
460 #define SPI_IDR_TXBUFE              (_U_(0x1) << SPI_IDR_TXBUFE_Pos)
461 #define   SPI_IDR_TXBUFE_0_Val            _U_(0x0)   /**< \brief (SPI_IDR) No effect. */
462 #define   SPI_IDR_TXBUFE_1_Val            _U_(0x1)   /**< \brief (SPI_IDR) Disables the corresponding interrupt. */
463 #define SPI_IDR_TXBUFE_0            (SPI_IDR_TXBUFE_0_Val          << SPI_IDR_TXBUFE_Pos)
464 #define SPI_IDR_TXBUFE_1            (SPI_IDR_TXBUFE_1_Val          << SPI_IDR_TXBUFE_Pos)
465 #define SPI_IDR_NSSR_Pos            8            /**< \brief (SPI_IDR) NSS Rising Interrupt Disable */
466 #define SPI_IDR_NSSR                (_U_(0x1) << SPI_IDR_NSSR_Pos)
467 #define   SPI_IDR_NSSR_0_Val              _U_(0x0)   /**< \brief (SPI_IDR) No effect. */
468 #define   SPI_IDR_NSSR_1_Val              _U_(0x1)   /**< \brief (SPI_IDR) Disables the corresponding interrupt. */
469 #define SPI_IDR_NSSR_0              (SPI_IDR_NSSR_0_Val            << SPI_IDR_NSSR_Pos)
470 #define SPI_IDR_NSSR_1              (SPI_IDR_NSSR_1_Val            << SPI_IDR_NSSR_Pos)
471 #define SPI_IDR_TXEMPTY_Pos         9            /**< \brief (SPI_IDR) Transmission Registers Empty Disable */
472 #define SPI_IDR_TXEMPTY             (_U_(0x1) << SPI_IDR_TXEMPTY_Pos)
473 #define   SPI_IDR_TXEMPTY_0_Val           _U_(0x0)   /**< \brief (SPI_IDR) No effect. */
474 #define   SPI_IDR_TXEMPTY_1_Val           _U_(0x1)   /**< \brief (SPI_IDR) Disables the corresponding interrupt. */
475 #define SPI_IDR_TXEMPTY_0           (SPI_IDR_TXEMPTY_0_Val         << SPI_IDR_TXEMPTY_Pos)
476 #define SPI_IDR_TXEMPTY_1           (SPI_IDR_TXEMPTY_1_Val         << SPI_IDR_TXEMPTY_Pos)
477 #define SPI_IDR_UNDES_Pos           10           /**< \brief (SPI_IDR) Underrun Error Interrupt Disable */
478 #define SPI_IDR_UNDES               (_U_(0x1) << SPI_IDR_UNDES_Pos)
479 #define SPI_IDR_MASK                _U_(0x000007FF) /**< \brief (SPI_IDR) MASK Register */
480 
481 /* -------- SPI_IMR : (SPI Offset: 0x1C) (R/  32) Interrupt Mask Register -------- */
482 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
483 typedef union {
484   struct {
485     uint32_t RDRF:1;           /*!< bit:      0  Receive Data Register Full Interrupt Mask */
486     uint32_t TDRE:1;           /*!< bit:      1  Transmit Data Register Empty Interrupt Mask */
487     uint32_t MODF:1;           /*!< bit:      2  Mode Fault Error Interrupt Mask    */
488     uint32_t OVRES:1;          /*!< bit:      3  Overrun Error Interrupt Mask       */
489     uint32_t ENDRX:1;          /*!< bit:      4  End of Receive Buffer Interrupt Mask */
490     uint32_t ENDTX:1;          /*!< bit:      5  End of Transmit Buffer Interrupt Mask */
491     uint32_t RXBUFF:1;         /*!< bit:      6  Receive Buffer Full Interrupt Mask */
492     uint32_t TXBUFE:1;         /*!< bit:      7  Transmit Buffer Empty Interrupt Mask */
493     uint32_t NSSR:1;           /*!< bit:      8  NSS Rising Interrupt Mask          */
494     uint32_t TXEMPTY:1;        /*!< bit:      9  Transmission Registers Empty Mask  */
495     uint32_t UNDES:1;          /*!< bit:     10  Underrun Error Interrupt Mask      */
496     uint32_t :21;              /*!< bit: 11..31  Reserved                           */
497   } bit;                       /*!< Structure used for bit  access                  */
498   uint32_t reg;                /*!< Type      used for register access              */
499 } SPI_IMR_Type;
500 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
501 
502 #define SPI_IMR_OFFSET              0x1C         /**< \brief (SPI_IMR offset) Interrupt Mask Register */
503 #define SPI_IMR_RESETVALUE          _U_(0x00000000); /**< \brief (SPI_IMR reset_value) Interrupt Mask Register */
504 
505 #define SPI_IMR_RDRF_Pos            0            /**< \brief (SPI_IMR) Receive Data Register Full Interrupt Mask */
506 #define SPI_IMR_RDRF                (_U_(0x1) << SPI_IMR_RDRF_Pos)
507 #define   SPI_IMR_RDRF_0_Val              _U_(0x0)   /**< \brief (SPI_IMR) The corresponding interrupt is not enabled. */
508 #define   SPI_IMR_RDRF_1_Val              _U_(0x1)   /**< \brief (SPI_IMR) The corresponding interrupt is enabled. */
509 #define SPI_IMR_RDRF_0              (SPI_IMR_RDRF_0_Val            << SPI_IMR_RDRF_Pos)
510 #define SPI_IMR_RDRF_1              (SPI_IMR_RDRF_1_Val            << SPI_IMR_RDRF_Pos)
511 #define SPI_IMR_TDRE_Pos            1            /**< \brief (SPI_IMR) Transmit Data Register Empty Interrupt Mask */
512 #define SPI_IMR_TDRE                (_U_(0x1) << SPI_IMR_TDRE_Pos)
513 #define   SPI_IMR_TDRE_0_Val              _U_(0x0)   /**< \brief (SPI_IMR) The corresponding interrupt is not enabled. */
514 #define   SPI_IMR_TDRE_1_Val              _U_(0x1)   /**< \brief (SPI_IMR) The corresponding interrupt is enabled. */
515 #define SPI_IMR_TDRE_0              (SPI_IMR_TDRE_0_Val            << SPI_IMR_TDRE_Pos)
516 #define SPI_IMR_TDRE_1              (SPI_IMR_TDRE_1_Val            << SPI_IMR_TDRE_Pos)
517 #define SPI_IMR_MODF_Pos            2            /**< \brief (SPI_IMR) Mode Fault Error Interrupt Mask */
518 #define SPI_IMR_MODF                (_U_(0x1) << SPI_IMR_MODF_Pos)
519 #define   SPI_IMR_MODF_0_Val              _U_(0x0)   /**< \brief (SPI_IMR) The corresponding interrupt is not enabled. */
520 #define   SPI_IMR_MODF_1_Val              _U_(0x1)   /**< \brief (SPI_IMR) The corresponding interrupt is enabled. */
521 #define SPI_IMR_MODF_0              (SPI_IMR_MODF_0_Val            << SPI_IMR_MODF_Pos)
522 #define SPI_IMR_MODF_1              (SPI_IMR_MODF_1_Val            << SPI_IMR_MODF_Pos)
523 #define SPI_IMR_OVRES_Pos           3            /**< \brief (SPI_IMR) Overrun Error Interrupt Mask */
524 #define SPI_IMR_OVRES               (_U_(0x1) << SPI_IMR_OVRES_Pos)
525 #define   SPI_IMR_OVRES_0_Val             _U_(0x0)   /**< \brief (SPI_IMR) The corresponding interrupt is not enabled. */
526 #define   SPI_IMR_OVRES_1_Val             _U_(0x1)   /**< \brief (SPI_IMR) The corresponding interrupt is enabled. */
527 #define SPI_IMR_OVRES_0             (SPI_IMR_OVRES_0_Val           << SPI_IMR_OVRES_Pos)
528 #define SPI_IMR_OVRES_1             (SPI_IMR_OVRES_1_Val           << SPI_IMR_OVRES_Pos)
529 #define SPI_IMR_ENDRX_Pos           4            /**< \brief (SPI_IMR) End of Receive Buffer Interrupt Mask */
530 #define SPI_IMR_ENDRX               (_U_(0x1) << SPI_IMR_ENDRX_Pos)
531 #define   SPI_IMR_ENDRX_0_Val             _U_(0x0)   /**< \brief (SPI_IMR) The corresponding interrupt is not enabled. */
532 #define   SPI_IMR_ENDRX_1_Val             _U_(0x1)   /**< \brief (SPI_IMR) The corresponding interrupt is enabled. */
533 #define SPI_IMR_ENDRX_0             (SPI_IMR_ENDRX_0_Val           << SPI_IMR_ENDRX_Pos)
534 #define SPI_IMR_ENDRX_1             (SPI_IMR_ENDRX_1_Val           << SPI_IMR_ENDRX_Pos)
535 #define SPI_IMR_ENDTX_Pos           5            /**< \brief (SPI_IMR) End of Transmit Buffer Interrupt Mask */
536 #define SPI_IMR_ENDTX               (_U_(0x1) << SPI_IMR_ENDTX_Pos)
537 #define   SPI_IMR_ENDTX_0_Val             _U_(0x0)   /**< \brief (SPI_IMR) The corresponding interrupt is not enabled. */
538 #define   SPI_IMR_ENDTX_1_Val             _U_(0x1)   /**< \brief (SPI_IMR) The corresponding interrupt is enabled. */
539 #define SPI_IMR_ENDTX_0             (SPI_IMR_ENDTX_0_Val           << SPI_IMR_ENDTX_Pos)
540 #define SPI_IMR_ENDTX_1             (SPI_IMR_ENDTX_1_Val           << SPI_IMR_ENDTX_Pos)
541 #define SPI_IMR_RXBUFF_Pos          6            /**< \brief (SPI_IMR) Receive Buffer Full Interrupt Mask */
542 #define SPI_IMR_RXBUFF              (_U_(0x1) << SPI_IMR_RXBUFF_Pos)
543 #define   SPI_IMR_RXBUFF_0_Val            _U_(0x0)   /**< \brief (SPI_IMR) The corresponding interrupt is not enabled. */
544 #define   SPI_IMR_RXBUFF_1_Val            _U_(0x1)   /**< \brief (SPI_IMR) The corresponding interrupt is enabled. */
545 #define SPI_IMR_RXBUFF_0            (SPI_IMR_RXBUFF_0_Val          << SPI_IMR_RXBUFF_Pos)
546 #define SPI_IMR_RXBUFF_1            (SPI_IMR_RXBUFF_1_Val          << SPI_IMR_RXBUFF_Pos)
547 #define SPI_IMR_TXBUFE_Pos          7            /**< \brief (SPI_IMR) Transmit Buffer Empty Interrupt Mask */
548 #define SPI_IMR_TXBUFE              (_U_(0x1) << SPI_IMR_TXBUFE_Pos)
549 #define   SPI_IMR_TXBUFE_0_Val            _U_(0x0)   /**< \brief (SPI_IMR) The corresponding interrupt is not enabled. */
550 #define   SPI_IMR_TXBUFE_1_Val            _U_(0x1)   /**< \brief (SPI_IMR) The corresponding interrupt is enabled. */
551 #define SPI_IMR_TXBUFE_0            (SPI_IMR_TXBUFE_0_Val          << SPI_IMR_TXBUFE_Pos)
552 #define SPI_IMR_TXBUFE_1            (SPI_IMR_TXBUFE_1_Val          << SPI_IMR_TXBUFE_Pos)
553 #define SPI_IMR_NSSR_Pos            8            /**< \brief (SPI_IMR) NSS Rising Interrupt Mask */
554 #define SPI_IMR_NSSR                (_U_(0x1) << SPI_IMR_NSSR_Pos)
555 #define   SPI_IMR_NSSR_0_Val              _U_(0x0)   /**< \brief (SPI_IMR) The corresponding interrupt is not enabled. */
556 #define   SPI_IMR_NSSR_1_Val              _U_(0x1)   /**< \brief (SPI_IMR) The corresponding interrupt is enabled. */
557 #define SPI_IMR_NSSR_0              (SPI_IMR_NSSR_0_Val            << SPI_IMR_NSSR_Pos)
558 #define SPI_IMR_NSSR_1              (SPI_IMR_NSSR_1_Val            << SPI_IMR_NSSR_Pos)
559 #define SPI_IMR_TXEMPTY_Pos         9            /**< \brief (SPI_IMR) Transmission Registers Empty Mask */
560 #define SPI_IMR_TXEMPTY             (_U_(0x1) << SPI_IMR_TXEMPTY_Pos)
561 #define   SPI_IMR_TXEMPTY_0_Val           _U_(0x0)   /**< \brief (SPI_IMR) The corresponding interrupt is not enabled. */
562 #define   SPI_IMR_TXEMPTY_1_Val           _U_(0x1)   /**< \brief (SPI_IMR) The corresponding interrupt is enabled. */
563 #define SPI_IMR_TXEMPTY_0           (SPI_IMR_TXEMPTY_0_Val         << SPI_IMR_TXEMPTY_Pos)
564 #define SPI_IMR_TXEMPTY_1           (SPI_IMR_TXEMPTY_1_Val         << SPI_IMR_TXEMPTY_Pos)
565 #define SPI_IMR_UNDES_Pos           10           /**< \brief (SPI_IMR) Underrun Error Interrupt Mask */
566 #define SPI_IMR_UNDES               (_U_(0x1) << SPI_IMR_UNDES_Pos)
567 #define SPI_IMR_MASK                _U_(0x000007FF) /**< \brief (SPI_IMR) MASK Register */
568 
569 /* -------- SPI_CSR : (SPI Offset: 0x30) (R/W 32) Chip Select Register -------- */
570 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
571 typedef union {
572   struct {
573     uint32_t CPOL:1;           /*!< bit:      0  Clock Polarity                     */
574     uint32_t NCPHA:1;          /*!< bit:      1  Clock Phase                        */
575     uint32_t CSNAAT:1;         /*!< bit:      2  Chip Select Not Active After Transfer */
576     uint32_t CSAAT:1;          /*!< bit:      3  Chip Select Active After Transfer  */
577     uint32_t BITS:4;           /*!< bit:  4.. 7  Bits Per Transfer                  */
578     uint32_t SCBR:8;           /*!< bit:  8..15  Serial Clock Baud Rate             */
579     uint32_t DLYBS:8;          /*!< bit: 16..23  Delay Before SPCK                  */
580     uint32_t DLYBCT:8;         /*!< bit: 24..31  Delay Between Consecutive Transfers */
581   } bit;                       /*!< Structure used for bit  access                  */
582   uint32_t reg;                /*!< Type      used for register access              */
583 } SPI_CSR_Type;
584 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
585 
586 #define SPI_CSR_OFFSET              0x30         /**< \brief (SPI_CSR offset) Chip Select Register */
587 #define SPI_CSR_RESETVALUE          _U_(0x00000000); /**< \brief (SPI_CSR reset_value) Chip Select Register */
588 
589 #define SPI_CSR_CPOL_Pos            0            /**< \brief (SPI_CSR) Clock Polarity */
590 #define SPI_CSR_CPOL                (_U_(0x1) << SPI_CSR_CPOL_Pos)
591 #define   SPI_CSR_CPOL_0_Val              _U_(0x0)   /**< \brief (SPI_CSR) The inactive state value of SPCK is logic level zero. */
592 #define   SPI_CSR_CPOL_1_Val              _U_(0x1)   /**< \brief (SPI_CSR) The inactive state value of SPCK is logic level one.CPOL is used to determine the inactive state value of the serial clock (SPCK). It is used with NCPHA to produce therequired clock/data relationship between master and slave devices. */
593 #define SPI_CSR_CPOL_0              (SPI_CSR_CPOL_0_Val            << SPI_CSR_CPOL_Pos)
594 #define SPI_CSR_CPOL_1              (SPI_CSR_CPOL_1_Val            << SPI_CSR_CPOL_Pos)
595 #define SPI_CSR_NCPHA_Pos           1            /**< \brief (SPI_CSR) Clock Phase */
596 #define SPI_CSR_NCPHA               (_U_(0x1) << SPI_CSR_NCPHA_Pos)
597 #define   SPI_CSR_NCPHA_0_Val             _U_(0x0)   /**< \brief (SPI_CSR) Data is changed on the leading edge of SPCK and captured on the following edge of SPCK. */
598 #define   SPI_CSR_NCPHA_1_Val             _U_(0x1)   /**< \brief (SPI_CSR) Data is captured on the leading edge of SPCK and changed on the following edge of SPCK.NCPHA determines which edge of SPCK causes data to change and which edge causes data to be captured. NCPHA isused with CPOL to produce the required clock/data relationship between master and slave devices. */
599 #define SPI_CSR_NCPHA_0             (SPI_CSR_NCPHA_0_Val           << SPI_CSR_NCPHA_Pos)
600 #define SPI_CSR_NCPHA_1             (SPI_CSR_NCPHA_1_Val           << SPI_CSR_NCPHA_Pos)
601 #define SPI_CSR_CSNAAT_Pos          2            /**< \brief (SPI_CSR) Chip Select Not Active After Transfer */
602 #define SPI_CSR_CSNAAT              (_U_(0x1) << SPI_CSR_CSNAAT_Pos)
603 #define SPI_CSR_CSAAT_Pos           3            /**< \brief (SPI_CSR) Chip Select Active After Transfer */
604 #define SPI_CSR_CSAAT               (_U_(0x1) << SPI_CSR_CSAAT_Pos)
605 #define   SPI_CSR_CSAAT_0_Val             _U_(0x0)   /**< \brief (SPI_CSR) The Peripheral Chip Select Line rises as soon as the last transfer is achieved. */
606 #define   SPI_CSR_CSAAT_1_Val             _U_(0x1)   /**< \brief (SPI_CSR) The Peripheral Chip Select does not rise after the last transfer is achieved. It remains active until a new transfer isrequested on a different chip select. */
607 #define SPI_CSR_CSAAT_0             (SPI_CSR_CSAAT_0_Val           << SPI_CSR_CSAAT_Pos)
608 #define SPI_CSR_CSAAT_1             (SPI_CSR_CSAAT_1_Val           << SPI_CSR_CSAAT_Pos)
609 #define SPI_CSR_BITS_Pos            4            /**< \brief (SPI_CSR) Bits Per Transfer */
610 #define SPI_CSR_BITS_Msk            (_U_(0xF) << SPI_CSR_BITS_Pos)
611 #define SPI_CSR_BITS(value)         (SPI_CSR_BITS_Msk & ((value) << SPI_CSR_BITS_Pos))
612 #define   SPI_CSR_BITS_8_BPT_Val          _U_(0x0)   /**< \brief (SPI_CSR) 8 bits per transfer */
613 #define   SPI_CSR_BITS_9_BPT_Val          _U_(0x1)   /**< \brief (SPI_CSR) 9 bits per transfer */
614 #define   SPI_CSR_BITS_10_BPT_Val         _U_(0x2)   /**< \brief (SPI_CSR) 10 bits per transfer */
615 #define   SPI_CSR_BITS_11_BPT_Val         _U_(0x3)   /**< \brief (SPI_CSR) 11 bits per transfer */
616 #define   SPI_CSR_BITS_12_BPT_Val         _U_(0x4)   /**< \brief (SPI_CSR) 12 bits per transfer */
617 #define   SPI_CSR_BITS_13_BPT_Val         _U_(0x5)   /**< \brief (SPI_CSR) 13 bits per transfer */
618 #define   SPI_CSR_BITS_14_BPT_Val         _U_(0x6)   /**< \brief (SPI_CSR) 14 bits per transfer */
619 #define   SPI_CSR_BITS_15_BPT_Val         _U_(0x7)   /**< \brief (SPI_CSR) 15 bits per transfer */
620 #define   SPI_CSR_BITS_16_BPT_Val         _U_(0x8)   /**< \brief (SPI_CSR) 16 bits per transfer */
621 #define SPI_CSR_BITS_8_BPT          (SPI_CSR_BITS_8_BPT_Val        << SPI_CSR_BITS_Pos)
622 #define SPI_CSR_BITS_9_BPT          (SPI_CSR_BITS_9_BPT_Val        << SPI_CSR_BITS_Pos)
623 #define SPI_CSR_BITS_10_BPT         (SPI_CSR_BITS_10_BPT_Val       << SPI_CSR_BITS_Pos)
624 #define SPI_CSR_BITS_11_BPT         (SPI_CSR_BITS_11_BPT_Val       << SPI_CSR_BITS_Pos)
625 #define SPI_CSR_BITS_12_BPT         (SPI_CSR_BITS_12_BPT_Val       << SPI_CSR_BITS_Pos)
626 #define SPI_CSR_BITS_13_BPT         (SPI_CSR_BITS_13_BPT_Val       << SPI_CSR_BITS_Pos)
627 #define SPI_CSR_BITS_14_BPT         (SPI_CSR_BITS_14_BPT_Val       << SPI_CSR_BITS_Pos)
628 #define SPI_CSR_BITS_15_BPT         (SPI_CSR_BITS_15_BPT_Val       << SPI_CSR_BITS_Pos)
629 #define SPI_CSR_BITS_16_BPT         (SPI_CSR_BITS_16_BPT_Val       << SPI_CSR_BITS_Pos)
630 #define SPI_CSR_SCBR_Pos            8            /**< \brief (SPI_CSR) Serial Clock Baud Rate */
631 #define SPI_CSR_SCBR_Msk            (_U_(0xFF) << SPI_CSR_SCBR_Pos)
632 #define SPI_CSR_SCBR(value)         (SPI_CSR_SCBR_Msk & ((value) << SPI_CSR_SCBR_Pos))
633 #define SPI_CSR_DLYBS_Pos           16           /**< \brief (SPI_CSR) Delay Before SPCK */
634 #define SPI_CSR_DLYBS_Msk           (_U_(0xFF) << SPI_CSR_DLYBS_Pos)
635 #define SPI_CSR_DLYBS(value)        (SPI_CSR_DLYBS_Msk & ((value) << SPI_CSR_DLYBS_Pos))
636 #define SPI_CSR_DLYBCT_Pos          24           /**< \brief (SPI_CSR) Delay Between Consecutive Transfers */
637 #define SPI_CSR_DLYBCT_Msk          (_U_(0xFF) << SPI_CSR_DLYBCT_Pos)
638 #define SPI_CSR_DLYBCT(value)       (SPI_CSR_DLYBCT_Msk & ((value) << SPI_CSR_DLYBCT_Pos))
639 #define SPI_CSR_MASK                _U_(0xFFFFFFFF) /**< \brief (SPI_CSR) MASK Register */
640 
641 /* -------- SPI_WPCR : (SPI Offset: 0xE4) (R/W 32) Write Protection control Register -------- */
642 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
643 typedef union {
644   struct {
645     uint32_t WPEN:1;           /*!< bit:      0  Write Protection Enable            */
646     uint32_t :7;               /*!< bit:  1.. 7  Reserved                           */
647     uint32_t WPKEY:24;         /*!< bit:  8..31  Write Protection Key Password      */
648   } bit;                       /*!< Structure used for bit  access                  */
649   uint32_t reg;                /*!< Type      used for register access              */
650 } SPI_WPCR_Type;
651 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
652 
653 #define SPI_WPCR_OFFSET             0xE4         /**< \brief (SPI_WPCR offset) Write Protection control Register */
654 #define SPI_WPCR_RESETVALUE         _U_(0x00000000); /**< \brief (SPI_WPCR reset_value) Write Protection control Register */
655 
656 #define SPI_WPCR_WPEN_Pos           0            /**< \brief (SPI_WPCR) Write Protection Enable */
657 #define SPI_WPCR_WPEN               (_U_(0x1) << SPI_WPCR_WPEN_Pos)
658 #define SPI_WPCR_WPKEY_Pos          8            /**< \brief (SPI_WPCR) Write Protection Key Password */
659 #define SPI_WPCR_WPKEY_Msk          (_U_(0xFFFFFF) << SPI_WPCR_WPKEY_Pos)
660 #define SPI_WPCR_WPKEY(value)       (SPI_WPCR_WPKEY_Msk & ((value) << SPI_WPCR_WPKEY_Pos))
661 #define   SPI_WPCR_WPKEY_VALUE_Val        _U_(0x535049)   /**< \brief (SPI_WPCR) SPI Write Protection Key Password */
662 #define SPI_WPCR_WPKEY_VALUE        (SPI_WPCR_WPKEY_VALUE_Val      << SPI_WPCR_WPKEY_Pos)
663 #define SPI_WPCR_MASK               _U_(0xFFFFFF01) /**< \brief (SPI_WPCR) MASK Register */
664 
665 /* -------- SPI_WPSR : (SPI Offset: 0xE8) (R/  32) Write Protection status Register -------- */
666 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
667 typedef union {
668   struct {
669     uint32_t WPVS:3;           /*!< bit:  0.. 2  Write Protection Violation Status  */
670     uint32_t :5;               /*!< bit:  3.. 7  Reserved                           */
671     uint32_t WPVSRC:8;         /*!< bit:  8..15  Write Protection Violation Source  */
672     uint32_t :16;              /*!< bit: 16..31  Reserved                           */
673   } bit;                       /*!< Structure used for bit  access                  */
674   uint32_t reg;                /*!< Type      used for register access              */
675 } SPI_WPSR_Type;
676 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
677 
678 #define SPI_WPSR_OFFSET             0xE8         /**< \brief (SPI_WPSR offset) Write Protection status Register */
679 #define SPI_WPSR_RESETVALUE         _U_(0x00000000); /**< \brief (SPI_WPSR reset_value) Write Protection status Register */
680 
681 #define SPI_WPSR_WPVS_Pos           0            /**< \brief (SPI_WPSR) Write Protection Violation Status */
682 #define SPI_WPSR_WPVS_Msk           (_U_(0x7) << SPI_WPSR_WPVS_Pos)
683 #define SPI_WPSR_WPVS(value)        (SPI_WPSR_WPVS_Msk & ((value) << SPI_WPSR_WPVS_Pos))
684 #define   SPI_WPSR_WPVS_WRITE_WITH_WP_Val _U_(0x1)   /**< \brief (SPI_WPSR) The Write Protection has blocked a Write access to a protected register (since the last read). */
685 #define   SPI_WPSR_WPVS_SWRST_WITH_WP_Val _U_(0x2)   /**< \brief (SPI_WPSR) Software Reset has been performed while Write Protection was enabled (since the last read or since the last write access on MR, IER, IDR or CSRx). */
686 #define   SPI_WPSR_WPVS_UNEXPECTED_WRITE_Val _U_(0x4)   /**< \brief (SPI_WPSR) Write accesses have been detected on MR (while a chip select was active) or on CSRi (while the Chip Select “i” was active) since the last read. */
687 #define SPI_WPSR_WPVS_WRITE_WITH_WP (SPI_WPSR_WPVS_WRITE_WITH_WP_Val << SPI_WPSR_WPVS_Pos)
688 #define SPI_WPSR_WPVS_SWRST_WITH_WP (SPI_WPSR_WPVS_SWRST_WITH_WP_Val << SPI_WPSR_WPVS_Pos)
689 #define SPI_WPSR_WPVS_UNEXPECTED_WRITE (SPI_WPSR_WPVS_UNEXPECTED_WRITE_Val << SPI_WPSR_WPVS_Pos)
690 #define SPI_WPSR_WPVSRC_Pos         8            /**< \brief (SPI_WPSR) Write Protection Violation Source */
691 #define SPI_WPSR_WPVSRC_Msk         (_U_(0xFF) << SPI_WPSR_WPVSRC_Pos)
692 #define SPI_WPSR_WPVSRC(value)      (SPI_WPSR_WPVSRC_Msk & ((value) << SPI_WPSR_WPVSRC_Pos))
693 #define SPI_WPSR_MASK               _U_(0x0000FF07) /**< \brief (SPI_WPSR) MASK Register */
694 
695 /* -------- SPI_FEATURES : (SPI Offset: 0xF8) (R/  32) Features Register -------- */
696 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
697 typedef union {
698   struct {
699     uint32_t NCS:4;            /*!< bit:  0.. 3  Number of Chip Selects             */
700     uint32_t PCONF:1;          /*!< bit:      4  Polarity is Configurable           */
701     uint32_t PPNCONF:1;        /*!< bit:      5  Polarity is Positive if Polarity is not Configurable */
702     uint32_t PHCONF:1;         /*!< bit:      6  Phase is Configurable              */
703     uint32_t PHZNCONF:1;       /*!< bit:      7  Phase is Zero if Phase is not Configurable */
704     uint32_t LENCONF:1;        /*!< bit:      8  Character Length is Configurable   */
705     uint32_t LENNCONF:7;       /*!< bit:  9..15  Character Length if not Configurable */
706     uint32_t EXTDEC:1;         /*!< bit:     16  External Decoder is True           */
707     uint32_t CSNAATIMPL:1;     /*!< bit:     17  CSNAAT Features are Implemented    */
708     uint32_t BRPBHSB:1;        /*!< bit:     18  Bridge Type is PB to HSB           */
709     uint32_t FIFORIMPL:1;      /*!< bit:     19  FIFO in Reception is Implemented   */
710     uint32_t SWPIMPL:1;        /*!< bit:     20  Spurious Write Protection is Implemented */
711     uint32_t :11;              /*!< bit: 21..31  Reserved                           */
712   } bit;                       /*!< Structure used for bit  access                  */
713   uint32_t reg;                /*!< Type      used for register access              */
714 } SPI_FEATURES_Type;
715 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
716 
717 #define SPI_FEATURES_OFFSET         0xF8         /**< \brief (SPI_FEATURES offset) Features Register */
718 
719 #define SPI_FEATURES_NCS_Pos        0            /**< \brief (SPI_FEATURES) Number of Chip Selects */
720 #define SPI_FEATURES_NCS_Msk        (_U_(0xF) << SPI_FEATURES_NCS_Pos)
721 #define SPI_FEATURES_NCS(value)     (SPI_FEATURES_NCS_Msk & ((value) << SPI_FEATURES_NCS_Pos))
722 #define SPI_FEATURES_PCONF_Pos      4            /**< \brief (SPI_FEATURES) Polarity is Configurable */
723 #define SPI_FEATURES_PCONF          (_U_(0x1) << SPI_FEATURES_PCONF_Pos)
724 #define SPI_FEATURES_PPNCONF_Pos    5            /**< \brief (SPI_FEATURES) Polarity is Positive if Polarity is not Configurable */
725 #define SPI_FEATURES_PPNCONF        (_U_(0x1) << SPI_FEATURES_PPNCONF_Pos)
726 #define SPI_FEATURES_PHCONF_Pos     6            /**< \brief (SPI_FEATURES) Phase is Configurable */
727 #define SPI_FEATURES_PHCONF         (_U_(0x1) << SPI_FEATURES_PHCONF_Pos)
728 #define SPI_FEATURES_PHZNCONF_Pos   7            /**< \brief (SPI_FEATURES) Phase is Zero if Phase is not Configurable */
729 #define SPI_FEATURES_PHZNCONF       (_U_(0x1) << SPI_FEATURES_PHZNCONF_Pos)
730 #define SPI_FEATURES_LENCONF_Pos    8            /**< \brief (SPI_FEATURES) Character Length is Configurable */
731 #define SPI_FEATURES_LENCONF        (_U_(0x1) << SPI_FEATURES_LENCONF_Pos)
732 #define SPI_FEATURES_LENNCONF_Pos   9            /**< \brief (SPI_FEATURES) Character Length if not Configurable */
733 #define SPI_FEATURES_LENNCONF_Msk   (_U_(0x7F) << SPI_FEATURES_LENNCONF_Pos)
734 #define SPI_FEATURES_LENNCONF(value) (SPI_FEATURES_LENNCONF_Msk & ((value) << SPI_FEATURES_LENNCONF_Pos))
735 #define SPI_FEATURES_EXTDEC_Pos     16           /**< \brief (SPI_FEATURES) External Decoder is True */
736 #define SPI_FEATURES_EXTDEC         (_U_(0x1) << SPI_FEATURES_EXTDEC_Pos)
737 #define SPI_FEATURES_CSNAATIMPL_Pos 17           /**< \brief (SPI_FEATURES) CSNAAT Features are Implemented */
738 #define SPI_FEATURES_CSNAATIMPL     (_U_(0x1) << SPI_FEATURES_CSNAATIMPL_Pos)
739 #define SPI_FEATURES_BRPBHSB_Pos    18           /**< \brief (SPI_FEATURES) Bridge Type is PB to HSB */
740 #define SPI_FEATURES_BRPBHSB        (_U_(0x1) << SPI_FEATURES_BRPBHSB_Pos)
741 #define SPI_FEATURES_FIFORIMPL_Pos  19           /**< \brief (SPI_FEATURES) FIFO in Reception is Implemented */
742 #define SPI_FEATURES_FIFORIMPL      (_U_(0x1) << SPI_FEATURES_FIFORIMPL_Pos)
743 #define SPI_FEATURES_SWPIMPL_Pos    20           /**< \brief (SPI_FEATURES) Spurious Write Protection is Implemented */
744 #define SPI_FEATURES_SWPIMPL        (_U_(0x1) << SPI_FEATURES_SWPIMPL_Pos)
745 #define SPI_FEATURES_MASK           _U_(0x001FFFFF) /**< \brief (SPI_FEATURES) MASK Register */
746 
747 /* -------- SPI_VERSION : (SPI Offset: 0xFC) (R/  32) Version Register -------- */
748 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
749 typedef union {
750   struct {
751     uint32_t VERSION:12;       /*!< bit:  0..11  Version                            */
752     uint32_t :4;               /*!< bit: 12..15  Reserved                           */
753     uint32_t MFN:3;            /*!< bit: 16..18  mfn                                */
754     uint32_t :13;              /*!< bit: 19..31  Reserved                           */
755   } bit;                       /*!< Structure used for bit  access                  */
756   uint32_t reg;                /*!< Type      used for register access              */
757 } SPI_VERSION_Type;
758 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
759 
760 #define SPI_VERSION_OFFSET          0xFC         /**< \brief (SPI_VERSION offset) Version Register */
761 #define SPI_VERSION_RESETVALUE      _U_(0x00000211); /**< \brief (SPI_VERSION reset_value) Version Register */
762 
763 #define SPI_VERSION_VERSION_Pos     0            /**< \brief (SPI_VERSION) Version */
764 #define SPI_VERSION_VERSION_Msk     (_U_(0xFFF) << SPI_VERSION_VERSION_Pos)
765 #define SPI_VERSION_VERSION(value)  (SPI_VERSION_VERSION_Msk & ((value) << SPI_VERSION_VERSION_Pos))
766 #define SPI_VERSION_MFN_Pos         16           /**< \brief (SPI_VERSION) mfn */
767 #define SPI_VERSION_MFN_Msk         (_U_(0x7) << SPI_VERSION_MFN_Pos)
768 #define SPI_VERSION_MFN(value)      (SPI_VERSION_MFN_Msk & ((value) << SPI_VERSION_MFN_Pos))
769 #define SPI_VERSION_MASK            _U_(0x00070FFF) /**< \brief (SPI_VERSION) MASK Register */
770 
771 /** \brief SPI hardware registers */
772 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
773 typedef struct {
774   __O  uint32_t           SPI_CR;	/**< \brief Offset: 0x00 ( /W 32) Control Register */
775   __IO uint32_t           SPI_MR;	/**< \brief Offset: 0x04 (R/W 32) Mode Register */
776   __I  uint32_t          SPI_RDR;	/**< \brief Offset: 0x08 (R/  32) Receive Data Register */
777   __O  uint32_t          SPI_TDR;	/**< \brief Offset: 0x0C ( /W 32) Transmit Data Register */
778   __I  uint32_t           SPI_SR;	/**< \brief Offset: 0x10 (R/  32) Status Register */
779   __O  uint32_t          SPI_IER;	/**< \brief Offset: 0x14 ( /W 32) Interrupt Enable Register */
780   __O  uint32_t          SPI_IDR;	/**< \brief Offset: 0x18 ( /W 32) Interrupt Disable Register */
781   __I  uint32_t          SPI_IMR;	/**< \brief Offset: 0x1C (R/  32) Interrupt Mask Register */
782   __I  uint8_t   Reserved1[0x10];
783   __IO uint32_t       SPI_CSR[4];	/**< \brief Offset: 0x30 (R/W 32) Chip Select Register */
784   __I  uint8_t   Reserved2[0xA4];
785   __IO uint32_t         SPI_WPCR;	/**< \brief Offset: 0xE4 (R/W 32) Write Protection control Register */
786   __I  uint32_t         SPI_WPSR;	/**< \brief Offset: 0xE8 (R/  32) Write Protection status Register */
787   __I  uint8_t    Reserved3[0xC];
788   __I  uint32_t     SPI_FEATURES;	/**< \brief Offset: 0xF8 (R/  32) Features Register */
789   __I  uint32_t      SPI_VERSION;	/**< \brief Offset: 0xFC (R/  32) Version Register */
790 } Spi;
791 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
792 
793 /*@}*/
794 
795 #endif /* _SAM4L_SPI_COMPONENT_ */
796