Add support for flash sizes on all supported AT91SAM7 cpus.
[bertos.git] / bertos / cpu / arm / io / at91_ssc.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
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.
10  *
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.
15  *
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
19  *
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.
28  *
29  * Copyright 2009 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \version $Id$
34  *
35  * \author Luca Ottaviano <lottaviano@develer.com>
36  *
37  * AT91SAM7 SSC register definitions.
38  * This file is based on NUT/OS implementation. See license below.
39  */
40
41 /*
42  * Copyright (C) 2006-2007 by egnite Software GmbH. All rights reserved.
43  *
44  * Redistribution and use in source and binary forms, with or without
45  * modification, are permitted provided that the following conditions
46  * are met:
47  *
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.
56  *
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
68  * SUCH DAMAGE.
69  *
70  * For additional information see http://www.ethernut.de/
71  */
72
73 #ifndef AT91_SSC_H
74 #define AT91_SSC_H
75
76 #include <io/at91sam7.h>
77
78 /**
79  * SSC Control Register
80  */
81 /*\{*/
82 #define SSC_CR_OFF                  0x00000000  ///< Control register offset.
83
84 #define SSC_RXEN                     0  ///< Receive enable.
85 #define SSC_RXDIS                    1  ///< Receive disable.
86 #define SSC_TXEN                     8  ///< Transmit enable.
87 #define SSC_TXDIS                    9  ///< Transmit disable.
88 #define SSC_SWRST                   15  ///< Software reset.
89 /*\}*/
90
91 /**
92  * SSC Clock Mode Register
93  */
94 /*\{*/
95 #define SSC_CMR_OFF                 0x00000004  ///< Clock mode register offset.
96
97 #define SSC_DIV_MASK                0x00000FFF  ///< Clock divider.
98 /*\}*/
99
100 /**
101  * SSC Receive/Transmit Clock Mode Register
102  */
103 /*\{*/
104 #define SSC_RCMR_OFF                0x00000010  ///< Receive clock mode register offset.
105 #define SSC_TCMR_OFF                0x00000018  ///< Transmit clock mode register offset.
106
107 #define SSC_CKS_MASK                0x00000003  ///< Receive clock selection.
108 #define SSC_CKS_DIV                 0x00000000  ///< Divided clock.
109 #define SSC_CKS_CLK                 0x00000001  ///< RK/TK clock signal.
110 #define SSC_CKS_PIN                 0x00000002  ///< TK/RK pin.
111 #define SSC_CKO_MASK                0x0000001C  ///< Receive clock output mode selection.
112 #define SSC_CKO_NONE                0x00000000  ///< None.
113 #define SSC_CKO_CONT                0x00000004  ///< Continous receive clock.
114 #define SSC_CKO_TRAN                0x00000008  ///< Receive clock only during data transfers.
115 #define SSC_CKI                              5  ///< Receive clock inversion.
116 #define SSC_CKG_MASK                0x000000C0  ///< Receive clock gating selection.
117 #define SSC_CKG_NONE                0x00000000  ///< None, continous clock.
118 #define SSC_CKG_FL                  0x00000040  ///< Continous receive clock.
119 #define SSC_CKG_FH                  0x00000080  ///< Receive clock only during data transfers.
120 #define SSC_START_MASK              0x00000F00  ///< Receive start selection.
121 #define SSC_START_CONT              0x00000000  ///< Receive start as soon as enabled.
122 #define SSC_START_TX                0x00000100  ///< Receive start on transmit start.
123 #define SSC_START_RX                0x00000100  ///< Receive start on receive start.
124 #define SSC_START_LOW_F             0x00000200  ///< Receive start on low level RF.
125 #define SSC_START_HIGH_F            0x00000300  ///< Receive start on high level RF.
126 #define SSC_START_FALL_F            0x00000400  ///< Receive start on falling edge RF.
127 #define SSC_START_RISE_F            0x00000500  ///< Receive start on rising edge RF.
128 #define SSC_START_LEVEL_F           0x00000600  ///< Receive start on any RF level change.
129 #define SSC_START_EDGE_F            0x00000700  ///< Receive start on any RF edge.
130 #define SSC_START_COMP0             0x00000800  ///< Receive on compare 0.
131 #define SSC_STOP                            12  ///< Receive stop selection.
132 #define SSC_STTDLY_MASK             0x00FF0000  ///< Receive start delay.
133 #define SSC_STTDLY_SHIFT                    16  ///< Least significant bit of receive start delay.
134 #define SSC_PERIOD_MASK             0xFF000000  ///< Receive period divider selection.
135 #define SSC_PERIOD_SHIFT                    24  ///< Least significant bit of receive period divider selection.
136 /*\}*/
137
138 /**
139  * SSC Receive/Transmit Frame Mode Registers
140  */
141 /*\{*/
142 #define SSC_RFMR_OFF                0x00000014  ///< Receive frame mode register offset.
143 #define SSC_TFMR_OFF                0x0000001C  ///< Transmit frame mode register offset.
144
145 #define SSC_DATLEN_MASK             0x0000001F  ///< Data length.
146 #define SSC_LOOP                             5  ///< Receiver loop mode.
147 #define SSC_DATDEF                           5  ///< Transmit default value.
148
149 #define SSC_MSBF                             7  ///< Most significant bit first.
150 #define SSC_DATNB_MASK              0x00000F00  ///< Data number per frame.
151 #define SSC_DATNB_SHIFT                      8  ///< Least significant bit of data number per frame.
152 #define SSC_FSLEN_MASK              0x000F0000  ///< Receive frame sync. length.
153 #define SSC_FSLEN_SHIFT                     16  ///< Least significant bit of receive frame sync. length.
154 #define SSC_FSOS                    0x00700000  ///< Receive frame sync. output selection.
155 #define SSC_FSOS_NONE               0x00000000  ///< No frame sync. Line set to input.
156 #define SSC_FSOS_NEGATIVE           0x00100000  ///< Negative pulse.
157 #define SSC_FSOS_POSITIVE           0x00200000  ///< Positive pulse.
158 #define SSC_FSOS_LOW                0x00300000  ///< Low during transfer.
159 #define SSC_FSOS_HIGH               0x00400000  ///< High during transfer.
160 #define SSC_FSOS_TOGGLE             0x00500000  ///< Toggling at each start.
161 #define SSC_FSDEN                           23  ///< Frame sync. data enable.
162 #define SSC_FSEDGE                          24  ///< Frame sync. edge detection.
163 /*\}*/
164
165 /**
166  * SSC Receive Holding Register
167  */
168 /*\{*/
169 #define SSC_RHR_OFF                 0x00000020  ///< Receive holding register offset.
170 /*\}*/
171
172 /**
173  * SSC Transmit Holding Register
174  */
175 /*\{*/
176 #define SSC_THR_OFF                 0x00000024  ///< Transmit holding register offset.
177 /*\}*/
178
179 /**
180  * SSC Receive Sync. Holding Register
181  */
182 /*\{*/
183 #define SSC_RSHR_OFF                0x00000030  ///< Receive sync. holding register offset.
184 /*\}*/
185
186 /**
187  * SSC Transmit Sync. Holding Register
188  */
189 /*\{*/
190 #define SSC_TSHR_OFF                0x00000034  ///< Transmit sync. holding register offset.
191 /*\}*/
192
193 /**
194  * SSC Receive Compare 0 Register
195  */
196 /*\{*/
197 #define SSC_RC0R_OFF                0x00000038  ///< Receive compare 0 register offset.
198 /*\}*/
199
200 /**
201  * SSC Receive Compare 1 Register
202  */
203 /*\{*/
204 #define SSC_RC1R_OFF                0x0000003C  ///< Receive compare 1 register offset.
205 /*\}*/
206
207 /**
208  * SSC Status and Interrupt Register
209  */
210 /*\{*/
211 #define SSC_SR_OFF                  0x00000040  ///< Status register offset.
212 #define SSC_IER_OFF                 0x00000044  ///< Interrupt enable register offset.
213 #define SSC_IDR_OFF                 0x00000048  ///< Interrupt disable register offset.
214 #define SSC_IMR_OFF                 0x0000004C  ///< Interrupt mask register offset.
215
216 #define SSC_TXRDY                            0  ///< Transmit ready.
217 #define SSC_TXEMPTY                          1  ///< Transmit empty.
218 #define SSC_ENDTX                            2  ///< End of transmission.
219 #define SSC_TXBUFE                           3  ///< Transmit buffer empty.
220 #define SSC_RXRDY                            4  ///< Receive ready.
221 #define SSC_OVRUN                            5  ///< Receive overrun.
222 #define SSC_ENDRX                            6  ///< End of receiption.
223 #define SSC_RXBUFF                           7  ///< Receive buffer full.
224 #define SSC_CP0                              8  ///< Compare 0.
225 #define SSC_CP1                              9  ///< Compare 1.
226 #define SSC_TXSYN                           10  ///< Transmit sync.
227 #define SSC_RXSYN                           11  ///< Receive sync.
228 #define SSC_TXENA                           16  ///< Transmit enable.
229 #define SSC_RXENA                           17  ///< Receive enable.
230
231
232 #if defined(SSC_BASE)
233         #define SSC_CR      (*((reg32_t *)(SSC_BASE + SSC_CR_OFF)))     ///< Control register address.
234         #define SSC_CMR     (*((reg32_t *)(SSC_BASE + SSC_CMR_OFF)))    ///< Clock mode register address.
235         #define SSC_RCMR    (*((reg32_t *)(SSC_BASE + SSC_RCMR_OFF)))   ///< Receive clock mode register address.
236         #define SSC_TCMR    (*((reg32_t *)(SSC_BASE + SSC_TCMR_OFF)))   ///< Transmit clock mode register address.
237         #define SSC_RFMR    (*((reg32_t *)(SSC_BASE + SSC_RFMR_OFF)))   ///< Receive frame mode register address.
238         #define SSC_TFMR    (*((reg32_t *)(SSC_BASE + SSC_TFMR_OFF)))   ///< Transmit frame mode register address.
239         #define SSC_RHR     (*((reg32_t *)(SSC_BASE + SSC_RHR_OFF)))    ///< Receive holding register address.
240         #define SSC_THR     (*((reg32_t *)(SSC_BASE + SSC_THR_OFF)))    ///< Transmit holding register address.
241         #define SSC_RSHR    (*((reg32_t *)(SSC_BASE + SSC_RSHR_OFF)))   ///< Receive sync. holding register address.
242         #define SSC_TSHR    (*((reg32_t *)(SSC_BASE + SSC_TSHR_OFF)))   ///< Transmit sync. holding register address.
243         #define SSC_RC0R    (*((reg32_t *)(SSC_BASE + SSC_RC0R_OFF)))   ///< Receive compare 0 register address.
244         #define SSC_RC1R    (*((reg32_t *)(SSC_BASE + SSC_RC1R_OFF)))   ///< Receive compare 1 register address.
245         #define SSC_SR      (*((reg32_t *)(SSC_BASE + SSC_SR_OFF)))     ///< Status register address.
246         #define SSC_IER     (*((reg32_t *)(SSC_BASE + SSC_IER_OFF)))    ///< Interrupt enable register address.
247         #define SSC_IDR     (*((reg32_t *)(SSC_BASE + SSC_IDR_OFF)))    ///< Interrupt disable register address.
248         #define SSC_IMR     (*((reg32_t *)(SSC_BASE + SSC_IMR_OFF)))    ///< Interrupt mask register address.
249         #if defined(SSC_HAS_PDC)
250                 #define SSC_RPR    (*((reg32_t *)(SSC_BASE + PERIPH_RPR_OFF)))  ///< PDC receive pointer register address.
251                 #define SSC_RCR    (*((reg32_t *)(SSC_BASE + PERIPH_RCR_OFF)))  ///< PDC receive counter register address.
252                 #define SSC_TPR    (*((reg32_t *)(SSC_BASE + PERIPH_TPR_OFF)))  ///< PDC transmit pointer register address.
253                 #define SSC_TCR    (*((reg32_t *)(SSC_BASE + PERIPH_TCR_OFF)))  ///< PDC transmit counter register address.
254                 #define SSC_RNPR   (*((reg32_t *)(SSC_BASE + PERIPH_RNPR_OFF))) ///< PDC receive next pointer register address.
255                 #define SSC_RNCR   (*((reg32_t *)(SSC_BASE + PERIPH_RNCR_OFF))) ///< PDC receive next counter register address.
256                 #define SSC_TNPR   (*((reg32_t *)(SSC_BASE + PERIPH_TNPR_OFF))) ///< PDC transmit next pointer register address.
257                 #define SSC_TNCR   (*((reg32_t *)(SSC_BASE + PERIPH_TNCR_OFF))) ///< PDC transmit next counter register address.
258                 #define SSC_PTCR   (*((reg32_t *)(SSC_BASE + PERIPH_PTCR_OFF))) ///< PDC transfer control register address.
259                 #define SSC_PTSR   (*((reg32_t *)(SSC_BASE + PERIPH_PTSR_OFF))) ///< PDC transfer status register address.
260         #endif /* SSC_HAS_PDC */
261
262 #endif /* SSC_BASE */
263
264
265 #endif /* AT91_SSC_H */