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 .github/workflows/arduino_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- master

jobs:
lint:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- master

jobs:
build:
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/issue_comment.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/new_issues.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/new_prs.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.3
- uses: pre-commit/action@v3.0.1
2 changes: 1 addition & 1 deletion .github/workflows/upload_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
- name: Upload components to component service
uses: espressif/upload-components-ci-action@v1
with:
name: "ESP32_IO_Expander"
name: "esp32_io_expander"
namespace: "espressif"
api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# ChangeLog

## v1.1.1 - 2025-07-07

### Enhancements:

* feat(ch422g): support enter/exit sleep

### Bug Fixes:

* fix(port): fix discarded qualifiers warning

## v1.1.0 - 2025-02-07

### Enhancements:
Expand Down
2 changes: 1 addition & 1 deletion idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.1.0"
version: "1.1.1"
description: ESP32_IO_Expander is a library designed for driving IO expander chips using ESP SoCs
url: https://github.com/esp-arduino-libs/ESP32_IO_Expander
repository: https://github.com/esp-arduino-libs/ESP32_IO_Expander.git
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ESP32_IO_Expander
version=1.1.0
version=1.1.1
author=espressif
maintainer=espressif
sentence=ESP32_IO_Expander is a library designed for driving IO expander chips using ESP SoCs
Expand Down
30 changes: 30 additions & 0 deletions src/chip/esp_expander_ch422g.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,34 @@ bool CH422G::enableAllIO_Output(void)
return true;
}

bool CH422G::enterSleep(void)
{
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();

ESP_UTILS_CHECK_FALSE_RETURN(isOverState(State::BEGIN), false, "Not begun");

ESP_UTILS_CHECK_ERROR_RETURN(
esp_io_expander_ch422g_enter_sleep(device_handle), false, "Enter sleep failed"
);

ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS();

return true;
}

bool CH422G::exitSleep(void)
{
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();

ESP_UTILS_CHECK_FALSE_RETURN(isOverState(State::BEGIN), false, "Not begun");

ESP_UTILS_CHECK_ERROR_RETURN(
esp_io_expander_ch422g_exit_sleep(device_handle), false, "Exit sleep failed"
);

ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS();

return true;
}

} // namespace esp_expander
14 changes: 14 additions & 0 deletions src/chip/esp_expander_ch422g.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ class CH422G: public Base {
* @return true if success, otherwise false
*/
bool enableAllIO_Output(void);

/**
* @brief Enter sleep mode
*
* @return true if success, otherwise false
*/
bool enterSleep(void);

/**
* @brief Exit sleep mode
*
* @return true if success, otherwise false
*/
bool exitSleep(void);
};

} // namespace esp_expander
Expand Down
2 changes: 1 addition & 1 deletion src/port/esp_io_expander.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef enum {
REG_DIRECTION,
} reg_type_t;

static char *TAG = "io_expander";
static const char *TAG = "io_expander";

static esp_err_t write_reg(esp_io_expander_handle_t handle, reg_type_t reg, uint32_t value);
static esp_err_t read_reg(esp_io_expander_handle_t handle, reg_type_t reg, uint32_t *value);
Expand Down
43 changes: 38 additions & 5 deletions src/port/esp_io_expander_ch422g.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@
// Default: | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |

// *INDENT-OFF*
#define REG_WR_OC_DEFAULT_VAL (0x0FUL)
#define REG_WR_IO_DEFAULT_VAL (0xFFUL)
#define REG_WR_OC_DEFAULT_VAL (0x0FU)
#define REG_WR_IO_DEFAULT_VAL (0xFFU)
#define REG_OUT_DEFAULT_VAL ((REG_WR_OC_DEFAULT_VAL << 8) | REG_WR_IO_DEFAULT_VAL)
#define REG_DIR_DEFAULT_VAL (0xFFFUL)
#define REG_DIR_DEFAULT_VAL (0xFFFU)

