Skip to content

[nuvoton] Sync drivers of Nuvoton-M480 platform. #3799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions bsp/nuvoton/libraries/m480/StdDriver/inc/nu_eadc.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,12 @@ extern "C"
u32ModuleNum,\
u32Condition,\
u16CMPData,\
u32MatchCount) ((eadc)->CMP[0] |=(((u32ModuleNum) << EADC_CMP_CMPSPL_Pos)|\
u32MatchCount) ((eadc)->CMP[0] = (((eadc)->CMP[0] & ~(EADC_CMP_CMPSPL_Msk|EADC_CMP_CMPCOND_Msk|EADC_CMP_CMPDAT_Msk|EADC_CMP_CMPMCNT_Msk))|\
(((u32ModuleNum) << EADC_CMP_CMPSPL_Pos)|\
(u32Condition) |\
((u16CMPData) << EADC_CMP_CMPDAT_Pos)| \
(((u32MatchCount) - 1) << EADC_CMP_CMPMCNT_Pos)|\
EADC_CMP_ADCMPEN_Msk))
EADC_CMP_ADCMPEN_Msk)))

/**
* @brief Configure the comparator 1 and enable it.
Expand All @@ -458,11 +459,12 @@ extern "C"
u32ModuleNum,\
u32Condition,\
u16CMPData,\
u32MatchCount) ((eadc)->CMP[1] |=(((u32ModuleNum) << EADC_CMP_CMPSPL_Pos)|\
u32MatchCount) ((eadc)->CMP[1] = (((eadc)->CMP[1] & ~(EADC_CMP_CMPSPL_Msk|EADC_CMP_CMPCOND_Msk|EADC_CMP_CMPDAT_Msk|EADC_CMP_CMPMCNT_Msk))|\
(((u32ModuleNum) << EADC_CMP_CMPSPL_Pos)|\
(u32Condition) |\
((u16CMPData) << EADC_CMP_CMPDAT_Pos)| \
(((u32MatchCount) - 1) << EADC_CMP_CMPMCNT_Pos)|\
EADC_CMP_ADCMPEN_Msk))
EADC_CMP_ADCMPEN_Msk)))

/**
* @brief Configure the comparator 2 and enable it.
Expand All @@ -483,11 +485,12 @@ extern "C"
u32ModuleNum,\
u32Condition,\
u16CMPData,\
u32MatchCount) ((eadc)->CMP[2] |=(((u32ModuleNum) << EADC_CMP_CMPSPL_Pos)|\
u32MatchCount) ((eadc)->CMP[2] = (((eadc)->CMP[2] & ~(EADC_CMP_CMPSPL_Msk|EADC_CMP_CMPCOND_Msk|EADC_CMP_CMPDAT_Msk|EADC_CMP_CMPMCNT_Msk))|\
(((u32ModuleNum) << EADC_CMP_CMPSPL_Pos)|\
(u32Condition) |\
((u16CMPData) << EADC_CMP_CMPDAT_Pos)| \
(((u32MatchCount) - 1) << EADC_CMP_CMPMCNT_Pos)|\
EADC_CMP_ADCMPEN_Msk))
EADC_CMP_ADCMPEN_Msk)))

/**
* @brief Configure the comparator 3 and enable it.
Expand All @@ -508,11 +511,12 @@ extern "C"
u32ModuleNum,\
u32Condition,\
u16CMPData,\
u32MatchCount) ((eadc)->CMP[3] |=(((u32ModuleNum) << EADC_CMP_CMPSPL_Pos)|\
u32MatchCount) ((eadc)->CMP[3] = (((eadc)->CMP[3] & ~(EADC_CMP_CMPSPL_Msk|EADC_CMP_CMPCOND_Msk|EADC_CMP_CMPDAT_Msk|EADC_CMP_CMPMCNT_Msk))|\
(((u32ModuleNum) << EADC_CMP_CMPSPL_Pos)|\
(u32Condition) |\
((u16CMPData) << EADC_CMP_CMPDAT_Pos)| \
(((u32MatchCount) - 1) << EADC_CMP_CMPMCNT_Pos)|\
EADC_CMP_ADCMPEN_Msk))
EADC_CMP_ADCMPEN_Msk)))

/**
* @brief Enable the compare window mode.
Expand Down
18 changes: 18 additions & 0 deletions bsp/nuvoton/libraries/m480/StdDriver/inc/nu_qspi.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ extern "C"
*/
#define QSPI_TRIGGER_TX_PDMA(qspi) ((qspi)->PDMACTL |= QSPI_PDMACTL_TXPDMAEN_Msk)

/**
* @brief Trigger TX and RX PDMA function.
* @param[in] qspi The pointer of the specified QSPI module.
* @return None.
* @details Set TXPDMAEN bit and RXPDMAEN bit of QSPI_PDMACTL register to enable TX and RX PDMA transfer function.
* \hideinitializer
*/
#define QSPI_TRIGGER_TX_RX_PDMA(qspi) ((qspi)->PDMACTL |= (QSPI_PDMACTL_TXPDMAEN_Msk | QSPI_PDMACTL_RXPDMAEN_Msk))

/**
* @brief Disable RX PDMA transfer.
* @param[in] qspi The pointer of the specified QSPI module.
Expand All @@ -113,6 +122,15 @@ extern "C"
*/
#define QSPI_DISABLE_TX_PDMA(qspi) ( (qspi)->PDMACTL &= ~QSPI_PDMACTL_TXPDMAEN_Msk )

/**
* @brief Disable TX and RX PDMA transfer.
* @param[in] qspi The pointer of the specified QSPI module.
* @return None.
* @details Clear TXPDMAEN bit and RXPDMAEN bit of QSPI_PDMACTL register to disable TX and RX PDMA transfer function.
* \hideinitializer
*/
#define QSPI_DISABLE_TX_RX_PDMA(qspi) ( (qspi)->PDMACTL &= ~(QSPI_PDMACTL_TXPDMAEN_Msk | QSPI_PDMACTL_RXPDMAEN_Msk) )

/**
* @brief Get the count of available data in RX FIFO.
* @param[in] qspi The pointer of the specified QSPI module.
Expand Down
18 changes: 18 additions & 0 deletions bsp/nuvoton/libraries/m480/StdDriver/inc/nu_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ extern "C"
*/
#define SPI_TRIGGER_TX_PDMA(spi) ((spi)->PDMACTL |= SPI_PDMACTL_TXPDMAEN_Msk)

/**
* @brief Trigger TX and RX PDMA function.
* @param[in] spi The pointer of the specified SPI module.
* @return None.
* @details Set TXPDMAEN bit and RXPDMAEN bit of SPI_PDMACTL register to enable TX and RX PDMA transfer function.
* \hideinitializer
*/
#define SPI_TRIGGER_TX_RX_PDMA(spi) ((spi)->PDMACTL |= (SPI_PDMACTL_TXPDMAEN_Msk | SPI_PDMACTL_RXPDMAEN_Msk))

/**
* @brief Disable RX PDMA transfer.
* @param[in] spi The pointer of the specified SPI module.
Expand All @@ -151,6 +160,15 @@ extern "C"
*/
#define SPI_DISABLE_TX_PDMA(spi) ( (spi)->PDMACTL &= ~SPI_PDMACTL_TXPDMAEN_Msk )

/**
* @brief Disable TX and RX PDMA transfer.
* @param[in] spi The pointer of the specified SPI module.
* @return None.
* @details Clear TXPDMAEN bit and RXPDMAEN bit of SPI_PDMACTL register to disable TX and RX PDMA transfer function.
* \hideinitializer
*/
#define SPI_DISABLE_TX_RX_PDMA(spi) ( (spi)->PDMACTL &= ~(SPI_PDMACTL_TXPDMAEN_Msk | SPI_PDMACTL_RXPDMAEN_Msk) )

