aboutsummaryrefslogtreecommitdiffstats
path: root/openpcd/firmware/src/openpcd.h
blob: a532f148c5329cf5c09d9759b36566f087022fcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef _OPENPCD_H
#define _OPENPCD_H

#include <openpcd.h>

#define Hz
#define	kHz	*1000 Hz
#define MHz	*1000 kHz
#define MCLK	(48 MHz)


#ifdef OLIMEX
#define OPENPCD_PIO_LED2	AT91C_PIO_PA17
#define OPENPCD_PIO_LED1	AT91C_PIO_PA18
#define OPENPCD_PIO_UDP_CNX	AT91C_PIO_PA24
#define OPENPCD_PIO_UDP_PUP	AT91C_PIO_PA16
#else
#define OPENPCD_PIO_UDP_CNX	AT91C_PIO_PA15
#define OPENPCD_PIO_UDP_PUP	AT91C_PIO_PA22
#define OPENPCD_PIO_LED1	AT91C_PIO_PA25
#define OPENPCD_PIO_LED2	AT91C_PIO_PA26
#endif

#define OPENPCD_IRQ_RC632	AT91C_ID_IRQ1

/* PIO A mapping for OpenPCD v0.2
 *
 * PA0	TIOA0	B	O	CARRIER_DIV_HELP
 * PA1	TIOB1	B	O	CARRIER_DIV
 * PA2	PA2	P	I	N/C
 * PA3	TWD	A	I/O	I2C
 *
 * PA4	TWCK	A	O	I2C
 * PA5	PA5	P	O	RFID_RESET
 * PA6	PA6	P	I	N/C
 * PA7	PA7	P	I	N/C
 *
 * PA8	PA8	P	I	N/C
 * PA9	DRXD	A	I	Debug
 * PA10	DTXD	A	O	Debug
 * PA11	NPCS0	A	O	SPI Slave Select
 *
 * PA12	MISO	A	I	SPi Master In
 * PA13	MOSI	A	O	SPI Maste Out
 * PA14	SPCK	A	O	SPI Clock
 * PA15		P	I	N/C
 *
 * PA16	PA16	P	O	UDP_PUP (disabled)
 * PA17	TD	A	O	MFIN	*
 * PA18	RD	A	I	MFOUT
 * PA19	RK	A	I	CARRIER_DIV
 *
 * PA20	PA20	P	I	AB_DETECT
 * PA21	PA21	P	I	N/C
 * PA22	PA22	P	I	UDP_PUP
 * PA23	PWM0	B	O	MFIN 	*
 *
 * PA24		P	I	N/C
 * PA25	PA25	P	O	LED1
 * PA26	PA26	P	O	LED2
 * PA27	PA27	P	I	BOOTLDR_SW
 *
 * PA28	TCLK1	B	I	PIO_CARRIER
 * PA29	TCLK2	B	I	CARRIER_DIV_HELP
 * PA30	IRQ1	A	I	RC632_IRQ
 * PA31	PA31	P	O	TRIGGER
 *
 * => PIO_PSR = 0x8f7181e4 (= PIO_PER)
 * => PIO_OSR = 0x86010020 (= PIO_OER)
 * => PIO_ASR = 0x400e7e18 
 * => PIO_BSR = 0x30800003
 *
 * * MFIN connected to both SSC and PWM output !!!
 */

#define OPENPCD_PIO_CDIV_HELP_OUT	AT91C_PA0_TIOA0
#define OPENPCD_PIO_CDIV_HELP_IN	AT91C_PA29_TCLK2
#define OPENPCD_PIO_MFIN_PWM		AT91C_PA23_PWM0
#define OPENPCD_PIO_CARRIER_DIV_OUT	AT91C_PA1_TIOB0
#define OPENPCD_PIO_MFIN_SSC_TX		AT91C_PA17_TD
#define OPENPCD_PIO_MFOUT_SSC_RX	AT91C_PA18_RD
#define OPENPCD_PIO_SSP_CKIN		AT91C_PA19_RK
#define OPENPCD_PIO_RC632_RESET		AT91C_PIO_PA5
#define OPENPCD_PIO_TRIGGER		AT91C_PIO_PA31
#define OPENPCD_PIO_CARRIER_IN		AT91C_PA28_TCLK1

#ifdef CONFIG_PICCSIM
#define OPENPICC_PIO_PLL_INHIBIT	AT91C_PIO_PA24
#define OPENPICC_PIO_SS1_GAIN		AT91C_PIO_PA11
#define OPENPICC_PIO_SS2_DT_THRESH	AT91C_PIO_PA8
#define OPENPICC_PIO_BOOTLDR		AT91C_PIO_PA6
#define OPENPICC_PIO_SLAVE_RESET	AT91C_PIO_PA5
#define OPENPICC_PIO_LOAD1		AT91C_PIO_PA2
#define OPENPICC_PIO_LOAD2		AT91C_PIO_PA3
#define OPENPICC_PIO_AB_DETECT		AT91C_PIO_PA20

#define OPENPICC_ADC_FIELD_STRENGTH	AT91C_ADC_CH4
#define OPENPICC_ADC_PLL_DEM		AT91C_ADC_CH5
#define OPENPICC_ADC_AN1		AT91C_ADC_CH6
#define OPENPICC_ADC_AN2		AT91C_ADC_CH7
#endif

#define OPENPCD_IRQ_PRIO_SPI	AT91C_AIC_PRIOR_HIGHEST
#define OPENPCD_IRQ_PRIO_SSC	(AT91C_AIC_PRIOR_HIGHEST-1)
#define OPENPCD_IRQ_PRIO_UDP	(AT91C_AIC_PRIOR_LOWEST+1)
#define OPENPCD_IRQ_PRIO_RC632	AT91C_AIC_PRIOR_LOWEST

#endif /* _OPENPCD_H */