Skip to content

Commit f105771

Browse files
Add CST9217 touch controller
1 parent 927b1a6 commit f105771

10 files changed

+526
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The functional block diagram is shown below:
9696
| Chipsemicorp | CHSC6540 |
9797
| FocalTech | FT5x06 |
9898
| GOODiX | GT911,GT1151 |
99-
| Hynitron | CST816S,CST820 |
99+
| Hynitron | CST816S,CST820,CST9217 |
100100
| Parade | TT21100 |
101101
| Sitronix | ST7123,ST1633 |
102102
| Solomon Systech | SPD2010 |

docs/drivers/touch.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
| CHSC6540 | - || |
88
| [CST816S](https://components.espressif.com/components/espressif/esp_lcd_touch_cst816s) | 1.0.3~1 || |
99
| CST820 | - || |
10+
| CST9217 | 1.0.0 || |
1011
| [FT5x06](https://components.espressif.com/components/espressif/esp_lcd_touch_ft5x06) | 1.0.6~1 || |
1112
| [GT911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911) | 1.1.1~1 || |
1213
| [GT1151](https://components.espressif.com/components/espressif/esp_lcd_touch_gt1151) | 1.0.5~2 || |

esp_panel_board_custom_conf.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@
346346
* Supported controllers:
347347
* - `AXS15231B`
348348
* - `CHSC6540`
349-
* - `CST816S`
350-
* - `CST820`
349+
* - `CST816S`, 'CST820', 'CST9217'
351350
* - `FT5x06`
352351
* - `GT911`, `GT1151`
353352
* - `SPD2010`

src/drivers/touch/esp_panel_touch_conf_internal.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@
7878
#endif
7979
#endif
8080

81+
#ifndef ESP_PANEL_DRIVERS_TOUCH_USE_CST9217
82+
#ifdef CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_CST9217
83+
#define ESP_PANEL_DRIVERS_TOUCH_USE_CST9217 CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_CST9217
84+
#else
85+
#define ESP_PANEL_DRIVERS_TOUCH_USE_CST9217 (0)
86+
#endif
87+
#endif
88+
8189
#ifndef ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06
8290
#ifdef CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06
8391
#define ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06 CONFIG_ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06
@@ -243,6 +251,14 @@
243251
#endif
244252
#endif
245253

254+
#ifndef ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST9217
255+
#if ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS || ESP_PANEL_DRIVERS_TOUCH_USE_CST9217
256+
#define ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST9217 (1)
257+
#else
258+
#define ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST9217 (0)
259+
#endif
260+
#endif
261+
246262
#ifndef ESP_PANEL_DRIVERS_TOUCH_ENABLE_FT5x06
247263
#if ESP_PANEL_DRIVERS_TOUCH_COMPILE_UNUSED_DRIVERS || ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06
248264
#define ESP_PANEL_DRIVERS_TOUCH_ENABLE_FT5x06 (1)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "esp_panel_touch_conf_internal.h"
8+
#if ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST9217
9+
10+
#include "utils/esp_panel_utils_log.h"
11+
#include "esp_panel_touch_cst9217.hpp"
12+
13+
namespace esp_panel::drivers {
14+
15+
TouchCST9217::~TouchCST9217()
16+
{
17+
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();
18+
19+
ESP_UTILS_CHECK_FALSE_EXIT(del(), "Delete failed");
20+
21+
ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS();
22+
}
23+
24+
bool TouchCST9217::begin()
25+
{
26+
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();
27+
28+
ESP_UTILS_CHECK_FALSE_RETURN(!isOverState(State::BEGIN), false, "Already begun");
29+
30+
// Initialize the touch if not initialized
31+
if (!isOverState(State::INIT)) {
32+
ESP_UTILS_CHECK_FALSE_RETURN(init(), false, "Init failed");
33+
}
34+
35+
// Create touch panel
36+
ESP_UTILS_CHECK_ERROR_RETURN(
37+
esp_lcd_touch_new_i2c_cst9217(
38+
getBus()->getControlPanelHandle(), getConfig().getDeviceFullConfig(), &touch_panel
39+
), false, "Create touch panel failed"
40+
);
41+
ESP_UTILS_LOGD("Create touch panel(@%p)", touch_panel);
42+
43+
setState(State::BEGIN);
44+
45+
ESP_UTILS_LOG_TRACE_EXIT_WITH_THIS();
46+
47+
return true;
48+
}
49+
50+
} // namespace esp_panel::drivers
51+
52+
#endif // ESP_PANEL_DRIVERS_TOUCH_ENABLE_CST9217
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include "port/esp_lcd_touch_cst9217.h"
10+
#include "esp_panel_touch_conf_internal.h"
11+
#include "esp_panel_touch.hpp"
12+
13+
namespace esp_panel::drivers {
14+
15+
/**
16+
* @brief CST9217 touch controller
17+
*
18+
* This class provides implementation for CST9217 touch controller, inheriting from
19+
* the base Touch class to provide common touch functionality
20+
*/
21+
class TouchCST9217 : public Touch {
22+
public:
23+
/**
24+
* @brief Default basic attributes for CST9217
25+
*/
26+
static constexpr BasicAttributes BASIC_ATTRIBUTES_DEFAULT = {
27+
.name = "CST9217",
28+
.max_points_num = 1,
29+
};
30+
31+
/**
32+
* @brief Construct a touch device instance with individual configuration parameters
33+
*
34+
* @param bus Bus interface for communicating with the touch device
35+
* @param width Panel width in pixels
36+
* @param height Panel height in pixels
37+
* @param rst_io Reset GPIO pin number (-1 if unused)
38+
* @param int_io Interrupt GPIO pin number (-1 if unused)
39+
*/
40+
TouchCST9217(Bus *bus, uint16_t width, uint16_t height, int rst_io = -1, int int_io = -1):
41+
Touch(BASIC_ATTRIBUTES_DEFAULT, bus, width, height, rst_io, int_io)
42+
{
43+
}
44+
45+
/**
46+
* @brief Construct a touch device instance with configuration
47+
*
48+
* @param[in] bus Pointer to the bus interface for communicating with the touch device
49+
* @param[in] config Configuration structure containing device settings and parameters
50+
*/
51+
TouchCST9217(Bus *bus, const Config &config): Touch(BASIC_ATTRIBUTES_DEFAULT, bus, config) {}
52+
53+
/**
54+
* @brief Construct a touch device instance with bus configuration and device configuration
55+
*
56+
* @param[in] bus_config Bus configuration
57+
* @param[in] touch_config Touch configuration
58+
* @note This constructor creates a new bus instance using the provided bus configuration
59+
*/
60+
TouchCST9217(const BusFactory::Config &bus_config, const Config &touch_config):
61+
Touch(BASIC_ATTRIBUTES_DEFAULT, bus_config, touch_config)
62+
{
63+
}
64+
65+
/**
66+
* @brief Destruct touch device
67+
*/
68+
~TouchCST9217() override;
69+
70+
/**
71+
* @brief Startup the touch device
72+
*
73+
* @return `true` if success, otherwise false
74+
*
75+
* @note This function should be called after `init()`
76+
*/
77+
bool begin() override;
78+
};
79+
80+
} // namespace esp_panel::drivers

src/drivers/touch/esp_panel_touch_factory.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ const utils::unordered_map<utils::string, TouchFactory::FunctionCreateDevice> To
3636
#if ESP_PANEL_DRIVERS_TOUCH_USE_CST820
3737
MAP_ITEM(CST820),
3838
#endif // CONFIG_ESP_PANEL_TOUCH_CST820
39+
#if ESP_PANEL_DRIVERS_TOUCH_USE_CST9217
40+
MAP_ITEM(CST9217),
41+
#endif // CONFIG_ESP_PANEL_TOUCH_CST9217
3942
#if ESP_PANEL_DRIVERS_TOUCH_USE_FT5x06
4043
MAP_ITEM(FT5x06),
4144
#endif // CONFIG_ESP_PANEL_TOUCH_FT5x06

src/drivers/touch/esp_panel_touch_factory.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "esp_panel_touch_chsc6540.hpp"
1515
#include "esp_panel_touch_cst816s.hpp"
1616
#include "esp_panel_touch_cst820.hpp"
17+
#include "esp_panel_touch_cst9217.hpp"
1718
#include "esp_panel_touch_ft5x06.hpp"
1819
#include "esp_panel_touch_gt911.hpp"
1920
#include "esp_panel_touch_gt1151.hpp"

0 commit comments

Comments
 (0)