target: Added target clock tristating to the target attach and detach functions

This commit is contained in:
dragonmux 2022-08-10 01:30:05 +01:00 committed by Piotr Esden-Tempski
parent d4d6218234
commit 8cf1d2f09c
1 changed files with 6 additions and 3 deletions

View File

@ -185,9 +185,12 @@ target *target_attach(target *t, struct target_controller *tc)
t->tc->destroy_callback(t->tc, t);
t->tc = tc;
platform_target_clk_output_enable(true);
if (!t->attach(t))
if (!t->attach(t)) {
platform_target_clk_output_enable(false);
return NULL;
}
t->attached = true;
return t;
@ -378,6 +381,7 @@ void target_print_progress(platform_timeout *const timeout)
void target_detach(target *t)
{
t->detach(t);
platform_target_clk_output_enable(false);
t->attached = false;
#if PC_HOSTED == 1
platform_buffer_flush();
@ -387,7 +391,6 @@ void target_detach(target *t)
bool target_check_error(target *t) {
if (t)
return t->check_error(t);
else
return false;
}