1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 20:10:18 +03:00

Fixed CLI DMA presence mask support.

This commit is contained in:
mikeller 2019-06-29 19:01:54 +12:00
parent 23ca254277
commit c60e31407d

View file

@ -4903,13 +4903,15 @@ typedef struct dmaoptEntry_s {
uint32_t presenceMask;
} dmaoptEntry_t;
#define MASK_IGNORED (0)
// Handy macros for keeping the table tidy.
// DEFS : Single entry
// DEFA : Array of uint8_t (stride = 1)
// DEFW : Wider stride case; array of structs.
#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) \
{ device, peripheral, pgn, sizeof(uint8_t), offsetof(type, member), max, mask }
@ -4917,8 +4919,6 @@ typedef struct dmaoptEntry_s {
#define DEFW(device, peripheral, pgn, type, member, max, mask) \
{ device, peripheral, pgn, sizeof(type), offsetof(type, member), max, mask }
#define MASK_IGNORED (0)
dmaoptEntry_t dmaoptEntryTable[] = {
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),
@ -5166,7 +5166,7 @@ static void cliDmaopt(char *cmdline)
pch = strtok_r(NULL, " ", &saveptr);
if (entry) {
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 : "");
return;
}