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 Keil MCB 1857/4357 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 "retarget.h"
36 
41 /*****************************************************************************
42  * Private types/enumerations/variables
43  ****************************************************************************/
44 /* Port and bit mapping for LEDs on GPIOs */
45 static const uint8_t ledports[] = {6, 6, 6, 6, 6, 4, 4, 4};
46 static const uint8_t ledbits[] = {24, 25, 26, 27, 28, 12, 13, 14};
47 
49 #define LCD_CS(x) ((x) ? (Chip_GPIO_SetPinState(LPC_GPIO_PORT, 7, 16, true)) : (Chip_GPIO_SetPinState(LPC_GPIO_PORT, \
50  7, 16, false)))
51 
53 uint32_t g_isPenDn;
54 uint32_t g_isNewPenDn;
55 const int32_t ad_left = 3813;
56 const int32_t ad_top = 3805;// 237;
57 const int32_t ad_right = 360;
58 const int32_t ad_bottom = 237; // 3805;
59 
61  8,
62  4,
63  4,
64  240,
65  4,
66  3,
67  4,
68  320,
69  0,
70  1,
71  1,
72  1,
73  1,
74  6,
75  LCD_TFT,
77  0
78 };
79 
80 /*****************************************************************************
81  * Public types/enumerations/variables
82  ****************************************************************************/
83 
84 /* System configuration variables used by chip driver */
85 const uint32_t ExtRateIn = 0;
86 const uint32_t OscRateIn = 12000000;
87 
88 /*****************************************************************************
89  * Private functions
90  ****************************************************************************/
91 
92 /* Very simple (inaccurate) delay function */
93 static void delay(uint32_t i) {
94  while (i--) {}
95 }
96 
97 /* Initializes default settings for UDA1380 */
98 static Status Board_Audio_CodecInit(int micIn)
99 {
100  /* Reset UDA1380 on board Keil */
104  /* delay 1us */
105  delay(100000);
106  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 4, 0, false);
107  delay(100000);
108 
109  if (!UDA1380_Init(UDA1380_MIC_IN_LR & - (micIn != 0))) {
110  return ERROR;
111  }
112 
113  return SUCCESS;
114 }
115 
117 /* Write to LCD controller, with A0 = 0 */
118 static void writeLCD00_16(uint16_t c) {
119 
120  uint8_t buf[1];
121  LCD_CS(0);
122  buf[0] = 0x70;
123  Chip_SSP_WriteFrames_Blocking(SSP_ID, buf, 1); // Start + WR Register
124  buf[0] = (uint8_t) (c);
126  LCD_CS(1);
127 }
128 
129 /* Write to LCD controller, with A0 = 1 */
130 static void writeLCD01_16(uint16_t c) {
131 
132  uint8_t buf[1];
133  LCD_CS(0);
134  buf[0] = 0x72;
135  Chip_SSP_WriteFrames_Blocking(SSP_ID, buf, 1); /* Start + WR Data */
136  buf[0] = (uint8_t) (c >> 8);
138  buf[0] = (uint8_t) (c);
140  LCD_CS(1);
141 }
142 
143 /* Write to LCD controller's register */
144 static void writeLCDReg(uint16_t reg, uint16_t dat) {
145  writeLCD00_16(reg);
146  writeLCD01_16(dat);
147 }
148 
149 /* Pin configuration to communicate with LCD Controller */
150 static void pinConfig(void)
151 {
152  /* (DC) */
154 }
155 
156 /* Writes a value to the STMPE811 register */
157 static uint32_t writeTSCReg(uint8_t regAddr, uint8_t value)
158 {
159  uint8_t val[2];
160  val[0] = regAddr;
161  val[1] = value;
162  return Chip_I2C_MasterSend(TSC_I2C_BUS, TSC_I2C_ADDR, val, sizeof(val));
163 }
164 
165 /* Reads a value to the STMPE811 register */
166 static uint32_t readTSCReg(uint8_t regAddr, uint8_t *value)
167 {
168  return Chip_I2C_MasterCmdRead(TSC_I2C_BUS, TSC_I2C_ADDR, regAddr, value, 1);
169 }
170 
171 /* Check if touch is detected or not */
172 static bool detectTSCTouch(void)
173 {
174  uint8_t CtrRegVal = 0;
175 
176  if (readTSCReg(TSC_CTRL, &CtrRegVal) == 1) {
177  if (CtrRegVal & (1 << 7)) {
178  return true;
179  }
180  }
181  return false;
182 }
183 
184 /* Get the touch coordinates from STMPE811 registers */
185 static Status getTSCCoord(int16_t *x, int16_t *y)
186 {
187  uint8_t fifo_size, tscData[4], i;
188 
189  /* Read all samples except the last one */
190  readTSCReg(FIFO_SIZE, &fifo_size);
191  for (i = 0; i < fifo_size; ++i) {
192  if (Chip_I2C_MasterCmdRead(TSC_I2C_BUS, TSC_I2C_ADDR, DATA_XYZ, tscData, 4) == 0) {
193  return ERROR;
194  }
195  }
196 
197  /* Retrieve last taken sample */
199  *x = (tscData[0] << 4) | ((tscData[1] & 0xF0) >> 4);
200  *y = ((tscData[1] & 0x0F) << 8) | tscData[2];
201 
202  /* Clear interrupt flags */
203  writeTSCReg(INT_STA, 0x1F);
204 
205  return SUCCESS;
206 }
207 
208 /*****************************************************************************
209  * Public functions
210  ****************************************************************************/
211 
212 /* Initialize UART pins */
214 {
215  if (pUART == LPC_USART0) {
216  Chip_SCU_PinMuxSet(0x2, 0, (SCU_MODE_PULLDOWN | SCU_MODE_FUNC1)); /* P2.0 : UART0_TXD */
218  }
219  else if (pUART == LPC_USART3) {
220  Chip_SCU_PinMuxSet(0x2, 3, (SCU_MODE_PULLDOWN | SCU_MODE_FUNC2)); /* P2.3 : UART3_TXD */
222  }
223 }
224 
225 /* Initialize debug output via UART for board */
227 {
228 #if defined(DEBUG_UART)
230 
232  Chip_UART_SetBaud(DEBUG_UART, 115200);
234 
235  /* Enable UART Transmit */
237 #endif
238 }
239 
240 /* Sends a character on the UART */
241 void Board_UARTPutChar(char ch)
242 {
243 #if defined(DEBUG_UART)
244  /* Wait for space in FIFO */
246  Chip_UART_SendByte(DEBUG_UART, (uint8_t) ch);
247 #endif
248 }
249 
250 /* Gets a character from the UART, returns EOF if no character is ready */
252 {
253 #if defined(DEBUG_UART)
255  return (int) Chip_UART_ReadByte(DEBUG_UART);
256  }
257 #endif
258  return EOF;
259 }
260 
261 /* Outputs a string on the debug UART */
262 void Board_UARTPutSTR(const char *str)
263 {
264 #if defined(DEBUG_UART)
265  while (*str != '\0') {
266  Board_UARTPutChar(*str++);
267  }
268 #endif
269 }
270 
271 /* Initializes board LED(s) */
272 static void Board_LED_Init()
273 {
274  int i;
275 
276  /* Must make sure J21 is installed to enabled LEDs */
277  /* PD.10 : LED 0 (leftmost) */
278  /* PD.11 : LED 1 */
279  /* PD.12 : LED 2 */
280  /* PD.13 : LED 3 */
281  /* PD.14 : LED 4 */
282  /* P9.0 : LED 5 */
283  /* P9.1 : LED 6 */
284  /* P9.2 : LED 7 (rightmost) */
285  for (i = 0; i < (sizeof(ledports) / sizeof(ledports[0])); i++) {
287  }
288 }
289 
290 /* Sets the state of a board LED to on or off */
291 void Board_LED_Set(uint8_t LEDNumber, bool On)
292 {
293  if (LEDNumber <= 7) {
294  Chip_GPIO_SetPinState(LPC_GPIO_PORT, ledports[LEDNumber], ledbits[LEDNumber], On);
295  }
296 }
297 
298 /* Returns the current state of a board LED */
299 bool Board_LED_Test(uint8_t LEDNumber)
300 {
301  if (LEDNumber <= 7) {
302  return (bool) Chip_GPIO_GetPinState(LPC_GPIO_PORT, ledports[LEDNumber], ledbits[LEDNumber]);
303  }
304  return false;
305 }
306 
307 void Board_LED_Toggle(uint8_t LEDNumber)
308 {
309  Board_LED_Set(LEDNumber, !Board_LED_Test(LEDNumber));
310 }
311 
312 /* Returns the MAC address assigned to this board */
313 void Board_ENET_GetMacADDR(uint8_t *mcaddr)
314 {
315  const uint8_t boardmac[] = {0x00, 0x60, 0x37, 0x12, 0x34, 0x56};
316 
317  memcpy(mcaddr, boardmac, 6);
318 }
319 
320 /* Set up and initialize all required blocks and functions related to the
321  board hardware */
322 void Board_Init(void)
323 {
324  /* Sets up DEBUG UART */
325  DEBUGINIT();
326 
327  /* Initializes GPIO */
329 
330  /* Setup GPIOs for USB demos */
331  Chip_SCU_PinMuxSet(0x9, 5, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2)); /* P9_5 USB1_VBUS_EN, USB1 VBus function */
332  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 */
333  Chip_SCU_PinMuxSet(0x6, 3, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1)); /* P6_3 USB0_PWR_EN, USB0 VBus function */
334 
335  /* Initialize LEDs */
336  Board_LED_Init();
337 #if defined(USE_RMII)
339 #else
341 #endif
342 }
343 
344 /* Sets up board specific ADC interface */
345 void Board_ADC_Init(void)
346 {}
347 
348 /* Sets up board specific I2C interface */
350 {
351  if (id == I2C1) {
352  /* Configure pin function for I2C1 on PE.13 (I2C1_SDA) and PE.15 (I2C1_SCL) */
355  }
356  else {
358  }
359 }
360 
361 /* Sets up board specific I2S interface and UDA1380 */
362 void Board_Audio_Init(LPC_I2S_T *pI2S, int micIn)
363 {
364  I2S_AUDIO_FORMAT_T I2S_Config;
365 
366  I2S_Config.SampleRate = 48000;
367  I2S_Config.ChannelNumber = 2; /* 1 is mono, 2 is stereo */
368  I2S_Config.WordWidth = 16; /* 8, 16 or 32 bits */
370  Chip_I2S_TxConfig(LPC_I2S0, &I2S_Config);
371 
372  /* Init UDA1380 CODEC */
373  while (Board_Audio_CodecInit(micIn) != SUCCESS) {}
374 }
375 
376 /* Initialize the LCD interface */
377 void Board_LCD_Init(void)
378 {
379  /* Reset LCD and wait for reset to complete */
381  while (Chip_RGU_InReset(RGU_LCD_RST)) {}
382 
383  /* Set backlight GPIO as an output */
385 
387 }
388 
389 /* Initialize the LCD controller on the external QVGA (320x240) TFT LCD*/
391 {
392  delay(5);
393 
394  pinConfig();
395  /* TBD Externally */
397  // NVIC_EnableIRQ(SSP_ID);
398  Chip_SSP_SetMaster(SSP_ID, true);
399  Chip_SSP_SetBitRate(SSP_ID, 1000000);
400 
401  /* LCD with HX8347-D LCD Controller */
403 
405 
406  delay(200);
407 
408  /* Driving ability settings ------------------------------------------------*/
409  writeLCDReg(0xEA, 0x00); /* Power control internal used (1) */
410  writeLCDReg(0xEB, 0x20); /* Power control internal used (2) */
411  writeLCDReg(0xEC, 0x0C); /* Source control internal used (1) */
412  writeLCDReg(0xED, 0xC7); /* Source control internal used (2) */
413  writeLCDReg(0xE8, 0x38); /* Source output period Normal mode */
414  writeLCDReg(0xE9, 0x10); /* Source output period Idle mode */
415  writeLCDReg(0xF1, 0x01); /* RGB 18-bit interface ;0x0110 */
416  writeLCDReg(0xF2, 0x10);
417 
418  /* Adjust the Gamma Curve --------------------------------------------------*/
419  writeLCDReg(0x40, 0x01);
420  writeLCDReg(0x41, 0x00);
421  writeLCDReg(0x42, 0x00);
422  writeLCDReg(0x43, 0x10);
423  writeLCDReg(0x44, 0x0E);
424  writeLCDReg(0x45, 0x24);
425  writeLCDReg(0x46, 0x04);
426  writeLCDReg(0x47, 0x50);
427  writeLCDReg(0x48, 0x02);
428  writeLCDReg(0x49, 0x13);
429  writeLCDReg(0x4A, 0x19);
430  writeLCDReg(0x4B, 0x19);
431  writeLCDReg(0x4C, 0x16);
432 
433  writeLCDReg(0x50, 0x1B);
434  writeLCDReg(0x51, 0x31);
435  writeLCDReg(0x52, 0x2F);
436  writeLCDReg(0x53, 0x3F);
437  writeLCDReg(0x54, 0x3F);
438  writeLCDReg(0x55, 0x3E);
439  writeLCDReg(0x56, 0x2F);
440  writeLCDReg(0x57, 0x7B);
441  writeLCDReg(0x58, 0x09);
442  writeLCDReg(0x59, 0x06);
443  writeLCDReg(0x5A, 0x06);
444  writeLCDReg(0x5B, 0x0C);
445  writeLCDReg(0x5C, 0x1D);
446  writeLCDReg(0x5D, 0xCC);
447 
448  /* Power voltage setting ---------------------------------------------------*/
449  writeLCDReg(0x1B, 0x1B);
450  writeLCDReg(0x1A, 0x01);
451  writeLCDReg(0x24, 0x2F);
452  writeLCDReg(0x25, 0x57);
453  writeLCDReg(0x23, 0x88);
454 
455  /* Power on setting --------------------------------------------------------*/
456  writeLCDReg(0x18, 0x36); /* Internal oscillator frequency adj */
457  writeLCDReg(0x19, 0x01); /* Enable internal oscillator */
458  writeLCDReg(0x01, 0x00); /* Normal mode, no scrool */
459  writeLCDReg(0x1F, 0x88); /* Power control 6 - DDVDH Off */
460  delay(20);
461  writeLCDReg(0x1F, 0x82); /* Power control 6 - Step-up: 3 x VCI */
462  delay(5);
463  writeLCDReg(0x1F, 0x92); /* Power control 6 - Step-up: On */
464  delay(5);
465  writeLCDReg(0x1F, 0xD2); /* Power control 6 - VCOML active */
466  delay(5);
467 
468  /* Color selection ---------------------------------------------------------*/
469  writeLCDReg(0x17, 0x55); /* RGB, System interface: 16 Bit/Pixel*/
470  writeLCDReg(0x00, 0x00); /* Scrolling off, no standby */
471 
472  /* Interface config --------------------------------------------------------*/
473  writeLCDReg(0x2F, 0x11); /* LCD Drive: 1-line inversion */
474  writeLCDReg(0x31, 0x02); /* Value for SPI: 0x00, RBG: 0x02 */
475  writeLCDReg(0x32, 0x00); /* DPL=0, HSPL=0, VSPL=0, EPL=0 */
476 
477  /* Display on setting ------------------------------------------------------*/
478  writeLCDReg(0x28, 0x38); /* PT(0,0) active, VGL/VGL */
479  delay(20);
480  writeLCDReg(0x28, 0x3C); /* Display active, VGL/VGL */
481 
482  writeLCDReg(0x16, 0x00); /* Mem Access Control (MX/Y/V/L,BGR) */
483 
484  /* Display scrolling settings ----------------------------------------------*/
485  writeLCDReg(0x0E, 0x00); /* TFA MSB */
486  writeLCDReg(0x0F, 0x00); /* TFA LSB */
487  writeLCDReg(0x10, 320 >> 8); /* VSA MSB */
488  writeLCDReg(0x11, 320 & 0xFF); /* VSA LSB */
489  writeLCDReg(0x12, 0x00); /* BFA MSB */
490  writeLCDReg(0x13, 0x00); /* BFA LSB */
491 
492 }
493 
494 /* Initializes the STMPE811 touch screen controller */
496 {
497  volatile int32_t i;
499 
500  /* Initialize Pin mux and other board related I2C stuff */
502 
503  /* Init I2C */
507 
508  /* Reset Touch-screen controller */
509  writeTSCReg(SYS_CTRL1, 0x02);
510 
511  for (i = 0; i < 200000; i++) {}
512 
513  /* Enable TSC and ADC */
514  writeTSCReg(SYS_CTRL2, 0x0C);
515  /* Enable Touch detect, FIFO */
516  writeTSCReg(INT_EN, 0x07);
517  /* Set sample time , 12-bit mode */
518  writeTSCReg(ADC_CTRL1, 0x69);
519 
520  for (i = 0; i < 40000; i++) {}
521 
522  /* ADC frequency 3.25 MHz */
523  writeTSCReg(ADC_CTRL2, 0x01);
524  /* Tracking index: 8, operation mode : XY only */
525  writeTSCReg(TSC_CTRL, 0x22);
526  /* Detect delay 10us Settle time 500us*/
527  writeTSCReg(TSC_CFG, 0xC2);
528  /* Threshold for FIFO */
529  writeTSCReg(FIFO_TH, 0x01);
530  /* FIFO reset */
531  writeTSCReg(FIFO_STA, 0x01);
532  /* FIFO not reset */
533  writeTSCReg(FIFO_STA, 0x00);
534  /* Drive 50 mA typical */
535  writeTSCReg(TSC_I_DRIVE, 0x01);
536  /* Pins are used for touchscreen */
538  /* Enable TSC */
539  writeTSCReg(TSC_CTRL, 0x01);
540  /* Clear interrupt status */
541  writeTSCReg(INT_STA, 0xFF);
542  /* Restore I2C to its default mode */
544 }
545 
546 /* Poll for Touch position */
547 bool Board_GetTouchPos(int16_t *pX, int16_t *pY)
548 {
549  bool res;
551 
552  /* It is very unlikely that this will loop more than once */
554  res = Board_I2C_GetTouchPos(pX, pY);
555  /* It is very unlikely that this will loop more than once */
557  return res;
558 }
559 
560 /* Get touch screen position */
561 bool Board_I2C_GetTouchPos(int16_t *pX, int16_t *pY)
562 {
563  int16_t x, y, rng;
564  if (detectTSCTouch()) {
565  getTSCCoord(&x, &y);
566  g_isPenDn = 1;
567  g_isNewPenDn = 1;
568 
569  /* calibrate X */
570  rng = ad_right - ad_left;
571  if (rng < 0) {
572  rng = -rng;
573  }
574  x -= (ad_right < ad_left) ? ad_right : ad_left;
575  *pX = (x * C_GLCD_H_SIZE) / rng;
576  if (ad_left > ad_right) {
577  *pX = C_GLCD_H_SIZE - *pX;
578  }
579 
580  /* calibrate Y */
581  rng = ad_bottom - ad_top;
582  if (rng < 0) {
583  rng = -rng;
584  }
585  y -= (ad_bottom < ad_top) ? ad_bottom : ad_top;
586  *pY = (y * C_GLCD_V_SIZE) / rng;
587  if (ad_top > ad_bottom) {
588  *pY = C_GLCD_V_SIZE - *pY;
589  }
590  }
591  else {
592  g_isPenDn = 0;
593  }
594 
595  if (g_isNewPenDn) {
596  g_isNewPenDn = 0;
597  if (*pX < 0) {
598  *pX = -*pX;
599  }
600  if (*pY < 0) {
601  *pY = -*pY;
602  }
603  return true;
604  }
605  return false;
606 }
607 
608 /* Turn on LCD backlight */
609 void Board_SetLCDBacklight(uint8_t Intensity)
610 {
611  bool OnOff = (bool) (Intensity != 0);
612 
613  Chip_GPIO_SetPinState(LPC_GPIO_PORT, 3, 8, OnOff);
614 }
615 
616 /* Initializes SDMMC interface */
618 {
619  Chip_SCU_PinMuxSet(0xC, 4, (SCU_PINIO_FAST | SCU_MODE_FUNC7)); /* PC.4 connected to SDIO_D0 */
620  Chip_SCU_PinMuxSet(0xC, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC7)); /* PC.5 connected to SDIO_D1 */
621  Chip_SCU_PinMuxSet(0xC, 6, (SCU_PINIO_FAST | SCU_MODE_FUNC7)); /* PC.6 connected to SDIO_D2 */
622  Chip_SCU_PinMuxSet(0xC, 7, (SCU_PINIO_FAST | SCU_MODE_FUNC7)); /* PC.7 connected to SDIO_D3 */
623 
624  Chip_SCU_PinMuxSet(0xC, 8, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC7)); /* PC.4 connected to SDIO_CD */
625  Chip_SCU_PinMuxSet(0xC, 10, (SCU_PINIO_FAST | SCU_MODE_FUNC7)); /* PC.10 connected to SDIO_CMD */
626  Chip_SCU_PinMuxSet(0xC, 0, (SCU_MODE_INACT | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC7));/* PC.0 connected to SDIO_CLK */
627 }
628 
629 /* Initializes SSP interface */
631 {
632  if (pSSP == LPC_SSP0) {
633  /* Set up clock and power for SSP0 module */
634  /* Configure SSP0 pins*/
635  Chip_SCU_PinMuxSet(0x3, 3, (SCU_PINIO_FAST | SCU_MODE_FUNC2)); /* P3.3 connected to SCL/SCLK SCU_MODE_FUNC2=SSP0 SCK0 */
636  Chip_SCU_PinMuxSet(0x3, 6, (SCU_PINIO_FAST | SCU_MODE_FUNC2)); /* P3.6 connected to nCS SCU_MODE_FUNC2=SSP0 SSEL0 */
637  Chip_SCU_PinMuxSet(0x3, 7, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)); /* P3.7 connected to SO SCU_MODE_FUNC2=SSP0 MISO0 */
638  Chip_SCU_PinMuxSet(0x3, 8, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)); /* P3.8 connected to nSI SCU_MODE_FUNC2=SSP0 MOSI0 */
639  }
640  else if (pSSP == LPC_SSP1) {
641  /* Set up clock and power for SSP1 module */
642  /* Configure SSP1 pins*/
643  Chip_SCU_PinMuxSet(0xF, 4, (SCU_PINIO_FAST | SCU_MODE_FUNC0)); /* PF.4 connected to SCL/SCLK SCU_MODE_FUNC0 = SSP1 SCK1 */
644  Chip_SCU_PinMuxSet(0xF, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC2)); /* PF.5 connected to nCS SCU_MODE_FUNC2 = SSP1 SSEL1 */
645  Chip_SCU_PinMuxSet(0xF, 6, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)); /* PF.6 connected to SO SCU_MODE_FUNC2 = SSP1 MISO1 */
646  Chip_SCU_PinMuxSet(0xF, 7, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)); /* PF.7 connected to nSI SCU_MODE_FUNC2 = SSP1 MOSI1 */
647  }
648  else {
649  return;
650  }
651 }
652 
653 /* Initializes board specific buttons */
655 {
658 }
659 
660 /* Sets up default states for joystick */
662 {
664  Chip_SCU_PinMuxSet(0xC, 11, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC4)); /* PC_11 as GPIO6[10] */
665  Chip_SCU_PinMuxSet(0xC, 12, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC4)); /* PC_12 as GPIO6[11] */
666  Chip_SCU_PinMuxSet(0xC, 13, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC4)); /* PC_13 as GPIO6[12] */
667  Chip_SCU_PinMuxSet(0xC, 14, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC4)); /* PC_14 as GPIO6[13] */
668 
674 }
675 
676 /* Gets joystick status */
677 uint8_t Joystick_GetStatus(void)
678 {
679 
680  uint8_t ret = NO_BUTTON_PRESSED;
681 
683  ret |= JOY_UP;
684  }
686  ret |= JOY_DOWN;
687  }
689  ret |= JOY_LEFT;
690  }
692  ret |= JOY_RIGHT;
693  }
695  ret |= JOY_PRESS;
696  }
697 
698  return ret;
699 }
700 
701 /* Gets buttons status */
702 uint32_t Buttons_GetStatus(void)
703 {
704  uint8_t ret = NO_BUTTON_PRESSED;
705 
707  ret |= BUTTONS_BUTTON1;
708  }
709  return ret;
710 }
711 
712 /* Initialize DAC interface for the board */
714 {
716 }
717