Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions components/zdevice/include/boreas/gpio_dt.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
/* Bits 0-7: dt_flags — board-level properties (uint8_t in gpio_dt_spec).
* Bit positions match upstream Zephyr dt-bindings/gpio/gpio.h. */
#define GPIO_ACTIVE_LOW BIT(0)
/* Named zero: active-high is the absence of the active-low bit. Mirrors
* upstream's GPIO_ACTIVE_HIGH so boards/devicetree can state intent explicitly. */
#define GPIO_ACTIVE_HIGH (0 << 0)
#define GPIO_OPEN_DRAIN BIT(1) /* reserved */
#define GPIO_OPEN_SOURCE BIT(2) /* reserved */
#define GPIO_PULL_UP BIT(4)
Expand Down
18 changes: 18 additions & 0 deletions test/main/test_gpio_flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,23 @@ static void test_gpio_set_dt_no_invert_active_high(void)
TEST_ASSERT_EQUAL(0, last_set_raw_value);
}

static void test_gpio_active_high_is_named_zero(void)
{
/* GPIO_ACTIVE_HIGH is the named absence of the active-low bit, so a spec
* declared with it must behave identically to dt_flags == 0. */
TEST_ASSERT_EQUAL(0, GPIO_ACTIVE_HIGH);

reset_mock();
const struct gpio_dt_spec spec = {
.port = &mock_gpio, .pin = 4, .dt_flags = GPIO_ACTIVE_HIGH};

gpio_pin_set_dt(&spec, 1);
TEST_ASSERT_EQUAL(1, last_set_raw_value);

gpio_pin_set_dt(&spec, 0);
TEST_ASSERT_EQUAL(0, last_set_raw_value);
}

static void test_gpio_get_dt_inverts_for_active_low(void)
{
reset_mock();
Expand Down Expand Up @@ -257,5 +274,6 @@ void test_gpio_flags_group(void)
RUN_TEST(test_gpio_active_low_stripped_from_driver_flags);
RUN_TEST(test_gpio_set_dt_inverts_for_active_low);
RUN_TEST(test_gpio_set_dt_no_invert_active_high);
RUN_TEST(test_gpio_active_high_is_named_zero);
RUN_TEST(test_gpio_get_dt_inverts_for_active_low);
}
Loading