Skip to content

Commit

Permalink
gpio interrupt register fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Anon Mall committed Jul 3, 2017
1 parent 64169a9 commit ddc7c2b
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions cpu/cc2538/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,19 @@
#include "periph/gpio.h"

#define GPIO_MASK (0xfffff000)
#define PORTNUM_MASK (0x00003000)
#define PORTNUM_MASK (0x00007000)
#define PORTNUM_SHIFT (12U)
#define PIN_MASK (0x00000007)
#define MODE_NOTSUP (0xff)

static inline cc2538_gpio_t *gpio(gpio_t pin)
{
if(((uint32_t)pin &GPIO_MASK) == 0){
uint32_t port = (pin & 0x18) >> 3;
return (cc2538_gpio_t*)(((uint32_t)GPIO_A)+(port << PORTNUM_SHIFT));
}else{
return (cc2538_gpio_t *)(pin & GPIO_MASK);
}
return (cc2538_gpio_t *)(pin & GPIO_MASK);
}

static inline int port_num(gpio_t pin)
{
if(((uint32_t)pin &GPIO_MASK) == 0){
return ((pin & 0x18) >> 3);
}
return (int)(((pin - (uint32_t)GPIO_A) & PORTNUM_MASK) >> PORTNUM_SHIFT);
return (int)((pin & PORTNUM_MASK) >> PORTNUM_SHIFT) - 1;
}

static inline int pin_num(gpio_t pin)
Expand Down Expand Up @@ -182,7 +174,7 @@ static inline void handle_isr(cc2538_gpio_t *gpio, int port_num)
{
uint32_t state = gpio->MIS;
gpio->IC = 0x000000ff;
gpio->IRQ_DETECT_ACK = 0x000000ff;
gpio->IRQ_DETECT_ACK = (0xff << (port_num * GPIO_BITS_PER_PORT));

for (int i = 0; i < GPIO_BITS_PER_PORT; i++) {
if (state & (1 << i)) {
Expand Down

0 comments on commit ddc7c2b

Please sign in to comment.