24
24
#define CMSDK_GPIO_1 CMSDK_GPIO1
25
25
#define PININT_IRQ 0
26
26
27
- static uint32_t channel_ids [CHANNEL_NUM ] = {0 };
27
+ static uintptr_t channel_contexts [CHANNEL_NUM ] = {0 };
28
28
static gpio_irq_handler irq_handler ;
29
29
30
30
static inline void handle_interrupt_in (uint32_t channel ) {
@@ -34,27 +34,27 @@ static inline void handle_interrupt_in(uint32_t channel) {
34
34
// * There is no user handler
35
35
// * It is a level interrupt, not an edge interrupt
36
36
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 ;
38
38
39
39
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 );
41
41
CMSDK_GPIO_0 -> INTPOLSET = ch_bit ;
42
42
}
43
43
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 );
45
45
}
46
46
CMSDK_GPIO_0 -> INTCLEAR = ch_bit ;
47
47
}
48
48
49
49
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 ;
51
51
52
52
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 );
54
54
CMSDK_GPIO_1 -> INTPOLSET = ch_bit ;
55
55
}
56
56
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 );
58
58
}
59
59
CMSDK_GPIO_1 -> INTCLEAR = ch_bit ;
60
60
}
@@ -94,7 +94,7 @@ void gpio1_irq14(void) {handle_interrupt_in(30);}
94
94
void gpio1_irq15 (void ) {handle_interrupt_in (31 );}
95
95
96
96
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 ) {
98
98
if (pin == NC ) {return -1 ;}
99
99
else {
100
100
@@ -103,8 +103,8 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
103
103
int found_free_channel = 0 ;
104
104
int i = 0 ;
105
105
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 ;
108
108
obj -> ch = i ;
109
109
found_free_channel = 1 ;
110
110
break ;
0 commit comments