Skip to content

Commit 124e759

Browse files
committed
GiGA Touch - define a callback function forwarder.
Added the ability to register a callback function to be called by the zephyr input system. This new code is only there if it is a GIGA and CONFIG_INPUT_GT911_INTERRUPT is defined. This includes adding a callback function that is linked in to the zephyr build, and export a function to call to allow us to register our own. Added an init variant to GIGA that if the touch interrupt is enabled, then it will clear out the old user defined callback if any. Signed-off-by: kurte <[email protected]>
1 parent 964e74b commit 124e759

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

loader/fixups.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,49 @@ SYS_INIT(disable_bootloader_mpu, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAU
3939
SYS_INIT(disable_mpu_rasr_xn, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
4040
#endif
4141

42-
#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_VIDEO)
42+
43+
#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_INPUT_GT911_INTERRUPT)
4344
#include <zephyr/kernel.h>
4445
#include <zephyr/device.h>
45-
#include <zephyr/drivers/clock_control.h>
4646
#include <zephyr/logging/log.h>
4747

48+
#include <zephyr/input/input.h>
49+
50+
// experiment to try to capture touch screen events
51+
void (*_giga_touch_callback)(struct input_event *evt, void *user_data) = 0;
52+
53+
void registerGigaTouchCallback(void (*cb)(struct input_event *evt, void *user_data))
54+
{
55+
_giga_touch_callback = cb;
56+
}
57+
58+
59+
void touch_event_callback(struct input_event *evt, void *user_data)
60+
{
61+
//printk("touch_event_callback(%p %p): %p %u %u %u %d\n", evt, user_data,
62+
// evt->dev, evt->sync, evt->type, evt->code, evt->value);
63+
if (_giga_touch_callback) {
64+
(*_giga_touch_callback)(evt, user_data);
65+
}
66+
}
67+
68+
static const struct device *const touch_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_touch));
69+
INPUT_CALLBACK_DEFINE(touch_dev, touch_event_callback, NULL);
70+
71+
#endif
72+
73+
#if (defined(CONFIG_BOARD_ARDUINO_GIGA_R1) || defined(CONFIG_BOARD_ARDUINO_PORTENTA_H7)) \
74+
&& defined(CONFIG_VIDEO)
75+
#include <zephyr/kernel.h>
76+
#include <zephyr/device.h>
77+
#include <zephyr/logging/log.h>
78+
#include <zephyr/drivers/clock_control.h>
79+
4880
int camera_ext_clock_enable(void)
4981
{
5082
int ret;
5183
uint32_t rate;
84+
5285
const struct device *cam_ext_clk_dev = DEVICE_DT_GET(DT_NODELABEL(pwmclock));
5386

5487
if (!device_is_ready(cam_ext_clk_dev)) {

loader/llext_exports.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ FORCE_EXPORT_SYM(video_buffer_alloc);
134134
FORCE_EXPORT_SYM(video_buffer_release);
135135
FORCE_EXPORT_SYM(video_set_ctrl);
136136
#endif
137+
#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_INPUT_GT911_INTERRUPT)
138+
FORCE_EXPORT_SYM(registerGigaTouchCallback);
139+
#endif
137140

138141
#if defined(CONFIG_SHARED_MULTI_HEAP)
139142
FORCE_EXPORT_SYM(shared_multi_heap_aligned_alloc);

variants/arduino_giga_r1_stm32h747xx_m7/variant.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@ void _on_1200_bps() {
66
*(__IO uint32_t *)tmp = (uint32_t)0xDF59;
77
NVIC_SystemReset();
88
}
9+
10+
#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_INPUT_GT911_INTERRUPT)
11+
extern "C" void registerGigaTouchCallback(void (*cb)(struct input_event *evt, void *user_data));
12+
void initVariant(void) {
13+
// Make sure to set to NULL in case previous sketch or pvevious build of sketch
14+
// set a callback, whoes pointer may not be valid
15+
registerGigaTouchCallback(nullptr);
16+
}
17+
#endif

0 commit comments

Comments
 (0)