/**
* @brief Get the count of available data in RX FIFO.
* @param[in] spi The pointer of the specified SPI module.
Expand Down
18 changes: 18 additions & 0 deletions bsp/nuvoton/libraries/m480/StdDriver/inc/nu_usci_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,15 @@ extern "C"
*/
#define USPI_TRIGGER_TX_PDMA(uspi) ((uspi)->PDMACTL |= USPI_PDMACTL_TXPDMAEN_Msk|USPI_PDMACTL_PDMAEN_Msk)

/**
* @brief Trigger TX and RX PDMA function.
* @param[in] uspi The pointer of the specified USCI_SPI module.
* @return None.
* @details Set TXPDMAEN bit and RXPDMAEN bit of USPI_PDMACTL register to enable TX and RX PDMA transfer function.
* \hideinitializer
*/
#define USPI_TRIGGER_TX_RX_PDMA(uspi) ((uspi)->PDMACTL |= USPI_PDMACTL_TXPDMAEN_Msk|USPI_PDMACTL_RXPDMAEN_Msk|USPI_PDMACTL_PDMAEN_Msk)

/**
* @brief Disable RX PDMA transfer.
* @param[in] uspi The pointer of the specified USCI_SPI module.
Expand All @@ -379,6 +388,15 @@ extern "C"
*/
#define USPI_DISABLE_TX_PDMA(uspi) ( (uspi)->PDMACTL &= ~USPI_PDMACTL_TXPDMAEN_Msk )

/**
* @brief Disable TX and RX PDMA transfer.
* @param[in] uspi The pointer of the specified USCI_SPI module.
* @return None.
* @details Clear TXPDMAEN bit and RXPDMAEN bit of USPI_PDMACTL register to disable TX and RX PDMA transfer function.
* \hideinitializer
*/
#define USPI_DISABLE_TX_RX_PDMA(uspi) ( (uspi)->PDMACTL &= ~(USPI_PDMACTL_TXPDMAEN_Msk | USPI_PDMACTL_RXPDMAEN_Msk))

uint32_t USPI_Open(USPI_T *uspi, uint32_t u32MasterSlave, uint32_t u32SPIMode, uint32_t u32DataWidth, uint32_t u32BusClock);
void USPI_Close(USPI_T *uspi);
void USPI_ClearRxBuf(USPI_T *uspi);
Expand Down
44 changes: 27 additions & 17 deletions bsp/nuvoton/libraries/m480/rtt_port/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ config SOC_SERIES_M480
select RT_USING_NETDEV

config NU_EMAC_PDMA_MEMCOPY
bool "Use PDMA for data tranferring"
bool "Use PDMA for data transferring"
select BSP_USING_PDMA
depends on BSP_USING_EMAC
default y
Expand All @@ -82,14 +82,15 @@ config SOC_SERIES_M480

menuconfig BSP_USING_EADC
bool "Enable Enhanced Analog-to-Digital Converter(EADC)"
select RT_USING_ADC

config BSP_USING_EADC0
bool "Enable EADC0"
depends on BSP_USING_EADC && RT_USING_ADC
if BSP_USING_EADC
config BSP_USING_EADC0
bool "Enable EADC0"

config BSP_USING_EADC1
bool "Enable EADC1"
depends on BSP_USING_EADC && RT_USING_ADC
config BSP_USING_EADC1
bool "Enable EADC1"
endif

menuconfig BSP_USING_TMR
bool "Enable Timer Controller(TIMER)"
Expand Down Expand Up @@ -371,12 +372,14 @@ config SOC_SERIES_M480

config BSP_USING_UI2C0
select RT_USING_I2C
select BSP_USING_UI2C
bool "UI2C0"
help
Choose this option if you need I2C function mode.

config BSP_USING_USPI0
select RT_USING_SPI
select BSP_USING_USPI
bool "USPI0"
help
Choose this option if you need SPI function mode.
Expand All @@ -391,7 +394,7 @@ config SOC_SERIES_M480
depends on BSP_USING_UUART0 && RT_SERIAL_USING_DMA

config BSP_USING_USPI0_PDMA
bool "Use PDMA for data tranferring"
bool "Use PDMA for data transferring"
select BSP_USING_USPI_PDMA
depends on BSP_USING_USPI0
endif
Expand All @@ -405,21 +408,21 @@ config SOC_SERIES_M480

config BSP_USING_UUART1
select RT_USING_SERIAL
select BSP_USING_UUART
select BSP_USING_UUART
bool "UUART1"
help
Choose this option if you need UART function mode.

config BSP_USING_UI2C1
select RT_USING_I2C
select BSP_USING_UI2C
select BSP_USING_UI2C
bool "UI2C1"
help
Choose this option if you need I2C function mode.

config BSP_USING_USPI1
select RT_USING_SPI
select BSP_USING_USPI
select BSP_USING_USPI
bool "USPI1"
help
Choose this option if you need SPI function mode.
Expand All @@ -434,7 +437,7 @@ config SOC_SERIES_M480
depends on BSP_USING_UUART1 && RT_SERIAL_USING_DMA

config BSP_USING_USPI1_PDMA
bool "Use PDMA for data tranferring"
bool "Use PDMA for data transferring"
select BSP_USING_USPI_PDMA
depends on BSP_USING_USPI1
endif
Expand All @@ -459,6 +462,10 @@ config SOC_SERIES_M480
config NU_SDH_HOTPLUG
bool "Using HOTPLUG"
default y

config NU_SDH_MOUNT_ON_ROOT
bool "Mount on root"

endif

menuconfig BSP_USING_CAN
Expand Down Expand Up @@ -652,7 +659,7 @@ config SOC_SERIES_M480
select BSP_USING_SPI_PDMA
depends on BSP_USING_SPI1
endif

choice
prompt "Select SPI2 function mode"
config BSP_USING_SPI2_NONE
Expand Down Expand Up @@ -686,7 +693,7 @@ config SOC_SERIES_M480
bool "NONE"
help
Choose this option if you need not SPI3.

config BSP_USING_SPI3
bool "Enable SPI3"
help
Expand Down Expand Up @@ -724,20 +731,23 @@ config SOC_SERIES_M480
bool "Enable Quad Serial Peripheral Interface(QSPI)"
select RT_USING_SPI
select RT_USING_QSPI
select BSP_USING_SPI

if BSP_USING_QSPI
if BSP_USING_QSPI
config BSP_USING_QSPI0
bool "Enable QSPI0"

config BSP_USING_QSPI0_PDMA
bool "Enable PDMA for QSPI0"
select BSP_USING_SPI_PDMA
depends on BSP_USING_QSPI0

config BSP_USING_QSPI1
bool "Enable QSPI1"

config BSP_USING_QSPI1_PDMA
bool "Enable PDMA for QSPI1"
bool "Enable PDMA for QSPI1"
select BSP_USING_SPI_PDMA
depends on BSP_USING_QSPI1
endif

Expand Down Expand Up @@ -857,7 +867,7 @@ config SOC_SERIES_M480

if BSP_USING_CRC
config NU_CRC_USE_PDMA
bool "Use PDMA for data tranferring."
bool "Use PDMA for data transferring."
select BSP_USING_PDMA
default y
endif
Expand Down
19 changes: 10 additions & 9 deletions bsp/nuvoton/libraries/m480/rtt_port/drv_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static struct nu_can nu_can_arr[] =
},
#endif
{0}
}; /* usart nu_usart */
}; /* struct nu_can */

/* Public functions ------------------------------------------------------------*/

Expand All @@ -112,7 +112,7 @@ static const struct rt_can_ops nu_can_ops =

static const struct can_configure nu_can_default_config = NU_CAN_CONFIG_DEFAULT;

