Skip to content

Commit 6e05523

Browse files
committed
GiGA Touch - Allow us to define a callback function and add a forwarder 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
1 parent 6621efb commit 6e05523

File tree

4 files changed

+47
-18
lines changed

4 files changed

+47
-18
lines changed

loader/fixups.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,47 @@ 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+
_giga_touch_callback = cb;
55+
}
56+
57+
58+
void touch_event_callback(struct input_event *evt, void *user_data)
59+
{
60+
//printk("touch_event_callback(%p %p): %p %u %u %u %d\n", evt, user_data,
61+
// evt->dev, evt->sync, evt->type, evt->code, evt->value);
62+
if (_giga_touch_callback) {
63+
(*_giga_touch_callback)(evt, user_data);
64+
}
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) ) && defined(CONFIG_VIDEO)
4373
#include <zephyr/kernel.h>
4474
#include <zephyr/device.h>
45-
#include <zephyr/drivers/clock_control.h>
4675
#include <zephyr/logging/log.h>
76+
#include <zephyr/drivers/clock_control.h>
4777

4878
int camera_ext_clock_enable(void)
4979
{
5080
int ret;
5181
uint32_t rate;
82+
5283
const struct device *cam_ext_clk_dev = DEVICE_DT_GET(DT_NODELABEL(pwmclock));
5384

5485
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

variants/arduino_portenta_h7_stm32h747xx_m7/arduino_portenta_h7_stm32h747xx_m7.overlay

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,11 @@
2727

2828
port {
2929
gc2145_ep_out: endpoint {
30-
remote-endpoint-label = "dcmi_ep_in";
30+
remote-endpoint = <&dcmi_ep_in>;
3131
};
3232
};
3333
};
3434

35-
ov7670: ov7670@21 {
36-
compatible = "ovti,ov7670";
37-
reg = <0x21>;
38-
39-
reset-gpios = <&gpioe 3 GPIO_ACTIVE_LOW>;
40-
pwdn-gpios = <&gpiod 5 GPIO_ACTIVE_LOW>;
41-
42-
port {
43-
ov7670_ep_out: endpoint {
44-
remote-endpoint-label = "dcmi_ep_in";
45-
};
46-
};
47-
};
4835
};
4936

5037
&i2c1 {
@@ -139,12 +126,11 @@
139126
pinctrl-names = "default";
140127
dmas = <&dma1 0 75 (STM32_DMA_PERIPH_TO_MEMORY | STM32_DMA_PERIPH_NO_INC |
141128
STM32_DMA_MEM_INC | STM32_DMA_PERIPH_32BITS | STM32_DMA_MEM_32BITS |
142-
STM32_DMA_PRIORITY_HIGH) STM32_DMA_FIFO_FULL>; //FULL for 7670, default FIFO_1_4
129+
STM32_DMA_PRIORITY_HIGH) STM32_DMA_FIFO_1_4>; //FULL for 7670, default FIFO_1_4
143130

144131
port {
145132
dcmi_ep_in: endpoint {
146133
remote-endpoint-label = "gc2145_ep_out";
147-
// remote-endpoint-label = "ov7670_ep_out";
148134
bus-width = <8>;
149135
hsync-active = <0>;
150136
vsync-active = <0>;

0 commit comments

Comments
 (0)