LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
board_nxp_xpresso_1769.c
Go to the documentation of this file.
1 /*
2  * @brief NXP LPC1769 Xpresso board file
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licensor disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #include "board.h"
33 #include "string.h"
34 
35 #include "lpc_phy_smsc87x0.c"
36 #include "retarget.c"
37 
42 /*****************************************************************************
43  * Private types/enumerations/variables
44  ****************************************************************************/
45 #define BUTTONS_BUTTON1_GPIO_PORT_NUM 2
46 #define BUTTONS_BUTTON1_GPIO_BIT_NUM 10
47 #define JOYSTICK_UP_GPIO_PORT_NUM 2
48 #define JOYSTICK_UP_GPIO_BIT_NUM 3
49 #define JOYSTICK_DOWN_GPIO_PORT_NUM 0
50 #define JOYSTICK_DOWN_GPIO_BIT_NUM 15
51 #define JOYSTICK_LEFT_GPIO_PORT_NUM 2
52 #define JOYSTICK_LEFT_GPIO_BIT_NUM 4
53 #define JOYSTICK_RIGHT_GPIO_PORT_NUM 0
54 #define JOYSTICK_RIGHT_GPIO_BIT_NUM 16
55 #define JOYSTICK_PRESS_GPIO_PORT_NUM 0
56 #define JOYSTICK_PRESS_GPIO_BIT_NUM 17
57 #define LED0_GPIO_PORT_NUM 0
58 #define LED0_GPIO_BIT_NUM 22
59 
60 /*****************************************************************************
61  * Public types/enumerations/variables
62  ****************************************************************************/
63 
66 
67 /*****************************************************************************
68  * Private functions
69  ****************************************************************************/
70 
71 /* Initializes board LED(s) */
72 static void Board_LED_Init(void)
73 {
74  /* Pin PIO0_22 is configured as GPIO pin during SystemInit */
75  /* Set the PIO_22 as output */
77 }
78 
79 /*****************************************************************************
80  * Public functions
81  ****************************************************************************/
82 
83 /* Update system core clock rate, should be called if the system has
84  a clock rate change */
86 {
87  /* CPU core speed */
89 }
90 
91 /* Initialize UART pins */
93 {
94  /* Pin Muxing has already been done during SystemInit */
95 }
96 
97 /* Initialize debug output via UART for board */
98 void Board_Debug_Init(void)
99 {
100 #if defined(DEBUG_ENABLE)
102 
103  /* Setup UART for 115.2K8N1 */
105  Chip_UART_SetBaud(DEBUG_UART, 115200);
107 
108  /* Enable UART Transmit */
110 #endif
111 }
112 
113 /* Sends a character on the UART */
114 void Board_UARTPutChar(char ch)
115 {
116 #if defined(DEBUG_ENABLE)
117  while (Chip_UART_SendByte(DEBUG_UART, (uint8_t) ch) == ERROR) {}
118 #endif
119 }
120 
121 /* Gets a character from the UART, returns EOF if no character is ready */
123 {
124 #if defined(DEBUG_ENABLE)
125  uint8_t data;
126 
127  if (Chip_UART_ReceiveByte(DEBUG_UART, &data) == SUCCESS) {
128  return (int) data;
129  }
130 #endif
131  return EOF;
132 }
133 
134 /* Outputs a string on the debug UART */
135 void Board_UARTPutSTR(char *str)
136 {
137 #if defined(DEBUG_ENABLE)
138  while (*str != '\0') {
139  Board_UARTPutChar(*str++);
140  }
141 #endif
142 }
143 
144 /* Sets the state of a board LED to on or off */
145 void Board_LED_Set(uint8_t LEDNumber, bool On)
146 {
147  /* There is only one LED */
148  if (LEDNumber == 0) {
150  }
151 }
152 
153 /* Returns the current state of a board LED */
154 bool Board_LED_Test(uint8_t LEDNumber)
155 {
157 }
158 
159 /* Set up and initialize all required blocks and functions related to the
160  board hardware */
161 void Board_Init(void)
162 {
163  /* Sets up DEBUG UART */
164  DEBUGINIT();
165 
166  /* Updates SystemCoreClock global var with current clock speed */
168 
169  /* Initializes GPIO */
172 
173  /* Initialize LEDs */
174  Board_LED_Init();
175 }
176 
177 /* Returns the MAC address assigned to this board */
178 void Board_ENET_GetMacADDR(uint8_t *mcaddr)
179 {
180  const uint8_t boardmac[] = {0x00, 0x60, 0x37, 0x12, 0x34, 0x56};
181 
182  memcpy(mcaddr, boardmac, 6);
183 }
184 
185 /* Initialize pin muxing for SSP interface */
187 {
188  if (pSSP == LPC_SSP1) {
189  /* Set up clock and muxing for SSP1 interface */
190  /*
191  * Initialize SSP0 pins connect
192  * P0.7: SCK
193  * P0.6: SSEL
194  * P0.8: MISO
195  * P0.9: MOSI
196  */
201  }
202  else {
203  /* Set up clock and muxing for SSP0 interface */
204  /*
205  * Initialize SSP0 pins connect
206  * P0.15: SCK
207  * P0.16: SSEL
208  * P0.17: MISO
209  * P0.18: MOSI
210  */
215  }
216 }
217 
218 /* Initialize pin muxing for SPI interface */
219 void Board_SPI_Init(bool isMaster)
220 {
221  /* Set up clock and muxing for SSP0 interface */
222  /*
223  * Initialize SSP0 pins connect
224  * P0.15: SCK
225  * P0.16: SSEL
226  * P0.17: MISO
227  * P0.18: MOSI
228  */
230  if (isMaster) {
232  Chip_GPIO_WriteDirBit(LPC_GPIO, 0, 16, true);
234 
235  }
236  else {
238  }
241 }
242 
243 /* Assert SSEL pin */
245 {
246  Chip_GPIO_WritePortBit(LPC_GPIO, 0, 16, false);
247 }
248 
249 /* De-Assert SSEL pin */
251 {
252  Chip_GPIO_WritePortBit(LPC_GPIO, 0, 16, true);
253 }
254 
255 void Board_Audio_Init(uint8_t audio_in_sel)
256 {}
257 
258 /* Sets up board specific I2C interface */
260 {
261  switch (id) {
262  case I2C0:
265  Chip_IOCON_SetI2CPad(LPC_IOCON, I2CPADCFG_STD_MODE);
266  break;
267 
268  case I2C1:
271  Chip_IOCON_EnableOD(LPC_IOCON, 0, 19);
272  Chip_IOCON_EnableOD(LPC_IOCON, 0, 20);
273  break;
274 
275  case I2C2:
278  Chip_IOCON_EnableOD(LPC_IOCON, 0, 10);
279  Chip_IOCON_EnableOD(LPC_IOCON, 0, 11);
280  break;
281  }
282 }
283 
285 {
287 }
288 
290 {
291  uint8_t ret = NO_BUTTON_PRESSED;
293  ret |= BUTTONS_BUTTON1;
294  }
295  return ret;
296 }
297 
299 {
307  IOCON_FUNC0);
312  IOCON_FUNC0);
318 }
319 
320 uint8_t Joystick_GetStatus(void)
321 {
322  uint8_t ret = NO_BUTTON_PRESSED;
324  ret |= JOY_UP;
325  }
327  ret |= JOY_DOWN;
328  }
330  ret |= JOY_LEFT;
331  }
333  ret |= JOY_RIGHT;
334  }
336  ret |= JOY_PRESS;
337  }
338  return ret;
339 }
340 
341 void Serial_CreateStream(void *Stream)
342 {}