More Kinetis updates

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3883 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-08-15 18:07:54 +00:00
parent d3b36f22ec
commit 2cd7449a3e
3 changed files with 61 additions and 48 deletions

View File

@ -166,22 +166,22 @@
/* Default Priorities */
#ifndef CONFIG_KINETIS_UART0PRIO
# define CONFIG_KINETIS_UART1PRIO NVIC_SYSH_PRIORITY_DEFAULT
# define CONFIG_KINETIS_UART0PRIO NVIC_SYSH_PRIORITY_DEFAULT
#endif
#ifndef CONFIG_KINETIS_UART1PRIO
# define CONFIG_KINETIS_UART2PRIO NVIC_SYSH_PRIORITY_DEFAULT
# define CONFIG_KINETIS_UART1PRIO NVIC_SYSH_PRIORITY_DEFAULT
#endif
#ifndef CONFIG_KINETIS_UART2PRIO
# define CONFIG_KINETIS_UART3PRIO NVIC_SYSH_PRIORITY_DEFAULT
# define CONFIG_KINETIS_UART2PRIO NVIC_SYSH_PRIORITY_DEFAULT
#endif
#ifndef CONFIG_KINETIS_UART3PRIO
# define CONFIG_KINETIS_UART4PRIO NVIC_SYSH_PRIORITY_DEFAULT
# define CONFIG_KINETIS_UART3PRIO NVIC_SYSH_PRIORITY_DEFAULT
#endif
#ifndef CONFIG_KINETIS_UART4PRIO
# define CONFIG_KINETIS_UART5PRIO NVIC_SYSH_PRIORITY_DEFAULT
# define CONFIG_KINETIS_UART4PRIO NVIC_SYSH_PRIORITY_DEFAULT
#endif
#ifndef CONFIG_KINETIS_UART5PRIO
# define CONFIG_KINETIS_UART6PRIO NVIC_SYSH_PRIORITY_DEFAULT
# define CONFIG_KINETIS_UART5PRIO NVIC_SYSH_PRIORITY_DEFAULT
#endif
/************************************************************************************

View File

@ -45,7 +45,10 @@
#include <nuttx/arch.h>
#include "up_arch.h"
#include "up_internal.h"
#include "kinetis_internal.h"
#include "kinetis_port.h"
#ifdef CONFIG_GPIO_IRQ
@ -62,7 +65,7 @@
#if defined (CONFIG_KINETIS_PORTAINTS) || defined (CONFIG_KINETIS_PORTBINTS) || \
defined (CONFIG_KINETIS_PORTCINTS) || defined (CONFIG_KINETIS_PORTDINTS) || \
defined (CONFIG_KINETIS_PORTEINTS)
# undef HAVE_PORTINTS
# define HAVE_PORTINTS 1
#endif
/****************************************************************************
@ -108,8 +111,8 @@ static xcpt_t g_porteisrs[32];
****************************************************************************/
#ifdef HAVE_PORTINTS
static int kinetis_portainterrupt(int irq, FAR void *context,
uintptr_t addr, xcpt_t **xcpt)
static int kinetis_portinterrupt(int irq, FAR void *context,
uintptr_t addr, xcpt_t *isrtab)
{
uint32_t isfr = getreg32(addr);
int i;
@ -125,18 +128,18 @@ static int kinetis_portainterrupt(int irq, FAR void *context,
*/
uint32_t bit = (1 << i);
if ((isfr & bit )) != 0)
if ((isfr & bit ) != 0)
{
/* I think that bits may be set in the ISFR for DMA activities
* well. So, no error is declared if there is no registered
* interrupt handler for the pin.
*/
if (xcpt[i])
if (isrtab[i])
{
/* There is a registered interrupt handler... invoke it */
(void)xcpt[i](irq, context);
(void)isrtab[i](irq, context);
}
/* Writing a one to the ISFR register will clear the pending
@ -258,7 +261,7 @@ void kinetis_pinirqinitialize(void)
xcpt_t kinetis_pinirqconfig(uint32_t pinset, xcpt_t pinisr)
{
#ifdef HAVE_PORTINTS
xcpt_t **table;
xcpt_t *isrtab;
xcpt_t oldisr;
irqstate_t flags;
unsigned int port;
@ -273,8 +276,8 @@ xcpt_t kinetis_pinirqconfig(uint32_t pinset, xcpt_t pinisr)
/* Get the port number and pin number */
port = (cfgset & _PIN_PORT_MASK) >> _PIN_PORT_SHIFT;
pin = (cfgset & _PIN_MASK) >> _PIN_SHIFT;
port = (pinset & _PIN_PORT_MASK) >> _PIN_PORT_SHIFT;
pin = (pinset & _PIN_MASK) >> _PIN_SHIFT;
/* Get the table associated with this port */
@ -284,27 +287,27 @@ xcpt_t kinetis_pinirqconfig(uint32_t pinset, xcpt_t pinisr)
{
#ifdef CONFIG_KINETIS_PORTAINTS
case KINETIS_PORTA :
table = g_portaisrs;
isrtab = g_portaisrs;
break;
#endif
#ifdef CONFIG_KINETIS_PORTBINTS
case KINETIS_PORTB :
table = g_portbisrs;
isrtab = g_portbisrs;
break;
#endif
#ifdef CONFIG_KINETIS_PORTCINTS
case KINETIS_PORTC :
table = g_portcisrs;
isrtab = g_portcisrs;
break;
#endif
#ifdef CONFIG_KINETIS_PORTDINTS
case KINETIS_PORTD :
table = g_portdisrs;
isrtab = g_portdisrs;
break;
#endif
#ifdef CONFIG_KINETIS_PORTEINTS
case KINETIS_PORTE :
table = g_porteisrs;
isrtab = g_porteisrs;
break;
#endif
default:
@ -313,12 +316,15 @@ xcpt_t kinetis_pinirqconfig(uint32_t pinset, xcpt_t pinisr)
/* Get the old PIN ISR and set the new PIN ISR */
oldisr = table[pin];
table[pin] = pinisr;
oldisr = isrtab[pin];
isrtab[pin] = pinisr;
/* And return the old PIN isr address */
return oldisr;
#else
return NULL;
#endif /* HAVE_PORTINTS */
}
/************************************************************************************
@ -345,6 +351,10 @@ void kinetis_pinirqenable(uint32_t pinset)
DEBUGASSERT(port < KINETIS_NPORTS);
if (port < KINETIS_NPORTS)
{
/* Get the base address of PORT block for this port */
base = KINETIS_PORT_BASE(port);
/* Modify the IRQC field of the port PCR register in order to enable
* the interrupt.
*/
@ -380,7 +390,7 @@ void kinetis_pinirqenable(uint32_t pinset)
putreg32(regval, base + KINETIS_PORT_PCR_OFFSET(pin));
}
#endif
#endif /* HAVE_PORTINTS */
}
/************************************************************************************
@ -407,6 +417,10 @@ void kinetis_pinirqdisable(uint32_t pinset)
DEBUGASSERT(port < KINETIS_NPORTS);
if (port < KINETIS_NPORTS)
{
/* Get the base address of PORT block for this port */
base = KINETIS_PORT_BASE(port);
/* Clear the IRQC field of the port PCR register in order to disable
* the interrupt.
*/
@ -415,6 +429,6 @@ void kinetis_pinirqdisable(uint32_t pinset)
regval &= ~PORT_PCR_IRQC_MASK;
putreg32(regval, base + KINETIS_PORT_PCR_OFFSET(pin));
}
#endif
#endif /* HAVE_PORTINTS */
}
#endif /* CONFIG_GPIO_IRQ */