#define REG_WR_SET_BIT_IO_OE (1 << 0)
#define REG_WR_SET_BIT_OD_EN (1 << 2)
#define REG_WR_SET_BIT_IO_OE (1U << 0)
#define REG_WR_SET_BIT_OD_EN (1U << 2)
#define REG_WR_SET_BIT_SLEEP (1U << 3)

/**
* @brief Device Structure Type
Expand Down Expand Up @@ -171,6 +172,38 @@ esp_err_t esp_io_expander_ch422g_set_all_output(esp_io_expander_handle_t handle)
return ESP_OK;
}

esp_err_t esp_io_expander_ch422g_enter_sleep(esp_io_expander_handle_t handle)
{
esp_io_expander_ch422g_t *ch422g = (esp_io_expander_ch422g_t *)__containerof(handle, esp_io_expander_ch422g_t, base);
uint8_t data = (uint8_t)(ch422g->regs.wr_set | REG_WR_SET_BIT_SLEEP);

// WR-SET
ESP_RETURN_ON_ERROR(
i2c_master_write_to_device(
ch422g->i2c_num, CH422G_REG_WR_SET, &data, sizeof(data), pdMS_TO_TICKS(I2C_TIMEOUT_MS)
), TAG, "Write WR_SET reg failed"
);
ch422g->regs.wr_set = data;

return ESP_OK;
}

esp_err_t esp_io_expander_ch422g_exit_sleep(esp_io_expander_handle_t handle)
{
esp_io_expander_ch422g_t *ch422g = (esp_io_expander_ch422g_t *)__containerof(handle, esp_io_expander_ch422g_t, base);
uint8_t data = (uint8_t)(ch422g->regs.wr_set & ~REG_WR_SET_BIT_SLEEP);

// WR-SET
ESP_RETURN_ON_ERROR(
i2c_master_write_to_device(
ch422g->i2c_num, CH422G_REG_WR_SET, &data, sizeof(data), pdMS_TO_TICKS(I2C_TIMEOUT_MS)
), TAG, "Write WR_SET reg failed"
);
ch422g->regs.wr_set = data;

return ESP_OK;
}

static esp_err_t read_input_reg(esp_io_expander_handle_t handle, uint32_t *value)
{
esp_io_expander_ch422g_t *ch422g = (esp_io_expander_ch422g_t *)__containerof(handle, esp_io_expander_ch422g_t, base);
Expand Down
4 changes: 4 additions & 0 deletions src/port/esp_io_expander_ch422g.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ esp_err_t esp_io_expander_ch422g_set_all_input(esp_io_expander_handle_t handle);

esp_err_t esp_io_expander_ch422g_set_all_output(esp_io_expander_handle_t handle);

esp_err_t esp_io_expander_ch422g_enter_sleep(esp_io_expander_handle_t handle);

esp_err_t esp_io_expander_ch422g_exit_sleep(esp_io_expander_handle_t handle);

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion src/port/esp_io_expander_ht8574.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ typedef struct {
} regs;
} esp_io_expander_ht8574_t;

static char *TAG = "ht8574";
static const char *TAG = "ht8574";

static esp_err_t read_input_reg(esp_io_expander_handle_t handle, uint32_t *value);
static esp_err_t write_output_reg(esp_io_expander_handle_t handle, uint32_t value);
Expand Down
2 changes: 1 addition & 1 deletion src/port/esp_io_expander_tca9554.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef struct {
} regs;
} esp_io_expander_tca9554_t;

static char *TAG = "tca9554";
static const char *TAG = "tca9554";

static esp_err_t read_input_reg(esp_io_expander_handle_t handle, uint32_t *value);
static esp_err_t write_output_reg(esp_io_expander_handle_t handle, uint32_t value);
Expand Down
2 changes: 1 addition & 1 deletion src/port/esp_io_expander_tca95xx_16bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef struct {
} regs;
} esp_io_expander_tca95xx_16bit_t;

static char *TAG = "tca95xx_16";
static const char *TAG = "tca95xx_16";

static esp_err_t read_input_reg(esp_io_expander_handle_t handle, uint32_t *value);
static esp_err_t write_output_reg(esp_io_expander_handle_t handle, uint32_t value);
Expand Down
Loading