serial: allow callback setting to be exclusive
Both the IRQ API and Asynchronous API support callback. However, since they are both interrupt driven, having callbacks on both API would interfere with each other in almost all cases. So this adds a kconfig to signal that the callbacks should be exclusive to each other. In other words, if one is set, the other should not be active. Drivers implementing both APIs have been updated to remove the callbacks from the other API. Though, this still leaves the option to disable the kconfig and allows both APIs to have callbacks if one desires. Fixes #48606 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
bbbc28a0ba
commit
9f02eeadf8
10 changed files with 106 additions and 0 deletions
|
@ -904,6 +904,11 @@ static void uart_stm32_irq_callback_set(const struct device *dev,
|
|||
|
||||
data->user_cb = cb;
|
||||
data->user_data = cb_data;
|
||||
|
||||
#if defined(CONFIG_UART_EXCLUSIVE_API_CALLBACKS)
|
||||
data->async_cb = NULL;
|
||||
data->async_user_data = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
|
@ -1125,6 +1130,11 @@ static int uart_stm32_async_callback_set(const struct device *dev,
|
|||
data->async_cb = callback;
|
||||
data->async_user_data = user_data;
|
||||
|
||||
#if defined(CONFIG_UART_EXCLUSIVE_API_CALLBACKS)
|
||||
data->user_cb = NULL;
|
||||
data->user_data = NULL;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue