2424#define CMSDK_GPIO_1 CMSDK_GPIO1
2525#define PININT_IRQ 0
2626
27- static uint32_t channel_ids [CHANNEL_NUM ] = {0 };
27+ static uintptr_t channel_contexts [CHANNEL_NUM ] = {0 };
2828static gpio_irq_handler irq_handler ;
2929
3030static inline void handle_interrupt_in (uint32_t channel ) {
@@ -34,27 +34,27 @@ static inline void handle_interrupt_in(uint32_t channel) {
3434 // * There is no user handler
3535 // * It is a level interrupt, not an edge interrupt
3636 if (ch_bit < 16 ){
37- if ( ((CMSDK_GPIO_0 -> INTSTATUS ) == 0 ) || (channel_ids [channel ] == 0 ) || ((CMSDK_GPIO_0 -> INTTYPESET ) == 0 ) ) return ;
37+ if ( ((CMSDK_GPIO_0 -> INTSTATUS ) == 0 ) || (channel_contexts [channel ] == 0 ) || ((CMSDK_GPIO_0 -> INTTYPESET ) == 0 ) ) return ;
3838
3939 if ((CMSDK_GPIO_0 -> INTTYPESET & ch_bit ) && (CMSDK_GPIO_0 -> INTPOLSET & ch_bit )) {
40- irq_handler (channel_ids [channel ], IRQ_RISE );
40+ irq_handler (channel_contexts [channel ], IRQ_RISE );
4141 CMSDK_GPIO_0 -> INTPOLSET = ch_bit ;
4242 }
4343 if ((CMSDK_GPIO_0 -> INTTYPESET & ch_bit ) && ~(CMSDK_GPIO_0 -> INTPOLSET & ch_bit )) {
44- irq_handler (channel_ids [channel ], IRQ_FALL );
44+ irq_handler (channel_contexts [channel ], IRQ_FALL );
4545 }
4646 CMSDK_GPIO_0 -> INTCLEAR = ch_bit ;
4747 }
4848
4949 if (ch_bit >=16 ) {
50- if ( ((CMSDK_GPIO_1 -> INTSTATUS ) == 0 ) || (channel_ids [channel ] == 0 ) || ((CMSDK_GPIO_1 -> INTTYPESET ) == 0 ) ) return ;
50+ if ( ((CMSDK_GPIO_1 -> INTSTATUS ) == 0 ) || (channel_contexts [channel ] == 0 ) || ((CMSDK_GPIO_1 -> INTTYPESET ) == 0 ) ) return ;
5151
5252 if ((CMSDK_GPIO_1 -> INTTYPESET & ch_bit ) && (CMSDK_GPIO_1 -> INTPOLSET & ch_bit )) {
53- irq_handler (channel_ids [channel ], IRQ_RISE );
53+ irq_handler (channel_contexts [channel ], IRQ_RISE );
5454 CMSDK_GPIO_1 -> INTPOLSET = ch_bit ;
5555 }
5656 if ((CMSDK_GPIO_1 -> INTTYPESET & ch_bit ) && ~(CMSDK_GPIO_1 -> INTPOLSET & ch_bit )) {
57- irq_handler (channel_ids [channel ], IRQ_FALL );
57+ irq_handler (channel_contexts [channel ], IRQ_FALL );
5858 }
5959 CMSDK_GPIO_1 -> INTCLEAR = ch_bit ;
6060 }
@@ -94,7 +94,7 @@ void gpio1_irq14(void) {handle_interrupt_in(30);}
9494void gpio1_irq15 (void ) {handle_interrupt_in (31 );}
9595
9696
97- int gpio_irq_init (gpio_irq_t * obj , PinName pin , gpio_irq_handler handler , uint32_t id ) {
97+ int gpio_irq_init (gpio_irq_t * obj , PinName pin , gpio_irq_handler handler , uintptr_t context ) {
9898 if (pin == NC ) {return -1 ;}
9999 else {
100100
@@ -103,8 +103,8 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
103103 int found_free_channel = 0 ;
104104 int i = 0 ;
105105 for (i = 0 ; i < CHANNEL_NUM ; i ++ ) {
106- if (channel_ids [i ] == 0 ) {
107- channel_ids [i ] = id ;
106+ if (channel_contexts [i ] == 0 ) {
107+ channel_contexts [i ] = context ;
108108 obj -> ch = i ;
109109 found_free_channel = 1 ;
110110 break ;
0 commit comments