[En-Nut-Discussion] Problem with GpioIrqEnable

zonedar sholder at summitsemi.com
Thu Mar 1 20:30:43 CET 2012


Hi Klaus,

  Thanks for the reply.  The call to NutRegisterIrqHandler is inside Nut's
GpioRegisterIrqHandler function below: 

int GpioRegisterIrqHandler(GPIO_SIGNAL * sig, int bit, void (*handler) (void
*), void *arg)
{
    int rc = 0;

    if (sig->ios_vector == 0) {
        /* This is the first call. Allocate the vector table. */
        sig->ios_vector = malloc(sizeof(GPIO_VECTOR) * 32);
        if (sig->ios_vector) {
            memset(sig->ios_vector, 0, sizeof(GPIO_VECTOR) * 32);
            /* Register our internal PIO interrupt service. */
            rc = NutRegisterIrqHandler(sig->ios_sig, sig->ios_handler,
sig->ios_vector);
            if (rc == 0) {
                rc = NutIrqEnable(sig->ios_sig);
            }
        }
        else {
            rc = -1;
        }
    }
    sig->ios_vector[bit].iov_handler = handler;
    sig->ios_vector[bit].iov_arg = arg;

    return rc;
}

I copied that function in to my source file to be sure that the registration
is being done and it is.

The code for is GpioIrqEnable as follows:

int GpioIrqEnable(GPIO_SIGNAL * sig, int bit)
{
    return (sig->ios_ctl) (NUT_IRQCTL_ENABLE, NULL, bit);
}

Where sig->ios_ctl is as follows:

static int PioCtlA(int cmd, void *param, int bit)
{
    int rc = 0;
    unsigned int *ival = (unsigned int *) param;
    uint32_t enabled = inr(PIOA_IMR) & _BV(bit);
    printf("\n\n\n\nhere PioCtlA\n");

    /* Disable interrupt. */
    if (enabled) {
        outr(PIOA_IDR, _BV(bit));
    }
    printf("\n\n\n\nhere2 PioCtlA\n");
    switch (cmd) {
    case NUT_IRQCTL_STATUS:
        if (enabled) {
            *ival |= 1;
        } else {
            *ival &= ~1;
        }
        printf("\n\n\n\nhere3 PioCtlA\n");
        break;
    case NUT_IRQCTL_ENABLE:
        enabled = 1;
        printf("\n\n\n\nhere 4 PioCtlA\n");
        break;
    case NUT_IRQCTL_DISABLE:
        enabled = 0;
        printf("\n\n\n\nhere5 PioCtlA\n");
        break;
    default:
        rc = -1;
        break;
    }

    /* Enable interrupt. */
    if (enabled) {
    	printf("\n\n\n\nhere6 PioCtlA\n");
        outr(PIOA_IER, _BV(bit));  //NOT returning from here
        printf("\n\n\n\nhere7 PioCtlA\n");
    }
    printf("\n\n\n\nhere8 PioCtlA\n");
    return rc;
}


As I mentioned it's not coming out of outr(PIOA_IER, _BV(bit)).

Thanks Again!

-Steve



Klaus Kloos wrote:
> 
> 
> 
> Hello Steve
> 
> The code of the function GpioIrqEnable is missing. So here is a short
> guess...
> Do you have set an IRQ-Handler for the used PIO before enabling the IRQ?
> something like
> 	NutRegisterIrqHandler(&sig_PIOB, MyIrqHandler, NULL);
> or (without NutOS)
>     	outr(AIC_SVR(PIOB_ID), (unsigned int) MyIrqHandler);
> 
> Greetings Klaus
> 
> 
> 


-- 
View this message in context: http://old.nabble.com/Problem-with-GpioIrqEnable-tp33422809p33423801.html
Sent from the MicroControllers - Ethernut mailing list archive at Nabble.com.




More information about the En-Nut-Discussion mailing list