Fixed CLI DMA presence mask support. (#8503)

Fixed CLI DMA presence mask support.
This commit is contained in:
Michael Keller 2019-07-03 08:18:39 +12:00 committed by GitHub
commit 1631831147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -4904,13 +4904,15 @@ typedef struct dmaoptEntry_s {
uint32_t presenceMask; uint32_t presenceMask;
} dmaoptEntry_t; } dmaoptEntry_t;
#define MASK_IGNORED (0)
// Handy macros for keeping the table tidy. // Handy macros for keeping the table tidy.
// DEFS : Single entry // DEFS : Single entry
// DEFA : Array of uint8_t (stride = 1) // DEFA : Array of uint8_t (stride = 1)
// DEFW : Wider stride case; array of structs. // DEFW : Wider stride case; array of structs.
#define DEFS(device, peripheral, pgn, type, member) \ #define DEFS(device, peripheral, pgn, type, member) \
{ device, peripheral, pgn, 0, offsetof(type, member), 0, 0 } { device, peripheral, pgn, 0, offsetof(type, member), 0, MASK_IGNORED }
#define DEFA(device, peripheral, pgn, type, member, max, mask) \ #define DEFA(device, peripheral, pgn, type, member, max, mask) \
{ device, peripheral, pgn, sizeof(uint8_t), offsetof(type, member), max, mask } { device, peripheral, pgn, sizeof(uint8_t), offsetof(type, member), max, mask }
@ -4918,8 +4920,6 @@ typedef struct dmaoptEntry_s {
#define DEFW(device, peripheral, pgn, type, member, max, mask) \ #define DEFW(device, peripheral, pgn, type, member, max, mask) \
{ device, peripheral, pgn, sizeof(type), offsetof(type, member), max, mask } { device, peripheral, pgn, sizeof(type), offsetof(type, member), max, mask }
#define MASK_IGNORED (0)
dmaoptEntry_t dmaoptEntryTable[] = { dmaoptEntry_t dmaoptEntryTable[] = {
DEFW("SPI_TX", DMA_PERIPH_SPI_TX, PG_SPI_PIN_CONFIG, spiPinConfig_t, txDmaopt, SPIDEV_COUNT, MASK_IGNORED), DEFW("SPI_TX", DMA_PERIPH_SPI_TX, PG_SPI_PIN_CONFIG, spiPinConfig_t, txDmaopt, SPIDEV_COUNT, MASK_IGNORED),
DEFW("SPI_RX", DMA_PERIPH_SPI_RX, PG_SPI_PIN_CONFIG, spiPinConfig_t, rxDmaopt, SPIDEV_COUNT, MASK_IGNORED), DEFW("SPI_RX", DMA_PERIPH_SPI_RX, PG_SPI_PIN_CONFIG, spiPinConfig_t, rxDmaopt, SPIDEV_COUNT, MASK_IGNORED),
@ -5167,7 +5167,7 @@ static void cliDmaopt(char *cmdline)
pch = strtok_r(NULL, " ", &saveptr); pch = strtok_r(NULL, " ", &saveptr);
if (entry) { if (entry) {
index = atoi(pch) - 1; index = atoi(pch) - 1;
if (index < 0 || index >= entry->maxIndex || !((entry->presenceMask != MASK_IGNORED) && (entry->presenceMask & BIT(index + 1)))) { if (index < 0 || index >= entry->maxIndex || (entry->presenceMask != MASK_IGNORED && !(entry->presenceMask & BIT(index + 1)))) {
cliPrintErrorLinef("BAD INDEX: '%s'", pch ? pch : ""); cliPrintErrorLinef("BAD INDEX: '%s'", pch ? pch : "");
return; return;
} }