MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / GPIO_IntConfig

Function GPIO_IntConfig

bsp/efm32/Libraries/emlib/src/em_gpio.c:145–181  ·  view source on GitHub ↗

/ * @brief * Configure GPIO interrupt. * * @details * If reconfiguring a GPIO interrupt that is already enabled, it is generally * recommended to disable it first, see GPIO_Disable(). * * The actual GPIO interrupt handler must be in place before enabling the * interrupt. * * Notice that any pending interrupt for the selected pin is cleared by this * function. * * @note

Source from the content-addressed store, hash-verified

143 * false to leave disabled. See GPIO_IntDisable() and GPIO_IntEnable().
144 ******************************************************************************/
145void GPIO_IntConfig(GPIO_Port_TypeDef port,
146 unsigned int pin,
147 bool risingEdge,
148 bool fallingEdge,
149 bool enable)
150{
151 uint32_t tmp;
152
153 EFM_ASSERT(GPIO_PORT_VALID(port) && GPIO_PIN_VALID(pin));
154
155 /* There are two registers controlling the interrupt configuration:
156 * The EXTIPSELL register controls pins 0-7 and EXTIPSELH controls
157 * pins 8-15. */
158 if (pin < 8)
159 {
160 GPIO->EXTIPSELL = (GPIO->EXTIPSELL & ~(0xF << (4 * pin))) |
161 (port << (4 * pin));
162 }
163 else
164 {
165 tmp = pin - 8;
166 GPIO->EXTIPSELH = (GPIO->EXTIPSELH & ~(0xF << (4 * tmp))) |
167 (port << (4 * tmp));
168 }
169
170 /* Enable/disable rising edge */
171 BITBAND_Peripheral(&(GPIO->EXTIRISE), pin, (unsigned int)risingEdge);
172
173 /* Enable/disable falling edge */
174 BITBAND_Peripheral(&(GPIO->EXTIFALL), pin, (unsigned int)fallingEdge);
175
176 /* Clear any pending interrupt */
177 GPIO->IFC = 1 << pin;
178
179 /* Finally enable/disable interrupt */
180 BITBAND_Peripheral(&(GPIO->IEN), pin, (unsigned int)enable);
181}
182
183
184/***************************************************************************//**

Callers 3

efm_hw_eth_initFunction · 0.50
efm32_hw_keys_initFunction · 0.50
efm_accel_configFunction · 0.50

Calls 1

BITBAND_PeripheralFunction · 0.85

Tested by

no test coverage detected