@@ -70,23 +70,40 @@ void __attribute__((weak, alias("ulp_lp_core_default_intr_handler"))) ulp_lp_cor
70
70
71
71
#if SOC_LP_CORE_SINGLE_INTERRUPT_VECTOR
72
72
73
- static void * s_intr_handlers [] = {
74
- ulp_lp_core_lp_io_intr_handler ,
75
- ulp_lp_core_lp_i2c_intr_handler ,
76
- ulp_lp_core_lp_uart_intr_handler ,
77
- ulp_lp_core_lp_timer_intr_handler ,
78
- 0 , // Reserved / Unused
79
- ulp_lp_core_lp_pmu_intr_handler ,
73
+ typedef struct {
74
+ void (* handler )(void * arg );
75
+ void * arg ;
76
+ } ulp_lp_core_intr_handler_t ;
77
+
78
+ static ulp_lp_core_intr_handler_t s_intr_handlers [] = {
79
+ {(void (* )(void * ))ulp_lp_core_lp_io_intr_handler , NULL },
80
+ {(void (* )(void * ))ulp_lp_core_lp_i2c_intr_handler , NULL },
81
+ {(void (* )(void * ))ulp_lp_core_lp_uart_intr_handler , NULL },
82
+ {(void (* )(void * ))ulp_lp_core_lp_timer_intr_handler , NULL },
83
+ {NULL , NULL }, // Reserved / Unused
84
+ {(void (* )(void * ))ulp_lp_core_lp_pmu_intr_handler , NULL },
80
85
};
81
86
87
+ int ulp_lp_core_intr_set_handler (int intr_source , void (* handler )(void * arg ), void * arg )
88
+ {
89
+ if (intr_source < 0 || intr_source >= sizeof (s_intr_handlers ) / sizeof (s_intr_handlers [0 ])) {
90
+ return -1 ;
91
+ }
92
+
93
+ s_intr_handlers [intr_source ].handler = handler ;
94
+ s_intr_handlers [intr_source ].arg = arg ;
95
+
96
+ return 0 ;
97
+ }
98
+
82
99
void __attribute__((weak )) ulp_lp_core_intr_handler (void )
83
100
{
84
101
uint8_t intr_source = lp_core_ll_get_triggered_interrupt_srcs ();
85
- for (int i = 0 ; i < sizeof (s_intr_handlers ) / 4 ; i ++ ) {
102
+ for (int i = 0 ; i < sizeof (s_intr_handlers ) / sizeof ( s_intr_handlers [ 0 ]) ; i ++ ) {
86
103
if (intr_source & (1 << i )) {
87
- void ( * handler )( void ) = s_intr_handlers [i ];
88
- if (handler ) {
89
- handler ();
104
+ ulp_lp_core_intr_handler_t * handler_entry = & s_intr_handlers [i ];
105
+ if (handler_entry -> handler ) {
106
+ handler_entry -> handler (handler_entry -> arg );
90
107
}
91
108
}
92
109
}
0 commit comments