Skip to content

Commit b6d6e20

Browse files
committed
GiGA Touch - define a callback function forwarder.
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: Kurt Eckhardt <[email protected]>
1 parent db649d0 commit b6d6e20

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

loader/fixups.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,48 @@ 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)
44+
#include <zephyr/kernel.h>
45+
#include <zephyr/device.h>
46+
#include <zephyr/logging/log.h>
47+
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+
static const struct device *const touch_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_touch));
68+
INPUT_CALLBACK_DEFINE(touch_dev, touch_event_callback, NULL);
69+
70+
#endif
71+
72+
#if (defined(CONFIG_BOARD_ARDUINO_GIGA_R1) || defined(CONFIG_BOARD_ARDUINO_PORTENTA_H7)) \
73+
&& defined(CONFIG_VIDEO)
4374
#include <zephyr/kernel.h>
4475
#include <zephyr/device.h>
45-
#include <zephyr/drivers/clock_control.h>
4676
#include <zephyr/logging/log.h>
77+
#include <zephyr/drivers/clock_control.h>
4778

4879
int camera_ext_clock_enable(void)
4980
{
5081
int ret;
5182
uint32_t rate;
83+
5284
const struct device *cam_ext_clk_dev = DEVICE_DT_GET(DT_NODELABEL(pwmclock));
5385

5486
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)