2020-12-21 14:34:01 +08:00
|
|
|
/**************************************************************************//**
|
|
|
|
*
|
|
|
|
* @copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2020-12-12 Wayne First version
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include "board.h"
|
|
|
|
|
|
|
|
static void nu_pin_uart_init(void)
|
|
|
|
{
|
|
|
|
/* UART0: GPF11, GPF12 */
|
|
|
|
outpw(REG_SYS_GPF_MFPH, (inpw(REG_SYS_GPF_MFPH) & 0xfff00fff) | 0x11000);
|
|
|
|
|
2021-11-15 11:23:26 +08:00
|
|
|
#if !defined(BOARD_USING_LCD_ILI9341)
|
2020-12-21 14:34:01 +08:00
|
|
|
/* UART1: GPF9, GPF10 */
|
|
|
|
outpw(REG_SYS_GPF_MFPH, (inpw(REG_SYS_GPF_MFPH) & 0xfffff00f) | 0x00220);
|
2021-11-15 11:23:26 +08:00
|
|
|
#endif
|
2020-12-21 14:34:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void nu_pin_emac_init(void)
|
|
|
|
{
|
|
|
|
/* EMAC0 */
|
|
|
|
outpw(REG_SYS_GPE_MFPL, 0x11111111);
|
|
|
|
outpw(REG_SYS_GPE_MFPH, (inpw(REG_SYS_GPE_MFPH) & ~0xFF) | 0x11);
|
|
|
|
|
|
|
|
/* EMAC1 */
|
|
|
|
// outpw(REG_SYS_GPF_MFPL, 0x11111111);
|
|
|
|
// outpw(REG_SYS_GPF_MFPH, (inpw(REG_SYS_GPF_MFPH) & ~0xFF) | 0x11);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nu_pin_sdh_init(void)
|
|
|
|
{
|
|
|
|
/* SDH1: PF[0, 6] */
|
|
|
|
outpw(REG_SYS_GPF_MFPL, (inpw(REG_SYS_GPF_MFPL) & ~0x0FFFFFFF) | 0x02222222);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nu_pin_qspi_init(void)
|
|
|
|
{
|
|
|
|
/* QSPI0: PD[2, 7] */
|
|
|
|
outpw(REG_SYS_GPD_MFPL, (inpw(REG_SYS_GPD_MFPL) & ~0xFFFFFF00) | 0x11111100);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nu_pin_spi_init(void)
|
|
|
|
{
|
|
|
|
/* SPI0: PD[8, 11] */
|
|
|
|
outpw(REG_SYS_GPD_MFPH, (inpw(REG_SYS_GPD_MFPH) & ~0x0000FFFF) | 0x00001111);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nu_pin_i2c_init(void)
|
|
|
|
{
|
|
|
|
/* I2C0: PA[0, 1] */
|
|
|
|
outpw(REG_SYS_GPA_MFPL, (inpw(REG_SYS_GPA_MFPL) & ~0x000000FF) | 0x00000033);
|
|
|
|
|
2022-01-16 18:43:27 +08:00
|
|
|
#if !defined(BSP_USING_ADC_TOUCH)
|
2020-12-21 14:34:01 +08:00
|
|
|
/* I2C2: PB5, PB7 */
|
|
|
|
outpw(REG_SYS_GPB_MFPL, (inpw(REG_SYS_GPB_MFPL) & ~0xF0F00000) | 0x20200000);
|
2022-01-16 18:43:27 +08:00
|
|
|
#endif
|
2020-12-21 14:34:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void nu_pin_pwm_init(void)
|
|
|
|
{
|
|
|
|
/* PWM02, PWM03: PF[7, 8] */
|
|
|
|
outpw(REG_SYS_GPF_MFPL, (inpw(REG_SYS_GPF_MFPL) & ~0xF0000000) | 0x40000000);
|
|
|
|
outpw(REG_SYS_GPF_MFPH, (inpw(REG_SYS_GPF_MFPH) & ~0x0000000F) | 0x00000004);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nu_pin_i2s_init(void)
|
|
|
|
{
|
|
|
|
/* I2S A[2, 6] */
|
|
|
|
outpw(REG_SYS_GPA_MFPL, (inpw(REG_SYS_GPA_MFPL) & ~0x0FFFFF00) | 0x02222200);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nu_pin_can_init(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-02-01 10:35:44 +08:00
|
|
|
#if defined(BSP_USING_USBD)
|
2020-12-29 19:35:43 +08:00
|
|
|
static void nu_pin_usbd_init(void)
|
|
|
|
{
|
|
|
|
/* USB0_VBUSVLD, PE.11 */
|
2021-02-01 10:35:44 +08:00
|
|
|
outpw(REG_SYS_GPE_MFPH, (inpw(REG_SYS_GPE_MFPH) & ~0x0000F000) | 0x00001000);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void nu_pin_usbh_init(void)
|
|
|
|
{
|
2020-12-29 19:35:43 +08:00
|
|
|
}
|
|
|
|
|
2020-12-21 14:34:01 +08:00
|
|
|
void nu_pin_init(void)
|
|
|
|
{
|
|
|
|
nu_pin_uart_init();
|
|
|
|
nu_pin_emac_init();
|
|
|
|
nu_pin_sdh_init();
|
|
|
|
nu_pin_qspi_init();
|
|
|
|
nu_pin_spi_init();
|
|
|
|
nu_pin_i2c_init();
|
|
|
|
nu_pin_pwm_init();
|
|
|
|
nu_pin_i2s_init();
|
|
|
|
nu_pin_can_init();
|
2021-02-01 10:35:44 +08:00
|
|
|
|
|
|
|
#if defined(BSP_USING_USBD)
|
2020-12-29 19:35:43 +08:00
|
|
|
nu_pin_usbd_init();
|
2021-02-01 10:35:44 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
nu_pin_usbh_init();
|
2020-12-21 14:34:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void nu_pin_deinit(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|