LPCOpen Platform for LPC18XX/43XX microcontrollers
18XX43XX
LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers
Main Page
Modules
Data Structures
Files
File List
Globals
software
lpc_core
lpc_board
boards_43xx
nxp_lpclink2_4370
board.c
Go to the documentation of this file.
1
/*
2
* @brief Hitex EVA 1850/4350 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 other sources files specific to this board */
36
#include "
retarget.h
"
37
42
/*****************************************************************************
43
* Private types/enumerations/variables
44
****************************************************************************/
45
#define LED0_PORT 0
46
#define LED0_PIN 8
47
48
/*****************************************************************************
49
* Public types/enumerations/variables
50
****************************************************************************/
51
52
/* System configuration variables used by chip driver */
53
const
uint32_t
ExtRateIn
= 0;
54
const
uint32_t
OscRateIn
= 12000000;
55
56
/*****************************************************************************
57
* Private functions
58
****************************************************************************/
59
60
/*****************************************************************************
61
* Public functions
62
****************************************************************************/
63
64
/* Initialize pin muxing for a UART */
65
void
Board_UART_Init
(
LPC_USART_T
*pUART)
66
{
67
if
(pUART ==
LPC_USART0
) {
68
}
69
else
if
(pUART ==
LPC_UART1
) {
70
}
71
else
if
(pUART ==
LPC_USART2
) {
72
/* P2.10 : UART2_TXD J3 -> Pin 8, P2.11 : UART2_RXD -> J3 Pin-7*/
73
Chip_SCU_PinMuxSet
(0x2, 10, (
SCU_MODE_PULLDOWN
|
SCU_MODE_FUNC2
));
74
Chip_SCU_PinMuxSet
(0x2, 11, (
SCU_MODE_INACT
|
SCU_MODE_INBUFF_EN
|
SCU_MODE_ZIF_DIS
|
SCU_MODE_FUNC2
));
75
}
76
else
if
(pUART ==
LPC_USART3
) {
77
}
78
}
79
80
/* Initialize debug output via UART for board */
81
void
Board_Debug_Init
(
void
)
82
{
83
#if defined(DEBUG_UART)
84
Board_UART_Init
(
DEBUG_UART
);
85
86
Chip_UART_Init
(
DEBUG_UART
);
87
Chip_UART_SetBaud
(
DEBUG_UART
, 115200);
88
Chip_UART_ConfigData
(
DEBUG_UART
,
UART_LCR_WLEN8
|
UART_LCR_SBS_1BIT
|
UART_LCR_PARITY_DIS
);
89
90
/* Enable UART Transmit */
91
Chip_UART_TXEnable
(
DEBUG_UART
);
92
#endif
93
}
94
95
/* Sends a character on the UART */
96
void
Board_UARTPutChar
(
char
ch)
97
{
98
#if defined(DEBUG_UART)
99
/* Wait for space in FIFO */
100
while
((
Chip_UART_ReadLineStatus
(
DEBUG_UART
) &
UART_LSR_THRE
) == 0) {}
101
Chip_UART_SendByte
(
DEBUG_UART
, (uint8_t) ch);
102
#endif
103
}
104
105
/* Gets a character from the UART, returns EOF if no character is ready */
106
int
Board_UARTGetChar
(
void
)
107
{
108
#if defined(DEBUG_UART)
109
if
(
Chip_UART_ReadLineStatus
(
DEBUG_UART
) &
UART_LSR_RDR
) {
110
return
(
int
)
Chip_UART_ReadByte
(
DEBUG_UART
);
111
}
112
#endif
113
return
EOF;
114
}
115
116
/* Outputs a string on the debug UART */
117
void
Board_UARTPutSTR
(
const
char
*str)
118
{
119
#if defined(DEBUG_UART)
120
while
(*str !=
'\0'
) {
121
Board_UARTPutChar
(*str++);
122
}
123
#endif
124
}
125
126
/* Initializes board LED(s) */
127
static
void
Board_LED_Init
()
128
{
129
/* Set ports as outputs with initial states off */
130
Chip_GPIO_SetPinDIROutput
(
LPC_GPIO_PORT
,
LED0_PORT
,
LED0_PIN
);
131
Chip_GPIO_SetPinState
(
LPC_GPIO_PORT
,
LED0_PORT
,
LED0_PIN
,
false
);
132
}
133
134
/* Sets the state of a board LED to on or off */
135
void
Board_LED_Set
(uint8_t LEDNumber,
bool
On)
136
{
137
/* Must connect JP3 to see LED0 and JP4 to see LED1 */
138
if
(LEDNumber == 0) {
139
Chip_GPIO_SetPinState
(
LPC_GPIO_PORT
,
LED0_PORT
,
LED0_PIN
, On);
140
}
141
}
142
143
/* Returns the current state of a board LED */
144
bool
Board_LED_Test
(uint8_t LEDNumber)
145
{
146
bool
On =
false
;
147
148
if
(LEDNumber == 0)
149
On = (bool)
Chip_GPIO_GetPinState
(
LPC_GPIO_PORT
,
LED0_PORT
,
LED0_PIN
);
150
151
return
On;
152
}
153
154
void
Board_LED_Toggle
(uint8_t LEDNumber)
155
{
156
Board_LED_Set
(LEDNumber, !
Board_LED_Test
(LEDNumber));
157
}
158
159
160
/* Set up and initialize all required blocks and functions related to the
161
board hardware */
162
void
Board_Init
(
void
)
163
{
164
/* Sets up DEBUG UART */
165
DEBUGINIT
();
166
167
/* Initializes GPIO */
168
Chip_GPIO_Init
(
LPC_GPIO_PORT
);
169
170
/* Initialize LEDs */
171
Board_LED_Init
();
172
}
173
174
/* Sets up board specific ADC interface */
175
void
Board_ADC_Init
(
void
)
176
{
177
/* Analog function ADC1_2 selected on pin PF_9 */
178
Chip_SCU_ADC_Channel_Config
(1, 2);
179
}
180
181
/* Sets up board specific I2C interface */
182
void
Board_I2C_Init
(
I2C_ID_T
id
)
183
{
184
if
(
id
==
I2C1
) {
185
/* Configure pin function for I2C1 on PE.13 (I2C1_SDA) and PE.15 (I2C1_SCL) */
186
Chip_SCU_PinMuxSet
(0xE, 13, (
SCU_MODE_ZIF_DIS
|
SCU_MODE_INBUFF_EN
|
SCU_MODE_FUNC2
));
187
Chip_SCU_PinMuxSet
(0xE, 15, (
SCU_MODE_ZIF_DIS
|
SCU_MODE_INBUFF_EN
|
SCU_MODE_FUNC2
));
188
}
189
else
{
190
Chip_SCU_I2C0PinConfig
(
I2C0_STANDARD_FAST_MODE
);
191
}
192
}
193
194
/* Initialize pin muxing for SSP interface */
195
void
Board_SSP_Init
(
LPC_SSP_T
*pSSP)
196
{
197
if
(pSSP ==
LPC_SSP0
) {
198
/* Not available on the board */
199
while
(1) {}
200
}
201
else
if
(pSSP ==
LPC_SSP1
) {
202
/* Set up clock and muxing for SSP1 interface */
203
/* SSEL: P1.20: J3 PIN-6 [Serial Expansion Interface] */
204
Chip_SCU_PinMuxSet
(0x1, 20, (
SCU_PINIO_FAST
|
SCU_MODE_FUNC1
));
205
/* MISO: P1.3: J3 PIN-5 [Serial Expansion Interface] */
206
Chip_SCU_PinMuxSet
(0x1, 3, (
SCU_MODE_INACT
|
SCU_MODE_INBUFF_EN
|
SCU_MODE_ZIF_DIS
|
SCU_MODE_FUNC5
));
207
/* MOSI: P1.4: J3 PIN-4 [Serial Expansion Interface] */
208
Chip_SCU_PinMuxSet
(0x1, 4, (
SCU_MODE_INACT
|
SCU_MODE_INBUFF_EN
|
SCU_MODE_ZIF_DIS
|
SCU_MODE_FUNC5
));
209
/* SCLK: PF.4: J3 PIN-3 [Serial Expansion Interface] */
210
Chip_SCU_PinMuxSet
(0xF, 4, (
SCU_PINIO_FAST
|
SCU_MODE_FUNC0
));
211
}
212
}
213
214
/* Initialize DAC interface for the board */
215
void
Board_DAC_Init
(
LPC_DAC_T
*pDAC)
216
{
217
Chip_SCU_DAC_Analog_Config
();
218
}
219
220
void
Board_Buttons_Init
(
void
)
// FIXME not functional ATM
221
{
222
}
223
224
uint32_t
Buttons_GetStatus
(
void
)
225
{
226
uint8_t ret =
NO_BUTTON_PRESSED
;
227
return
ret;
228
}
229
230
/* Initialize joystick interface on board */
231
void
Board_Joystick_Init
(
void
)
232
{}
233
234
/* Returns joystick states on board */
235
uint8_t
Joystick_GetStatus
(
void
)
236
{
237
return
NO_BUTTON_PRESSED
;
238
}
239
Generated on Fri Feb 20 2015 21:29:41 for LPCOpen Platform for LPC18XX/43XX microcontrollers by
1.8.3.1