]> git.zerfleddert.de Git - proxmark3-svn/blob - include/at91sam7s128.h
added eh_frame needed for gcc 4.4.1 or higher
[proxmark3-svn] / include / at91sam7s128.h
1 //-----------------------------------------------------------------------------
2 // Incomplete register definitions for the AT91SAM7S128 chip.
3 // Jonathan Westhues, Jul 2005
4 //-----------------------------------------------------------------------------
5
6 #ifndef __AT91SAM7S128_H
7 #define __AT91SAM7S128_H
8
9 #define REG(x) (*(volatile unsigned long *)(x))
10
11 //-------------
12 // Peripheral IDs
13
14 #define PERIPH_AIC_FIQ 0
15 #define PERIPH_SYSIRQ 1
16 #define PERIPH_PIOA 2
17 #define PERIPH_ADC 4
18 #define PERIPH_SPI 5
19 #define PERIPH_US0 6
20 #define PERIPH_US1 7
21 #define PERIPH_SSC 8
22 #define PERIPH_TWI 9
23 #define PERIPH_PWMC 10
24 #define PERIPH_UDP 11
25 #define PERIPH_TC0 12
26 #define PERIPH_TC1 13
27 #define PERIPH_TC2 14
28 #define PERIPH_AIC_IRQ0 30
29 #define PERIPH_AIC_IRQ1 31
30
31 //-------------
32 // Reset Controller
33
34 #define RSTC_BASE (0xfffffd00)
35
36 #define RSTC_CONTROL REG(RSTC_BASE+0x00)
37 #define RSTC_STATUS REG(RSTC_BASE+0x04)
38
39 #define RST_CONTROL_KEY (0xa5<<24)
40 #define RST_CONTROL_PROCESSOR_RESET (1<<0)
41 #define RST_STATUS_TYPE_MASK (7<<8)
42 #define RST_STATUS_TYPE_POWERUP (0<<8)
43 #define RST_STATUS_TYPE_WATCHDOG (2<<8)
44 #define RST_STATUS_TYPE_SOFTWARE (3<<8)
45 #define RST_STATUS_TYPE_USER (4<<8)
46 #define RST_STATUS_TYPE_BROWNOUT (5<<8)
47
48
49 //-------------
50 // PWM Controller
51
52 #define PWM_BASE (0xfffcc000)
53
54 #define PWM_MODE REG(PWM_BASE+0x00)
55 #define PWM_ENABLE REG(PWM_BASE+0x04)
56 #define PWM_DISABLE REG(PWM_BASE+0x08)
57 #define PWM_STATUS REG(PWM_BASE+0x0c)
58 #define PWM_INTERRUPT_ENABLE REG(PWM_BASE+0x10)
59 #define PWM_INTERRUPT_DISABLE REG(PWM_BASE+0x14)
60 #define PWM_INTERRUPT_MASK REG(PWM_BASE+0x18)
61 #define PWM_INTERRUPT_STATUS REG(PWM_BASE+0x1c)
62 #define PWM_CH_MODE(x) REG(PWM_BASE+0x200+((x)*0x20))
63 #define PWM_CH_DUTY_CYCLE(x) REG(PWM_BASE+0x204+((x)*0x20))
64 #define PWM_CH_PERIOD(x) REG(PWM_BASE+0x208+((x)*0x20))
65 #define PWM_CH_COUNTER(x) REG(PWM_BASE+0x20c+((x)*0x20))
66 #define PWM_CH_UPDATE(x) REG(PWM_BASE+0x210+((x)*0x20))
67
68 #define PWM_MODE_DIVA(x) ((x)<<0)
69 #define PWM_MODE_PREA(x) ((x)<<8)
70 #define PWM_MODE_DIVB(x) ((x)<<16)
71 #define PWM_MODE_PREB(x) ((x)<<24)
72
73 #define PWM_CHANNEL(x) (1<<(x))
74
75 #define PWM_CH_MODE_PRESCALER(x) ((x)<<0)
76 #define PWM_CH_MODE_PERIOD_CENTER_ALIGNED (1<<8)
77 #define PWM_CH_MODE_POLARITY_STARTS_HIGH (1<<9)
78 #define PWM_CH_MODE_UPDATE_UPDATES_PERIOD (1<<10)
79
80 //-------------
81 // Debug Unit
82
83 #define DBG_BASE (0xfffff200)
84
85 #define DBGU_CR REG(DBG_BASE+0x0000)
86 #define DBGU_MR REG(DBG_BASE+0x0004)
87 #define DBGU_IER REG(DBG_BASE+0x0008)
88 #define DBGU_IDR REG(DBG_BASE+0x000C)
89 #define DBGU_IMR REG(DBG_BASE+0x0010)
90 #define DBGU_SR REG(DBG_BASE+0x0014)
91 #define DBGU_RHR REG(DBG_BASE+0x0018)
92 #define DBGU_THR REG(DBG_BASE+0x001C)
93 #define DBGU_BRGR REG(DBG_BASE+0x0020)
94 #define DBGU_CIDR REG(DBG_BASE+0x0040)
95 #define DBGU_EXID REG(DBG_BASE+0x0044)
96 #define DBGU_FNR REG(DBG_BASE+0x0048)
97
98 //-------------
99 // Embedded Flash Controller
100
101 #define MC_BASE (0xffffff00)
102
103 #define MC_FLASH_MODE0 REG(MC_BASE+0x60)
104 #define MC_FLASH_COMMAND REG(MC_BASE+0x64)
105 #define MC_FLASH_STATUS REG(MC_BASE+0x68)
106 #define MC_FLASH_MODE1 REG(MC_BASE+0x70)
107
108 #define MC_FLASH_MODE_READY_INTERRUPT_ENABLE (1<<0)
109 #define MC_FLASH_MODE_LOCK_INTERRUPT_ENABLE (1<<2)
110 #define MC_FLASH_MODE_PROG_ERROR_INTERRUPT_ENABLE (1<<3)
111 #define MC_FLASH_MODE_NO_ERASE_BEFORE_PROGRAMMING (1<<7)
112 #define MC_FLASH_MODE_FLASH_WAIT_STATES(x) ((x)<<8)
113 #define MC_FLASH_MODE_MASTER_CLK_IN_MHZ(x) ((x)<<16)
114
115 #define MC_FLASH_COMMAND_FCMD(x) ((x)<<0)
116 #define MC_FLASH_COMMAND_PAGEN(x) ((x)<<8)
117 #define MC_FLASH_COMMAND_KEY ((0x5a)<<24)
118
119 #define FCMD_NOP 0x0
120 #define FCMD_WRITE_PAGE 0x1
121 #define FCMD_SET_LOCK_BIT 0x2
122 #define FCMD_WRITE_PAGE_LOCK 0x3
123 #define FCMD_CLEAR_LOCK_BIT 0x4
124 #define FCMD_ERASE_ALL 0x8
125 #define FCMD_SET_GP_NVM_BIT 0xb
126 #define FCMD_SET_SECURITY_BIT 0xf
127
128 #define MC_FLASH_STATUS_READY (1<<0)
129 #define MC_FLASH_STATUS_LOCK_ERROR (1<<2)
130 #define MC_FLASH_STATUS_PROGRAMMING_ERROR (1<<3)
131 #define MC_FLASH_STATUS_SECURITY_BIT_ACTIVE (1<<4)
132 #define MC_FLASH_STATUS_GP_NVM_ACTIVE_0 (1<<8)
133 #define MC_FLASH_STATUS_GP_NVM_ACTIVE_1 (1<<9)
134 #define MC_FLASH_STATUS_LOCK_ACTIVE(x) (1<<((x)+16))
135
136 #define FLASH_PAGE_SIZE_BYTES 256
137 #define FLASH_PAGE_COUNT 512
138
139 //-------------
140 // Watchdog Timer - 12 bit down counter, uses slow clock divided by 128 as source
141
142 #define WDT_BASE (0xfffffd40)
143
144 #define WDT_CONTROL REG(WDT_BASE+0x00)
145 #define WDT_MODE REG(WDT_BASE+0x04)
146 #define WDT_STATUS REG(WDT_BASE+0x08)
147
148 #define WDT_HIT() WDT_CONTROL = 0xa5000001
149
150 #define WDT_MODE_COUNT(x) ((x)<<0)
151 #define WDT_MODE_INTERRUPT_ON_EVENT (1<<12)
152 #define WDT_MODE_RESET_ON_EVENT_ENABLE (1<<13)
153 #define WDT_MODE_RESET_ON_EVENT (1<<14)
154 #define WDT_MODE_WATCHDOG_DELTA(x) ((x)<<16)
155 #define WDT_MODE_HALT_IN_DEBUG_MODE (1<<28)
156 #define WDT_MODE_HALT_IN_IDLE_MODE (1<<29)
157 #define WDT_MODE_DISABLE (1<<15)
158
159 //-------------
160 // Parallel Input/Output Controller
161
162 #define PIO_BASE (0xfffff400)
163
164 #define PIO_ENABLE REG(PIO_BASE+0x000)
165 #define PIO_DISABLE REG(PIO_BASE+0x004)
166 #define PIO_STATUS REG(PIO_BASE+0x008)
167 #define PIO_OUTPUT_ENABLE REG(PIO_BASE+0x010)
168 #define PIO_OUTPUT_DISABLE REG(PIO_BASE+0x014)
169 #define PIO_OUTPUT_STATUS REG(PIO_BASE+0x018)
170 #define PIO_GLITCH_ENABLE REG(PIO_BASE+0x020)
171 #define PIO_GLITCH_DISABLE REG(PIO_BASE+0x024)
172 #define PIO_GLITCH_STATUS REG(PIO_BASE+0x028)
173 #define PIO_OUTPUT_DATA_SET REG(PIO_BASE+0x030)
174 #define PIO_OUTPUT_DATA_CLEAR REG(PIO_BASE+0x034)
175 #define PIO_OUTPUT_DATA_STATUS REG(PIO_BASE+0x038)
176 #define PIO_PIN_DATA_STATUS REG(PIO_BASE+0x03c)
177 #define PIO_OPEN_DRAIN_ENABLE REG(PIO_BASE+0x050)
178 #define PIO_OPEN_DRAIN_DISABLE REG(PIO_BASE+0x054)
179 #define PIO_OPEN_DRAIN_STATUS REG(PIO_BASE+0x058)
180 #define PIO_NO_PULL_UP_ENABLE REG(PIO_BASE+0x060)
181 #define PIO_NO_PULL_UP_DISABLE REG(PIO_BASE+0x064)
182 #define PIO_NO_PULL_UP_STATUS REG(PIO_BASE+0x068)
183 #define PIO_PERIPHERAL_A_SEL REG(PIO_BASE+0x070)
184 #define PIO_PERIPHERAL_B_SEL REG(PIO_BASE+0x074)
185 #define PIO_PERIPHERAL_WHICH REG(PIO_BASE+0x078)
186 #define PIO_OUT_WRITE_ENABLE REG(PIO_BASE+0x0a0)
187 #define PIO_OUT_WRITE_DISABLE REG(PIO_BASE+0x0a4)
188 #define PIO_OUT_WRITE_STATUS REG(PIO_BASE+0x0a8)
189
190 //-------------
191 // USB Device Port
192
193 #define UDP_BASE (0xfffb0000)
194
195 #define UDP_FRAME_NUMBER REG(UDP_BASE+0x0000)
196 #define UDP_GLOBAL_STATE REG(UDP_BASE+0x0004)
197 #define UDP_FUNCTION_ADDR REG(UDP_BASE+0x0008)
198 #define UDP_INTERRUPT_ENABLE REG(UDP_BASE+0x0010)
199 #define UDP_INTERRUPT_DISABLE REG(UDP_BASE+0x0014)
200 #define UDP_INTERRUPT_MASK REG(UDP_BASE+0x0018)
201 #define UDP_INTERRUPT_STATUS REG(UDP_BASE+0x001c)
202 #define UDP_INTERRUPT_CLEAR REG(UDP_BASE+0x0020)
203 #define UDP_RESET_ENDPOINT REG(UDP_BASE+0x0028)
204 #define UDP_ENDPOINT_CSR(x) REG(UDP_BASE+0x0030+((x)*4))
205 #define UDP_ENDPOINT_FIFO(x) REG(UDP_BASE+0x0050+((x)*4))
206 #define UDP_TRANSCEIVER_CTRL REG(UDP_BASE+0x0074)
207
208 #define UDP_GLOBAL_STATE_ADDRESSED (1<<0)
209 #define UDP_GLOBAL_STATE_CONFIGURED (1<<1)
210 #define UDP_GLOBAL_STATE_SEND_RESUME_ENABLED (1<<2)
211 #define UDP_GLOBAL_STATE_RESUME_RECEIVED (1<<3)
212 #define UDP_GLOBAL_STATE_REMOTE_WAKE_UP_ENABLED (1<<4)
213
214 #define UDP_FUNCTION_ADDR_ENABLED (1<<8)
215
216 #define UDP_INTERRUPT_ENDPOINT(x) (1<<(x))
217 #define UDP_INTERRUPT_SUSPEND (1<<8)
218 #define UDP_INTERRUPT_RESUME (1<<9)
219 #define UDP_INTERRUPT_EXTERNAL_RESUME (1<<10)
220 #define UDP_INTERRUPT_SOF (1<<11)
221 #define UDP_INTERRUPT_END_OF_BUS_RESET (1<<12)
222 #define UDP_INTERRUPT_WAKEUP (1<<13)
223
224 #define UDP_RESET_ENDPOINT_NUMBER(x) (1<<(x))
225
226 #define UDP_CSR_TX_PACKET_ACKED (1<<0)
227 #define UDP_CSR_RX_PACKET_RECEIVED_BANK_0 (1<<1)
228 #define UDP_CSR_RX_HAVE_READ_SETUP_DATA (1<<2)
229 #define UDP_CSR_STALL_SENT (1<<3)
230 #define UDP_CSR_TX_PACKET (1<<4)
231 #define UDP_CSR_FORCE_STALL (1<<5)
232 #define UDP_CSR_RX_PACKET_RECEIVED_BANK_1 (1<<6)
233 #define UDP_CSR_CONTROL_DATA_DIR (1<<7)
234 #define UDP_CSR_EPTYPE_CONTROL (0<<8)
235 #define UDP_CSR_EPTYPE_ISOCHRON_OUT (1<<8)
236 #define UDP_CSR_EPTYPE_ISOCHRON_IN (5<<8)
237 #define UDP_CSR_EPTYPE_BULK_OUT (2<<8)
238 #define UDP_CSR_EPTYPE_BULK_IN (6<<8)
239 #define UDP_CSR_EPTYPE_INTERRUPT_OUT (3<<8)
240 #define UDP_CSR_EPTYPE_INTERRUPT_IN (7<<8)
241 #define UDP_CSR_IS_DATA1 (1<<11)
242 #define UDP_CSR_ENABLE_EP (1<<15)
243 #define UDP_CSR_BYTES_RECEIVED(x) (((x) >> 16) & 0x7ff)
244
245 #define UDP_TRANSCEIVER_CTRL_DISABLE (1<<8)
246
247 //-------------
248 // Power Management Controller
249
250 #define PMC_BASE (0xfffffc00)
251
252 #define PMC_SYS_CLK_ENABLE REG(PMC_BASE+0x0000)
253 #define PMC_SYS_CLK_DISABLE REG(PMC_BASE+0x0004)
254 #define PMC_SYS_CLK_STATUS REG(PMC_BASE+0x0008)
255 #define PMC_PERIPHERAL_CLK_ENABLE REG(PMC_BASE+0x0010)
256 #define PMC_PERIPHERAL_CLK_DISABLE REG(PMC_BASE+0x0014)
257 #define PMC_PERIPHERAL_CLK_STATUS REG(PMC_BASE+0x0018)
258 #define PMC_MAIN_OSCILLATOR REG(PMC_BASE+0x0020)
259 #define PMC_MAIN_CLK_FREQUENCY REG(PMC_BASE+0x0024)
260 #define PMC_PLL REG(PMC_BASE+0x002c)
261 #define PMC_MASTER_CLK REG(PMC_BASE+0x0030)
262 #define PMC_PROGRAMMABLE_CLK_0 REG(PMC_BASE+0x0040)
263 #define PMC_PROGRAMMABLE_CLK_1 REG(PMC_BASE+0x0044)
264 #define PMC_INTERRUPT_ENABLE REG(PMC_BASE+0x0060)
265 #define PMC_INTERRUPT_DISABLE REG(PMC_BASE+0x0064)
266 #define PMC_INTERRUPT_STATUS REG(PMC_BASE+0x0068)
267 #define PMC_INTERRUPT_MASK REG(PMC_BASE+0x006c)
268
269 #define PMC_SYS_CLK_PROCESSOR_CLK (1<<0)
270 #define PMC_SYS_CLK_UDP_CLK (1<<7)
271 #define PMC_SYS_CLK_PROGRAMMABLE_CLK_0 (1<<8)
272 #define PMC_SYS_CLK_PROGRAMMABLE_CLK_1 (1<<9)
273 #define PMC_SYS_CLK_PROGRAMMABLE_CLK_2 (1<<10)
274
275 #define PMC_MAIN_OSCILLATOR_STABILIZED (1<<0)
276 #define PMC_MAIN_OSCILLATOR_PLL_LOCK (1<<2)
277 #define PMC_MAIN_OSCILLATOR_MCK_READY (1<<3)
278 #define PMC_MAIN_OSCILLATOR_ENABLE (1<<0)
279 #define PMC_MAIN_OSCILLATOR_BYPASS (1<<1)
280 #define PMC_MAIN_OSCILLATOR_STARTUP_DELAY(x) ((x)<<8)
281
282 #define PMC_PLL_DIVISOR(x) (x)
283 #define PMC_PLL_COUNT_BEFORE_LOCK(x) ((x)<<8)
284 #define PMC_PLL_FREQUENCY_RANGE(x) ((x)<<14)
285 #define PMC_PLL_MULTIPLIER(x) (((x)-1)<<16)
286 #define PMC_PLL_USB_DIVISOR(x) ((x)<<28)
287
288 #define PMC_CLK_SELECTION_PLL_CLOCK (3<<0)
289 #define PMC_CLK_SELECTION_MAIN_CLOCK (1<<0)
290 #define PMC_CLK_SELECTION_SLOW_CLOCK (0<<0)
291 #define PMC_CLK_PRESCALE_DIV_1 (0<<2)
292 #define PMC_CLK_PRESCALE_DIV_2 (1<<2)
293 #define PMC_CLK_PRESCALE_DIV_4 (2<<2)
294 #define PMC_CLK_PRESCALE_DIV_8 (3<<2)
295 #define PMC_CLK_PRESCALE_DIV_16 (4<<2)
296 #define PMC_CLK_PRESCALE_DIV_32 (5<<2)
297 #define PMC_CLK_PRESCALE_DIV_64 (6<<2)
298
299 //-------------
300 // Serial Peripheral Interface (SPI)
301
302 #define SPI_BASE (0xfffe0000)
303
304 #define SPI_CONTROL REG(SPI_BASE+0x00)
305 #define SPI_MODE REG(SPI_BASE+0x04)
306 #define SPI_RX_DATA REG(SPI_BASE+0x08)
307 #define SPI_TX_DATA REG(SPI_BASE+0x0c)
308 #define SPI_STATUS REG(SPI_BASE+0x10)
309 #define SPI_INTERRUPT_ENABLE REG(SPI_BASE+0x14)
310 #define SPI_INTERRUPT_DISABLE REG(SPI_BASE+0x18)
311 #define SPI_INTERRUPT_MASK REG(SPI_BASE+0x1c)
312 #define SPI_FOR_CHIPSEL_0 REG(SPI_BASE+0x30)
313 #define SPI_FOR_CHIPSEL_1 REG(SPI_BASE+0x34)
314 #define SPI_FOR_CHIPSEL_2 REG(SPI_BASE+0x38)
315 #define SPI_FOR_CHIPSEL_3 REG(SPI_BASE+0x3c)
316
317 #define SPI_CONTROL_ENABLE (1<<0)
318 #define SPI_CONTROL_DISABLE (1<<1)
319 #define SPI_CONTROL_RESET (1<<7)
320 #define SPI_CONTROL_LAST_TRANSFER (1<<24)
321
322 #define SPI_MODE_MASTER (1<<0)
323 #define SPI_MODE_VARIABLE_CHIPSEL (1<<1)
324 #define SPI_MODE_CHIPSELS_DECODED (1<<2)
325 #define SPI_MODE_USE_DIVIDED_CLOCK (1<<3)
326 #define SPI_MODE_MODE_FAULT_DETECTION_OFF (1<<4)
327 #define SPI_MODE_LOOPBACK (1<<7)
328 #define SPI_MODE_CHIPSEL(x) ((x)<<16)
329 #define SPI_MODE_DELAY_BETWEEN_CHIPSELS(x) ((x)<<24)
330
331 #define SPI_RX_DATA_CHIPSEL(x) (((x)>>16)&0xf)
332
333 #define SPI_TX_DATA_CHIPSEL(x) ((x)<<16)
334 #define SPI_TX_DATA_LAST_TRANSFER (1<<24)
335
336 #define SPI_STATUS_RECEIVE_FULL (1<<0)
337 #define SPI_STATUS_TRANSMIT_EMPTY (1<<1)
338 #define SPI_STATUS_MODE_FAULT (1<<2)
339 #define SPI_STATUS_OVERRUN (1<<3)
340 #define SPI_STATUS_END_OF_RX_BUFFER (1<<4)
341 #define SPI_STATUS_END_OF_TX_BUFFER (1<<5)
342 #define SPI_STATUS_RX_BUFFER_FULL (1<<6)
343 #define SPI_STATUS_TX_BUFFER_EMPTY (1<<7)
344 #define SPI_STATUS_NSS_RISING_DETECTED (1<<8)
345 #define SPI_STATUS_TX_EMPTY (1<<9)
346 #define SPI_STATUS_SPI_ENABLED (1<<16)
347
348 #define SPI_FOR_CHIPSEL_INACTIVE_CLK_1 (1<<0)
349 #define SPI_FOR_CHIPSEL_PHASE (1<<1)
350 #define SPI_FOR_CHIPSEL_LEAVE_CHIPSEL_LOW (1<<3)
351 #define SPI_FOR_CHIPSEL_BITS_IN_WORD(x) ((x)<<4)
352 #define SPI_FOR_CHIPSEL_DIVISOR(x) ((x)<<8)
353 #define SPI_FOR_CHIPSEL_DELAY_BEFORE_CLK(x) ((x)<<16)
354 #define SPI_FOR_CHIPSEL_INTERWORD_DELAY(x) ((x)<<24)
355
356 //-------------
357 // Analog to Digital Converter
358
359 #define ADC_BASE (0xfffd8000)
360
361 #define ADC_CONTROL REG(ADC_BASE+0x00)
362 #define ADC_MODE REG(ADC_BASE+0x04)
363 #define ADC_CHANNEL_ENABLE REG(ADC_BASE+0x10)
364 #define ADC_CHANNEL_DISABLE REG(ADC_BASE+0x14)
365 #define ADC_CHANNEL_STATUS REG(ADC_BASE+0x18)
366 #define ADC_STATUS REG(ADC_BASE+0x1c)
367 #define ADC_LAST_CONVERTED_DATA REG(ADC_BASE+0x20)
368 #define ADC_INTERRUPT_ENABLE REG(ADC_BASE+0x24)
369 #define ADC_INTERRUPT_DISABLE REG(ADC_BASE+0x28)
370 #define ADC_INTERRUPT_MASK REG(ADC_BASE+0x2c)
371 #define ADC_CHANNEL_DATA(x) REG(ADC_BASE+0x30+(4*(x)))
372
373 #define ADC_CONTROL_RESET (1<<0)
374 #define ADC_CONTROL_START (1<<1)
375
376 #define ADC_MODE_HW_TRIGGERS_ENABLED (1<<0)
377 #define ADC_MODE_8_BIT_RESOLUTION (1<<4)
378 #define ADC_MODE_SLEEP (1<<5)
379 #define ADC_MODE_PRESCALE(x) ((x)<<8)
380 #define ADC_MODE_STARTUP_TIME(x) ((x)<<16)
381 #define ADC_MODE_SAMPLE_HOLD_TIME(x) ((x)<<24)
382
383 #define ADC_CHANNEL(x) (1<<(x))
384
385 #define ADC_END_OF_CONVERSION(x) (1<<(x))
386 #define ADC_OVERRUN_ERROR(x) (1<<(8+(x)))
387 #define ADC_DATA_READY (1<<16)
388 #define ADC_GENERAL_OVERRUN (1<<17)
389 #define ADC_END_OF_RX_BUFFER (1<<18)
390 #define ADC_RX_BUFFER_FULL (1<<19)
391
392 #define ADC_CHAN_LF 4
393 #define ADC_CHAN_HF 5
394 //-------------
395 // Synchronous Serial Controller
396
397 #define SSC_BASE (0xfffd4000)
398
399 #define SSC_CONTROL REG(SSC_BASE+0x00)
400 #define SSC_CLOCK_DIVISOR REG(SSC_BASE+0x04)
401 #define SSC_RECEIVE_CLOCK_MODE REG(SSC_BASE+0x10)
402 #define SSC_RECEIVE_FRAME_MODE REG(SSC_BASE+0x14)
403 #define SSC_TRANSMIT_CLOCK_MODE REG(SSC_BASE+0x18)
404 #define SSC_TRANSMIT_FRAME_MODE REG(SSC_BASE+0x1c)
405 #define SSC_RECEIVE_HOLDING REG(SSC_BASE+0x20)
406 #define SSC_TRANSMIT_HOLDING REG(SSC_BASE+0x24)
407 #define SSC_RECEIVE_SYNC_HOLDING REG(SSC_BASE+0x30)
408 #define SSC_TRANSMIT_SYNC_HOLDING REG(SSC_BASE+0x34)
409 #define SSC_STATUS REG(SSC_BASE+0x40)
410 #define SSC_INTERRUPT_ENABLE REG(SSC_BASE+0x44)
411 #define SSC_INTERRUPT_DISABLE REG(SSC_BASE+0x48)
412 #define SSC_INTERRUPT_MASK REG(SSC_BASE+0x4c)
413
414 #define SSC_CONTROL_RX_ENABLE (1<<0)
415 #define SSC_CONTROL_RX_DISABLE (1<<1)
416 #define SSC_CONTROL_TX_ENABLE (1<<8)
417 #define SSC_CONTROL_TX_DISABLE (1<<9)
418 #define SSC_CONTROL_RESET (1<<15)
419
420 #define SSC_CLOCK_MODE_SELECT(x) ((x)<<0)
421 #define SSC_CLOCK_MODE_OUTPUT(x) ((x)<<2)
422 #define SSC_CLOCK_MODE_INVERT (1<<5)
423 #define SSC_CLOCK_MODE_START(x) ((x)<<8)
424 #define SSC_CLOCK_MODE_START_DELAY(x) ((x)<<16)
425 #define SSC_CLOCK_MODE_FRAME_PERIOD(x) ((x)<<24)
426
427 #define SSC_FRAME_MODE_BITS_IN_WORD(x) (((x)-1)<<0)
428 #define SSC_FRAME_MODE_LOOPBACK (1<<5) // for RX
429 #define SSC_FRAME_MODE_DEFAULT_IS_1 (1<<5) // for TX
430 #define SSC_FRAME_MODE_MSB_FIRST (1<<7)
431 #define SSC_FRAME_MODE_WORDS_PER_TRANSFER(x) ((x)<<8)
432 #define SSC_FRAME_MODE_FRAME_SYNC_LEN(x) ((x)<<16)
433 #define SSC_FRAME_MODE_FRAME_SYNC_TYPE(x) ((x)<<20)
434 #define SSC_FRAME_MODE_SYNC_DATA_ENABLE (1<<23) // for TX only
435 #define SSC_FRAME_MODE_NEGATIVE_EDGE (1<<24)
436
437 #define SSC_STATUS_TX_READY (1<<0)
438 #define SSC_STATUS_TX_EMPTY (1<<1)
439 #define SSC_STATUS_TX_ENDED (1<<2)
440 #define SSC_STATUS_TX_BUF_EMPTY (1<<3)
441 #define SSC_STATUS_RX_READY (1<<4)
442 #define SSC_STATUS_RX_OVERRUN (1<<5)
443 #define SSC_STATUS_RX_ENDED (1<<6)
444 #define SSC_STATUS_RX_BUF_FULL (1<<7)
445 #define SSC_STATUS_TX_SYNC_OCCURRED (1<<10)
446 #define SSC_STATUS_RX_SYNC_OCCURRED (1<<11)
447 #define SSC_STATUS_TX_ENABLED (1<<16)
448 #define SSC_STATUS_RX_ENABLED (1<<17)
449
450 //-------------
451 // Peripheral DMA Controller
452 //
453 // There is one set of registers for every peripheral that supports DMA.
454
455 #define PDC_RX_POINTER(x) REG((x)+0x100)
456 #define PDC_RX_COUNTER(x) REG((x)+0x104)
457 #define PDC_TX_POINTER(x) REG((x)+0x108)
458 #define PDC_TX_COUNTER(x) REG((x)+0x10c)
459 #define PDC_RX_NEXT_POINTER(x) REG((x)+0x110)
460 #define PDC_RX_NEXT_COUNTER(x) REG((x)+0x114)
461 #define PDC_TX_NEXT_POINTER(x) REG((x)+0x118)
462 #define PDC_TX_NEXT_COUNTER(x) REG((x)+0x11c)
463 #define PDC_CONTROL(x) REG((x)+0x120)
464 #define PDC_STATUS(x) REG((x)+0x124)
465
466 #define PDC_RX_ENABLE (1<<0)
467 #define PDC_RX_DISABLE (1<<1)
468 #define PDC_TX_ENABLE (1<<8)
469 #define PDC_TX_DISABLE (1<<9)
470
471 //-------------
472 // Timer/Counter base
473
474 #define TC_BASE (0xfffa0000)
475
476 #define TC_BCR REG(TC_BASE+0xC0)
477 #define TC_BMR REG(TC_BASE+0xC4)
478
479 #define TC_BCR_SYNC (1<<0)
480
481 #define TC_CCR_CLKEN (1<<0)
482 #define TC_CCR_CLKDIS (1<<1)
483 #define TC_CCR_SWTRG (1<<2)
484
485 #define TC_CMR_TCCLKS (7<<0)
486 #define TC_CMR_TCCLKS_TIMER_CLOCK1 (0<<0)
487 #define TC_CMR_TCCLKS_TIMER_CLOCK2 (1<<0)
488 #define TC_CMR_TCCLKS_TIMER_CLOCK3 (2<<0)
489 #define TC_CMR_TCCLKS_TIMER_CLOCK4 (3<<0)
490 #define TC_CMR_TCCLKS_TIMER_CLOCK5 (4<<0)
491 #define TC_CMR_TCCLKS_XC0 (5<<0)
492 #define TC_CMR_TCCLKS_XC1 (6<<0)
493 #define TC_CMR_TCCLKS_XC2 (7<<0)
494 #define TC_CMR_CLKI (1<<3)
495 #define TC_CMR_BURST (3<<4)
496 #define TC_CMR_BURST_XC0 (1<<4)
497 #define TC_CMR_BURST_XC1 (2<<4)
498 #define TC_CMR_BURST_XC2 (3<<4)
499 #define TC_CMR_LDBSTOP (1<<6)
500 #define TC_CMR_CPCSTOP (1<<6)
501 #define TC_CMR_LDBDIS (1<<7)
502 #define TC_CMR_CPCDIS (1<<7)
503 #define TC_CMR_ETRGEDG (3<<8)
504 #define TC_CMR_ETRGEDG_NONE (0<<8)
505 #define TC_CMR_ETRGEDG_RISING (1<<8)
506 #define TC_CMR_ETRGEDG_FALLING (2<<8)
507 #define TC_CMR_ETRGEDG_EACH (3<<8)
508 #define TC_CMR_EEVTEDG (3<<8)
509 #define TC_CMR_EEVTEDG_NONE (0<<8)
510 #define TC_CMR_EEVTEDG_RISING (1<<8)
511 #define TC_CMR_EEVTEDG_FALLING (2<<8)
512 #define TC_CMR_EEVTEDG_EACH (3<<8)
513 #define TC_CMR_ABETRG (1<<10)
514 #define TC_CMR_EEVT (3<<10)
515 #define TC_CMR_EEVT_TIOB (0<<10)
516 #define TC_CMR_EEVT_XC0 (1<<10)
517 #define TC_CMR_EEVT_XC1 (2<<10)
518 #define TC_CMR_EEVT_XC2 (3<<10)
519 #define TC_CMR_ENETRG (1<<12)
520 #define TC_CMR_WAVSEL (3<<13)
521 #define TC_CMR_WAVSEL_UP (0<<13)
522 #define TC_CMR_WAVSEL_UP_AUTO (2<<13)
523 #define TC_CMR_WAVSEL_UPDOWN (1<<13)
524 #define TC_CMR_WAVSEL_UPDOWN_AUTO (3<<13)
525 #define TC_CMR_CPCTRG (1<<14)
526 #define TC_CMR_WAVE (1<<15)
527 #define TC_CMR_LDRA (3<<16)
528 #define TC_CMR_LDRA_NONE (0<<16)
529 #define TC_CMR_LDRA_RISING (1<<16)
530 #define TC_CMR_LDRA_FALLING (2<<16)
531 #define TC_CMR_LDRA_EACH (3<<16)
532 #define TC_CMR_ACPA (3<<16)
533 #define TC_CMR_ACPA_NONE (0<<16)
534 #define TC_CMR_ACPA_SET (1<<16)
535 #define TC_CMR_ACPA_CLEAR (2<<16)
536 #define TC_CMR_ACPA_TOGGLE (3<<16)
537 #define TC_CMR_LDRB (3<<18)
538 #define TC_CMR_LDRB_NONE (0<<18)
539 #define TC_CMR_LDRB_RISING (1<<18)
540 #define TC_CMR_LDRB_FALLING (2<<18)
541 #define TC_CMR_LDRB_EACH (3<<18)
542 #define TC_CMR_ACPC (3<<18)
543 #define TC_CMR_ACPC_NONE (0<<18)
544 #define TC_CMR_ACPC_SET (1<<18)
545 #define TC_CMR_ACPC_CLEAR (2<<18)
546 #define TC_CMR_ACPC_TOGGLE (3<<18)
547 #define TC_CMR_AEEVT (3<<20)
548 #define TC_CMR_AEEVT_NONE (0<<20)
549 #define TC_CMR_AEEVT_SET (1<<20)
550 #define TC_CMR_AEEVT_CLEAR (2<<20)
551 #define TC_CMR_AEEVT_TOGGLE (3<<20)
552 #define TC_CMR_ASWTRG (3<<22)
553 #define TC_CMR_ASWTRG_NONE (0<<22)
554 #define TC_CMR_ASWTRG_SET (1<<22)
555 #define TC_CMR_ASWTRG_CLEAR (2<<22)
556 #define TC_CMR_ASWTRG_TOGGLE (3<<22)
557 #define TC_CMR_BCPB (3<<24)
558 #define TC_CMR_BCPB_NONE (0<<24)
559 #define TC_CMR_BCPB_SET (1<<24)
560 #define TC_CMR_BCPB_CLEAR (2<<24)
561 #define TC_CMR_BCPB_TOGGLE (3<<24)
562 #define TC_CMR_BCPC (3<<26)
563 #define TC_CMR_BCPC_NONE (0<<26)
564 #define TC_CMR_BCPC_SET (1<<26)
565 #define TC_CMR_BCPC_CLEAR (2<<26)
566 #define TC_CMR_BCPC_TOGGLE (3<<26)
567 #define TC_CMR_BEEVT (3<<28)
568 #define TC_CMR_BEEVT_NONE (0<<28)
569 #define TC_CMR_BEEVT_SET (1<<28)
570 #define TC_CMR_BEEVT_CLEAR (2<<28)
571 #define TC_CMR_BEEVT_TOGGLE (3<<28)
572 #define TC_CMR_BSWTRG (3<<30)
573 #define TC_CMR_BSWTRG_NONE (0<<30)
574 #define TC_CMR_BSWTRG_SET (1<<30)
575 #define TC_CMR_BSWTRG_CLEAR (2<<30)
576 #define TC_CMR_BSWTRG_TOGGLE (3<<30)
577
578 #define TC_SR_COVFS (1<<0)
579 #define TC_SR_LOVFS (1<<1)
580 #define TC_SR_CPAS (1<<2)
581 #define TC_SR_CPBS (1<<3)
582 #define TC_SR_CPCS (1<<4)
583 #define TC_SR_LDRAS (1<<5)
584 #define TC_SR_LDRBS (1<<6)
585 #define TC_SR_ETRGS (1<<7)
586 #define TC_SR_CLKSTA (1<<16)
587 #define TC_SR_MTIOA (1<<17)
588 #define TC_SR_MTIOB (1<<18)
589
590 //-------------
591 // Timer/Counter 0
592
593 #define TC0_BASE (TC_BASE+0x40*0)
594
595 #define TC0_CCR REG(TC0_BASE+0x00)
596 #define TC0_CMR REG(TC0_BASE+0x04)
597 #define TC0_CV REG(TC0_BASE+0x10)
598 #define TC0_RA REG(TC0_BASE+0x14)
599 #define TC0_RB REG(TC0_BASE+0x18)
600 #define TC0_RC REG(TC0_BASE+0x1C)
601 #define TC0_SR REG(TC0_BASE+0x20)
602 #define TC0_IER REG(TC0_BASE+0x24)
603 #define TC0_IDR REG(TC0_BASE+0x28)
604 #define TC0_IMR REG(TC0_BASE+0x2C)
605
606 //-------------
607 // Timer/Counter 1
608
609 #define TC1_BASE (TC_BASE+0x40*1)
610
611 #define TC1_CCR REG(TC1_BASE+0x00)
612 #define TC1_CMR REG(TC1_BASE+0x04)
613 #define TC1_CV REG(TC1_BASE+0x10)
614 #define TC1_RA REG(TC1_BASE+0x14)
615 #define TC1_RB REG(TC1_BASE+0x18)
616 #define TC1_RC REG(TC1_BASE+0x1C)
617 #define TC1_SR REG(TC1_BASE+0x20)
618 #define TC1_IER REG(TC1_BASE+0x24)
619 #define TC1_IDR REG(TC1_BASE+0x28)
620 #define TC1_IMR REG(TC1_BASE+0x2C)
621
622 //-------------
623 // Timer/Counter 2
624
625 #define TC2_BASE (TC_BASE+0x40*2)
626
627 #define TC2_CCR REG(TC2_BASE+0x00)
628 #define TC2_CMR REG(TC2_BASE+0x04)
629 #define TC2_CV REG(TC2_BASE+0x10)
630 #define TC2_RA REG(TC2_BASE+0x14)
631 #define TC2_RB REG(TC2_BASE+0x18)
632 #define TC2_RC REG(TC2_BASE+0x1C)
633 #define TC2_SR REG(TC2_BASE+0x20)
634 #define TC2_IER REG(TC2_BASE+0x24)
635 #define TC2_IDR REG(TC2_BASE+0x28)
636 #define TC2_IMR REG(TC2_BASE+0x2C)
637
638
639 #endif
Impressum, Datenschutz