You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
7 years ago
|
//
|
||
|
// Created by MightyPork on 2017/11/24.
|
||
|
//
|
||
|
|
||
|
#include "platform.h"
|
||
|
#include "unit.h"
|
||
|
#include "resources.h"
|
||
|
|
||
|
// Abort partly inited unit
|
||
|
void clean_failed_unit(Unit *unit)
|
||
|
{
|
||
|
if (unit == NULL) return;
|
||
|
|
||
|
dbg("!! Init of [%s] failed!", unit->name);
|
||
|
|
||
|
// Free if it looks like it might've been allocated
|
||
|
if (isDynAlloc(unit->data)) {
|
||
|
dbg("Freeing allocated unit data");
|
||
|
free(unit->data);
|
||
|
unit->data = NULL;
|
||
|
}
|
||
|
if (isDynAlloc(unit->name)) {
|
||
|
dbg("Freeing allocated name");
|
||
|
free((void *) unit->name);
|
||
|
unit->name = NULL;
|
||
|
}
|
||
|
|
||
|
dbg("Releasing any held resources");
|
||
|
// Release any already claimed resources
|
||
|
rsc_teardown(unit);
|
||
|
}
|
||
|
|
||
|
// ----------------------------------------------------
|
||
|
|
||
|
// system unit is used to claim peripherals on behalf of the system (e.g. HAL tick source)
|
||
|
Unit UNIT_SYSTEM = {
|
||
|
.name = "SYSTEM"
|
||
|
};
|
||
|
|
||
|
// ----------------------------------------------------
|
||
|
|
||
|
// platform unit is used to claim peripherals not present on the current platform
|
||
|
Unit UNIT_PLATFORM = {
|
||
|
.name = "PLATFORM"
|
||
|
};
|
||
|
|
||
|
// ----------------------------------------------------
|