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_812.c
Go to the documentation of this file.
1 /*
2  * @brief NXP XPresso 812 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 
39 /*****************************************************************************
40  * Private types/enumerations/variables
41  ****************************************************************************/
42 
43 #define RED_LED_PORT_BIT 7
44 #define BLUE_LED_PORT_BIT 16
45 #define GREEN_LED_PORT_BIT 17
46 
48 
49 /*****************************************************************************
50  * Public types/enumerations/variables
51  ****************************************************************************/
52 
53 /*****************************************************************************
54  * Private functions
55  ****************************************************************************/
56 
57 /* Initialize the LEDs on the NXP LPC812 XPresso Board */
58 static void Board_LED_Init(void)
59 {
60  uint8_t i;
61  for (i = 0; i < sizeof(LED_BITS); i++) {
64  }
65 }
66 
67 /*****************************************************************************
68  * Public functions
69  ****************************************************************************/
70 
71 /* Set the LED to the state of "On" */
72 void Board_LED_Set(uint8_t LEDNumber, bool On)
73 {
75 }
76 
77 /* Return the state of LEDNumber */
78 bool Board_LED_Test(uint8_t LEDNumber)
79 {
80  return (bool) !Chip_GPIO_ReadPortBit(LPC_GPIO_PORT, LPC8XX_PORT_NUM, LED_BITS[LEDNumber]);
81 }
82 
83 /* System Clock Frequency (Core Clock) */
85 
86 /*
87  * Update system core clock rate, should be called if the system has
88  * a clock rate change
89  */
91 {
92  /* CPU core speed */
94 }
95 
96 /* Board UART Initialisation function */
98 {
99  /* Enable the clock to the Switch Matrix */
101  Chip_Clock_SetUARTClockDiv(1); /* divided by 1 */
102  if (pUART == LPC_USART0) {
103  /*connect the U0_TXD_O and U0_RXD_I signals to port pins(P0.4, P0.0) */
107  /* Enable USART0 clock */
108  Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_UART0); // FIXME UART clocking and reset need to be part of CHIP driver
109  /* Peripheral reset control to USART0, a "1" bring it out of reset. */
111  }
112  else if (pUART == LPC_USART1) {
113  /*connect the U1_TXD_O and U1_RXD_I signals to port pins(P0.13, P0.14) */
116  /* Enable USART1 clock */
117  Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_UART1); // FIXME UART clocking and reset need to be part of CHIP driver
118  /* Peripheral reset control to USART1, a "1" bring it out of reset. */
120  }
121  else {
122  /*connect the U2_TXD_O and U2_RXD_I signals to port pins(P0.13, P0.14) */
125  /* Enable USART2 clock */
126  Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_UART2); // FIXME UART clocking and reset need to be part of CHIP driver
127  /* Peripheral reset control to USART2, a "1" bring it out of reset. */
129  }
130 }
131 
132 /* Initialize pin muxing for SPI interface */
134 {
135  /* Enable the clock to the Switch Matrix */
137  if (pSPI == LPC_SPI0) {
138  /*
139  * Initialize SSP0 pins connect
140  * SCK0: PINASSIGN3[31:24] : Select P0.12
141  * MOSI: PINASSIGN4[7:0] : Select P0.14
142  * MISO0: PINASSIGN4[15:8]: Select P0.6
143  * SSEL0: PINASSIGN4[23:16] : Select P0.13
144  */
150 
151  }
152  else {
153  /*
154  * Initialize SSP0 pins connect
155  * SCK1: PINASSIGN4[31:24]: Select P0.12
156  * MOSI1: PINASSIGN5[7:0]: Select P0.14
157  * MISO1: PINASSIGN5[15:8] : Select P0.6
158  * SSEL1: PINASSIGN5[23:16]: Select P0.13
159  */
165  }
166  /* Disable the clock to the Switch Matrix to save power */
168 }
169 
170 /* Initializes clock and pin muxing for I2C interface */
171 void Board_I2C_Init(void)
172 {
173  /* Enable the clock to the Switch Matrix */
175  /* Connect the I2C_SDA and I2C_SCL signals to port pins(P0.10, P0.11) */
178 
179  /* Enable Fast Mode Plus for I2C pins */
182 }
183 
184 /* Sends a character on the UART */
185 void Board_UARTPutChar(char ch)
186 {
187 #if defined(DEBUG_UART)
188  while (Chip_UART_SendByte(DEBUG_UART, (uint8_t) ch) == ERROR) {}
189 #endif
190 }
191 
192 /* Gets a character from the UART, returns EOF if no character is ready */
194 {
195 #if defined(DEBUG_UART)
196  uint8_t data;
197 
198  if (Chip_UART_ReceiveByte(DEBUG_UART, &data) == SUCCESS) {
199  return (int) data;
200  }
201 #endif
202  return EOF;
203 }
204 
205 /* Outputs a string on the debug UART */
206 void Board_UARTPutSTR(char *str)
207 {
208 #if defined(DEBUG_UART)
209  while (*str != '\0') {
210  Board_UARTPutChar(*str++);
211  }
212 #endif
213 }
214 
215 /* Initialize debug output via UART for board */
217 {
218 #if defined(DEBUG_UART)
220 
221 
225 #endif
226 }
227 
228 /* Set up and initialize all required blocks and functions related to the
229  board hardware */
230 void Board_Init(void)
231 {
232  /* Initialize the system core clock variable */
234 
235  /* Sets up DEBUG UART */
236  DEBUGINIT();
237 
238  /* Initialize GPIO */
240 
241  /* Initialize the LEDs */
242  Board_LED_Init();
243 }
244