diff --git a/os/xhal/codegen/hal_cb_driver.xml b/os/xhal/codegen/hal_cb_driver.xml
new file mode 100644
index 000000000..b0fafdb14
--- /dev/null
+++ b/os/xhal/codegen/hal_cb_driver.xml
@@ -0,0 +1,58 @@
+
+
+ Common ancestor of callback-based drivers
+
+ hal_base_driver.xml
+
+
+
+
+ Generic HAL notification callback type.
+
+
+
+ Class of a callback-based driver.
+
+
+ Driver callback.
+ Can be @p NULL.
+
+
+
+
+ cb = NULL;]]>
+
+
+
+
+
+
+ Associates a callback to the driver instance.
+
+ Callback function to be associated. Passing @p NULL disables the
+ existing callback, if any.
+ cb = cb;]]>
+
+
+ Returns the callback associated to the driver instance.
+ cb;]]>
+
+
+
+
+
+
+
+
+ hal.h
+
+
+
\ No newline at end of file
diff --git a/os/xhal/codegen/modules.xml b/os/xhal/codegen/modules.xml
index 0df0c791f..b6863e6d5 100644
--- a/os/xhal/codegen/modules.xml
+++ b/os/xhal/codegen/modules.xml
@@ -1,6 +1,7 @@
+
@@ -13,6 +14,7 @@
&hal_base_driver;
+ &hal_cb_driver;
&hal_channels;
&hal_block_io;
&hal_buffered_serial;
diff --git a/os/xhal/include/hal.h b/os/xhal/include/hal.h
index 6b366e5b0..87daa1721 100644
--- a/os/xhal/include/hal.h
+++ b/os/xhal/include/hal.h
@@ -292,10 +292,8 @@ static inline halfreq_t halClockGetPointX(halclkpt_t clkpt) {
#include "oop_base_interface.h"
#include "oop_sequential_stream.h"
#include "hal_base_driver.h"
-//#include "hal_objects.h"
-//#include "hal_streams.h"
+#include "hal_cb_driver.h"
#include "hal_channels.h"
-//#include "hal_files.h"
#include "hal_block_io.h"
//#include "hal_mmcsd.h"
//#include "hal_persistent.h"
diff --git a/os/xhal/include/hal_cb_driver.h b/os/xhal/include/hal_cb_driver.h
new file mode 100644
index 000000000..14b43f985
--- /dev/null
+++ b/os/xhal/include/hal_cb_driver.h
@@ -0,0 +1,184 @@
+/*
+ ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file hal_cb_driver.h
+ * @brief Generated Callback Driver header.
+ * @note This is a generated file, do not edit directly.
+ *
+ * @addtogroup HAL_CB_DRIVER
+ * @brief Common ancestor of callback-based drivers.
+ * @{
+ */
+
+#ifndef HAL_CB_DRIVER_H
+#define HAL_CB_DRIVER_H
+
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Generic HAL notification callback type.
+ */
+typedef void (*hal_cb_t)(void *ip);
+
+/**
+ * @class hal_cb_driver_c
+ * @extends base_object_c, hal_base_driver_c.
+ *
+ * @brief Class of a callback-based driver.
+ *
+ * @name Class @p hal_cb_driver_c structures
+ * @{
+ */
+
+/**
+ * @brief Type of a callback driver class.
+ */
+typedef struct hal_cb_driver hal_cb_driver_c;
+
+/**
+ * @brief Class @p hal_cb_driver_c virtual methods table.
+ */
+struct hal_cb_driver_vmt {
+ /* From base_object_c.*/
+ void (*dispose)(void *ip);
+ /* From hal_base_driver_c.*/
+ msg_t (*start)(void *ip);
+ void (*stop)(void *ip);
+ msg_t (*configure)(void *ip, const void *config);
+ /* From hal_cb_driver_c.*/
+};
+
+/**
+ * @brief Structure representing a callback driver class.
+ */
+struct hal_cb_driver {
+ /**
+ * @brief Virtual Methods Table.
+ */
+ const struct hal_cb_driver_vmt *vmt;
+ /**
+ * @brief Driver state.
+ */
+ driver_state_t state;
+ /**
+ * @brief Driver argument.
+ */
+ void *arg;
+#if (HAL_USE_MUTUAL_EXCLUSION == TRUE) || defined (__DOXYGEN__)
+ /**
+ * @brief Driver mutex.
+ */
+ mutex_t mutex;
+#endif /* HAL_USE_MUTUAL_EXCLUSION == TRUE */
+#if (HAL_USE_REGISTRY == TRUE) || defined (__DOXYGEN__)
+ /**
+ * @brief Driver identifier.
+ */
+ unsigned int id;
+ /**
+ * @brief Driver name.
+ */
+ const char *name;
+ /**
+ * @brief Registry link structure.
+ */
+ hal_regent_t regent;
+#endif /* HAL_USE_REGISTRY == TRUE */
+ /**
+ * @brief Driver callback.
+ * @note Can be @p NULL.
+ */
+ hal_cb_t cb;
+};
+/** @} */
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ /* Methods of hal_cb_driver_c.*/
+ void *__cbdrv_objinit_impl(void *ip, const void *vmt);
+ void __cbdrv_dispose_impl(void *ip);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
+/**
+ * @name Inline methods of hal_cb_driver_c
+ * @{
+ */
+/**
+ * @memberof hal_cb_driver_c
+ * @public
+ *
+ * @brief Associates a callback to the driver instance.
+ *
+ * @param[in,out] ip Pointer to a @p hal_cb_driver_c instance.
+ * @param cb Callback function to be associated. Passing @p
+ * NULL disables the existing callback, if any.
+ */
+CC_FORCE_INLINE
+static inline void drvSetCallback(void *ip, hal_cb_t cb) {
+ hal_cb_driver_c *self = (hal_cb_driver_c *)ip;
+
+ self->cb = cb;
+}
+
+/**
+ * @memberof hal_cb_driver_c
+ * @public
+ *
+ * @brief Returns the callback associated to the driver instance.
+ *
+ * @param[in,out] ip Pointer to a @p hal_cb_driver_c instance.
+ */
+CC_FORCE_INLINE
+static inline hal_cb_t drvGetCallback(void *ip) {
+ hal_cb_driver_c *self = (hal_cb_driver_c *)ip;
+
+ return self->cb;
+}
+/** @} */
+
+#endif /* HAL_CB_DRIVER_H */
+
+/** @} */
diff --git a/os/xhal/src/hal_cb_driver.c b/os/xhal/src/hal_cb_driver.c
new file mode 100644
index 000000000..c720aa028
--- /dev/null
+++ b/os/xhal/src/hal_cb_driver.c
@@ -0,0 +1,109 @@
+/*
+ ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file hal_cb_driver.c
+ * @brief Generated Callback Driver source.
+ * @note This is a generated file, do not edit directly.
+ *
+ * @addtogroup HAL_CB_DRIVER
+ * @{
+ */
+
+#include "hal.h"
+
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module class "hal_cb_driver_c" methods. */
+/*===========================================================================*/
+
+/**
+ * @name Methods implementations of hal_cb_driver_c
+ * @{
+ */
+/**
+ * @memberof hal_cb_driver_c
+ * @protected
+ *
+ * @brief Implementation of object creation.
+ * @note This function is meant to be used by derived classes.
+ *
+ * @param[out] ip Pointer to a @p hal_cb_driver_c instance to be
+ * initialized.
+ * @param[in] vmt VMT pointer for the new object.
+ * @return A new reference to the object.
+ */
+void *__cbdrv_objinit_impl(void *ip, const void *vmt) {
+ hal_cb_driver_c *self = (hal_cb_driver_c *)ip;
+
+ /* Initialization of the ancestors-defined parts.*/
+ __drv_objinit_impl(self, vmt);
+
+ /* Initialization code.*/
+ self->cb = NULL;
+
+ return self;
+}
+
+/**
+ * @memberof hal_cb_driver_c
+ * @protected
+ *
+ * @brief Implementation of object finalization.
+ * @note This function is meant to be used by derived classes.
+ *
+ * @param[in,out] ip Pointer to a @p hal_cb_driver_c instance to be
+ * disposed.
+ */
+void __cbdrv_dispose_impl(void *ip) {
+ hal_cb_driver_c *self = (hal_cb_driver_c *)ip;
+
+ /* No finalization code.*/
+ (void)self;
+
+ /* Finalization of the ancestors-defined parts.*/
+ __drv_dispose_impl(self);
+}
+/** @} */
+
+/** @} */