arch/arm/src/samdl: Correct a link time error if CONFIG_SAMDL_EIC is not enabled.

This commit is contained in:
Gregory Nutt 2018-01-17 11:15:43 -06:00
parent 667ff07e6a
commit 2d95fa6d2a
3 changed files with 73 additions and 31 deletions

View File

@ -83,7 +83,7 @@ static int sam_eic_isr(int irq, FAR void *context, FAR void *arg)
for(bit=0;bit<SAM_IRQ_NEXTINTS;bit++)
{
if(intflag >> bit & 0x1)
if (intflag >> bit & 0x1)
{
irq_dispatch(SAM_IRQ_EXTINT0 + bit, context);
}
@ -126,7 +126,13 @@ void sam_eic_dumpregs(void)
* Name: sam_eic_initialize
*
* Description:
* Configure the external interrupt controller.
* Initialize the external interrupt controller (EIC).
*
* Input Parameters:
* gclkgen - GCLK Generator
*
* Returned Value:
* None
*
****************************************************************************/
@ -151,12 +157,26 @@ int sam_eic_initialize(uint8_t gclkgen)
return OK;
}
/****************************************************************************
* Name: sam_eic_initialize
*
* Description:
* Enable a external interrupt.
*
* Input Parameters:
* irq - SAM_IRQ_EXTINTn IRQ to be enabled
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_irq_enable(int irq)
{
uint32_t config;
int eirq = irq - SAM_IRQ_EXTINT0;
config = getreg32(SAM_EIC_CONFIG0);
config = getreg32(SAM_EIC_CONFIG0);
config |= EIC_CONFIG0_FILTEN(eirq) | EIC_CONFIG0_SENSE_FALL(eirq);
putreg32(config, SAM_EIC_CONFIG0);
@ -165,6 +185,21 @@ int sam_eic_irq_enable(int irq)
return OK;
}
/****************************************************************************
* Name: sam_eic_config
*
* Description:
* Configure the interrupt edge sensitivity in CONFIGn register of the EIC
*
* Input Parameters:
* eirq - Pin to be configured
* pinset - Configuration of the pin
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_config(uint8_t eirq, port_pinset_t pinset)
{
uint32_t reg;
@ -173,18 +208,24 @@ int sam_eic_config(uint8_t eirq, port_pinset_t pinset)
/* Determine which of the CONFIG[0:2] registers to write to */
if(eirq < 8)
if (eirq < 8)
{
reg = SAM_EIC_CONFIG0;
val = EIC_CONFIG0_SENSE_BOTH(eirq);
if(pinset & PORT_INT_RISING)
val = EIC_CONFIG0_SENSE_RISE(eirq);
if(pinset & PORT_INT_FALLING)
val = EIC_CONFIG0_SENSE_FALL(eirq);
if (pinset & PORT_INT_RISING)
{
val = EIC_CONFIG0_SENSE_RISE(eirq);
}
if (pinset & PORT_INT_FALLING)
{
val = EIC_CONFIG0_SENSE_FALL(eirq);
}
val |= EIC_CONFIG0_FILTEN(eirq);
}
else if(eirq < 16)
else if (eirq < 16)
{
reg = SAM_EIC_CONFIG1;
val = EIC_CONFIG1_FILTEN(eirq) | EIC_CONFIG1_SENSE_FALL(eirq);
@ -197,7 +238,7 @@ int sam_eic_config(uint8_t eirq, port_pinset_t pinset)
/* Write the new config to the CONFIGn register */
config = getreg32(reg);
config = getreg32(reg);
config |= val;
putreg32(config, reg);
@ -206,6 +247,5 @@ int sam_eic_config(uint8_t eirq, port_pinset_t pinset)
putreg32(EIC_EXTINT(eirq), SAM_EIC_INTENSET);
sam_eic_dumpregs();
return OK;
}

View File

@ -57,19 +57,7 @@
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Inline Functions
****************************************************************************/
/****************************************************************************
* Public Data
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
@ -82,14 +70,10 @@ extern "C"
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: sam_eic_configure
* Name: sam_eic_initialize
*
* Description:
* Configure the EIC
* Initialize the EIC
*
* Input Parameters:
* gclkgen - GCLK Generator
@ -100,6 +84,22 @@ extern "C"
****************************************************************************/
int sam_eic_initialize(uint8_t gclkgen);
/****************************************************************************
* Name: sam_eic_config
*
* Description:
* Configure the interrupt edge sensitivity in CONFIGn register of the EIC
*
* Input Parameters:
* eirq - Pin to be configured
* pinset - Configuration of the pin
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_config(uint8_t eirq, port_pinset_t pinset);
#undef EXTERN

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/samdl/sam_port.c
*
* Copyright (C) 2014-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2016, 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -204,9 +204,11 @@ static inline void sam_configinterrupt(uintptr_t base, port_pinset_t pinset)
putreg32(regval, base + SAM_PORT_WRCONFIG_OFFSET);
#ifdef CONFIG_SAMDL_EIC
/* Configure the interrupt edge sensitivity in CONFIGn register of the EIC */
sam_eic_config(pin, pinset);
#endif
#ifdef CONFIG_DEBUG_GPIO_INFO
sam_dumpport(pinset, "extint");