Common driver base abstract class.
oop_base_object.xml
Enables the mutual exclusion APIs on driver instances.
Disabling this option saves both code and data space.
Enables the HAL registry for drivers.
Disabling this option saves both code and data space.
Type of a driver state variable.
Type of a registry entry structure.
Structure representing a registry entry.
Next entry in the drivers registry.
Previous entry in the drivers registry.
Ancestor class of stateful HAL drivers.
Driver state.
Associated configuration structure.
Driver argument.
Driver mutex.
Driver identifier.
Driver name.
Registry link structure.
state = HAL_DRV_STATE_STOP;
self->arg = NULL;
self->config = NULL;
osalMutexObjectInit(&self->mutex);
#if HAL_USE_REGISTRY == TRUE
self->id = 0U;
self->name = "unk";
drv_reg_insert(self);
#endif]]>
Low level driver start.
The operation status.
Low level driver stop.
Performs driver configuration.
New driver
configuration.
The configuration pointer.
If the configuration has been rejected.
Driver start.
The operation status.
Operation successful.
If a required resources
cannot be allocated.
If a required HW resource is
already in use.
If an HW failure occurred.
state) {
case HAL_DRV_STATE_UNINIT:
/* Falls through.*/
case HAL_DRV_STATE_STARTING:
/* Falls through.*/
case HAL_DRV_STATE_STOPPING:
msg = HAL_RET_INV_STATE;
break;
case HAL_DRV_STATE_STOP:
/* Physically starting the peripheral.*/
msg = __drv_start(self);
if (msg == HAL_RET_SUCCESS) {
self->state = HAL_DRV_STATE_READY;
/* LLD is supposed to set a default configuration.*/
osalDbgAssert(self->config != NULL, "no configuration");
}
else {
self->state = HAL_DRV_STATE_STOP;
}
default:
/* Any other state ignored, driver already started.*/
break;
}
osalSysUnlock();
return msg;]]>
Driver close.
state != HAL_DRV_STATE_UNINIT, "invalid state");
if ((self->state != HAL_DRV_STATE_STOP) &&
(self->state != HAL_DRV_STATE_STARTING)) {
__drv_stop(self);
self->state = HAL_DRV_STATE_STOP;
self->config = NULL;
}
osalSysUnlock();]]>
Driver configure.
New driver
configuration.
msg_t msg;
osalSysLock();
osalDbgAssert(self->state != HAL_DRV_STATE_UNINIT, "invalid state");
self->config = __drv_do_configure(self, config);
if (self->config == NULL) {
msg = HAL_RET_CONFIG_ERROR;
}
else {
msg = HAL_RET_SUCCESS;
}
osalSysUnlock();
return msg;
Driver state get.
The driver state.
state;]]>
Driver state set.
New driver
state.
state = state;]]>
Driver argument get.
The driver argument.
arg;]]>
Driver argument set.
New driver argument.
arg = arg;]]>
Driver name get.
Returns "unk" if registry is disabled.
The driver name.
name;
#else
return "unk";
#endif]]>
Driver name set.
Does nothing if registry is disabled.
New driver name.
name = name;
#else
(void)name;
#endif]]>
Driver lock.
mutex);]]>
Driver unlock.
mutex);]]>
List header for the HAL registry
Drivers manager initialization.
Return the first driver in the HAL registry.
A pointer to the first driver object.
If the registry is empty.
Return the next driver in the HAL registry.
This function is only available when HAL registry is enabled.
Previously
found driver.
A pointer to the next driver object.
If there is no next driver.
regent.next;
if (rep == &hal_registry) {
return NULL;
}
return oopGetOwner(hal_base_driver_c, regent, rep);]]>
Driver open by name.
This function is only available when HAL registry is enabled.
Driver name.
Pointer to store the
error code or @p NULL. Note that in case of
driver not found the
returned code is @p HAL_RET_SUCCESS.
A reference to the driver.
If an error occurred.
string.h
hal.h
Driver insertion in the HAL registry.
This function is only available when HAL registry is enabled.
Pointer to
the @p hal_base_driver_c instance to be inserted.
regent.next = &hal_registry;
drvp->regent.prev = hal_registry.prev;
drvp->regent.prev->next = &drvp->regent;
hal_registry.prev = &drvp->regent;]]>
Driver removal from the HAL registry.
Pointer to
the @p hal_base_driver_c instance to be inserted.
regent.prev->next = drvp->regent.next;
drvp->regent.next->prev = drvp->regent.prev;
]]>