4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
34 * \author Francesco Sacchi <batt@develer.com>
36 * AT91SAM7 SPI register definitions.
37 * This file is based on NUT/OS implementation. See license below.
42 * Copyright (C) 2006-2007 by egnite Software GmbH. All rights reserved.
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
48 * 1. Redistributions of source code must retain the above copyright
49 * notice, this list of conditions and the following disclaimer.
50 * 2. Redistributions in binary form must reproduce the above copyright
51 * notice, this list of conditions and the following disclaimer in the
52 * documentation and/or other materials provided with the distribution.
53 * 3. Neither the name of the copyright holders nor the names of
54 * contributors may be used to endorse or promote products derived
55 * from this software without specific prior written permission.
57 * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
58 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
59 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
60 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
61 * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
62 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
63 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
64 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
65 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
66 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
67 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70 * For additional information see http://www.ethernut.de/
78 * SPI Control Register
81 #define SPI_CR_OFF 0x00000000 ///< Control register offset.
83 #define SPI_SPIEN 0 ///< SPI enable.
84 #define SPI_SPIDIS 1 ///< SPI disable.
85 #define SPI_SWRST 7 ///< Software reset.
86 #define SPI_LASTXFER 24 ///< Last transfer.
93 #define SPI_MR_OFF 0x00000004 ///< Mode register offset.
95 #define SPI_MSTR 0 ///< Master mode.
96 #define SPI_PS 1 ///< Peripheral select.
97 #define SPI_PCSDEC 2 ///< Chip select decode.
98 #define SPI_FDIV 3 ///< Clock selection.
99 #define SPI_MODFDIS 4 ///< Mode fault detection.
100 #define SPI_LLB 7 ///< Local loopback enable.
101 #define SPI_PCS 0x000F0000 ///< Peripheral chip select mask.
102 #define SPI_PCS_0 0x000E0000 ///< Peripheral chip select 0.
103 #define SPI_PCS_1 0x000D0000 ///< Peripheral chip select 1.
104 #define SPI_PCS_2 0x000B0000 ///< Peripheral chip select 2.
105 #define SPI_PCS_3 0x00070000 ///< Peripheral chip select 3.
106 #define SPI_PCS_SHIFT 16 ///< Least significant bit of peripheral chip select.
107 #define SPI_DLYBCS 0xFF000000 ///< Mask for delay between chip selects.
108 #define SPI_DLYBCS_SHIFT 24 ///< Least significant bit of delay between chip selects.
112 * SPI Receive Data Register
115 #define SPI_RDR_OFF 0x00000008 ///< Receive data register offset.
117 #define SPI_RD 0x0000FFFF ///< Receive data mask.
118 #define SPI_RD_SHIFT 0 ///< Least significant bit of receive data.
122 * SPI Transmit Data Register
125 #define SPI_TDR_OFF 0x0000000C ///< Transmit data register offset.
127 #define SPI_TD 0x0000FFFF ///< Transmit data mask.
128 #define SPI_TD_SHIFT 0 ///< Least significant bit of transmit data.
132 * SPI Status and Interrupt Register
135 #define SPI_SR_OFF 0x00000010 ///< Status register offset.
136 #define SPI_IER_OFF 0x00000014 ///< Interrupt enable register offset.
137 #define SPI_IDR_OFF 0x00000018 ///< Interrupt disable register offset.
138 #define SPI_IMR_OFF 0x0000001C ///< Interrupt mask register offset.
140 #define SPI_RDRF 0 ///< Receive data register full.
141 #define SPI_TDRE 1 ///< Transmit data register empty.
142 #define SPI_MODF 2 ///< Mode fault error.
143 #define SPI_OVRES 3 ///< Overrun error status.
144 #define SPI_ENDRX 4 ///< End of RX buffer.
145 #define SPI_ENDTX 5 ///< End of TX buffer.
146 #define SPI_RXBUFF 6 ///< RX buffer full.
147 #define SPI_TXBUFE 7 ///< TX buffer empty.
148 #define SPI_NSSR 8 ///< NSS rising.
149 #define SPI_TXEMPTY 9 ///< Transmission register empty.
150 #define SPI_SPIENS 16 ///< SPI enable status.
154 * SPI Chip Select Registers
157 #define SPI_CSR0_OFF 0x00000030 ///< Chip select register 0 offset.
158 #define SPI_CSR1_OFF 0x00000034 ///< Chip select register 1 offset.
159 #define SPI_CSR2_OFF 0x00000038 ///< Chip select register 2 offset.
160 #define SPI_CSR3_OFF 0x0000003C ///< Chip select register 3 offset.
162 #define SPI_CPOL 0 ///< Clock polarity.
163 #define SPI_NCPHA 1 ///< Clock phase.
164 #define SPI_CSAAT 3 ///< Chip select active after transfer.
165 #define SPI_BITS 0x000000F0 ///< Bits per transfer mask.
166 #define SPI_BITS_8 0x00000000 ///< 8 bits per transfer.
167 #define SPI_BITS_9 0x00000010 ///< 9 bits per transfer.
168 #define SPI_BITS_10 0x00000020 ///< 10 bits per transfer.
169 #define SPI_BITS_11 0x00000030 ///< 11 bits per transfer.
170 #define SPI_BITS_12 0x00000040 ///< 12 bits per transfer.
171 #define SPI_BITS_13 0x00000050 ///< 13 bits per transfer.
172 #define SPI_BITS_14 0x00000060 ///< 14 bits per transfer.
173 #define SPI_BITS_15 0x00000070 ///< 15 bits per transfer.
174 #define SPI_BITS_16 0x00000080 ///< 16 bits per transfer.
175 #define SPI_BITS_SHIFT 4 ///< Least significant bit of bits per transfer.
176 #define SPI_SCBR 0x0000FF00 ///< Serial clock baud rate mask.
177 #define SPI_SCBR_SHIFT 8 ///< Least significant bit of serial clock baud rate.
178 #define SPI_DLYBS 0x00FF0000 ///< Delay before SPCK mask.
179 #define SPI_DLYBS_SHIFT 16 ///< Least significant bit of delay before SPCK.
180 #define SPI_DLYBCT 0xFF000000 ///< Delay between consecutive transfers mask.
181 #define SPI_DLYBCT_SHIFT 24 ///< Least significant bit of delay between consecutive transfers.
185 * Single SPI Register Addresses
188 #if defined(SPI_BASE)
189 #define SPI0_BASE SPI_BASE
190 #define SPI_CR SPI0_CR ///< SPI Control Register Write-only.
191 #define SPI_MR SPI0_MR ///< SPI Mode Register Read/Write Reset=0x0.
192 #define SPI_RDR SPI0_RDR ///< SPI Receive Data Register Read-only Reset=0x0.
193 #define SPI_TDR SPI0_TDR ///< SPI Transmit Data Register Write-only .
194 #define SPI_SR SPI0_SR ///< SPI Status Register Read-only Reset=0x000000F0.
195 #define SPI_IER SPI0_IER ///< SPI Interrupt Enable Register Write-only.
196 #define SPI_IDR SPI0_IDR ///< SPI Interrupt Disable Register Write-only.
197 #define SPI_IMR SPI0_IMR ///< SPI Interrupt Mask Register Read-only Reset=0x0.
198 #define SPI_CSR0 SPI0_CSR0 ///< SPI Chip Select Register 0 Read/Write Reset=0x0.
199 #define SPI_CSR1 SPI0_CSR1 ///< SPI Chip Select Register 1 Read/Write Reset=0x0.
200 #define SPI_CSR2 SPI0_CSR2 ///< SPI Chip Select Register 2 Read/Write Reset=0x0.
201 #define SPI_CSR3 SPI0_CSR3 ///< SPI Chip Select Register 3 Read/Write Reset=0x0.
202 #if defined(SPI_HAS_PDC)
203 #define SPI_RPR SPI0_RPR ///< PDC channel 0 receive pointer register.
204 #define SPI_RCR SPI0_RCR ///< PDC channel 0 receive counter register.
205 #define SPI_TPR SPI0_TPR ///< PDC channel 0 transmit pointer register.
206 #define SPI_TCR SPI0_TCR ///< PDC channel 0 transmit counter register.
207 #define SPI_RNPR SPI0_RNPR ///< PDC channel 0 receive next pointer register.
208 #define SPI_RNCR SPI0_RNCR ///< PDC channel 0 receive next counter register.
209 #define SPI_TNPR SPI0_TNPR ///< PDC channel 0 transmit next pointer register.
210 #define SPI_TNCR SPI0_TNCR ///< PDC channel 0 transmit next counter register.
211 #define SPI_PTCR SPI0_PTCR ///< PDC channel 0 transfer control register.
212 #define SPI_PTSR SPI0_PTSR ///< PDC channel 0 transfer status register.
213 #endif /* SPI_HAS_PDC */
214 #endif /* SPI_BASE */
218 * SPI 0 Register Addresses
221 #if defined(SPI0_BASE)
222 #define SPI0_CR (*((reg32_t *)(SPI0_BASE + SPI_CR_OFF))) ///< SPI Control Register Write-only.
223 #define SPI0_MR (*((reg32_t *)(SPI0_BASE + SPI_MR_OFF))) ///< SPI Mode Register Read/Write Reset=0x0.
224 #define SPI0_RDR (*((reg32_t *)(SPI0_BASE + SPI_RDR_OFF))) ///< SPI Receive Data Register Read-only Reset=0x0.
225 #define SPI0_TDR (*((reg32_t *)(SPI0_BASE + SPI_TDR_OFF))) ///< SPI Transmit Data Register Write-only .
226 #define SPI0_SR (*((reg32_t *)(SPI0_BASE + SPI_SR_OFF))) ///< SPI Status Register Read-only Reset=0x000000F0.
227 #define SPI0_IER (*((reg32_t *)(SPI0_BASE + SPI_IER_OFF))) ///< SPI Interrupt Enable Register Write-only.
228 #define SPI0_IDR (*((reg32_t *)(SPI0_BASE + SPI_IDR_OFF))) ///< SPI Interrupt Disable Register Write-only.
229 #define SPI0_IMR (*((reg32_t *)(SPI0_BASE + SPI_IMR_OFF))) ///< SPI Interrupt Mask Register Read-only Reset=0x0.
230 #define SPI0_CSR0 (*((reg32_t *)(SPI0_BASE + SPI_CSR0_OFF))) ///< SPI Chip Select Register 0 Read/Write Reset=0x0.
231 #define SPI0_CSR1 (*((reg32_t *)(SPI0_BASE + SPI_CSR1_OFF))) ///< SPI Chip Select Register 1 Read/Write Reset=0x0.
232 #define SPI0_CSR2 (*((reg32_t *)(SPI0_BASE + SPI_CSR2_OFF))) ///< SPI Chip Select Register 2 Read/Write Reset=0x0.
233 #define SPI0_CSR3 (*((reg32_t *)(SPI0_BASE + SPI_CSR3_OFF))) ///< SPI Chip Select Register 3 Read/Write Reset=0x0.
234 #if defined(SPI_HAS_PDC)
235 #define SPI0_RPR (*((reg32_t *)(SPI0_BASE + PERIPH_RPR_OFF))) ///< PDC channel 0 receive pointer register.
236 #define SPI0_RCR (*((reg32_t *)(SPI0_BASE + PERIPH_RCR_OFF))) ///< PDC channel 0 receive counter register.
237 #define SPI0_TPR (*((reg32_t *)(SPI0_BASE + PERIPH_TPR_OFF))) ///< PDC channel 0 transmit pointer register.
238 #define SPI0_TCR (*((reg32_t *)(SPI0_BASE + PERIPH_TCR_OFF))) ///< PDC channel 0 transmit counter register.
239 #define SPI0_RNPR (*((reg32_t *)(SPI0_BASE + PERIPH_RNPR_OFF))) ///< PDC channel 0 receive next pointer register.
240 #define SPI0_RNCR (*((reg32_t *)(SPI0_BASE + PERIPH_RNCR_OFF))) ///< PDC channel 0 receive next counter register.
241 #define SPI0_TNPR (*((reg32_t *)(SPI0_BASE + PERIPH_TNPR_OFF))) ///< PDC channel 0 transmit next pointer register.
242 #define SPI0_TNCR (*((reg32_t *)(SPI0_BASE + PERIPH_TNCR_OFF))) ///< PDC channel 0 transmit next counter register.
243 #define SPI0_PTCR (*((reg32_t *)(SPI0_BASE + PERIPH_PTCR_OFF))) ///< PDC channel 0 transfer control register.
244 #define SPI0_PTSR (*((reg32_t *)(SPI0_BASE + PERIPH_PTSR_OFF))) ///< PDC channel 0 transfer status register.
245 #endif /* SPI_HAS_PDC */
246 #endif /* SPI0_BASE */
250 * SPI 1 Register Addresses
253 #if defined(SPI1_BASE)
254 #define SPI1_CR (*((reg32_t *)(SPI1_BASE + SPI_CR_OFF))) ///< SPI Control Register Write-only.
255 #define SPI1_MR (*((reg32_t *)(SPI1_BASE + SPI_MR_OFF))) ///< SPI Mode Register Read/Write Reset=0x0.
256 #define SPI1_RDR (*((reg32_t *)(SPI1_BASE + SPI_RDR_OFF))) ///< SPI Receive Data Register Read-only Reset=0x0.
257 #define SPI1_TDR (*((reg32_t *)(SPI1_BASE + SPI_TDR_OFF))) ///< SPI Transmit Data Register Write-only .
258 #define SPI1_SR (*((reg32_t *)(SPI1_BASE + SPI_SR_OFF))) ///< SPI Status Register Read-only Reset=0x000000F0.
259 #define SPI1_IER (*((reg32_t *)(SPI1_BASE + SPI_IER_OFF))) ///< SPI Interrupt Enable Register Write-only.
260 #define SPI1_IDR (*((reg32_t *)(SPI1_BASE + SPI_IDR_OFF))) ///< SPI Interrupt Disable Register Write-only.
261 #define SPI1_IMR (*((reg32_t *)(SPI1_BASE + SPI_IMR_OFF))) ///< SPI Interrupt Mask Register Read-only Reset=0x0.
262 #define SPI1_CSR0 (*((reg32_t *)(SPI1_BASE + SPI_CSR0_OFF))) ///< SPI Chip Select Register 0 Read/Write Reset=0x0.
263 #define SPI1_CSR1 (*((reg32_t *)(SPI1_BASE + SPI_CSR1_OFF))) ///< SPI Chip Select Register 1 Read/Write Reset=0x0.
264 #define SPI1_CSR2 (*((reg32_t *)(SPI1_BASE + SPI_CSR2_OFF))) ///< SPI Chip Select Register 2 Read/Write Reset=0x0.
265 #define SPI1_CSR3 (*((reg32_t *)(SPI1_BASE + SPI_CSR3_OFF))) ///< SPI Chip Select Register 3 Read/Write Reset=0x0.
266 #if defined(SPI_HAS_PDC)
267 #define SPI1_RPR (*((reg32_t *)(SPI1_BASE + PERIPH_RPR_OFF))) ///< PDC channel 1 receive pointer register.
268 #define SPI1_RCR (*((reg32_t *)(SPI1_BASE + PERIPH_RCR_OFF))) ///< PDC channel 1 receive counter register.
269 #define SPI1_TPR (*((reg32_t *)(SPI1_BASE + PERIPH_TPR_OFF))) ///< PDC channel 1 transmit pointer register.
270 #define SPI1_TCR (*((reg32_t *)(SPI1_BASE + PERIPH_TCR_OFF))) ///< PDC channel 1 transmit counter register.
271 #define SPI1_RNPR (*((reg32_t *)(SPI1_BASE + PERIPH_RNPR_OFF))) ///< PDC channel 1 receive next pointer register.
272 #define SPI1_RNCR (*((reg32_t *)(SPI1_BASE + PERIPH_RNCR_OFF))) ///< PDC channel 1 receive next counter register.
273 #define SPI1_TNPR (*((reg32_t *)(SPI1_BASE + PERIPH_TNPR_OFF))) ///< PDC channel 1 transmit next pointer register.
274 #define SPI1_TNCR (*((reg32_t *)(SPI1_BASE + PERIPH_TNCR_OFF))) ///< PDC channel 1 transmit next counter register.
275 #define SPI1_PTCR (*((reg32_t *)(SPI1_BASE + PERIPH_PTCR_OFF))) ///< PDC channel 1 transfer control register.
276 #define SPI1_PTSR (*((reg32_t *)(SPI1_BASE + PERIPH_PTSR_OFF))) ///< PDC channel 1 transfer status register.
277 #endif /* SPI_HAS_PDC */
278 #endif /* SPI1_BASE */
281 #endif /* AT91_SPI_H */