/* Interrupt Handle Funtion ----------------------------------------------------*/
/* Interrupt Handle Function ----------------------------------------------------*/
#if defined(BSP_USING_CAN0)
/* CAN0 interrupt entry */
void CAN0_IRQHandler(void)
Expand Down Expand Up @@ -238,7 +238,7 @@ static rt_err_t nu_can_configure(struct rt_can_device *can, struct can_configure
RT_ASSERT(can != RT_NULL);
RT_ASSERT(cfg != RT_NULL);

/* Get base address of uart register */
/* Get base address of CAN register */
CAN_T *can_base = ((nu_can_t)can)->can_base;

RT_ASSERT(can_base != RT_NULL);
Expand Down Expand Up @@ -312,7 +312,7 @@ static rt_err_t nu_can_control(struct rt_can_device *can, int cmd, void *arg)
#ifdef RT_CAN_USING_HDR
struct rt_can_filter_config *filter_cfg;
#endif
/* Get base address of uart register */
/* Get base address of CAN register */
CAN_T *can_base = ((nu_can_t)can)->can_base;

RT_ASSERT(can_base != RT_NULL);
Expand Down Expand Up @@ -346,7 +346,6 @@ static rt_err_t nu_can_control(struct rt_can_device *can, int cmd, void *arg)
{
/* Enable Status Change Interrupt */
CAN_EnableInt(can_base, CAN_CON_IE_Msk | CAN_CON_SIE_Msk);
NVIC_SetPriority(((nu_can_t)can)->can_irq_n, (1 << __NVIC_PRIO_BITS) - 2);
/* Enable NVIC interrupt. */
NVIC_EnableIRQ(((nu_can_t)can)->can_irq_n);

Expand All @@ -355,7 +354,6 @@ static rt_err_t nu_can_control(struct rt_can_device *can, int cmd, void *arg)
{
/* Enable Error Status and Status Change Interrupt */
CAN_EnableInt(can_base, CAN_CON_IE_Msk | CAN_CON_SIE_Msk | CAN_CON_EIE_Msk);
NVIC_SetPriority(((nu_can_t)can)->can_irq_n, (1 << __NVIC_PRIO_BITS) - 2);
/* Enable NVIC interrupt. */
NVIC_EnableIRQ(((nu_can_t)can)->can_irq_n);
}
Expand Down Expand Up @@ -440,6 +438,9 @@ static rt_err_t nu_can_control(struct rt_can_device *can, int cmd, void *arg)
rt_memcpy(arg, &can->status, sizeof(can->status));
}
break;
default:
return -(RT_EINVAL);

}

return RT_EOK;
Expand All @@ -449,7 +450,7 @@ static int nu_can_sendmsg(struct rt_can_device *can, const void *buf, rt_uint32_
{
STR_CANMSG_T tMsg;
struct rt_can_msg *pmsg = (struct rt_can_msg *) buf;
/* Get base address of uart register */
/* Get base address of CAN register */
CAN_T *can_base = ((nu_can_t)can)->can_base;

RT_ASSERT(can_base != RT_NULL);
Expand Down Expand Up @@ -495,7 +496,7 @@ static int nu_can_recvmsg(struct rt_can_device *can, void *buf, rt_uint32_t boxn
{
STR_CANMSG_T tMsg;
struct rt_can_msg *pmsg = (struct rt_can_msg *) buf;
/* Get base address of uart register */
/* Get base address of CAN register */
CAN_T *can_base = ((nu_can_t)can)->can_base;

RT_ASSERT(can_base != RT_NULL);
Expand Down Expand Up @@ -558,7 +559,7 @@ static int rt_hw_can_init(void)
RT_ASSERT(ret == RT_EOK);
}

return ret;
return (int)ret;
}
INIT_DEVICE_EXPORT(rt_hw_can_init);
#endif //#if defined(BSP_USING_CAN)
Loading