@@ -45,10 +45,58 @@ SYS_INIT(disable_mpu_rasr_xn, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT)
4545#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+ typedef struct {
52+ int32_t x ;
53+ int32_t y ;
54+ int32_t pressed ;
55+ } touch_point_t ;
56+
57+ touch_point_t last_touch_point ;
58+
59+ static struct k_sem touch_event_sync ;
60+
61+ bool getVideoTouchEvent (touch_point_t * tp , k_timeout_t timeout ) {
62+ if (k_sem_take (& touch_event_sync , timeout ) != 0 ) return false;
63+ // BUGBUG: should probably put stuff in to return only
64+ // data from whole event, but first see if anything works
65+ memcpy (tp , & last_touch_point , sizeof (touch_point_t ));
66+ return true;
67+ }
68+
69+
70+ void touch_event_callback (struct input_event * evt , void * user_data )
71+ {
72+ //printk("touch_event_callback(%p %p): %p %u %u %u %d\n", evt, user_data,
73+ // evt->dev, evt->sync, evt->type, evt->code, evt->value);
74+ if (evt -> code == INPUT_ABS_X ) {
75+ last_touch_point .x = evt -> value ;
76+ }
77+ if (evt -> code == INPUT_ABS_Y ) {
78+ last_touch_point .y = evt -> value ;
79+ }
80+ if (evt -> code == INPUT_BTN_TOUCH ) {
81+ last_touch_point .pressed = evt -> value ;
82+ }
83+ if (evt -> sync ) {
84+ k_sem_give (& touch_event_sync );
85+ }
86+ }
87+ static const struct device * const touch_dev = DEVICE_DT_GET (DT_CHOSEN (zephyr_touch ));
88+ INPUT_CALLBACK_DEFINE (touch_dev , touch_event_callback , NULL );
89+
90+
4891int camera_ext_clock_enable (void )
4992{
5093 int ret ;
5194 uint32_t rate ;
95+
96+ // Hack in init semaphore for touch events
97+ k_sem_init (& touch_event_sync , 0 , 1 );
98+
99+
52100 const struct device * cam_ext_clk_dev = DEVICE_DT_GET (DT_NODELABEL (pwmclock ));
53101
54102 if (!device_is_ready (cam_ext_clk_dev )) {
@@ -99,7 +147,7 @@ int smh_init(void) {
99147 return 0 ;
100148}
101149
102- SYS_INIT (smh_init , POST_KERNEL , CONFIG_CLOCK_CONTROL_PWM_INIT_PRIORITY );
150+ SYS_INIT (smh_init , POST_KERNEL , CONFIG_KERNEL_INIT_PRIORITY_DEFAULT );
103151#endif
104152
105153#if defined(CONFIG_BOARD_ARDUINO_PORTENTA_C33 ) && defined(CONFIG_LLEXT )
0 commit comments