Merge pull request #471 from ADVANSEE/cc2538-gpio-power-up

cc2538: gpio: Add support for power up
This commit is contained in:
George Oikonomou 2013-12-05 09:25:05 -08:00
commit 8b003c30c7
2 changed files with 49 additions and 0 deletions

View file

@ -90,6 +90,7 @@ gpio_port_a_isr()
notify(REG(GPIO_A_BASE | GPIO_MIS), GPIO_A_NUM); notify(REG(GPIO_A_BASE | GPIO_MIS), GPIO_A_NUM);
GPIO_CLEAR_INTERRUPT(GPIO_A_BASE, 0xFF); GPIO_CLEAR_INTERRUPT(GPIO_A_BASE, 0xFF);
GPIO_CLEAR_POWER_UP_INTERRUPT(GPIO_A_NUM, 0xFF);
ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }
@ -105,6 +106,7 @@ gpio_port_b_isr()
notify(REG(GPIO_B_BASE | GPIO_MIS), GPIO_B_NUM); notify(REG(GPIO_B_BASE | GPIO_MIS), GPIO_B_NUM);
GPIO_CLEAR_INTERRUPT(GPIO_B_BASE, 0xFF); GPIO_CLEAR_INTERRUPT(GPIO_B_BASE, 0xFF);
GPIO_CLEAR_POWER_UP_INTERRUPT(GPIO_B_NUM, 0xFF);
ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }
@ -120,6 +122,7 @@ gpio_port_c_isr()
notify(REG(GPIO_C_BASE | GPIO_MIS), GPIO_C_NUM); notify(REG(GPIO_C_BASE | GPIO_MIS), GPIO_C_NUM);
GPIO_CLEAR_INTERRUPT(GPIO_C_BASE, 0xFF); GPIO_CLEAR_INTERRUPT(GPIO_C_BASE, 0xFF);
GPIO_CLEAR_POWER_UP_INTERRUPT(GPIO_C_NUM, 0xFF);
ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }
@ -135,6 +138,7 @@ gpio_port_d_isr()
notify(REG(GPIO_D_BASE | GPIO_MIS), GPIO_D_NUM); notify(REG(GPIO_D_BASE | GPIO_MIS), GPIO_D_NUM);
GPIO_CLEAR_INTERRUPT(GPIO_D_BASE, 0xFF); GPIO_CLEAR_INTERRUPT(GPIO_D_BASE, 0xFF);
GPIO_CLEAR_POWER_UP_INTERRUPT(GPIO_D_NUM, 0xFF);
ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENERGEST_OFF(ENERGEST_TYPE_IRQ);
} }

View file

@ -214,6 +214,51 @@ typedef void (* gpio_callback_t)(uint8_t port, uint8_t pin);
#define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK) \ #define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK) \
do { REG((PORT_BASE) | GPIO_AFSEL) &= ~(PIN_MASK); } while(0) do { REG((PORT_BASE) | GPIO_AFSEL) &= ~(PIN_MASK); } while(0)
/** \brief Set pins with PIN_MASK of port PORT to trigger a power-up interrupt
* on rising edge.
* \param PORT GPIO Port (not port base address)
* \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
*/
#define GPIO_POWER_UP_ON_RISING(PORT, PIN_MASK) \
do { REG(GPIO_PORT_TO_BASE(PORT) | GPIO_P_EDGE_CTRL) &= \
~((PIN_MASK) << ((PORT) << 3)); } while(0)
/** \brief Set pins with PIN_MASK of port PORT to trigger a power-up interrupt
* on falling edge.
* \param PORT GPIO Port (not port base address)
* \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
*/
#define GPIO_POWER_UP_ON_FALLING(PORT, PIN_MASK) \
do { REG(GPIO_PORT_TO_BASE(PORT) | GPIO_P_EDGE_CTRL) |= \
(PIN_MASK) << ((PORT) << 3); } while(0)
/** \brief Enable power-up interrupt triggering for pins with PIN_MASK of port
* PORT.
* \param PORT GPIO Port (not port base address)
* \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
*/
#define GPIO_ENABLE_POWER_UP_INTERRUPT(PORT, PIN_MASK) \
do { REG(GPIO_PORT_TO_BASE(PORT) | GPIO_PI_IEN) |= \
(PIN_MASK) << ((PORT) << 3); } while(0)
/** \brief Disable power-up interrupt triggering for pins with PIN_MASK of port
* PORT.
* \param PORT GPIO Port (not port base address)
* \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
*/
#define GPIO_DISABLE_POWER_UP_INTERRUPT(PORT, PIN_MASK) \
do { REG(GPIO_PORT_TO_BASE(PORT) | GPIO_PI_IEN) &= \
~((PIN_MASK) << ((PORT) << 3)); } while(0)
/** \brief Clear power-up interrupt triggering for pins with PIN_MASK of port
* PORT.
* \param PORT GPIO Port (not port base address)
* \param PIN_MASK Pin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
*/
#define GPIO_CLEAR_POWER_UP_INTERRUPT(PORT, PIN_MASK) \
do { REG(GPIO_PORT_TO_BASE(PORT) | GPIO_IRQ_DETECT_ACK) = \
(PIN_MASK) << ((PORT) << 3); } while(0)
/** /**
* \brief Converts a pin number to a pin mask * \brief Converts a pin number to a pin mask
* \param The pin number in the range [0..7] * \param The pin number in the range [0..7]