diff --git a/cpu/cc2538/dev/gpio.h b/cpu/cc2538/dev/gpio.h index eb2851270..c81482c9e 100644 --- a/cpu/cc2538/dev/gpio.h +++ b/cpu/cc2538/dev/gpio.h @@ -114,6 +114,20 @@ typedef void (* gpio_callback_t)(uint8_t port, uint8_t pin); #define GPIO_CLR_PIN(PORT_BASE, PIN_MASK) \ do { REG(((PORT_BASE) | GPIO_DATA) + ((PIN_MASK) << 2)) = 0x00; } while(0) +/** \brief Set pins with PIN_MASK of port with PORT_BASE to value. + * \param PORT_BASE GPIO Port register offset + * \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80 + */ +#define GPIO_WRITE_PIN(PORT_BASE, PIN_MASK, value) \ + do { REG(((PORT_BASE) | GPIO_DATA) + ((PIN_MASK) << 2)) = (value); } while(0) + +/** \brief Read pins with PIN_MASK of port with PORT_BASE. + * \param PORT_BASE GPIO Port register offset + * \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80 + */ +#define GPIO_READ_PIN(PORT_BASE, PIN_MASK) \ + REG(((PORT_BASE) | GPIO_DATA) + ((PIN_MASK) << 2)) + /** \brief Set pins with PIN_MASK of port with PORT_BASE to detect edge. * \param PORT_BASE GPIO Port register offset * \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80 @@ -176,6 +190,14 @@ typedef void (* gpio_callback_t)(uint8_t port, uint8_t pin); #define GPIO_DISABLE_INTERRUPT(PORT_BASE, PIN_MASK) \ do { REG((PORT_BASE) | GPIO_IE) &= ~(PIN_MASK); } while(0) +/** \brief Clear interrupt triggering for pins with PIN_MASK of port with + * PORT_BASE. + * \param PORT_BASE GPIO Port register offset + * \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80 + */ +#define GPIO_CLEAR_INTERRUPT(PORT_BASE, PIN_MASK) \ + do { REG((PORT_BASE) | GPIO_IC) = (PIN_MASK); } while(0) + /** \brief Configure the pin to be under peripheral control with PIN_MASK of * port with PORT_BASE. * \param PORT_BASE GPIO Port register offset