Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions drivers/display/mb_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ static inline void update_pins(struct mb_display *disp, u32_t val)
u32_t pin, prev = (disp->cur + 2) % 3;

/* Disable the previous row */
gpio_pin_write(disp->dev, ROW_PIN(prev), 0);
gpio_pin_set_raw(disp->dev, ROW_PIN(prev), 0);

/* Set the column pins to their correct values */
for (pin = LED_COL1_GPIO_PIN; pin <= LED_COL9_GPIO_PIN; pin++) {
gpio_pin_write(disp->dev, pin, !!(val & BIT(pin)));
gpio_pin_set_raw(disp->dev, pin, !!(val & BIT(pin)));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not want to change the original !!(), leaving it to @jhedberg if he prefers to use a simple & instead.

Copy link
Member

@jhedberg jhedberg Jan 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't the correct values of the last parameter 0 and 1? That's what the !! is there for.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way the function is documented x & mask should work ("Writing any value other than 0 will set it to a high physical level.") Either !!(x & mask) or (x & mask) != 0 are good for clarity of intention. Sometimes people are confused by !!x though I personally like it (except where MISRA essential type requires a "boolean" expression).

}

/* Enable the new row */
gpio_pin_write(disp->dev, ROW_PIN(disp->cur), 1);
gpio_pin_set_raw(disp->dev, ROW_PIN(disp->cur), 1);
}

static void reset_display(struct mb_display *disp)
Expand Down Expand Up @@ -434,18 +434,18 @@ static int mb_display_init(struct device *dev)

__ASSERT(dev, "No GPIO device found");

gpio_pin_configure(display.dev, LED_ROW1_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_ROW2_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_ROW3_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_COL1_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_COL2_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_COL3_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_COL4_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_COL5_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_COL6_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_COL7_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_COL8_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_COL9_GPIO_PIN, GPIO_DIR_OUT);
gpio_pin_configure(display.dev, LED_ROW1_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_ROW2_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_ROW3_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_COL1_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_COL2_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_COL3_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_COL4_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_COL5_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_COL6_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_COL7_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_COL8_GPIO_PIN, GPIO_OUTPUT);
gpio_pin_configure(display.dev, LED_COL9_GPIO_PIN, GPIO_OUTPUT);

return 0;
}
Expand Down