Convert more drivers to use use irq_attach with argument.
This commit is contained in:
parent
a581e9206d
commit
b4ff7391f8
@ -78,13 +78,15 @@ struct stm32_lower_s
|
|||||||
{
|
{
|
||||||
const struct vs1053_lower_s lower; /* Low-level MCU interface */
|
const struct vs1053_lower_s lower; /* Low-level MCU interface */
|
||||||
xcpt_t handler; /* VS1053 interrupt handler */
|
xcpt_t handler; /* VS1053 interrupt handler */
|
||||||
|
FAR void *arg; /* Interrupt handler argument */
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int up_attach(FAR const struct vs1053_lower_s *lower, xcpt_t handler);
|
static int up_attach(FAR const struct vs1053_lower_s *lower, xcpt_t handler,
|
||||||
|
FAR void *arg);
|
||||||
static void up_enable(FAR const struct vs1053_lower_s *lower);
|
static void up_enable(FAR const struct vs1053_lower_s *lower);
|
||||||
static void up_disable(FAR const struct vs1053_lower_s *lower);
|
static void up_disable(FAR const struct vs1053_lower_s *lower);
|
||||||
static void up_reset(FAR const struct vs1053_lower_s *lower, bool state);
|
static void up_reset(FAR const struct vs1053_lower_s *lower, bool state);
|
||||||
@ -110,6 +112,7 @@ static struct stm32_lower_s g_vs1053lower =
|
|||||||
.irq = GPIO_VS1053_DREQ_IRQ
|
.irq = GPIO_VS1053_DREQ_IRQ
|
||||||
},
|
},
|
||||||
.handler = NULL,
|
.handler = NULL,
|
||||||
|
.arg = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -120,11 +123,13 @@ static struct stm32_lower_s g_vs1053lower =
|
|||||||
* Name: struct vs1053_lower_s methods
|
* Name: struct vs1053_lower_s methods
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int up_attach(FAR const struct vs1053_lower_s *lower, xcpt_t handler)
|
static int up_attach(FAR const struct vs1053_lower_s *lower, xcpt_t handler,
|
||||||
|
FAR void *arg)
|
||||||
{
|
{
|
||||||
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)lower;
|
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)lower;
|
||||||
|
|
||||||
priv->handler = handler; /* Save the handler for later */
|
priv->handler = handler; /* Save the handler for later */
|
||||||
|
priv->arg = arg; /* Along with the handler argument */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,13 +217,6 @@ static const struct audio_ops_s g_audioops =
|
|||||||
vs1053_release /* release */
|
vs1053_release /* release */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ISR context pointers */
|
|
||||||
|
|
||||||
static struct vs1053_struct_s *g_isrdata[CONFIG_VS1053_DEVICE_COUNT] =
|
|
||||||
{
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Volume control log table. This table is in increments of 2% of
|
/* Volume control log table. This table is in increments of 2% of
|
||||||
* requested volume level and is the register value that should be
|
* requested volume level and is the register value that should be
|
||||||
* programmed to the VS1053 to achieve that volume pecentage.
|
* programmed to the VS1053 to achieve that volume pecentage.
|
||||||
@ -1215,32 +1208,12 @@ err_out:
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int vs1053_dreq_isr(int irq, FAR void *context)
|
static int vs1053_dreq_isr(int irq, FAR void *context, FAR void *arg)
|
||||||
{
|
{
|
||||||
struct vs1053_struct_s *dev = NULL;
|
struct vs1053_struct_s *dev = (struct vs1053_struct_s *)arg;
|
||||||
struct audio_msg_s msg;
|
struct audio_msg_s msg;
|
||||||
|
|
||||||
/* Get the driver context */
|
DEBUGASSERT(dev != NULL);
|
||||||
|
|
||||||
#if CONFIG_VS1053_DEVICE_COUNT == 1
|
|
||||||
dev = g_isrdata[0]; /* Simple case */
|
|
||||||
#else
|
|
||||||
/* More complex case */
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
|
|
||||||
for (x = 0; x < CONFIG_VS1053_DEVICE_COUNT; x++)
|
|
||||||
{
|
|
||||||
if (g_isrdata[x]->hw_lower->irq == irq)
|
|
||||||
{
|
|
||||||
dev = g_isrdata[x];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBUGASSERT(dev);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Now create a message and send it to the workerthread */
|
/* Now create a message and send it to the workerthread */
|
||||||
|
|
||||||
@ -1909,33 +1882,10 @@ struct audio_lowerhalf_s *vs1053_initialize(FAR struct spi_dev_s *spi,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Attach our ISR to this device */
|
/* Attach our ISR to this device */
|
||||||
dev->hw_lower->attach(dev->hw_lower, vs1053_dreq_isr);
|
|
||||||
|
|
||||||
/* Find a slot to save the device context for ISR lookup */
|
dev->hw_lower->attach(dev->hw_lower, vs1053_dreq_isr, dev);
|
||||||
|
|
||||||
#if CONFIG_VS1053_DEVICE_COUNT == 1
|
/* Do some initialization of the codec */
|
||||||
g_isrdata[0] = dev; /* The simple case */
|
|
||||||
#else
|
|
||||||
/* The more complex case */
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
|
|
||||||
/* Initialize the ISR data if not alrady */
|
|
||||||
|
|
||||||
for (x = 0; x < CONFIG_VS1053_DEVICE_COUNT; x++)
|
|
||||||
{
|
|
||||||
/* Find an empty slot */
|
|
||||||
|
|
||||||
if (g_isrdata[x] == NULL)
|
|
||||||
{
|
|
||||||
g_isrdata[x] = dev;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Do some initialization of the codec */
|
|
||||||
|
|
||||||
vs1053_shutdown(&dev->lower); /* Go to shutdown state */
|
vs1053_shutdown(&dev->lower); /* Go to shutdown state */
|
||||||
}
|
}
|
||||||
|
@ -85,14 +85,6 @@
|
|||||||
|
|
||||||
#define BUF ((struct eth_hdr_s *)cs89x0->cs_dev.d_buf)
|
#define BUF ((struct eth_hdr_s *)cs89x0->cs_dev.d_buf)
|
||||||
|
|
||||||
/* If there is only one CS89x0 instance, then mapping the CS89x0 IRQ to
|
|
||||||
* a driver state instance is trivial.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if CONFIG_CS89x0_NINTERFACES == 1
|
|
||||||
# define cs89x0_mapirq(irq) g_cs89x0[0]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PKTBUF_SIZE (MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE)
|
#define PKTBUF_SIZE (MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -123,9 +115,6 @@ static int cs89x0_txpoll(struct net_driver_s *dev);
|
|||||||
|
|
||||||
static void cs89x0_receive(struct cs89x0_driver_s *cs89x0);
|
static void cs89x0_receive(struct cs89x0_driver_s *cs89x0);
|
||||||
static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16_t isq);
|
static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16_t isq);
|
||||||
#if CONFIG_CS89x0_NINTERFACES > 1
|
|
||||||
static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq);
|
|
||||||
#endif
|
|
||||||
static int cs89x0_interrupt(int irq, FAR void *context, FAR void *arg);
|
static int cs89x0_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||||
|
|
||||||
/* Watchdog timer expirations */
|
/* Watchdog timer expirations */
|
||||||
@ -621,40 +610,6 @@ static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16_t isq)
|
|||||||
(void)devif_poll(&cs89x0->cs_dev, cs89x0_txpoll);
|
(void)devif_poll(&cs89x0->cs_dev, cs89x0_txpoll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Function: cs89x0_mapirq
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Map an IRQ number to a CS89x0 device state instance. This is only
|
|
||||||
* necessary to handler the case where the architecture includes more than
|
|
||||||
* on CS89x0 chip.
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* irq - Number of the IRQ that generated the interrupt
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* A reference to device state structure (NULL if irq does not correspond
|
|
||||||
* to any CS89x0 device).
|
|
||||||
*
|
|
||||||
* Assumptions:
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#if CONFIG_CS89x0_NINTERFACES > 1
|
|
||||||
static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < CONFIG_CS89x0_NINTERFACES; i++)
|
|
||||||
{
|
|
||||||
if (g_cs89x0[i] && g_cs89x0[i].irq == irq)
|
|
||||||
{
|
|
||||||
return g_cs89x0[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: cs89x0_interrupt
|
* Function: cs89x0_interrupt
|
||||||
*
|
*
|
||||||
@ -674,15 +629,10 @@ static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq)
|
|||||||
|
|
||||||
static int cs89x0_interrupt(int irq, FAR void *context, FAR void *arg)
|
static int cs89x0_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||||
{
|
{
|
||||||
register struct cs89x0_driver_s *cs89x0 = s89x0_mapirq(irq);
|
FAR struct cs89x0_driver_s *cs89x0 = (FAR struct cs89x0_driver_s *)arg;
|
||||||
uint16_t isq;
|
uint16_t isq;
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FEATURES
|
DEBUGASSERT(cs89x0 != NULL);
|
||||||
if (!cs89x0)
|
|
||||||
{
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Read and process all of the events from the ISQ */
|
/* Read and process all of the events from the ISQ */
|
||||||
|
|
||||||
@ -1023,7 +973,7 @@ int cs89x0_initialize(FAR const cs89x0_driver_s *cs89x0, int devno)
|
|||||||
|
|
||||||
/* Attach the IRQ to the driver */
|
/* Attach the IRQ to the driver */
|
||||||
|
|
||||||
if (irq_attach(cs89x0->irq, cs89x0_interrupt, NULL))
|
if (irq_attach(cs89x0->irq, cs89x0_interrupt, cs89x0))
|
||||||
{
|
{
|
||||||
/* We could not attach the ISR to the ISR */
|
/* We could not attach the ISR to the ISR */
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* drivers/serial/uart_16550.c
|
* drivers/serial/uart_16550.c
|
||||||
* Serial driver for 16550 UART
|
* Serial driver for 16550 UART
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011, 2013, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -74,10 +74,8 @@ struct u16550_s
|
|||||||
uint32_t baud; /* Configured baud */
|
uint32_t baud; /* Configured baud */
|
||||||
uint32_t uartclk; /* UART clock frequency */
|
uint32_t uartclk; /* UART clock frequency */
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
uart_datawidth_t ier; /* Saved IER value */
|
uart_datawidth_t ier; /* Saved IER value */
|
||||||
uint8_t irq; /* IRQ associated with this UART */
|
uint8_t irq; /* IRQ associated with this UART */
|
||||||
#endif
|
|
||||||
#ifndef CONFIG_16550_SUPRESS_CONFIG
|
#ifndef CONFIG_16550_SUPRESS_CONFIG
|
||||||
uint8_t parity; /* 0=none, 1=odd, 2=even */
|
uint8_t parity; /* 0=none, 1=odd, 2=even */
|
||||||
uint8_t bits; /* Number of bits (7 or 8) */
|
uint8_t bits; /* Number of bits (7 or 8) */
|
||||||
@ -89,21 +87,19 @@ struct u16550_s
|
|||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int u16550_setup(struct uart_dev_s *dev);
|
static int u16550_setup(FAR struct uart_dev_s *dev);
|
||||||
static void u16550_shutdown(struct uart_dev_s *dev);
|
static void u16550_shutdown(FAR struct uart_dev_s *dev);
|
||||||
static int u16550_attach(struct uart_dev_s *dev);
|
static int u16550_attach(FAR struct uart_dev_s *dev);
|
||||||
static void u16550_detach(struct uart_dev_s *dev);
|
static void u16550_detachFAR struct uart_dev_s *dev);
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
static int u16550_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||||
static int u16550_interrupt(int irq, void *context, FAR void *arg);
|
static int u16550_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||||
#endif
|
static int u16550_receive(FAR struct uart_dev_s *dev, uint32_t *status);
|
||||||
static int u16550_ioctl(struct file *filep, int cmd, unsigned long arg);
|
static void u16550_rxint(FAR struct uart_dev_s *dev, bool enable);
|
||||||
static int u16550_receive(struct uart_dev_s *dev, uint32_t *status);
|
static bool u16550_rxavailable(FAR struct uart_dev_s *dev);
|
||||||
static void u16550_rxint(struct uart_dev_s *dev, bool enable);
|
static void u16550_send(FAR struct uart_dev_s *dev, int ch);
|
||||||
static bool u16550_rxavailable(struct uart_dev_s *dev);
|
static void u16550_txint(FAR struct uart_dev_s *dev, bool enable);
|
||||||
static void u16550_send(struct uart_dev_s *dev, int ch);
|
static bool u16550_txready(FAR struct uart_dev_s *dev);
|
||||||
static void u16550_txint(struct uart_dev_s *dev, bool enable);
|
static bool u16550_txempty(FAR struct uart_dev_s *dev);
|
||||||
static bool u16550_txready(struct uart_dev_s *dev);
|
|
||||||
static bool u16550_txempty(struct uart_dev_s *dev);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@ -157,9 +153,7 @@ static struct u16550_s g_uart0priv =
|
|||||||
.baud = CONFIG_16550_UART0_BAUD,
|
.baud = CONFIG_16550_UART0_BAUD,
|
||||||
.uartclk = CONFIG_16550_UART0_CLOCK,
|
.uartclk = CONFIG_16550_UART0_CLOCK,
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
.irq = CONFIG_16550_UART0_IRQ,
|
.irq = CONFIG_16550_UART0_IRQ,
|
||||||
#endif
|
|
||||||
#ifndef CONFIG_16550_SUPRESS_CONFIG
|
#ifndef CONFIG_16550_SUPRESS_CONFIG
|
||||||
.parity = CONFIG_16550_UART0_PARITY,
|
.parity = CONFIG_16550_UART0_PARITY,
|
||||||
.bits = CONFIG_16550_UART0_BITS,
|
.bits = CONFIG_16550_UART0_BITS,
|
||||||
@ -194,9 +188,7 @@ static struct u16550_s g_uart1priv =
|
|||||||
.baud = CONFIG_16550_UART1_BAUD,
|
.baud = CONFIG_16550_UART1_BAUD,
|
||||||
.uartclk = CONFIG_16550_UART1_CLOCK,
|
.uartclk = CONFIG_16550_UART1_CLOCK,
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
.irq = CONFIG_16550_UART1_IRQ,
|
.irq = CONFIG_16550_UART1_IRQ,
|
||||||
#endif
|
|
||||||
#ifndef CONFIG_16550_SUPRESS_CONFIG
|
#ifndef CONFIG_16550_SUPRESS_CONFIG
|
||||||
.parity = CONFIG_16550_UART1_PARITY,
|
.parity = CONFIG_16550_UART1_PARITY,
|
||||||
.bits = CONFIG_16550_UART1_BITS,
|
.bits = CONFIG_16550_UART1_BITS,
|
||||||
@ -231,9 +223,7 @@ static struct u16550_s g_uart2priv =
|
|||||||
.baud = CONFIG_16550_UART2_BAUD,
|
.baud = CONFIG_16550_UART2_BAUD,
|
||||||
.uartclk = CONFIG_16550_UART2_CLOCK,
|
.uartclk = CONFIG_16550_UART2_CLOCK,
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
.irq = CONFIG_16550_UART2_IRQ,
|
.irq = CONFIG_16550_UART2_IRQ,
|
||||||
#endif
|
|
||||||
#ifndef CONFIG_16550_SUPRESS_CONFIG
|
#ifndef CONFIG_16550_SUPRESS_CONFIG
|
||||||
.parity = CONFIG_16550_UART2_PARITY,
|
.parity = CONFIG_16550_UART2_PARITY,
|
||||||
.bits = CONFIG_16550_UART2_BITS,
|
.bits = CONFIG_16550_UART2_BITS,
|
||||||
@ -268,9 +258,7 @@ static struct u16550_s g_uart3priv =
|
|||||||
.baud = CONFIG_16550_UART3_BAUD,
|
.baud = CONFIG_16550_UART3_BAUD,
|
||||||
.uartclk = CONFIG_16550_UART3_CLOCK,
|
.uartclk = CONFIG_16550_UART3_CLOCK,
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
.irq = CONFIG_16550_UART3_IRQ,
|
.irq = CONFIG_16550_UART3_IRQ,
|
||||||
#endif
|
|
||||||
#ifndef CONFIG_16550_SUPRESS_CONFIG
|
#ifndef CONFIG_16550_SUPRESS_CONFIG
|
||||||
.parity = CONFIG_16550_UART3_PARITY,
|
.parity = CONFIG_16550_UART3_PARITY,
|
||||||
.bits = CONFIG_16550_UART3_BITS,
|
.bits = CONFIG_16550_UART3_BITS,
|
||||||
@ -483,7 +471,6 @@ static inline void u16550_serialout(FAR struct u16550_s *priv, int offset,
|
|||||||
* Name: u16550_disableuartint
|
* Name: u16550_disableuartint
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
static inline void u16550_disableuartint(FAR struct u16550_s *priv,
|
static inline void u16550_disableuartint(FAR struct u16550_s *priv,
|
||||||
FAR uart_datawidth_t *ier)
|
FAR uart_datawidth_t *ier)
|
||||||
{
|
{
|
||||||
@ -495,23 +482,16 @@ static inline void u16550_disableuartint(FAR struct u16550_s *priv,
|
|||||||
priv->ier &= ~UART_IER_ALLIE;
|
priv->ier &= ~UART_IER_ALLIE;
|
||||||
u16550_serialout(priv, UART_IER_OFFSET, priv->ier);
|
u16550_serialout(priv, UART_IER_OFFSET, priv->ier);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# define u16550_disableuartint(priv,ier)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: u16550_restoreuartint
|
* Name: u16550_restoreuartint
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
static inline void u16550_restoreuartint(FAR struct u16550_s *priv, uint32_t ier)
|
static inline void u16550_restoreuartint(FAR struct u16550_s *priv, uint32_t ier)
|
||||||
{
|
{
|
||||||
priv->ier |= ier & UART_IER_ALLIE;
|
priv->ier |= ier & UART_IER_ALLIE;
|
||||||
u16550_serialout(priv, UART_IER_OFFSET, priv->ier);
|
u16550_serialout(priv, UART_IER_OFFSET, priv->ier);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# define u16550_restoreuartint(priv,ier)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: u16550_enablebreaks
|
* Name: u16550_enablebreaks
|
||||||
@ -586,9 +566,7 @@ static int u16550_setup(struct uart_dev_s *dev)
|
|||||||
|
|
||||||
/* Set up the IER */
|
/* Set up the IER */
|
||||||
|
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
priv->ier = u16550_serialin(priv, UART_IER_OFFSET);
|
priv->ier = u16550_serialin(priv, UART_IER_OFFSET);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set up the LCR */
|
/* Set up the LCR */
|
||||||
|
|
||||||
@ -682,13 +660,12 @@ static void u16550_shutdown(struct uart_dev_s *dev)
|
|||||||
|
|
||||||
static int u16550_attach(struct uart_dev_s *dev)
|
static int u16550_attach(struct uart_dev_s *dev)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
|
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Attach and enable the IRQ */
|
/* Attach and enable the IRQ */
|
||||||
|
|
||||||
ret = irq_attach(priv->irq, u16550_interrupt, NULL);
|
ret = irq_attach(priv->irq, u16550_interrupt, dev);
|
||||||
#ifndef CONFIG_ARCH_NOINTC
|
#ifndef CONFIG_ARCH_NOINTC
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
@ -700,9 +677,6 @@ static int u16550_attach(struct uart_dev_s *dev)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
|
||||||
return OK;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -717,13 +691,10 @@ static int u16550_attach(struct uart_dev_s *dev)
|
|||||||
|
|
||||||
static void u16550_detach(FAR struct uart_dev_s *dev)
|
static void u16550_detach(FAR struct uart_dev_s *dev)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
|
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
|
||||||
#ifndef CONFIG_ARCH_NOINTC
|
|
||||||
up_disable_irq(priv->irq);
|
up_disable_irq(priv->irq);
|
||||||
#endif
|
|
||||||
irq_detach(priv->irq);
|
irq_detach(priv->irq);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -738,42 +709,14 @@ static void u16550_detach(FAR struct uart_dev_s *dev)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
static int u16550_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||||
static int u16550_interrupt(int irq, void *context, FAR void *arg)
|
|
||||||
{
|
{
|
||||||
struct uart_dev_s *dev = NULL;
|
struct uart_dev_s *dev = (struct uart_dev_s *)arg;
|
||||||
struct u16550_s *priv;
|
struct u16550_s *priv;
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
int passes;
|
int passes;
|
||||||
|
|
||||||
#ifdef CONFIG_16550_UART0
|
DEBUGASSERT(dev != NULL && dev->priv != NULL);
|
||||||
if (g_uart0priv.irq == irq)
|
|
||||||
{
|
|
||||||
dev = &g_uart0port;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_16550_UART1
|
|
||||||
if (g_uart1priv.irq == irq)
|
|
||||||
{
|
|
||||||
dev = &g_uart1port;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_16550_UART2
|
|
||||||
if (g_uart2priv.irq == irq)
|
|
||||||
{
|
|
||||||
dev = &g_uart2port;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_16550_UART3
|
|
||||||
if (g_uart3priv.irq == irq)
|
|
||||||
{
|
|
||||||
dev = &g_uart3port;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ASSERT(dev != NULL);
|
|
||||||
priv = (FAR struct u16550_s *)dev->priv;
|
priv = (FAR struct u16550_s *)dev->priv;
|
||||||
|
|
||||||
/* Loop until there are no characters to be transferred or,
|
/* Loop until there are no characters to be transferred or,
|
||||||
@ -856,7 +799,6 @@ static int u16550_interrupt(int irq, void *context, FAR void *arg)
|
|||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: u16550_ioctl
|
* Name: u16550_ioctl
|
||||||
@ -959,7 +901,6 @@ static int u16550_receive(struct uart_dev_s *dev, uint32_t *status)
|
|||||||
|
|
||||||
static void u16550_rxint(struct uart_dev_s *dev, bool enable)
|
static void u16550_rxint(struct uart_dev_s *dev, bool enable)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
|
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
@ -969,8 +910,8 @@ static void u16550_rxint(struct uart_dev_s *dev, bool enable)
|
|||||||
{
|
{
|
||||||
priv->ier &= ~UART_IER_ERBFI;
|
priv->ier &= ~UART_IER_ERBFI;
|
||||||
}
|
}
|
||||||
|
|
||||||
u16550_serialout(priv, UART_IER_OFFSET, priv->ier);
|
u16550_serialout(priv, UART_IER_OFFSET, priv->ier);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -1011,7 +952,6 @@ static void u16550_send(struct uart_dev_s *dev, int ch)
|
|||||||
|
|
||||||
static void u16550_txint(struct uart_dev_s *dev, bool enable)
|
static void u16550_txint(struct uart_dev_s *dev, bool enable)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
|
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
@ -1034,7 +974,6 @@ static void u16550_txint(struct uart_dev_s *dev, bool enable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -1161,11 +1100,9 @@ void up_serialinit(void)
|
|||||||
int up_putc(int ch)
|
int up_putc(int ch)
|
||||||
{
|
{
|
||||||
FAR struct u16550_s *priv = (FAR struct u16550_s *)CONSOLE_DEV.priv;
|
FAR struct u16550_s *priv = (FAR struct u16550_s *)CONSOLE_DEV.priv;
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
uart_datawidth_t ier;
|
uart_datawidth_t ier;
|
||||||
|
|
||||||
u16550_disableuartint(priv, &ier);
|
u16550_disableuartint(priv, &ier);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Check for LF */
|
/* Check for LF */
|
||||||
|
|
||||||
@ -1177,9 +1114,7 @@ int up_putc(int ch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
u16550_putc(priv, ch);
|
u16550_putc(priv, ch);
|
||||||
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
|
|
||||||
u16550_restoreuartint(priv, ier);
|
u16550_restoreuartint(priv, ier);
|
||||||
#endif
|
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -66,7 +66,8 @@
|
|||||||
|
|
||||||
struct vs1053_lower_s
|
struct vs1053_lower_s
|
||||||
{
|
{
|
||||||
int (*attach)(FAR const struct vs1053_lower_s *lower, xcpt_t handler);
|
int (*attach)(FAR const struct vs1053_lower_s *lower, xcpt_t handler,
|
||||||
|
FAR void *arg);
|
||||||
void (*enable)(FAR const struct vs1053_lower_s *lower);
|
void (*enable)(FAR const struct vs1053_lower_s *lower);
|
||||||
void (*disable)(FAR const struct vs1053_lower_s *lower);
|
void (*disable)(FAR const struct vs1053_lower_s *lower);
|
||||||
void (*reset)(FAR const struct vs1053_lower_s *lower, bool state);
|
void (*reset)(FAR const struct vs1053_lower_s *lower, bool state);
|
||||||
|
Loading…
Reference in New Issue
Block a user