diff options
Diffstat (limited to 'lib/chibios-contrib/os/hal/boards/PJRC_TEENSY_3_5/board.c')
-rw-r--r-- | lib/chibios-contrib/os/hal/boards/PJRC_TEENSY_3_5/board.c | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/lib/chibios-contrib/os/hal/boards/PJRC_TEENSY_3_5/board.c b/lib/chibios-contrib/os/hal/boards/PJRC_TEENSY_3_5/board.c new file mode 100644 index 000000000..b081f1404 --- /dev/null +++ b/lib/chibios-contrib/os/hal/boards/PJRC_TEENSY_3_5/board.c | |||
@@ -0,0 +1,218 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2015 RedoX https://github.com/RedoXyde | ||
3 | Copyright (C) 2017 Wim Lewis | ||
4 | |||
5 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | you may not use this file except in compliance with the License. | ||
7 | You may obtain a copy of the License at | ||
8 | |||
9 | http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | |||
11 | Unless required by applicable law or agreed to in writing, software | ||
12 | distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | See the License for the specific language governing permissions and | ||
15 | limitations under the License. | ||
16 | */ | ||
17 | #include "hal.h" | ||
18 | |||
19 | #if HAL_USE_PAL || defined(__DOXYGEN__) | ||
20 | /** | ||
21 | * @brief PAL setup. | ||
22 | * @details Digital I/O ports static configuration as defined in @p board.h. | ||
23 | * This variable is used by the HAL when initializing the PAL driver. | ||
24 | */ | ||
25 | |||
26 | #define SOME_GPIO PAL_MODE_INPUT_PULLUP | ||
27 | |||
28 | const PALConfig pal_default_config = | ||
29 | { | ||
30 | .ports = { | ||
31 | { | ||
32 | /* | ||
33 | * PORTA setup. | ||
34 | * | ||
35 | * PTA0 -PTA3 -- bootloading coprocessor | ||
36 | * PTA5 -- PIN25 | ||
37 | * PTA12-PTA13 -- PIN3-PIN4 | ||
38 | * PTA14-PTA16 -- PIN26-PIN28 | ||
39 | * PTA17 -- PIN39 / A20 | ||
40 | * PTA26 -- PIN42 | ||
41 | * PTA28 -- PIN40 | ||
42 | * PTA29 -- PIN41 | ||
43 | * | ||
44 | * PTA18/19 crystal | ||
45 | */ | ||
46 | .port = IOPORT1, | ||
47 | .pads = { | ||
48 | /* PTA0-PTA3 -- bootloading coprocessor */ | ||
49 | PAL_MODE_ALTERNATIVE_7, PAL_MODE_UNCONNECTED, | ||
50 | PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_7, | ||
51 | |||
52 | PAL_MODE_UNCONNECTED, | ||
53 | PAL_MODE_OUTPUT_PUSHPULL, /* PIN25 */ | ||
54 | PAL_MODE_UNCONNECTED, | ||
55 | PAL_MODE_UNCONNECTED, | ||
56 | PAL_MODE_UNCONNECTED, | ||
57 | PAL_MODE_UNCONNECTED, | ||
58 | PAL_MODE_UNCONNECTED, | ||
59 | PAL_MODE_UNCONNECTED, | ||
60 | PAL_MODE_UNCONNECTED, /* PIN3 */ | ||
61 | PAL_MODE_OUTPUT_PUSHPULL, /* PIN4 */ | ||
62 | PAL_MODE_OUTPUT_PUSHPULL, /* PIN26 */ | ||
63 | PAL_MODE_UNCONNECTED, /* PIN27 */ | ||
64 | PAL_MODE_UNCONNECTED, /* PIN28 */ | ||
65 | PAL_MODE_UNCONNECTED, /* PIN39 */ | ||
66 | PAL_MODE_INPUT_ANALOG, /* XTAL0 */ | ||
67 | PAL_MODE_INPUT_ANALOG, /* XTAL0 */ | ||
68 | PAL_MODE_UNCONNECTED, | ||
69 | PAL_MODE_UNCONNECTED, | ||
70 | PAL_MODE_UNCONNECTED, | ||
71 | PAL_MODE_UNCONNECTED, | ||
72 | PAL_MODE_UNCONNECTED, | ||
73 | PAL_MODE_UNCONNECTED, | ||
74 | PAL_MODE_UNCONNECTED, /* PIN42 */ | ||
75 | PAL_MODE_UNCONNECTED, | ||
76 | PAL_MODE_UNCONNECTED, /* PIN40 */ | ||
77 | PAL_MODE_UNCONNECTED, /* PIN41 */ | ||
78 | PAL_MODE_UNCONNECTED, | ||
79 | PAL_MODE_UNCONNECTED, | ||
80 | }, | ||
81 | }, | ||
82 | { | ||
83 | /* | ||
84 | * PORTB setup. | ||
85 | * | ||
86 | * PTB0 - PIN16 | ||
87 | * PTB1 - PIN17 | ||
88 | * PTB2 - PIN19 | ||
89 | * PTB3 - PIN18 | ||
90 | * PTB10 - PIN31 | ||
91 | * PTB11 - PIN32 | ||
92 | * PTB16 - PIN0 - UART0_TX | ||
93 | * PTB17 - PIN1 - UART0_RX | ||
94 | * PTB18 - PIN32 | ||
95 | * PTB19 - PIN25 | ||
96 | */ | ||
97 | .port = IOPORT2, | ||
98 | .pads = { | ||
99 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
100 | PAL_MODE_OUTPUT_PUSHPULL, SOME_GPIO, SOME_GPIO, | ||
101 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
102 | PAL_MODE_UNCONNECTED, SOME_GPIO, SOME_GPIO, | ||
103 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
104 | PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_3, PAL_MODE_ALTERNATIVE_3, | ||
105 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, SOME_GPIO, | ||
106 | SOME_GPIO, SOME_GPIO, SOME_GPIO, | ||
107 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
108 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
109 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
110 | }, | ||
111 | }, | ||
112 | { | ||
113 | /* | ||
114 | * PORTC setup. | ||
115 | * | ||
116 | * PTC0 - PIN15 | ||
117 | * PTC1 - PIN22 | ||
118 | * PTC2 - PIN23 | ||
119 | * PTC3 - PIN9 | ||
120 | * PTC4 - PIN10 | ||
121 | * PTC5 - PIN13 | ||
122 | * PTC6 - PIN11 | ||
123 | * PTC7 - PIN12 | ||
124 | * PTC8 - PIN35 | ||
125 | * PTC9 - PIN36 | ||
126 | * PTC10 - PIN37 | ||
127 | * PTC11 - PIN38 | ||
128 | */ | ||
129 | .port = IOPORT3, | ||
130 | .pads = { | ||
131 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
132 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
133 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
134 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
135 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
136 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
137 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
138 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
139 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
140 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
141 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
142 | }, | ||
143 | }, | ||
144 | { | ||
145 | /* | ||
146 | * PORTD setup. | ||
147 | * | ||
148 | * PTD0 - PIN2 | ||
149 | * PTD1 - PIN14 | ||
150 | * PTD2 - PIN7 | ||
151 | * PTD3 - PIN8 | ||
152 | * PTD4 - PIN6 | ||
153 | * PTD5 - PIN20 | ||
154 | * PTD6 - PIN21 | ||
155 | * PTD7 - PIN5 | ||
156 | */ | ||
157 | .port = IOPORT4, | ||
158 | .pads = { | ||
159 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
160 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
161 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, SOME_GPIO, | ||
162 | PAL_MODE_UNCONNECTED, SOME_GPIO, SOME_GPIO, | ||
163 | SOME_GPIO, SOME_GPIO, SOME_GPIO, | ||
164 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
165 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
166 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
167 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
168 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
169 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
170 | }, | ||
171 | }, | ||
172 | { | ||
173 | /* | ||
174 | * PORTE setup. | ||
175 | * | ||
176 | * PTE0 - PTE5 -- SDHC slot | ||
177 | * PTE6 -- USB OTG power switch (Teensy3.6 only) | ||
178 | * PTE10 - PIN56 | ||
179 | * PTE11 - PIN57 | ||
180 | * PTE24 - PIN33 | ||
181 | * PTE25 - PIN34 | ||
182 | * PTE26 - PIN24 | ||
183 | */ | ||
184 | .port = IOPORT5, | ||
185 | .pads = { | ||
186 | PAL_MODE_ALTERNATIVE_4, PAL_MODE_ALTERNATIVE_4, PAL_MODE_ALTERNATIVE_4, | ||
187 | PAL_MODE_ALTERNATIVE_4, PAL_MODE_ALTERNATIVE_4, PAL_MODE_ALTERNATIVE_4, | ||
188 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
189 | PAL_MODE_UNCONNECTED, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
190 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
191 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
192 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
193 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
194 | PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, | ||
195 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
196 | PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, | ||
197 | }, | ||
198 | }, | ||
199 | }, | ||
200 | }; | ||
201 | #endif | ||
202 | |||
203 | /** | ||
204 | * @brief Early initialization code. | ||
205 | * @details This initialization must be performed just after stack setup | ||
206 | * and before any other initialization. | ||
207 | */ | ||
208 | void __early_init(void) { | ||
209 | |||
210 | k60x_clock_init(); | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * @brief Board-specific initialization code. | ||
215 | * @todo Add your board-specific code, if any. | ||
216 | */ | ||
217 | void boardInit(void) { | ||
218 | } | ||