-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-lpc4367.h
314 lines (255 loc) · 16.8 KB
/
config-lpc4367.h
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
/*
* ++++++++++++++++++
* +++++++++++++++++++++++++++++
* +++++++ +++++++++
* +++++++ +++++++++++++
* ++++++++++++++++++++ ++++++++++
* +++++++++++++++++++++ +++
* +++++ +++
* +++ ######### ######### ######## ######### ######### +++++++ ++
* +++ +++++ #### #### ######## #### #### ##### #### #### #### +++ ++++ +++
* +++ ++++ ### ## ### ### ### ### ### ### ### ++++++++ +++
* ++++ ++++ ########## ### ########## ### ### ### ### ++++ +++++
* +++++++ ###### ## ### ######## ### ## ## ### ++++++++++
*
* Copyright 2017 Technolution BV [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// ============================================================================================
// ============================================================================================
// ============================================================================================
// Start of LPC4367 specific setup
// ============================================================================================
// ============================================================================================
// ============================================================================================
#define HARDWARE_VERSION (3) // 0, 1 & 2 were AM0, AM1 & AM2. There are no sense pins on this board, so set in software */
// ----- Clocks (llb_init.c)
// -------------------------
#define CLOCK0 PINDEF(0, 0, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0))
#define CLOCK1 PINDEF(0, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0))
#define CLOCK2 PINDEF(0, 2, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0))
#define CLOCK3 PINDEF(0, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0))
// ----- FLASH (llb_init.c)
// ------------------------
#define SPIFI_SCK PINDEF(0x3, 3, (SCU_PINIO_FAST | SCU_MODE_FUNC3))
#define SPIFI_SIO3 PINDEF(0x3, 4, (SCU_PINIO_FAST | SCU_MODE_FUNC3))
#define SPIFI_SIO2 PINDEF(0x3, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC3))
#define SPIFI_MISO PINDEF(0x3, 6, (SCU_PINIO_FAST | SCU_MODE_FUNC3))
#define SPIFI_MOSI PINDEF(0x3, 7, (SCU_PINIO_FAST | SCU_MODE_FUNC3))
#define SPIFI_CS PINDEF(0x3, 8, (SCU_PINIO_FAST | SCU_MODE_FUNC3))
// ----- Stats timer (stats.c & FreeRTOSConfig.h)
// ----------------------------------------------
#define STATS_TIMER LPC_TIMER3
// ----- I2C (i2chandler.c)
// ------------------------
#define I2C0_MODE I2C0_FAST_MODE_PLUS
#define I2C0_BITRATE (400000)
#define I2C0_INTPRIORITY (7)
// ------ IPC (ipcHandler.c)
// --------------------------
/* To avoid life getting complicated, make sure this is a multiple of 4 */
#define IPC_QUEUE_LEN (128)
/* Where we place the buffers... */
#define ADDR_IPCAPP_BUFFER (0x20007C00)
#define ADDR_IPCSUB_BUFFER (ADDR_IPCAPP_BUFFER+2*(sizeof(struct buff)+IPC_QUEUE_LEN))
// ----- DIST setup (either dist.c or vldist.c)
// --------------------------------------------
#define MINDIST (150) /* Minimum distance at which vehicle will eStop */
#ifndef VL_DISTANCE
// ----- DIST setup (dist.c)
// -------------------------
#define DIST_TRIG_FRONT GPIOPINDEF(0x0E, 13, SCU_MODE_FUNC4, 7, 13) // PATCH required!!
#define DIST_CAP_FRONT GIMAPINDEF(0x05, 3, (SCU_MODE_FUNC5 | SCU_MODE_INBUFF_EN | SCU_MODE_PULLDOWN), (1 << 4)) // patch required! // T8 (timer 1 capture input 3, GIMA select T1_CAP3)
#define DIST_CAP_TIMER_INPUT_FRONT 3
#define DIST_TRIG_BACK GPIOPINDEF(0x05, 2, SCU_MODE_FUNC0, 2, 11) //ball R4
#define DIST_CAP_BACK GIMAPINDEF(0x07, 13, (SCU_MODE_FUNC1 | SCU_MODE_INBUFF_EN | SCU_MODE_PULLDOWN), (0 << 4)) // C16 (Timer 1 capture input 2, GIMA select CTIN_4)
#define DIST_CAP_TIMER_INPUT_BACK (2)
#define DIST_INTPRIORITY (7)
#define DIST_SAMPLE_RATE 20 // 20 Hz
#define DIST_TIMER LPC_TIMER1 /* Timer used for distance measurement*/
#define DIST_TIMER_INTERRUPT TIMER1_IRQHandler /* Ensure this matches with the line below!! */
#define DIST_TIMER_IRQ TIMER1_IRQn /* Ensure this matches with the line below!! */
#else
// ----- VL Distance Sensor (vldist.c)
// -----------------------------------
enum VLDIST_CHANNEL_ENUM {VLDIST_FRONT, VLDIST_REAR, VLDISTNONE };
#define NUM_VLS (VLDISTNONE)
#define VLS0ID 0x10
#define VLS0EN GPIOPINDEF(0x01, 16, SCU_MODE_FUNC0, 0, 3)
#define VLS1ID 0x11
#define VLS1EN GPIOPINDEF(0x07, 1, SCU_MODE_FUNC0, 3, 9)
#define VLSLIST {VLS0ID,VLS0EN},{VLS1ID,VLS1EN}
#endif
// Motor Encoder (rotenc.c)
// -------------------------
#define ROT_ENC_INT_PRIORITY (6)
#define ROT_A GPIOPINDEF(0x2, 2, (SCU_MODE_FUNC4 | SCU_MODE_INBUFF_EN | SCU_MODE_PULLUP), 5, 2)
#define ROT_A_CHANNEL 5
#define ROT_A_HANDLER GPIO5_IRQHandler
#define ROT_A_IRQn PIN_INT5_IRQn
#define ROT_B GPIOPINDEF(0x1, 8, (SCU_MODE_FUNC0 | SCU_MODE_INBUFF_EN | SCU_MODE_PULLUP), 1, 1 )
#define ROT_B_CHANNEL 3
#define ROT_B_HANDLER GPIO3_IRQHandler
#define ROT_B_IRQn PIN_INT3_IRQn
// Connection to HLB warning (gio.c)
// ---------------------------------
#define CONNECTED_TICKS (MILLIS_TO_TICKS(10000))
// ----- Motor Control (motor.c)
// -----------------------------
#define MOTOR0_M0 GPIOPINDEF(0x2,12, (SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN), 1, 12)
#define MOTOR0_M1 GPIOPINDEF(0x2, 9, (SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN), 1, 10)
#define MOTOR0_PIN SCT_PINDEF(0x6, 5, SCU_MODE_FUNC1, 6)
#define SERVO_PIN SCT_PINDEF(0x1, 5, SCU_MODE_FUNC1, 10)
// ----- MPU9250 9D sensor Setup (nined.c)
// ---------------------------------------
#define AK8963_I2C_ADDR (0x0c)
#define NINED_INT GPIOPINDEF(0x2,13, (SCU_MODE_FUNC0 | SCU_MODE_INBUFF_EN | SCU_MODE_INACT), 1,13)
#define NINED_INT_PRI (6)
#define NINED_SENSOR_ID (0x68)
#define MAG_SENSOR_ID (0x0C)
#define NINED_SENSOR_SPEED (400000)
#define NINED_SDA PINDEF(0x2, 3, (SCU_MODE_FUNC1 | SCU_MODE_ZIF_DIS | SCU_MODE_INBUFF_EN))
#define NINED_SCL PINDEF(0x2, 4, (SCU_MODE_FUNC1 | SCU_MODE_ZIF_DIS | SCU_MODE_INBUFF_EN))
#define MAG_WAKEUP_TIME (MILLIS_TO_TICKS(500))
#define GYRO_WAKEUP_TIME (MILLIS_TO_TICKS(100))
// DWM1000 module (dw1000.c &dwif.c)
// ---------------------------------
//#define BE_VERBOSE // Define if you want information about the success of transmission
#define RANGE_ON_TERMINAL // Define if you want ranging information to be output
//#define REPORT_STATE_TRANSITIONS // Define to get information about state changes
#define MAX_FRAME_SIZE 127
#define DW_SPI_PORT LPC_SSP1
#define DW_SSP_CLKINDEX SYSCTL_CLOCK_SSP1
#define DW_SSP_RESETINDEX RESET_SSP1
#define DW_PININT_HANDLER M0_GPIO4_IRQHandler
#define DW_PININT_CHANNEL (4)
#define DW_PININT_NVIC_NAME PIN_INT4_IRQn
#define DW_PININT_PRIORITY (6)
#define DW_LOW_SPI_SPEED (3000000)
#define DW_HIGH_SPI_SPEED (10000000)
// Pin Allocations...
#define DW_MISO PINDEF(0x01, 3, (SCU_MODE_FUNC5 | SCU_MODE_INBUFF_EN))
#define DW_MOSI PINDEF(0x01, 4, (SCU_MODE_FUNC5))
#define DW_SEL GPIOPINDEF(0x06, 1, (SCU_MODE_FUNC0),3, 0)
#define DW_CLK PINDEF(0x0f, 4, (SCU_MODE_FUNC0))
#define DW_INT GPIOPINDEF(0x03, 5, (SCU_MODE_FUNC0|SCU_MODE_INBUFF_EN|SCU_MODE_ZIF_DIS|SCU_MODE_PULLDOWN), 1, 15)
#define DW_RST GPIOPINDEF(0x2, 6, (SCU_MODE_FUNC4 | SCU_MODE_INBUFF_EN | SCU_MODE_INACT), 5, 6)
// --- DEBUG LEDS (gio.c)
// ----------------------
#define DEBUG_LED0 GPIOPINDEF(0x01, 1, (SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN), 0, 8)
#define RGB_LED_B GPIOPINDEF(0x06, 9, SCU_MODE_FUNC0, 3, 5)
/* This pin does double duty as the ISP switch, so it needs its pullup on */
#define RGB_LED_G USERBUTTON
#define RGB_LED_R GPIOPINDEF(0x06,11, SCU_MODE_FUNC0, 3, 7)
/* LED function allocations to pins */
#define HB_LED (DBG0_LED)
#define USER_BUTTON_LED (DBG0_LED)
#define DW_ANNLED (DBG0_LED)
#define DW_RXLED (DBG0_LED)
#define SD_RD_ACCESS_LED (DBG0_LED)
#define SD_WR_ACCESS_LED (DBG0_LED)
// LED configuration (leds.c)
// --------------------------
#define NUM_OF_RGB_LEDS (8)
#define LEDSTRING_DAT GPIOPINDEF(0x01, 6, SCU_MODE_FUNC0, 1, 9)
#define LEDSTRING_CLK GPIOPINDEF(0x01, 9, SCU_MODE_FUNC0, 1, 2)
// ----- UART configuration (uarthandler.c)
// ----------------------------------------
/* TX is FROM the MCU to the Host (i.e. it's an output) */
/* This is the FTDI Header: Make sure JP11 is fitted to allow P6_4 to be the TX Pin!! */
#define UART0_TX PINDEF(0x06, 4,(SCU_MODE_FUNC2 | SCU_MODE_INACT))
#define UART0_RX PINDEF(0x02, 1,(SCU_MODE_FUNC1 | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS))
/* This is J2 18 & 19 on the Arduino header */
#define UART1_TX PINDEF(0x01,13,SCU_MODE_FUNC1)
#define UART1_RX PINDEF(0x01,14,(SCU_MODE_FUNC1 | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS))
/* This is J2 13 & 15 on the Arduino header */
#define UART2_TX PINDEF(0x02,10,SCU_MODE_FUNC2)
#define UART2_RX PINDEF(0x02,11,(SCU_MODE_FUNC2 | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS))
/* This is not pinned on the 100 pin package, but it can be put onto P2_3/P2_4 if you don't need I2C there */
#define UART3_TX PINDEF(0x04, 1,SCU_MODE_FUNC6)
#define UART3_RX PINDEF(0x04, 2,(SCU_MODE_FUNC6 | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS))
#define UART_INTPRIORITY (7)
// ---- Serial port that is used for HLB communication (lmsmsg.c)
// --------------------------------------------------------------
#define LLB_IF_PORT SERPORT_UART1
#define LLB_IF_BAUDRATE (230400)
// ---- Serial port that is used for the debug & interactive terminal (ui.c)
// -------------------------------------------------------------------------
#define TERMINAL_PORT SERPORT_USB
#define TERMINAL_BAUDRATE (115200)
#define TERMINAL_PROMPT ">"
// ---- Smoke Maker (Used for Camera power at the moment) (gio.c)
// --------------------------------------------------------------
#define SMOKE GPIOPINDEF(0x1,7, (SCU_MODE_FUNC0 | SCU_MODE_INACT), 1, 0)
/* User button setup for interrupt */
#define USERBUTTON GPIOPINDEF(0x02,7, (SCU_MODE_FUNC0 | SCU_MODE_INBUFF_EN | SCU_MODE_PULLUP), 0, 7)
// --- ADC Configuration for Battery Level (mainloop.c)
// ----------------------------------------------------
#define BATTERY_ADC_PORT LPC_ADC0
#define BATTERY_ADC_CHANNEL ADC_CH0
#ifdef INCLUDE_SDMMC
// --- SDMMC Configuration (sdif.c)
// --------------------------------
#define SDMMC_SDIO_D0 PINDEF(0xC, 4, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC7))
#define SDMMC_SDIO_D1 PINDEF(0xC, 5, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC7))
#define SDMMC_SDIO_D2 PINDEF(0xC, 6, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC7))
#define SDMMC_SDIO_D3 PINDEF(0xC, 7, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC7))
#define SDMMC_CLKPIN (0)
#define SDMMC_CLKCFG (SCU_MODE_INACT | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC4)
#define SDMMC_SDIO_CMD PINDEF(1, 6, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC7))
#define SDIO_INTPRIORITY (7)
#endif
#ifdef INCLUDE_ETHERNET
// ----- Ethernet (enet.c)
// -----------------------
#define ENET_TXD0 PINDEF(0x1, 18, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3))
#define ENET_TXD1 PINDEF(0x1, 20, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3))
#define ENET_TXEN PINDEF(0x0, 1, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC6))
#define ENET_RXD0 PINDEF(0x1, 15, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3))
#define ENET_RXD1 PINDEF(0x0, 0, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2))
#define ENET_RX_DV PINDEF(0xC, 8, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3))
#define ENET_MDIO PINDEF(0x1, 17, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3))
#define ENET_MDC PINDEF(0x2, 0, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_PULLUP | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC7))
#define ENET_TXCLK PINDEF(0x1, 19, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC0))
#define ENET_RESET GPIOPINDEF(0xD, 13, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC4),6,27)
#define BOARD_ENET_PHY_ADDR 0x00 /* Address of the RMII Phy */
#define ENET_INTERRUPT_PRIORITY (6)
#define USE_RMII
#endif
#ifdef INCLUDE_CAN
// ---- CAN Parameters (can.c)
// ---------------------------
#define CAN_BITRATE (500000)
#define CAN_IF LPC_C_CAN0
#define CAN_INTERFACE (CCAN_MSG_IF1)
#define CAN_RD PINDEF(0x3, 1, (SCU_MODE_FUNC2|SCU_MODE_INBUFF_EN))
#define CAN_TD PINDEF(0x3, 2, (SCU_MODE_FUNC2))
#endif
#ifdef INCLUDE_AUDIO
// Sound Output (audio.c)
// ----------------------
#define AUDIO_ENABLE GPIOPINDEF(0x01, 3, SCU_MODE_FUNC0, 0, 10)
#define AUDIO_OUT GPIOPINDEF(0x04, 4, (SCU_MODE_FUNC0|SCU_MODE_PULLUP), 2, 4)
#define AUDIO_INT_PRIORITY (7)
#endif
// ============================================================================================
// ============================================================================================
// ============================================================================================
// End of LPC4367 specific setup
// ============================================================================================
// ============================================================================================
// ============================================================================================