#if 1 // EMG - Need to poll Switch state from web server /* Enable IRQ signals on the port */ MCF_GPIO_PNQPAR = 0 | MCF_GPIO_PNQPAR_IRQ1_IRQ1 | MCF_GPIO_PNQPAR_IRQ4_IRQ4 | MCF_GPIO_PNQPAR_IRQ7_IRQ7; MCF_GPIO_PGPPAR = 0 | MCF_GPIO_PGPPAR_IRQ11_IRQ11; /* Set EPORT to look for rising edges */ MCF_EPORT_EPPAR0 = 0 | MCF_EPORT_EPPAR_EPPA1_RISING | MCF_EPORT_EPPAR_EPPA4_RISING | MCF_EPORT_EPPAR_EPPA7_RISING; MCF_EPORT_EPPAR1 = 0 | MCF_EPORT_EPPAR_EPPA11_RISING; /* Clear any currently triggered events on the EPORT */ MCF_EPORT_EPIER0 = 0 | MCF_EPORT_EPIER_EPIE1 | MCF_EPORT_EPIER_EPIE4 | MCF_EPORT_EPIER_EPIE7; MCF_EPORT_EPIER1 = 0 | MCF_EPORT_EPIER_EPIE11; /* Enable interrupts in the interrupt controller */ MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK1); // MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK4); // MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK7); // MCF_INTC1_ICR35 = MCF_INTC_ICR_IL(4); MCF_INTC1_IMRH &= ~(MCF_INTC_IMRH_MASK35); #else
mcf5223_gpio_init() { ... /* Enable interrupts in the interrupt controller */ MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK1); // MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK4); // MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK7); // ... MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASKALL); ...}
//maskall first MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASKALL); ... MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK1); // MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK4); // MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK7); //
the interrupts from switches work then.
Additionally, if we slightly modified and moved the mcf5223_powerup_config() function call before mcf5223_gpio_init() function call, the poll_switches() function would detect SW1 and SW2 power up states correctly:
void mcf5223_powerup_config( void ){ //these two registers will be overwritten later in the mcf5223_gpio_init() if required MCF_GPIO_PNQPAR = 0; MCF_GPIO_PGPPAR = 0; powerup_config_flags = poll_switches() | 0x80;// powerup_config_flags = 0x01; // DHCP enabled }
mcf5223_gpio_init(){ ... mcf5223_powerup_config(); mcf5223_gpio_init(); ...}
INTERRUPT_SETUP interrupt_setup; // interrupt configuration parameters interrupt_setup.int_type = PORT_INTERRUPT; // identifier when configuring interrupt_setup.int_handler = test_irq_1; // handling function interrupt_setup.int_priority = (INTERRUPT_LEVEL_2); // low priority interrupt_setup.int_port_bit = 1; // The IRQ input connected interrupt_setup.int_port_sense = IRQ_BOTH_EDGES; // Interrupt on this edge fnConfigureInterrupt((void *)&interrupt_setup); // configure test interrupt interrupt_setup.int_priority = (INTERRUPT_LEVEL_3); // low priority interrupt_setup.int_handler = test_irq_4; // handling function interrupt_setup.int_port_bit = 4; // The IRQ input connected interrupt_setup.int_port_sense = IRQ_RISING_EDGE; // Interrupt on this edge fnConfigureInterrupt((void *)&interrupt_setup); // configure test interrupt interrupt_setup.int_priority = (INTERRUPT_LEVEL_3); // low priority interrupt_setup.int_handler = test_irq_5; // handling function interrupt_setup.int_port_bit = 5; // The IRQ input connected interrupt_setup.int_port_sense = IRQ_RISING_EDGE; // Interrupt on this edge fnConfigureInterrupt((void *)&interrupt_setup); // configure test interrupt interrupt_setup.int_priority = (INTERRUPT_LEVEL_4); // low priority (test not available on 80 pin devices) interrupt_setup.int_handler = test_irq_7; // handling function interrupt_setup.int_port_bit = 7; // The IRQ input connected interrupt_setup.int_port_sense = IRQ_FALLING_EDGE; // Interrupt on this edge fnConfigureInterrupt((void *)&interrupt_setup); // configure test interrupt interrupt_setup.int_priority = (INTERRUPT_LEVEL_6); // low priority interrupt_setup.int_handler = test_irq_11; // handling function interrupt_setup.int_port_bit = 11; // The IRQ input connected (on all devices) interrupt_setup.int_port_sense = IRQ_RISING_EDGE; // Interrupt on this edge fnConfigureInterrupt((void *)&interrupt_setup); // configure test interrupt
static void test_irq_7(void){ fnInterruptMessage(OWN_TASK, IRQ7_EVENT);}