Skip to content
Closed
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
GiGA Touch - Allow us to define a callback function and add a forward…
…er in fixups.

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.

This version also added in the changes to fixups that allow a camera to work on Portenta H7.
Needed to have it do the same as GIGA to start the PWM if INPUT is configured in.

And updated the portentas remote_endpoint define to be using the same format as used in the giga overlay
Also changed to STM32_DMA_FIFO_1-4, like the GIGA currently has

Update arduino_portenta_h7_stm32h747xx_m7.overlay

Fix build

Fix the overlay, newer zephyr wants different form...
  • Loading branch information
KurtE committed Aug 2, 2025
commit 6fe1f6a7a9850fc29ba6e72cd03674b4907a354c
35 changes: 33 additions & 2 deletions loader/fixups.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,47 @@ SYS_INIT(disable_bootloader_mpu, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAU
SYS_INIT(disable_mpu_rasr_xn, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
#endif

#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_VIDEO)

#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_INPUT_GT911_INTERRUPT)
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/logging/log.h>

#include <zephyr/input/input.h>

// experiment to try to capture touch screen events
void (*_giga_touch_callback)(struct input_event *evt, void *user_data) = 0;

void registerGigaTouchCallback(void (*cb)(struct input_event *evt, void *user_data)) {
_giga_touch_callback = cb;
}


void touch_event_callback(struct input_event *evt, void *user_data)
{
//printk("touch_event_callback(%p %p): %p %u %u %u %d\n", evt, user_data,
// evt->dev, evt->sync, evt->type, evt->code, evt->value);
if (_giga_touch_callback) {
(*_giga_touch_callback)(evt, user_data);
}
}

static const struct device *const touch_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_touch));
INPUT_CALLBACK_DEFINE(touch_dev, touch_event_callback, NULL);

#endif

#if (defined(CONFIG_BOARD_ARDUINO_GIGA_R1) || defined(CONFIG_BOARD_ARDUINO_PORTENTA_H7) ) && defined(CONFIG_VIDEO)
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/logging/log.h>
#include <zephyr/drivers/clock_control.h>

int camera_ext_clock_enable(void)
{
int ret;
uint32_t rate;

const struct device *cam_ext_clk_dev = DEVICE_DT_GET(DT_NODELABEL(pwmclock));

if (!device_is_ready(cam_ext_clk_dev)) {
Expand Down
3 changes: 3 additions & 0 deletions loader/llext_exports.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ FORCE_EXPORT_SYM(video_buffer_alloc);
FORCE_EXPORT_SYM(video_buffer_release);
FORCE_EXPORT_SYM(video_set_ctrl);
#endif
#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_INPUT_GT911_INTERRUPT)
FORCE_EXPORT_SYM(registerGigaTouchCallback);
#endif

#if defined(CONFIG_SHARED_MULTI_HEAP)
FORCE_EXPORT_SYM(shared_multi_heap_aligned_alloc);
Expand Down
9 changes: 9 additions & 0 deletions variants/arduino_giga_r1_stm32h747xx_m7/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ void _on_1200_bps() {
*(__IO uint32_t *)tmp = (uint32_t)0xDF59;
NVIC_SystemReset();
}

#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_INPUT_GT911_INTERRUPT)
extern "C" void registerGigaTouchCallback(void (*cb)(struct input_event *evt, void *user_data));
void initVariant(void) {
// Make sure to set to NULL in case previous sketch or pvevious build of sketch
// set a callback, whoes pointer may not be valid
registerGigaTouchCallback(nullptr);
}
#endif