Skip to content

Commit

Permalink
Merge branch 'bugfix/gpio_set_level_atomic_v5.4' into 'release/v5.4'
Browse files Browse the repository at this point in the history
fix(gpio): improve set level performance (v5.4)

See merge request espressif/esp-idf!34764
  • Loading branch information
suda-morris committed Nov 11, 2024
2 parents df64e63 + a5fee4b commit bfebd2e
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions components/hal/esp32/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,15 +498,15 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t
{
if (level) {
if (gpio_num < 32) {
hw->out_w1ts = (1 << gpio_num);
hw->out_w1ts = 1 << gpio_num;
} else {
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->out1_w1ts, data, (1 << (gpio_num - 32)));
hw->out1_w1ts.val = 1 << (gpio_num - 32);
}
} else {
if (gpio_num < 32) {
hw->out_w1tc = (1 << gpio_num);
hw->out_w1tc = 1 << gpio_num;
} else {
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->out1_w1tc, data, (1 << (gpio_num - 32)));
hw->out1_w1tc.val = 1 << (gpio_num - 32);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/hal/esp32c2/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ __attribute__((always_inline))
static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t level)
{
if (level) {
hw->out_w1ts.out_w1ts = (1 << gpio_num);
hw->out_w1ts.val = 1 << gpio_num;
} else {
hw->out_w1tc.out_w1tc = (1 << gpio_num);
hw->out_w1tc.val = 1 << gpio_num;
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/hal/esp32c3/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ __attribute__((always_inline))
static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t level)
{
if (level) {
hw->out_w1ts.out_w1ts = (1 << gpio_num);
hw->out_w1ts.val = 1 << gpio_num;
} else {
hw->out_w1tc.out_w1tc = (1 << gpio_num);
hw->out_w1tc.val = 1 << gpio_num;
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/hal/esp32c5/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ __attribute__((always_inline))
static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t level)
{
if (level) {
hw->out_w1ts.out_w1ts = (1 << gpio_num);
hw->out_w1ts.val = 1 << gpio_num;
} else {
hw->out_w1tc.out_w1tc = (1 << gpio_num);
hw->out_w1tc.val = 1 << gpio_num;
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/hal/esp32c6/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ __attribute__((always_inline))
static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t level)
{
if (level) {
hw->out_w1ts.out_w1ts = (1 << gpio_num);
hw->out_w1ts.val = 1 << gpio_num;
} else {
hw->out_w1tc.out_w1tc = (1 << gpio_num);
hw->out_w1tc.val = 1 << gpio_num;
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/hal/esp32c61/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ __attribute__((always_inline))
static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t level)
{
if (level) {
hw->out_w1ts.out_w1ts = (1 << gpio_num);
hw->out_w1ts.val = 1 << gpio_num;
} else {
hw->out_w1tc.out_w1tc = (1 << gpio_num);
hw->out_w1tc.val = 1 << gpio_num;
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/hal/esp32h2/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ __attribute__((always_inline))
static inline void gpio_ll_set_level(gpio_dev_t *hw, gpio_num_t gpio_num, uint32_t level)
{
if (level) {
hw->out_w1ts.out_w1ts = (1 << gpio_num);
hw->out_w1ts.val = 1 << gpio_num;
} else {
hw->out_w1tc.out_w1tc = (1 << gpio_num);
hw->out_w1tc.val = 1 << gpio_num;
}
}

Expand Down
8 changes: 4 additions & 4 deletions components/hal/esp32p4/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,15 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t
{
if (level) {
if (gpio_num < 32) {
hw->out_w1ts.out_w1ts = (1 << gpio_num);
hw->out_w1ts.val = 1 << gpio_num;
} else {
hw->out1_w1ts.out1_w1ts = (1 << (gpio_num - 32));
hw->out1_w1ts.val = 1 << (gpio_num - 32);
}
} else {
if (gpio_num < 32) {
hw->out_w1tc.out_w1tc = (1 << gpio_num);
hw->out_w1tc.val = 1 << gpio_num;
} else {
hw->out1_w1tc.out1_w1tc = (1 << (gpio_num - 32));
hw->out1_w1tc.val = 1 << (gpio_num - 32);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/hal/esp32s2/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,15 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t
{
if (level) {
if (gpio_num < 32) {
hw->out_w1ts = (1 << gpio_num);
hw->out_w1ts = 1 << gpio_num;
} else {
hw->out1_w1ts.data = (1 << (gpio_num - 32));
hw->out1_w1ts.val = 1 << (gpio_num - 32);
}
} else {
if (gpio_num < 32) {
hw->out_w1tc = (1 << gpio_num);
hw->out_w1tc = 1 << gpio_num;
} else {
hw->out1_w1tc.data = (1 << (gpio_num - 32));
hw->out1_w1tc.val = 1 << (gpio_num - 32);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/hal/esp32s3/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,15 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t
{
if (level) {
if (gpio_num < 32) {
hw->out_w1ts = (1 << gpio_num);
hw->out_w1ts = 1 << gpio_num;
} else {
hw->out1_w1ts.data = (1 << (gpio_num - 32));
hw->out1_w1ts.val = 1 << (gpio_num - 32);
}
} else {
if (gpio_num < 32) {
hw->out_w1tc = (1 << gpio_num);
hw->out_w1tc = 1 << gpio_num;
} else {
hw->out1_w1tc.data = (1 << (gpio_num - 32));
hw->out1_w1tc.val = 1 << (gpio_num - 32);
}
}
}
Expand Down

0 comments on commit bfebd2e

Please sign in to comment.