Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bernd-herzog committed May 5, 2023
1 parent e80e4e3 commit df8e79f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions firmware/common/cpld_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
namespace portapack {
namespace cpld {

uint32_t update_if_necessary(
CpldUpdateStatus update_if_necessary(
const Config config
) {
jtag::GPIOTarget target {
Expand All @@ -51,7 +51,7 @@ uint32_t update_if_necessary(

/* Run-Test/Idle */
if( !cpld.idcode_ok() ) {
return 1;
return CpldUpdateStatus::Idcode_check_failed;
}

cpld.sample();
Expand All @@ -62,7 +62,7 @@ uint32_t update_if_necessary(
* in passive state.
*/
if( !cpld.silicon_id_ok() ) {
return 2;
return CpldUpdateStatus::Silicon_id_check_failed;
}

/* Verify CPLD contents against current bitstream. */
Expand All @@ -86,7 +86,7 @@ uint32_t update_if_necessary(
cpld.disable();
}

return ok ? 0 : 3;
return ok ? CpldUpdateStatus::Success : CpldUpdateStatus::Program_failed;
}

} /* namespace cpld */
Expand Down
10 changes: 8 additions & 2 deletions firmware/common/cpld_update.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@
namespace portapack {
namespace cpld {


uint32_t update_if_necessary(
enum class CpldUpdateStatus {
Success = 0,
Idcode_check_failed = 1,
Silicon_id_check_failed = 2,
Program_failed = 3
};

CpldUpdateStatus update_if_necessary(
const Config config
);

Expand Down

0 comments on commit df8e79f

Please sign in to comment.