@@ -45,10 +45,58 @@ SYS_INIT(disable_mpu_rasr_xn, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT)
45
45
#include <zephyr/drivers/clock_control.h>
46
46
#include <zephyr/logging/log.h>
47
47
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
+
48
91
int camera_ext_clock_enable (void )
49
92
{
50
93
int ret ;
51
94
uint32_t rate ;
95
+
96
+ // Hack in init semaphore for touch events
97
+ k_sem_init (& touch_event_sync , 0 , 1 );
98
+
99
+
52
100
const struct device * cam_ext_clk_dev = DEVICE_DT_GET (DT_NODELABEL (pwmclock ));
53
101
54
102
if (!device_is_ready (cam_ext_clk_dev )) {
@@ -99,7 +147,7 @@ int smh_init(void) {
99
147
return 0 ;
100
148
}
101
149
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 );
103
151
#endif
104
152
105
153
#if defined(CONFIG_BOARD_ARDUINO_PORTENTA_C33 ) && defined(CONFIG_LLEXT )
0 commit comments