/** * @brief Configures and activates the EXT peripheral. * * @param[in] extp pointer to the @p EXTDriver object * * @notapi */ void ext_lld_start(EXTDriver *extp) { int i; /* Configure all pins as edge sensitive */ #if LPC122x_EXT_USE_EXT0 if (extp == &EXTD0) { LPC_GPIO0->IS = 0; ext_lld_exti_irq_enable(EXTI0_IRQ); } #endif #if LPC122x_EXT_USE_EXT1 if (extp == &EXTD1) { LPC_GPIO1->IS = 0; ext_lld_exti_irq_enable(EXTI1_IRQ); } #endif #if LPC122x_EXT_USE_EXT2 if (extp == &EXTD2) { LPC_GPIO2->IS = 0; ext_lld_exti_irq_enable(EXTI2_IRQ); } #endif /* Configuration of autostart channels.*/ for (i = 0; i < EXT_MAX_CHANNELS; i++) if (extp->config->channels[i].mode & EXT_CH_MODE_AUTOSTART) ext_lld_channel_enable(extp, i); else ext_lld_channel_disable(extp, i); }
/** * @brief Configures and activates the EXT peripheral. * * @param[in] extp pointer to the @p EXTDriver object * * @notapi */ void ext_lld_start(EXTDriver *extp) { if (extp->state == EXT_STOP) ext_lld_exti_irq_enable(); /* Configuration of automatic channels.*/ for (expchannel_t channel = 0; channel < EXT_MAX_CHANNELS; channel++) { uint32_t mode = extp->config->channels[channel].mode; PORT_TypeDef *port = extp->config->channels[channel].port; uint32_t pin = extp->config->channels[channel].pin; /* Initialize the channel map */ #if KINETIS_EXT_PORTA_WIDTH > 0 if (port == PORTA) porta_channel_map[pin] = channel; else #endif #if KINETIS_EXT_PORTB_WIDTH > 0 if (port == PORTB) portb_channel_map[pin] = channel; else #endif #if KINETIS_EXT_PORTC_WIDTH > 0 if (port == PORTC) portc_channel_map[pin] = channel; else #endif #if KINETIS_EXT_PORTD_WIDTH > 0 if (port == PORTD) portd_channel_map[pin] = channel; else #endif #if KINETIS_EXT_PORTE_WIDTH > 0 if (port == PORTE) porte_channel_map[pin] = channel; else #endif {} if (mode & EXT_CH_MODE_AUTOSTART) ext_lld_channel_enable(extp, channel); else if (port != NULL) ext_lld_channel_disable(extp, channel); } }
/** * @brief Enables an EXT channel. * * @param[in] extp pointer to the @p EXTDriver object * @param[in] channel channel to be enabled * * @notapi */ void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel) { /* program the IOpin for this channel */ LPC_SYSCON->PINTSEL[channel] = extp->config->channels[channel].iopin; /* Programming edge irq enables */ if (extp->config->channels[channel].mode & EXT_CH_MODE_RISING_EDGE) LPC_PIN_INT->SIENR = (1 << channel); else LPC_PIN_INT->CIENR = (1 << channel); if (extp->config->channels[channel].mode & EXT_CH_MODE_FALLING_EDGE) LPC_PIN_INT->SIENF = (1 << channel); else LPC_PIN_INT->CIENF = (1 << channel); LPC_PIN_INT->RISE = (1<<channel); LPC_PIN_INT->FALL = (1<<channel); LPC_PIN_INT->IST = (1<<channel); ext_lld_exti_irq_enable( channel ); }