refactoring

This commit is contained in:
bernd-herzog 2023-05-05 12:58:28 +02:00
parent e80e4e3bfd
commit df8e79f9e6
2 changed files with 11 additions and 5 deletions

View File

@ -33,7 +33,7 @@
namespace portapack { namespace portapack {
namespace cpld { namespace cpld {
uint32_t update_if_necessary( CpldUpdateStatus update_if_necessary(
const Config config const Config config
) { ) {
jtag::GPIOTarget target { jtag::GPIOTarget target {
@ -51,7 +51,7 @@ uint32_t update_if_necessary(
/* Run-Test/Idle */ /* Run-Test/Idle */
if( !cpld.idcode_ok() ) { if( !cpld.idcode_ok() ) {
return 1; return CpldUpdateStatus::Idcode_check_failed;
} }
cpld.sample(); cpld.sample();
@ -62,7 +62,7 @@ uint32_t update_if_necessary(
* in passive state. * in passive state.
*/ */
if( !cpld.silicon_id_ok() ) { if( !cpld.silicon_id_ok() ) {
return 2; return CpldUpdateStatus::Silicon_id_check_failed;
} }
/* Verify CPLD contents against current bitstream. */ /* Verify CPLD contents against current bitstream. */
@ -86,7 +86,7 @@ uint32_t update_if_necessary(
cpld.disable(); cpld.disable();
} }
return ok ? 0 : 3; return ok ? CpldUpdateStatus::Success : CpldUpdateStatus::Program_failed;
} }
} /* namespace cpld */ } /* namespace cpld */

View File

@ -27,8 +27,14 @@
namespace portapack { namespace portapack {
namespace cpld { namespace cpld {
enum class CpldUpdateStatus {
Success = 0,
Idcode_check_failed = 1,
Silicon_id_check_failed = 2,
Program_failed = 3
};
uint32_t update_if_necessary( CpldUpdateStatus update_if_necessary(
const Config config const Config config
); );