Skip to content

Conversation

quytranpzz
Copy link
Contributor

Add Input subsys support on Renesas RX CTSU HWIP

Copy link

github-actions bot commented Sep 25, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-hal_renesas DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Sep 25, 2025
@quytranpzz quytranpzz force-pushed the rx_zephyr_support_ctsu branch 2 times, most recently from d4c5731 to 4dd7324 Compare September 26, 2025 06:40
@quytranpzz quytranpzz marked this pull request as ready for review September 26, 2025 08:33
@zephyrbot zephyrbot added area: RX platform: Renesas Renesas area: Input Input Subsystem and Drivers platform: Renesas RA Renesas Electronics Corporation, RA area: Samples Samples labels Sep 26, 2025
@quytranpzz quytranpzz force-pushed the rx_zephyr_support_ctsu branch from 4dd7324 to 04a6047 Compare October 8, 2025 16:14
@github-actions github-actions bot removed the manifest label Oct 8, 2025
@github-actions github-actions bot removed the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Oct 8, 2025
@quytranpzz quytranpzz requested a review from thenguyenyf October 8, 2025 16:15
@quytranpzz quytranpzz force-pushed the rx_zephyr_support_ctsu branch from 04a6047 to 7fccb78 Compare October 8, 2025 16:23
thenguyenyf
thenguyenyf previously approved these changes Oct 9, 2025
Copy link
Contributor

@thenguyenyf thenguyenyf left a comment

Choose a reason for hiding this comment

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

LGTM

KhiemNguyenT
KhiemNguyenT previously approved these changes Oct 9, 2025
Copy link

@KhiemNguyenT KhiemNguyenT left a comment

Choose a reason for hiding this comment

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

Look good to me, too.

@KhiemNguyenT KhiemNguyenT added this to the v4.3.0 milestone Oct 9, 2025
}

if (data->work_phase == SCANNING) {
if (p_arg->event == CTSU_EVENT_SCAN_COMPLETE) {
Copy link
Member

Choose a reason for hiding this comment

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

swap the argument, unindent the normal case and return on this one

if (p_arg->event != CTSU_EVENT_SCAN_COMPLETE) {
        return;
}

k_work_submit(&data->data_process_work);

You could probably also merge the two conditions? return if `data->work_phase == SCANNING && p_arg->event ~= CTSU_EVENT_SCAN_COMPLETE`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's done, thank you

CONTAINER_OF(work, struct renesas_rx_ctsu_data, data_process_work);
const struct device *dev = data->dev;
const struct renesas_rx_ctsu_config *config = dev->config;
fsp_err_t ret = FSP_SUCCESS;
Copy link
Member

Choose a reason for hiding this comment

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

drop the initializer, you literally set this in the next line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dropped it

int button_position = 0;

while (changed_buttons != 0) {
if (changed_buttons & 0x1) {
Copy link
Member

Choose a reason for hiding this comment

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

BIT(0) instead of 0x01? up to you, no strong feelings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yah, I have updated, thanks

int index = config->button_position_index[button_position];

input_report_key(dev, config->buttons[index].event,
data->curr_buttons_data & (1 << button_position), true,
Copy link
Member

Choose a reason for hiding this comment

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

BIT(button_position) instead of 1 << button_position

}
}

void timer_callback(struct k_timer *timer)
Copy link
Member

Choose a reason for hiding this comment

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

static

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, I have updated

}
}

void button2_task(void)
Copy link
Member

Choose a reason for hiding this comment

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

static

#endif /* CONFIG_INPUT_RENESAS_RX_QE_TOUCH_CFG */
}

void button1_task(void)
Copy link
Member

Choose a reason for hiding this comment

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

static

Comment on lines 34 to 35
#define DEBOUNCE_TIMES 3
#define DEBOUNCE_INTERVAL_MS (500 / DEBOUNCE_TIMES)
Copy link
Member

Choose a reason for hiding this comment

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

unused? drop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, dropped it

Comment on lines 147 to 148
leds_on_off[(current_main_led + i) % 4] =
((led_state >> i) & 0x1) ? LED_ON : LED_OFF;
Copy link
Member

Choose a reason for hiding this comment

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

why not just have a

if (led_state & BIT(i)) {
   gpio_pin_set_dt(...)
} else {
   gpio_pin_set_dt(...)
}

current logic seems unnecessarily complicated, two cycles, the global variable...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the code, thanks

#define QE_TOUCH_DEFINE_H

/* Macro definitions */
#define QE_TOUCH_VERSION (0x0420)
Copy link
Member

Choose a reason for hiding this comment

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

drop the parenthesis from the literals here, they are only needed on expressions, no point adding them everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dropped the parenthesis

@fabiobaltieri
Copy link
Member

hey, few coding style things, sorry for the delay reviewing this, ooo at the moment

@quytranpzz quytranpzz dismissed stale reviews from KhiemNguyenT and thenguyenyf via 013669e October 10, 2025 04:41
@quytranpzz quytranpzz force-pushed the rx_zephyr_support_ctsu branch from 7fccb78 to 013669e Compare October 10, 2025 04:41
@duynguyenxa duynguyenxa added platform: Renesas RX Renesas Electronics Corp, RX and removed platform: Renesas RA Renesas Electronics Corporation, RA labels Oct 13, 2025
k_sem_give(&data->tune_scan_end);
}

if (data->work_phase == SCANNING) {
Copy link
Member

Choose a reason for hiding this comment

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

can you swap this and make it an early return as well? May even do a single if with the one below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated this, could you please take a look?

#ifndef CONFIG_INPUT_RENESAS_RX_QE_TOUCH_CFG
#define CTSU_HAL_CONFIG_DEFINE(idx) \
.ctsu_cfg = \
{ \
Copy link
Member

Choose a reason for hiding this comment

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

nit: bring this to the line above? that's the normal formatting, I usually let it go on macros because I know clang-format does not respect that but you have it right on the field below so I presume you are manually indenting, may as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I did try moving it to the line above as in the field below, but clang-format automatically reformatted it to the current layout

Minh Tang added 4 commits October 13, 2025 10:45
Add support for Capatitive Touch Sensing Unit driver for RX MCUs

Signed-off-by: Minh Tang <[email protected]>
Add support CTSU device tree node for Renesas RX130

Signed-off-by: Minh Tang <[email protected]>
Add Pinctrl, status okay for CTSU node on RSK-RX130

Signed-off-by: Minh Tang <[email protected]>
Add sample for CTSU input driver using QE config files on
RSK-RX130-512KB

Signed-off-by: Minh Tang <[email protected]>
@quytranpzz quytranpzz force-pushed the rx_zephyr_support_ctsu branch from 013669e to da088e5 Compare October 13, 2025 10:47
@zephyrbot zephyrbot added the platform: Renesas RA Renesas Electronics Corporation, RA label Oct 13, 2025
Copy link

@fabiobaltieri
Copy link
Member

@quytranpzz hey, sorry this needs a rebase now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards/SoCs area: Devicetree Bindings area: Input Input Subsystem and Drivers area: RX area: Samples Samples platform: Renesas RA Renesas Electronics Corporation, RA platform: Renesas RX Renesas Electronics Corp, RX platform: Renesas Renesas

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants