drivers: serial: serial_test: support IRQ callback user data
This driver previously caused an assertion error if non-NULL user_data was passed to uart_irq_callback_set. Add support for this by storing the user data and passing it back to the IRQ callback function. Signed-off-by: Robert Hancock <robert.hancock@calian.com>
This commit is contained in:
parent
c2b408df9b
commit
c3f9e6d1ba
1 changed files with 3 additions and 6 deletions
|
@ -31,6 +31,7 @@ struct serial_vnd_data {
|
||||||
void *callback_data;
|
void *callback_data;
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
uart_irq_callback_user_data_t irq_isr;
|
uart_irq_callback_user_data_t irq_isr;
|
||||||
|
void *irq_isr_user_data;
|
||||||
bool irq_rx_enabled;
|
bool irq_rx_enabled;
|
||||||
bool irq_tx_enabled;
|
bool irq_tx_enabled;
|
||||||
#endif
|
#endif
|
||||||
|
@ -80,7 +81,7 @@ static void irq_process(const struct device *dev)
|
||||||
LOG_ERR("no isr registered");
|
LOG_ERR("no isr registered");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
data->irq_isr(dev, NULL);
|
data->irq_isr(dev, data->irq_isr_user_data);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,11 +142,6 @@ static void irq_callback_set(const struct device *dev, uart_irq_callback_user_da
|
||||||
{
|
{
|
||||||
struct serial_vnd_data *data = dev->data;
|
struct serial_vnd_data *data = dev->data;
|
||||||
|
|
||||||
/* Not implemented. Ok because `user_data` is always NULL in the current
|
|
||||||
* implementation of core UART API.
|
|
||||||
*/
|
|
||||||
__ASSERT_NO_MSG(user_data == NULL);
|
|
||||||
|
|
||||||
#if defined(CONFIG_UART_EXCLUSIVE_API_CALLBACKS) && defined(CONFIG_UART_ASYNC_API)
|
#if defined(CONFIG_UART_EXCLUSIVE_API_CALLBACKS) && defined(CONFIG_UART_ASYNC_API)
|
||||||
if (data->read_buf) {
|
if (data->read_buf) {
|
||||||
LOG_ERR("Setting callback to NULL while asynchronous API is in use.");
|
LOG_ERR("Setting callback to NULL while asynchronous API is in use.");
|
||||||
|
@ -155,6 +151,7 @@ static void irq_callback_set(const struct device *dev, uart_irq_callback_user_da
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data->irq_isr = cb;
|
data->irq_isr = cb;
|
||||||
|
data->irq_isr_user_data = user_data;
|
||||||
LOG_DBG("callback set");
|
LOG_DBG("callback set");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue