RTEMS  5.1
component_spi.h
1 /* ---------------------------------------------------------------------------- */
2 /* Atmel Microcontroller Software Support */
3 /* SAM Software Package License */
4 /* ---------------------------------------------------------------------------- */
5 /* Copyright (c) 2015, Atmel Corporation */
6 /* */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without */
10 /* modification, are permitted provided that the following condition is met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, */
13 /* this list of conditions and the disclaimer below. */
14 /* */
15 /* Atmel's name may not be used to endorse or promote products derived from */
16 /* this software without specific prior written permission. */
17 /* */
18 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
19 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
21 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */
22 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
24 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
25 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
26 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
28 /* ---------------------------------------------------------------------------- */
29 
30 #ifndef _SAME70_SPI_COMPONENT_
31 #define _SAME70_SPI_COMPONENT_
32 
33 /* ============================================================================= */
35 /* ============================================================================= */
38 
39 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
40 
41 typedef struct {
42  __O uint32_t SPI_CR;
43  __IO uint32_t SPI_MR;
44  __I uint32_t SPI_RDR;
45  __O uint32_t SPI_TDR;
46  __I uint32_t SPI_SR;
47  __O uint32_t SPI_IER;
48  __O uint32_t SPI_IDR;
49  __I uint32_t SPI_IMR;
50  __I uint32_t Reserved1[4];
51  __IO uint32_t SPI_CSR[4];
52  __I uint32_t Reserved2[41];
53  __IO uint32_t SPI_WPMR;
54  __I uint32_t SPI_WPSR;
55 } Spi;
56 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
57 /* -------- SPI_CR : (SPI Offset: 0x00) Control Register -------- */
58 #define SPI_CR_SPIEN (0x1u << 0)
59 #define SPI_CR_SPIDIS (0x1u << 1)
60 #define SPI_CR_SWRST (0x1u << 7)
61 #define SPI_CR_LASTXFER (0x1u << 24)
62 /* -------- SPI_MR : (SPI Offset: 0x04) Mode Register -------- */
63 #define SPI_MR_MSTR (0x1u << 0)
64 #define SPI_MR_PS (0x1u << 1)
65 #define SPI_MR_PCSDEC (0x1u << 2)
66 #define SPI_MR_MODFDIS (0x1u << 4)
67 #define SPI_MR_WDRBT (0x1u << 5)
68 #define SPI_MR_LLB (0x1u << 7)
69 #define SPI_MR_PCS_Pos 16
70 #define SPI_MR_PCS_Msk (0xfu << SPI_MR_PCS_Pos)
71 #define SPI_MR_PCS(value) ((SPI_MR_PCS_Msk & ((value) << SPI_MR_PCS_Pos)))
72 #define SPI_MR_DLYBCS_Pos 24
73 #define SPI_MR_DLYBCS_Msk (0xffu << SPI_MR_DLYBCS_Pos)
74 #define SPI_MR_DLYBCS(value) ((SPI_MR_DLYBCS_Msk & ((value) << SPI_MR_DLYBCS_Pos)))
75 /* -------- SPI_RDR : (SPI Offset: 0x08) Receive Data Register -------- */
76 #define SPI_RDR_RD_Pos 0
77 #define SPI_RDR_RD_Msk (0xffffu << SPI_RDR_RD_Pos)
78 #define SPI_RDR_PCS_Pos 16
79 #define SPI_RDR_PCS_Msk (0xfu << SPI_RDR_PCS_Pos)
80 /* -------- SPI_TDR : (SPI Offset: 0x0C) Transmit Data Register -------- */
81 #define SPI_TDR_TD_Pos 0
82 #define SPI_TDR_TD_Msk (0xffffu << SPI_TDR_TD_Pos)
83 #define SPI_TDR_TD(value) ((SPI_TDR_TD_Msk & ((value) << SPI_TDR_TD_Pos)))
84 #define SPI_TDR_PCS_Pos 16
85 #define SPI_TDR_PCS_Msk (0xfu << SPI_TDR_PCS_Pos)
86 #define SPI_TDR_PCS(value) ((SPI_TDR_PCS_Msk & ((value) << SPI_TDR_PCS_Pos)))
87 #define SPI_TDR_LASTXFER (0x1u << 24)
88 /* -------- SPI_SR : (SPI Offset: 0x10) Status Register -------- */
89 #define SPI_SR_RDRF (0x1u << 0)
90 #define SPI_SR_TDRE (0x1u << 1)
91 #define SPI_SR_MODF (0x1u << 2)
92 #define SPI_SR_OVRES (0x1u << 3)
93 #define SPI_SR_NSSR (0x1u << 8)
94 #define SPI_SR_TXEMPTY (0x1u << 9)
95 #define SPI_SR_UNDES (0x1u << 10)
96 #define SPI_SR_SPIENS (0x1u << 16)
97 /* -------- SPI_IER : (SPI Offset: 0x14) Interrupt Enable Register -------- */
98 #define SPI_IER_RDRF (0x1u << 0)
99 #define SPI_IER_TDRE (0x1u << 1)
100 #define SPI_IER_MODF (0x1u << 2)
101 #define SPI_IER_OVRES (0x1u << 3)
102 #define SPI_IER_NSSR (0x1u << 8)
103 #define SPI_IER_TXEMPTY (0x1u << 9)
104 #define SPI_IER_UNDES (0x1u << 10)
105 /* -------- SPI_IDR : (SPI Offset: 0x18) Interrupt Disable Register -------- */
106 #define SPI_IDR_RDRF (0x1u << 0)
107 #define SPI_IDR_TDRE (0x1u << 1)
108 #define SPI_IDR_MODF (0x1u << 2)
109 #define SPI_IDR_OVRES (0x1u << 3)
110 #define SPI_IDR_NSSR (0x1u << 8)
111 #define SPI_IDR_TXEMPTY (0x1u << 9)
112 #define SPI_IDR_UNDES (0x1u << 10)
113 /* -------- SPI_IMR : (SPI Offset: 0x1C) Interrupt Mask Register -------- */
114 #define SPI_IMR_RDRF (0x1u << 0)
115 #define SPI_IMR_TDRE (0x1u << 1)
116 #define SPI_IMR_MODF (0x1u << 2)
117 #define SPI_IMR_OVRES (0x1u << 3)
118 #define SPI_IMR_NSSR (0x1u << 8)
119 #define SPI_IMR_TXEMPTY (0x1u << 9)
120 #define SPI_IMR_UNDES (0x1u << 10)
121 /* -------- SPI_CSR[4] : (SPI Offset: 0x30) Chip Select Register -------- */
122 #define SPI_CSR_CPOL (0x1u << 0)
123 #define SPI_CSR_NCPHA (0x1u << 1)
124 #define SPI_CSR_CSNAAT (0x1u << 2)
125 #define SPI_CSR_CSAAT (0x1u << 3)
126 #define SPI_CSR_BITS_Pos 4
127 #define SPI_CSR_BITS_Msk (0xfu << SPI_CSR_BITS_Pos)
128 #define SPI_CSR_BITS(value) ((SPI_CSR_BITS_Msk & ((value) << SPI_CSR_BITS_Pos)))
129 #define SPI_CSR_BITS_8_BIT (0x0u << 4)
130 #define SPI_CSR_BITS_9_BIT (0x1u << 4)
131 #define SPI_CSR_BITS_10_BIT (0x2u << 4)
132 #define SPI_CSR_BITS_11_BIT (0x3u << 4)
133 #define SPI_CSR_BITS_12_BIT (0x4u << 4)
134 #define SPI_CSR_BITS_13_BIT (0x5u << 4)
135 #define SPI_CSR_BITS_14_BIT (0x6u << 4)
136 #define SPI_CSR_BITS_15_BIT (0x7u << 4)
137 #define SPI_CSR_BITS_16_BIT (0x8u << 4)
138 #define SPI_CSR_SCBR_Pos 8
139 #define SPI_CSR_SCBR_Msk (0xffu << SPI_CSR_SCBR_Pos)
140 #define SPI_CSR_SCBR(value) ((SPI_CSR_SCBR_Msk & ((value) << SPI_CSR_SCBR_Pos)))
141 #define SPI_CSR_DLYBS_Pos 16
142 #define SPI_CSR_DLYBS_Msk (0xffu << SPI_CSR_DLYBS_Pos)
143 #define SPI_CSR_DLYBS(value) ((SPI_CSR_DLYBS_Msk & ((value) << SPI_CSR_DLYBS_Pos)))
144 #define SPI_CSR_DLYBCT_Pos 24
145 #define SPI_CSR_DLYBCT_Msk (0xffu << SPI_CSR_DLYBCT_Pos)
146 #define SPI_CSR_DLYBCT(value) ((SPI_CSR_DLYBCT_Msk & ((value) << SPI_CSR_DLYBCT_Pos)))
147 /* -------- SPI_WPMR : (SPI Offset: 0xE4) Write Protection Mode Register -------- */
148 #define SPI_WPMR_WPEN (0x1u << 0)
149 #define SPI_WPMR_WPKEY_Pos 8
150 #define SPI_WPMR_WPKEY_Msk (0xffffffu << SPI_WPMR_WPKEY_Pos)
151 #define SPI_WPMR_WPKEY(value) ((SPI_WPMR_WPKEY_Msk & ((value) << SPI_WPMR_WPKEY_Pos)))
152 #define SPI_WPMR_WPKEY_PASSWD (0x535049u << 8)
153 /* -------- SPI_WPSR : (SPI Offset: 0xE8) Write Protection Status Register -------- */
154 #define SPI_WPSR_WPVS (0x1u << 0)
155 #define SPI_WPSR_WPVSRC_Pos 8
156 #define SPI_WPSR_WPVSRC_Msk (0xffu << SPI_WPSR_WPVSRC_Pos)
159 
160 
161 #endif /* _SAME70_SPI_COMPONENT_ */
__I uint32_t SPI_SR
(Spi Offset: 0x10) Status Register
Definition: component_spi.h:46
__I uint32_t SPI_IMR
(Spi Offset: 0x1C) Interrupt Mask Register
Definition: component_spi.h:49
__I uint32_t SPI_RDR
(Spi Offset: 0x08) Receive Data Register
Definition: component_spi.h:44
#define __IO
Definition: core_cm7.h:287
#define __O
Definition: core_cm7.h:286
Spi hardware registers.
Definition: component_spi.h:41
__O uint32_t SPI_IER
(Spi Offset: 0x14) Interrupt Enable Register
Definition: component_spi.h:47
__IO uint32_t SPI_WPMR
(Spi Offset: 0xE4) Write Protection Mode Register
Definition: component_spi.h:53
__O uint32_t SPI_TDR
(Spi Offset: 0x0C) Transmit Data Register
Definition: component_spi.h:45
__O uint32_t SPI_IDR
(Spi Offset: 0x18) Interrupt Disable Register
Definition: component_spi.h:48
__I uint32_t SPI_WPSR
(Spi Offset: 0xE8) Write Protection Status Register
Definition: component_spi.h:54
__O uint32_t SPI_CR
(Spi Offset: 0x00) Control Register
Definition: component_spi.h:42
__IO uint32_t SPI_MR
(Spi Offset: 0x04) Mode Register
Definition: component_spi.h:43
#define __I
Definition: core_cm7.h:284