View File

@ -591,7 +591,7 @@ static void up_disableuartint(struct up_dev_s *priv, uint8_t *ie)
*ie = priv->ie;
}
up_restoreint(priv, 0);
up_restoreuartint(priv, 0);
irqrestore(flags);
}
@ -611,8 +611,8 @@ static int up_setup(struct uart_dev_s *dev)
/* Configure the UART as an RS-232 UART */
uart_configure(priv->uartbase, priv->baud, priv->clock, priv->parity,
priv->bits);
kinetis_uartconfigure(priv->uartbase, priv->baud, priv->clock,
priv->parity, priv->bits);
#endif
/* Make sure that all interrupts are disabled */
@ -643,11 +643,11 @@ static void up_shutdown(struct uart_dev_s *dev)
/* Disable interrupts */
up_restoreint(priv, 0);
up_restoreuartint(priv, 0);
/* Reset hardware and disable Rx and Tx */
uart_reset(priv->uartbase);
kinetis_uartreset(priv->uartbase);
}
/****************************************************************************
@ -709,7 +709,7 @@ static void up_detach(struct uart_dev_s *dev)
/* Disable interrupts */
up_restoreint(priv, 0);
up_restoreuartint(priv, 0);
#ifdef CONFIG_DEBUG
up_disable_irq(priv->irqe);
#endif
@ -741,42 +741,42 @@ static int up_interrupte(int irq, void *context)
uint8_t regval;
#ifdef CONFIG_KINETIS_UART0
if (g_uart0priv.irq == irqe)
if (g_uart0priv.irqe == irq)
{
dev = &g_uart0port;
}
else
#endif
#ifdef CONFIG_KINETIS_UART1
if (g_uart1priv.irq == irqe)
if (g_uart1priv.irqe == irq)
{
dev = &g_uart1port;
}
else
#endif
#ifdef CONFIG_KINETIS_UART2
if (g_uart2priv.irq == irqe)
if (g_uart2priv.irqe == irq)
{
dev = &g_uart2port;
}
else
#endif
#ifdef CONFIG_KINETIS_UART3
if (g_uart3priv.irq == irqe)
if (g_uart3priv.irqe == irq)
{
dev = &g_uart1port;
}
else
#endif
#ifdef CONFIG_KINETIS_UART4
if (g_uart4priv.irq == irqe)
if (g_uart4priv.irqe == irq)
{
dev = &g_uart1port;
}
else
#endif
#ifdef CONFIG_KINETIS_UART5
if (g_uart5priv.irq == irqe)
if (g_uart5priv.irqe == irq)
{
dev = &g_uart1port;
}
@ -822,7 +822,6 @@ static int up_interrupts(int irq, void *context)
struct uart_dev_s *dev = NULL;
struct up_dev_s *priv;
int passes;
unsigned int size;
#ifdef CONFIG_KINETIS_UARTFIFOS
unsigned int count;
#else
@ -831,35 +830,35 @@ static int up_interrupts(int irq, void *context)
bool handled;
#ifdef CONFIG_KINETIS_UART0
if (g_uart0priv.irq == irqs)
if (g_uart0priv.irqs == irq)
{
dev = &g_uart0port;
}
else
#endif
#ifdef CONFIG_KINETIS_UART1
if (g_uart1priv.irq == irqs)
if (g_uart1priv.irqs == irq)
{
dev = &g_uart1port;
}
else
#endif
#ifdef CONFIG_KINETIS_UART2
if (g_uart2priv.irq == irqs)
if (g_uart2priv.irqs == irq)
{
dev = &g_uart2port;
}
else
#endif
#ifdef CONFIG_KINETIS_UART3
if (g_uart3priv.irq == irqs)
if (g_uart3priv.irqs == irq)
{
dev = &g_uart1port;
}
else
#endif
#ifdef CONFIG_KINETIS_UART4
if (g_uart4priv.irq == irqs)
if (g_uart4priv.irqs == irq)
{
dev = &g_uart1port;
}
@ -1228,21 +1227,21 @@ void up_earlyserialinit(void)
* pic32mx_consoleinit()
*/
up_restoreint(TTYS0_DEV.priv, 0);
up_restoreuartint(TTYS0_DEV.priv, 0);
#ifdef TTYS1_DEV
up_restoreint(TTYS1_DEV.priv, 0);
up_restoreuartint(TTYS1_DEV.priv, 0);
#endif
#ifdef TTYS2_DEV
up_restoreint(TTYS2_DEV.priv, 0);
up_restoreuartint(TTYS2_DEV.priv, 0);
#endif
#ifdef TTYS3_DEV
up_restoreint(TTYS3_DEV.priv, 0);
up_restoreuartint(TTYS3_DEV.priv, 0);
#endif
#ifdef TTYS4_DEV
up_restoreint(TTYS4_DEV.priv, 0);
up_restoreuartint(TTYS4_DEV.priv, 0);
#endif
#ifdef TTYS5_DEV
up_restoreint(TTYS5_DEV.priv, 0);
up_restoreuartint(TTYS5_DEV.priv, 0);
#endif
/* Configuration whichever one is the console */