/*
 * Copyright (c) 2013 - 2016, Freescale Semiconductor, Inc.
 * Copyright 2016-2017 NXP
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * o Redistributions of source code must retain the above copyright notice, this list
 *   of conditions and the following disclaimer.
 *
 * o Redistributions in binary form must reproduce the above copyright notice, this
 *   list of conditions and the following disclaimer in the documentation and/or
 *   other materials provided with the distribution.
 *
 * o Neither the name of the copyright holder nor the names of its
 *   contributors may be used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
!!GlobalInfo
product: Pins v3.0
processor: MKE15Z256xxx7
package_id: MKE15Z256VLL7
mcu_data: ksdk2_0
processor_version: 2.0.0
board: FRDM-KE15Z
pin_labels:
- {pin_num: '81', pin_signal: ADC1_SE4/TSI0_CH15/PTC6/LPUART1_RX, label: UART1_RX_TGTMCU}
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
 */

#include "fsl_common.h"
#include "fsl_port.h"
#include "pin_mux.h"

/*FUNCTION**********************************************************************
 * 
 * Function Name : BOARD_InitBootPins
 * Description   : Calls initialization functions.
 * 
 *END**************************************************************************/
void BOARD_InitBootPins(void) {
    BOARD_InitPins();
}

#define PIN0_IDX                         0u   /*!< Pin number for pin 0 in a port */
#define PIN2_IDX                         2u   /*!< Pin number for pin 0 in a port */
#define PIN3_IDX                         3u   /*!< Pin number for pin 0 in a port */
#define PIN6_IDX                         6u   /*!< Pin number for pin 6 in a port */
#define PIN7_IDX                         7u   /*!< Pin number for pin 7 in a port */
#define PIN15_IDX                       15u   /*!< Pin number for pin 15 in a port */
#define PIN16_IDX                       16u   /*!< Pin number for pin 16 in a port */


/*FUNCTION**********************************************************************
 *
 * Function Name : BOARD_InitPins
 * Description   : Configures pin routing and optionally pin electrical features.
 *
 *END**************************************************************************/
void BOARD_InitPins(void) {
  CLOCK_EnableClock(kCLOCK_PortC);                           /* Clock Control: 0x01u */
  CLOCK_EnableClock(kCLOCK_PortD);                           /* Clock Control: 0x01u */
  CLOCK_EnableClock(kCLOCK_PortA);                           /* Clock Control: 0x01u */
  CLOCK_EnableClock(kCLOCK_PortB);                           /* Clock Control: 0x01u */

  PORT_SetPinMux(PORTC, 8, kPORT_MuxAlt2);            /* PORTC6 (pin 81) is configured as LPUART1_RX */
  PORT_SetPinMux(PORTC, 9, kPORT_MuxAlt2);            /* PORTC7 (pin 80) is configured as LPUART1_TX */
  
  PORT_SetPinMux(PORTA, 2, kPORT_MuxAlt6);            /* PORTC6 (pin 81) is configured as LPUART0_RX */
  PORT_SetPinMux(PORTA, 3, kPORT_MuxAlt6);            /* PORTC7 (pin 80) is configured as LPUART0_TX */
  
    PORT_SetPinMux(PORTB, 11U, kPORT_MuxAsGpio);
    PORT_SetPinMux(PORTB,  9U, kPORT_MuxAsGpio); 
    PORT_SetPinMux(PORTB, 16U, kPORT_MuxAsGpio); 
    PORT_SetPinMux(PORTB, 17U, kPORT_MuxAsGpio);
    PORT_SetPinMux(PORTA, 17U, kPORT_MuxAsGpio);

}

/*******************************************************************************
 * EOF
 ******************************************************************************/
