Use sensible return convention for platform_target_get_power()

This commit is contained in:
Gareth McMullin 2015-02-28 21:23:24 -08:00
parent 1b2cd547bc
commit 5d136398e1
2 changed files with 7 additions and 4 deletions

View File

@ -234,7 +234,7 @@ static bool cmd_target_power(target *t, int argc, const char **argv)
(void)t; (void)t;
if (argc == 1) if (argc == 1)
gdb_outf("Target Power: %s\n", gdb_outf("Target Power: %s\n",
!platform_target_get_power() ? "enabled" : "disabled"); platform_target_get_power() ? "enabled" : "disabled");
else else
platform_target_set_power(!strncmp(argv[1], "enable", strlen(argv[1]))); platform_target_set_power(!strncmp(argv[1], "enable", strlen(argv[1])));
return true; return true;

View File

@ -158,12 +158,15 @@ void platform_srst_set_val(bool assert)
gpio_set_val(SRST_PORT, SRST_PIN, !assert); gpio_set_val(SRST_PORT, SRST_PIN, !assert);
} }
} }
bool platform_target_get_power(void) {
bool platform_target_get_power(void)
{
if (platform_hwversion() > 0) { if (platform_hwversion() > 0) {
return gpio_get(PWR_BR_PORT, PWR_BR_PIN); return !gpio_get(PWR_BR_PORT, PWR_BR_PIN);
} }
return 1; /* 1 = Unpowered */ return 0;
} }
void platform_target_set_power(bool power) void platform_target_set_power(bool power)
{ {
if (platform_hwversion() > 0) { if (platform_hwversion() > 0) {