Merge pull request #1693 from blckmn/tag_output

Minor clean up of port / pin output in Resource command.
This commit is contained in:
Michael Keller 2016-11-29 10:34:41 +13:00 committed by GitHub
commit c120e702de
2 changed files with 16 additions and 18 deletions

View File

@ -50,6 +50,8 @@ uint16_t IO_Pin(IO_t io);
#define IO_GPIOBYTAG(tag) IO_GPIO(IOGetByTag(tag)) #define IO_GPIOBYTAG(tag) IO_GPIO(IOGetByTag(tag))
#define IO_PINBYTAG(tag) IO_Pin(IOGetByTag(tag)) #define IO_PINBYTAG(tag) IO_Pin(IOGetByTag(tag))
#define IO_GPIOPortIdxByTag(tag) DEFIO_TAG_GPIOID(tag)
#define IO_GPIOPinIdxByTag(tag) DEFIO_TAG_PIN(tag)
uint32_t IO_EXTI_Line(IO_t io); uint32_t IO_EXTI_Line(IO_t io);
ioRec_t *IO_Rec(IO_t io); ioRec_t *IO_Rec(IO_t io);

View File

@ -3811,47 +3811,43 @@ static void printResource(uint8_t dumpMask, master_t *defaultConfig)
if (resourceTable[i].maxIndex > 0) { if (resourceTable[i].maxIndex > 0) {
for (int index = 0; index < resourceTable[i].maxIndex; index++) { for (int index = 0; index < resourceTable[i].maxIndex; index++) {
ioTag_t ioPtr = *(resourceTable[i].ptr + index); ioTag_t ioTag = *(resourceTable[i].ptr + index);
ioTag_t ioPtrDefault = *(resourceTable[i].ptr + index - (uint32_t)&masterConfig + (uint32_t)defaultConfig); ioTag_t ioTagDefault = *(resourceTable[i].ptr + index - (uint32_t)&masterConfig + (uint32_t)defaultConfig);
IO_t io = IOGetByTag(ioPtr); bool equalsDefault = ioTag == ioTagDefault;
IO_t ioDefault = IOGetByTag(ioPtrDefault);
bool equalsDefault = io == ioDefault;
const char *format = "resource %s %d %c%02d\r\n"; const char *format = "resource %s %d %c%02d\r\n";
const char *formatUnassigned = "resource %s %d NONE\r\n"; const char *formatUnassigned = "resource %s %d NONE\r\n";
if (DEFIO_TAG_ISEMPTY(ioDefault)) { if (!ioTagDefault) {
cliDefaultPrintf(dumpMask, equalsDefault, formatUnassigned, owner, RESOURCE_INDEX(index)); cliDefaultPrintf(dumpMask, equalsDefault, formatUnassigned, owner, RESOURCE_INDEX(index));
} else { } else {
cliDefaultPrintf(dumpMask, equalsDefault, format, owner, RESOURCE_INDEX(index), IO_GPIOPortIdx(ioDefault) + 'A', IO_GPIOPinIdx(ioDefault)); cliDefaultPrintf(dumpMask, equalsDefault, format, owner, RESOURCE_INDEX(index), IO_GPIOPortIdxByTag(ioTagDefault) + 'A', IO_GPIOPinIdxByTag(ioTagDefault));
} }
if (DEFIO_TAG_ISEMPTY(io)) { if (!ioTag) {
if (!(dumpMask & HIDE_UNUSED)) { if (!(dumpMask & HIDE_UNUSED)) {
cliDumpPrintf(dumpMask, equalsDefault, formatUnassigned, owner, RESOURCE_INDEX(index)); cliDumpPrintf(dumpMask, equalsDefault, formatUnassigned, owner, RESOURCE_INDEX(index));
} }
} else { } else {
cliDumpPrintf(dumpMask, equalsDefault, format, owner, RESOURCE_INDEX(index), IO_GPIOPortIdx(io) + 'A', IO_GPIOPinIdx(io)); cliDumpPrintf(dumpMask, equalsDefault, format, owner, RESOURCE_INDEX(index), IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag));
} }
} }
} else { } else {
ioTag_t ioPtr = *resourceTable[i].ptr; ioTag_t ioTag = *resourceTable[i].ptr;
ioTag_t ioPtrDefault = *(resourceTable[i].ptr - (uint32_t)&masterConfig + (uint32_t)defaultConfig); ioTag_t ioTagDefault = *(resourceTable[i].ptr - (uint32_t)&masterConfig + (uint32_t)defaultConfig);
IO_t io = IOGetByTag(ioPtr); bool equalsDefault = ioTag == ioTagDefault;
IO_t ioDefault = IOGetByTag(ioPtrDefault);
bool equalsDefault = io == ioDefault;
const char *format = "resource %s %c%02d\r\n"; const char *format = "resource %s %c%02d\r\n";
const char *formatUnassigned = "resource %s NONE\r\n"; const char *formatUnassigned = "resource %s NONE\r\n";
if (DEFIO_TAG_ISEMPTY(ioDefault)) { if (!ioTagDefault) {
cliDefaultPrintf(dumpMask, equalsDefault, formatUnassigned, owner); cliDefaultPrintf(dumpMask, equalsDefault, formatUnassigned, owner);
} else { } else {
cliDefaultPrintf(dumpMask, equalsDefault, format, owner, IO_GPIOPortIdx(ioDefault) + 'A', IO_GPIOPinIdx(ioDefault)); cliDefaultPrintf(dumpMask, equalsDefault, format, owner, IO_GPIOPortIdxByTag(ioTagDefault) + 'A', IO_GPIOPinIdxByTag(ioTagDefault));
} }
if (DEFIO_TAG_ISEMPTY(io)) { if (!ioTag) {
if (!(dumpMask & HIDE_UNUSED)) { if (!(dumpMask & HIDE_UNUSED)) {
cliDumpPrintf(dumpMask, equalsDefault, formatUnassigned, owner); cliDumpPrintf(dumpMask, equalsDefault, formatUnassigned, owner);
} }
} else { } else {
cliDumpPrintf(dumpMask, equalsDefault, format, owner, IO_GPIOPortIdx(io) + 'A', IO_GPIOPinIdx(io)); cliDumpPrintf(dumpMask, equalsDefault, format, owner, IO_GPIOPortIdxByTag(ioTag) + 'A', IO_GPIOPinIdxByTag(ioTag));
} }
} }
} }