LPCOpen Platform for LPC18XX/43XX microcontrollers  18XX43XX
LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers
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 
46 /* Port and bit mapping for LEDs on GPIOs */
47 static const uint8_t ledports[] = {4, 7, 7, 7};
48 static const uint8_t ledbits[] = {1, 5, 6, 8};
49 
50 /* TSC2046 control byte definitions */
51 #define TSC2046_CONVERSION_BITS 12
52 #define TSC_START (0x01 << 7)
53 #define TSC_CHANNEL_X (0x05 << 4) /* differential */
54 #define TSC_CHANNEL_Y (0x01 << 4) /* differential */
55 #define TSC_CHANNEL_Z1 (0x03 << 4) /* differential */
56 #define TSC_CHANNEL_Z2 (0x04 << 4) /* differential */
57 #define TSC_8BIT (0x01 << 3)
58 #define TSC_12BIT (0x00 << 3)
59 #define TSC_PD 0x00
60 #define TSC_ADC_ON 0x01
61 #define TSC_REF_ON 0x02
62 #if (TSC2046_CONVERSION_BITS == 12)
63 #define TSC_CONVERSION_MODE TSC_12BIT
64 #else
65 #define TSC_CONVERSION_MODE TSC_8BIT
66 #endif
67 
68 #define TSC_SER_MODE (0x01 << 2) /* Single-Ended Reference Mode */
69 #define TSC_DFR_MODE (0x00 << 2) /* Differential Reference Mode */
70 
71 #define X_MEASURE (TSC_START | TSC_CHANNEL_X | TSC_CONVERSION_MODE | TSC_DFR_MODE | TSC_ADC_ON)
72 #define Y_MEASURE (TSC_START | TSC_CHANNEL_Y | TSC_CONVERSION_MODE | TSC_DFR_MODE | TSC_ADC_ON)
73 #define Z1_MEASURE (TSC_START | TSC_CHANNEL_Z1 | TSC_CONVERSION_MODE | TSC_DFR_MODE | TSC_ADC_ON)
74 #define Z2_MEASURE (TSC_START | TSC_CHANNEL_Z2 | TSC_CONVERSION_MODE | TSC_DFR_MODE | TSC_ADC_ON)
75 #define PWRDOWN (TSC_START | TSC_CHANNEL_Y | TSC_CONVERSION_MODE | TSC_DFR_MODE | TSC_PD)
76 
77 typedef struct {
78  int16_t ad_left; /* left margin */
79  int16_t ad_right; /* right margin */
80  int16_t ad_top; /* top margin */
81  int16_t ad_bottom; /* bottom margin */
82  int16_t lcd_width; /* lcd horizontal size */
83  int16_t lcd_height; /* lcd vertical size */
84  uint8_t swap_xy; /* 1: swap x-y coords */
86 
87 #define LCD_DC_CMD (Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0x07, 8, false))
88 #define LCD_DC_DATA (Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0x07, 8, true))
89 
90 #if (TSC2046_CONVERSION_BITS == 12)
91 #define TSC2046_COORD_MAX (0xFFF)
92 #define TSC2046_DELTA_VARIANCE (0x50)
93 #else
94 #define TSC2046_COORD_MAX (0xFF)
95 #define TSC2046_DELTA_VARIANCE (0x03)
96 #endif
97 #define COORD_GET_NUM (10)
98 
101  3758, 149, 3914, 163, 240, 320, 1
102 };
103 
108  28, /* Horizontal back porch in clocks */
109  10, /* Horizontal front porch in clocks */
110  2, /* HSYNC pulse width in clocks */
111  240, /* Pixels per line */
112  2, /* Vertical back porch in clocks */
113  1, /* Vertical front porch in clocks */
114  2, /* VSYNC pulse width in clocks */
115  320, /* Lines per panel */
116  0, /* Invert output enable, 1 = invert */
117  1, /* Invert panel clock, 1 = invert */
118  1, /* Invert HSYNC, 1 = invert */
119  1, /* Invert VSYNC, 1 = invert */
120  1, /* AC bias frequency in clocks (not used) */
121  6, /* Maximum bits per pixel the display supports */
122  LCD_TFT, /* LCD panel type */
123  LCD_COLOR_FORMAT_BGR, /* BGR or RGB */
124  0 /* Dual panel, 1 = dual panel display */
125 };
126 
127 /*****************************************************************************
128  * Public types/enumerations/variables
129  ****************************************************************************/
130 
131 /* System configuration variables used by chip driver */
132 const uint32_t ExtRateIn = 0;
133 const uint32_t OscRateIn = 12000000;
134 
135 /*****************************************************************************
136  * Private functions
137  ****************************************************************************/
138 
139 /* Very simple (inaccurate) delay function */
140 static void delayMs(uint32_t ms)
141 {
142  uint32_t i;
143  for (i = 0; i < 100 * ms; i++) {}
144 }
145 
146 /* Additional (SPI) pin configuration for LCD interface signals */
147 static void lcdPinConfig(void)
148 {
149  /* PC.11 connected to GPIO = SSEL_MUX_A, PC.12 connected to GPIO = SSEL_MUX_B */
154 
155  /* Configure SSP0 pins */
156  /* PF.0 connected to SCL/SCLK */
158  /* PF.1 connected to nCS */
160  /* PF.2 connected to SO */
162  /* PF.3 connected to nSI */
164 
165  /* DC PIN */
168 }
169 
170 /* Write to a LCD register using SPI */
171 static void writeLCDReg(uint16_t addr, uint16_t data)
172 {
173  uint8_t buf[2];
174 
175  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0x06, 10, true);
176  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0x06, 11, false);
177 
178  LCD_DC_CMD;
179 
180  buf[0] = 0;
181  buf[1] = (addr & 0xff);
182 
184 
185  LCD_DC_DATA;
186  buf[0] = (data >> 8);
187  buf[1] = (data & 0xff);
189 
190  LCD_DC_CMD;
191 
192  buf[0] = (0);
193  buf[1] = (0x22);
195 }
196 
197 /* Initialize SSD1289 LCD Controller */
198 static void initSSD1289(void)
199 {
200  writeLCDReg(0x00, 0x0001);
201  delayMs(15);
202  writeLCDReg(0x03, 0x6E3E); // 0xAEAC
203  writeLCDReg(0x0C, 0x0007);
204  writeLCDReg(0x0D, 0x000E); // 0x000F
205  writeLCDReg(0x0E, 0x2C00); // 0x2900
206  writeLCDReg(0x1E, 0x00AE); // 0x00B3
207  delayMs(15);
208  writeLCDReg(0x07, 0x0021);
209  delayMs(50);
210  writeLCDReg(0x07, 0x0023);
211  delayMs(50);
212  writeLCDReg(0x07, 0x0033);
213  delayMs(50);
214 
215  writeLCDReg(0x01, 0x2B3F);
216  writeLCDReg(0x02, 0x0600);
217  writeLCDReg(0x10, 0x0000);
218  delayMs(15);
219  writeLCDReg(0x11, 0xC5B0); // 0x65b0
220  delayMs(20);
221  writeLCDReg(0x05, 0x0000);
222  writeLCDReg(0x06, 0x0000);
223  writeLCDReg(0x16, 0xEF1C);
224  writeLCDReg(0x17, 0x0003);
225  writeLCDReg(0x07, 0x0233);
226  writeLCDReg(0x0B, 0x5312);
227  writeLCDReg(0x0F, 0x0000);
228  writeLCDReg(0x25, 0xE000);
229  delayMs(20);
230  writeLCDReg(0x41, 0x0000);
231  writeLCDReg(0x42, 0x0000);
232  writeLCDReg(0x48, 0x0000);
233  writeLCDReg(0x49, 0x013F);
234  writeLCDReg(0x44, 0xEF00);
235  writeLCDReg(0x45, 0x0000);
236  writeLCDReg(0x46, 0x013F);
237  writeLCDReg(0x4A, 0x0000);
238  writeLCDReg(0x4B, 0x0000);
239  delayMs(20);
240  writeLCDReg(0x30, 0x0707);
241  writeLCDReg(0x31, 0x0704);
242  writeLCDReg(0x32, 0x0005); // 0x0204
243  writeLCDReg(0x33, 0x0402); // 0x0201
244  writeLCDReg(0x34, 0x0203);
245  writeLCDReg(0x35, 0x0204);
246  writeLCDReg(0x36, 0x0204);
247  writeLCDReg(0x37, 0x0401); // 0x0502
248  writeLCDReg(0x3A, 0x0302);
249  writeLCDReg(0x3B, 0x0500);
250  delayMs(20);
251  writeLCDReg(0x22, 0x0000);
252 }
253 
254 /* Send/Receive data to/from TSC2046. */
255 static void readWriteTSC2046(uint8_t command, uint16_t *data)
256 {
257  uint8_t rx_data[2], tx_data[1] = {0x00};
258 
259  tx_data[0] = command;
260  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 6, 10, false);
261  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 6, 11, true);
262 
263  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 7, 16, false);
264 
267 
268 #if (TSC2046_CONVERSION_BITS == 8)
269  *data = (((rx_data[0] << 8) | (rx_data[1])) >> 7) & 0xFF;
270 #else
271  *data = (((rx_data[0] << 8) | rx_data[1]) >> 3) & 0xFFF;
272 #endif
273  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 7, 16, true);
274 }
275 
276 /* Evaluate the coordinates received from TSC2046. */
277 static Status evalTSC2046Coord(uint8_t command, uint16_t *coord)
278 {
279  uint32_t i;
280  uint16_t Tmp = 0, previousTmp;
281  int16_t diff = 0;
282  *coord = 0;
283  for (i = 0; i < COORD_GET_NUM; i++) {
284  previousTmp = Tmp;
285  readWriteTSC2046(command, &Tmp);
286  if (Tmp > TSC2046_COORD_MAX) {
287  return ERROR;
288  }
289  if (i > 0) {
290  diff = Tmp - previousTmp;
291  }
292  if (diff < 0) {
293  diff = 0 - diff;
294  }
295  if (diff > TSC2046_DELTA_VARIANCE) {
296  return ERROR;
297  }
298  *coord += Tmp;
299  }
300  *coord /= COORD_GET_NUM;
301  return SUCCESS;
302 }
303 
304 /* Convert the coord received from TSC to a value on truly LCD */
305 static int16_t calibrateTSC2046(int16_t Coord, int16_t MinVal, int16_t MaxVal, int16_t TrueSize)
306 {
307  int16_t tmp;
308  int16_t ret;
309  uint8_t convert = 0;
310 
311  /* Swap value? */
312  if (MinVal > MaxVal) {
313  tmp = MaxVal;
314  MaxVal = MinVal;
315  MinVal = tmp;
316  convert = 1;
317  }
318 
319  ret = (Coord - MinVal) * TrueSize / (MaxVal - MinVal);
320  if (convert) {
321  ret = TrueSize - ret;
322  }
323 
324  return ret;
325 }
326 
327 static void delay(uint32_t i) {
328  while (i--) {}
329 }
330 
331 /* Initialize UDA1380 CODEC */
332 static Status Board_Audio_CodecInit(int micIn)
333 {
334  /* Reset UDA1380 on board Hitex A4*/
335  /* PE_9: UDA_RST on Hitex A4 */
339  /* delay 1us */
340  delay(100000);
341  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 7, 9, false);
342  delay(100000);
343 
344  if (!UDA1380_Init(UDA1380_MIC_IN_LR & - (micIn != 0))) {
345  return ERROR;
346  }
347 
348  return SUCCESS;
349 }
350 
351 /*****************************************************************************
352  * Public functions
353  ****************************************************************************/
354 
355 /* Initialize pin muxing for a UART */
357 {
358  if (pUART == LPC_USART0) {
359  Chip_SCU_PinMuxSet(0xF, 10, (SCU_MODE_PULLDOWN | SCU_MODE_FUNC1)); /* PF.10 : UART0_TXD */
360  Chip_SCU_PinMuxSet(0xF, 11, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC1)); /* PF.11 : UART0_RXD */
361  }
362  else if (pUART == LPC_UART1) {
363  Chip_SCU_PinMuxSet(0xC, 13, (SCU_MODE_PULLDOWN | SCU_MODE_FUNC2)); /* PC.13 : UART1_TXD - pin 1 of SV14 */
364  Chip_SCU_PinMuxSet(0xC, 14, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)); /* PC.14 : UART1_RX - pin 2 of SV14 */
365  }
366  else if (pUART == LPC_USART2) {
367  /* P1.15 : UART2_TXD - pin 11 of SV6, P1.16 : UART2_RXD - pin 3 of SV6 */
370  }
371  else if (pUART == LPC_USART3) {
372  /* P9.3 : UART3_TXD - pin 15 of SV6, P9.4 : UART3_RXD - pin 7 of SV3 */
375  }
376 }
377 
378 /* Initialize debug output via UART for board */
380 {
381 #if defined(DEBUG_UART)
383 
385  Chip_UART_SetBaud(DEBUG_UART, 115200);
387 
388  /* Enable UART Transmit */
390 #endif
391 }
392 
393 /* Sends a character on the UART */
394 void Board_UARTPutChar(char ch)
395 {
396 #if defined(DEBUG_UART)
397  /* Wait for space in FIFO */
399  Chip_UART_SendByte(DEBUG_UART, (uint8_t) ch);
400 #endif
401 }
402 
403 /* Gets a character from the UART, returns EOF if no character is ready */
405 {
406 #if defined(DEBUG_UART)
408  return (int) Chip_UART_ReadByte(DEBUG_UART);
409  }
410 #endif
411  return EOF;
412 }
413 
414 /* Outputs a string on the debug UART */
415 void Board_UARTPutSTR(const char *str)
416 {
417 #if defined(DEBUG_UART)
418  while (*str != '\0') {
419  Board_UARTPutChar(*str++);
420  }
421 #endif
422 }
423 
424 /* Initializes board LED(s) */
425 static void Board_LED_Init()
426 {
427  int i;
428 
429  /* Set ports as outputs with initial states off */
430  for (i = 0; i < (sizeof(ledports) / sizeof(ledports[0])); i++) {
433  }
435 }
436 
437 /* Sets the state of a board LED to on or off */
438 void Board_LED_Set(uint8_t LEDNumber, bool On)
439 {
440  /* Must connect JP3 to see LED0 and JP4 to see LED1 */
441  if (LEDNumber == 0) {
442  On = !On;
443  }
444 
445  if (LEDNumber < 4) {
446  Chip_GPIO_SetPinState(LPC_GPIO_PORT, ledports[LEDNumber], ledbits[LEDNumber], !On);
447  }
448 }
449 
450 /* Returns the current state of a board LED */
451 bool Board_LED_Test(uint8_t LEDNumber)
452 {
453  bool On = false;
454 
455  if (LEDNumber < 4) {
456  On = (bool) !Chip_GPIO_GetPinState(LPC_GPIO_PORT, ledports[LEDNumber], ledbits[LEDNumber]);
457 
458  if (LEDNumber == 0) {
459  On = !On;
460  }
461  }
462 
463  return On;
464 }
465 
466 void Board_LED_Toggle(uint8_t LEDNumber)
467 {
468  Board_LED_Set(LEDNumber, !Board_LED_Test(LEDNumber));
469 }
470 
471 /* Initialize button(s) interface on board */
472 void Board_Buttons_Init(void) // FIXME not functional ATM
473 {
476 }
477 
478 /* Returns button(s) state on board */
479 uint32_t Buttons_GetStatus(void)
480 {
481  uint8_t ret = NO_BUTTON_PRESSED;
483  ret |= BUTTONS_BUTTON1;
484  }
485  return ret;
486 }
487 
488 /* Initialize joystick interface on board */
490 {}
491 
492 /* Returns joystick states on board */
493 uint8_t Joystick_GetStatus(void)
494 {
495  return NO_BUTTON_PRESSED;
496 }
497 
498 /* Returns the MAC address assigned to this board */
499 void Board_ENET_GetMacADDR(uint8_t *mcaddr)
500 {
501  const uint8_t boardmac[] = {0x00, 0x60, 0x37, 0x12, 0x34, 0x56};
502 
503  memcpy(mcaddr, boardmac, 6);
504 }
505 
506 /* Set up and initialize all required blocks and functions related to the
507  board hardware */
508 void Board_Init(void)
509 {
510  /* Sets up DEBUG UART */
511  DEBUGINIT();
512 
513  /* Initializes GPIO */
515 
516  /* Setup GPIOs for USB demos */
517 #if 0 /* FIXME: the following call removed on the Hitex board as it interferes with muxed MII state */
518  // Chip_SCU_PinMuxSet(0x9, 5, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2)); // P9_5 USB1_VBUS_EN, USB1 VBus function
519 #endif
520  Chip_SCU_PinMuxSet(0x2, 5, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)); // P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION
521  Chip_SCU_PinMuxSet(0x6, 3, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1)); // P6_3 USB0_PWR_EN, USB0 VBus function
522 
523  /* Initialize LEDs */
524  Board_LED_Init();
525 
526 #if defined(USE_RMII)
528 #else
530 #endif
531 }
532 
533 /* Sets up board specific ADC interface */
534 void Board_ADC_Init(void)
535 {
536  /* Analog function ADC1_2 selected on pin PF_9 */
538 }
539 
540 /* Sets up board specific I2C interface */
542 {
543  if (id == I2C1) {
544  /* Configure pin function for I2C1 on PE.13 (I2C1_SDA) and PE.15 (I2C1_SCL) */
547  }
548  else {
550  }
551 }
552 
553 /* Initialize LCD Interface */
554 void Board_LCD_Init(void)
555 {
556  /* Reset LCD and wait for reset to complete */
558  while (Chip_RGU_InReset(RGU_LCD_RST)) {}
559 
560  lcdPinConfig();
562 }
563 
564 /* Initialize the LCD controller on the external QVGA (320x240) TFT LCD*/
566 {
567  SSP_ConfigFormat ssp_format;
568 
571  Chip_SSP_SetBitRate(LPC_SSP0, 1000000);
572 
573  ssp_format.frameFormat = SSP_FRAMEFORMAT_SPI;
574  ssp_format.bits = SSP_BITS_8;
575  ssp_format.clockMode = SSP_CLOCK_MODE0;
576 
577  Chip_SSP_SetFormat(LPC_SSP0, ssp_format.bits, ssp_format.frameFormat, ssp_format.clockMode);
579 
580  delayMs(200);
581 
582  /* initialize LCD controller */
583  initSSD1289();
584 
587 }
588 
589 /* Initialize TSC2046 touchscreen controller */
591 {
592  uint16_t dummy_data;
593  SSP_ConfigFormat ssp_format;
594 
595  /* Configure SSP0 pins*/
596  lcdPinConfig();
598 
600 
601  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 6, 10, false);
602  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 6, 11, true);
603 
605 
607  Chip_SSP_SetBitRate(LPC_SSP0, 200000);
608 
609  ssp_format.frameFormat = SSP_FRAMEFORMAT_SPI;
610  ssp_format.bits = SSP_BITS_8;
611  ssp_format.clockMode = SSP_CLOCK_MODE3;
612 
613  Chip_SSP_SetFormat(LPC_SSP0, ssp_format.bits, ssp_format.frameFormat, ssp_format.clockMode);
615 
616  /* Enable Touch Screen Controller */
617  readWriteTSC2046(PWRDOWN, &dummy_data);
618 }
619 
620 /* Get Touch coordinates */
621 bool Board_GetTouchPos(int16_t *pX, int16_t *pY)
622 {
623  uint16_t tmp;
624  uint16_t x, y, z1, z2, z = 0;
625  Status Sts = SUCCESS;
626 
631 
632  if (z1 != 0) {
633  z = x * ((z2 / z1) - 1);
634  }
635  if ((z <= 0) || (z > 35000)) {
636  return false;
637  }
638  /* Get X-Coordinate */
639  Sts = evalTSC2046Coord(X_MEASURE, &x);
640 
641  if (Sts == ERROR) {
642  return false;
643  }
644  /* Get Y-Coordinate */
645  Sts = evalTSC2046Coord(Y_MEASURE, &y);
646  if (Sts == ERROR) {
647  return false;
648  }
649  /* Get Z1-Value */
650  Sts = evalTSC2046Coord(Z1_MEASURE, &z1);
651  if (Sts == ERROR) {
652  return false;
653  }
654  /* Get Z2-Value */
655  Sts = evalTSC2046Coord(Z2_MEASURE, &z2);
656  if (Sts == ERROR) {
657  return false;
658  }
659 
660  z = x * ((z2 / z1) - 1);
661  if ((z <= 0) || (z > 35000)) {
662  return false;
663  }
664  else {
665  /* Swap, adjust to truly size of LCD */
666  if (TSC_Config.swap_xy) {
667  *pY = calibrateTSC2046(x, TSC_Config.ad_top, TSC_Config.ad_bottom, TSC_Config.lcd_height);
668  *pX = calibrateTSC2046(y, TSC_Config.ad_left, TSC_Config.ad_right, TSC_Config.lcd_width);
669  }
670  else {
671  *pX = calibrateTSC2046(x, TSC_Config.ad_top, TSC_Config.ad_bottom, TSC_Config.lcd_width);
672  *pY = calibrateTSC2046(y, TSC_Config.ad_left, TSC_Config.ad_right, TSC_Config.lcd_height);
673  }
674  }
675  readWriteTSC2046(PWRDOWN, &tmp);
676 
677  return true;
678 }
679 
680 /* Turn on Board LCD Backlight */
681 void Board_SetLCDBacklight(uint8_t Intensity)
682 {
683  bool OnOff = (bool) (Intensity != 0);
684 
685  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 3, 8, OnOff);
686 }
687 
688 /* Initialize pin muxing for SDMMC interface */
690 {
691  Chip_SCU_PinMuxSet(0xc, 9, (SCU_MODE_INACT | SCU_MODE_FUNC7)); /* Pc.9 SDIO power */
692  Chip_SCU_PinMuxSet(0xc, 2, (SCU_MODE_INACT | SCU_MODE_FUNC7)); /* Pc.2 SDIO LED */
693  Chip_SCU_PinMuxSet(0xf, 10, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC6)); /* Pf.10 SDIO WP */
694  Chip_SCU_PinMuxSet(0xc, 8, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC7)); /* Pc.8 SDIO CD */
695  Chip_SCU_PinMuxSet(0xc, 6, (SCU_PINIO_FAST | SCU_MODE_FUNC7)); /* Pc.6 SDIO D2 */
696  Chip_SCU_PinMuxSet(0xc, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC7)); /* Pc.5 SDIO D1 */
697  Chip_SCU_PinMuxSet(0xc, 4, (SCU_PINIO_FAST | SCU_MODE_FUNC7)); /* Pc.4 SDIO D0 */
698  Chip_SCU_PinMuxSet(0xc, 0, (SCU_MODE_INACT | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC7)); /* Pc.0 SDIO clock */
699  Chip_SCU_PinMuxSet(0xc, 10, (SCU_PINIO_FAST | SCU_MODE_FUNC7)); /* Pc.10 SDIO command */
700  Chip_SCU_PinMuxSet(0xc, 7, (SCU_PINIO_FAST | SCU_MODE_FUNC7)); /* Pc.7 SDIO D3 */
701 }
702 
703 /* Initialize pin muxing for SSP interface */
705 {
706  if (pSSP == LPC_SSP0) {
707  /* Set up clock and muxing for SSP0 interface */
708  // #if !defined(HITEX_LCD_TERM)
709  /* PC.11 connected to GPIO = SSEL_MUX_A, PC.12 connected to GPIO = SSEL_MUX_B */
714  // #endif
715  /* PF.0 connected to SCL/SCLK SCU_MODE_FUNC2=SSP0 SCK0 */
717  /* PF.1 connected to nCS SCU_MODE_FUNC2=SSP0 SSEL0 */
719  /* PF.2 connected to SO SCU_MODE_FUNC2=SSP0 MISO0 */
721  /* PF.3 connected to nSI SCU_MODE_FUNC2=SSP0 MOSI0 */
723  }
724  else if (pSSP == LPC_SSP1) {
725  /* Set up clock and muxing for SSP1 interface */
726  /* P1.19 connected to SCL/SCLK SCU_MODE_FUNC1=SSP1 SCK1 */
728  /* P1.20 connected to nCS SCU_MODE_FUNC1=SSP1 SSEL1 */
730  /* P0.0 connected to SO SCU_MODE_FUNC1=SSP1 MISO1 */
732  /* P0.1 connected to nSI SCU_MODE_FUNC2=SSP1 MOSI1 */
734  }
735 }
736 
737 /* Initialize I2S interface for the board and UDA1380 */
738 void Board_Audio_Init(LPC_I2S_T *pI2S, int micIn)
739 {
740  I2S_AUDIO_FORMAT_T I2S_Config;
741 
742  I2S_Config.SampleRate = 48000;
743  I2S_Config.ChannelNumber = 2; // 1 is mono, 2 is stereo
744  I2S_Config.WordWidth = 16; // 8, 16 or 32 bits
745  Chip_I2S_Init(pI2S);
746  Chip_I2S_TxConfig(pI2S, &I2S_Config);
747 
748  /* Init UDA1380 CODEC */
749  while (Board_Audio_CodecInit(micIn) != SUCCESS) {}
750 
751 }
752 
753 /* Initialize DAC interface for the board */
755 {
757 }
758