Samraksh / eMote

eMote OS -- Multiple Ports (using .NET MF v4.3)
0 stars 0 forks source link

.NOW GPIO input interrupt parameters #146

Closed ChrisAtSamraksh closed 9 years ago

ChrisAtSamraksh commented 10 years ago

Port.InterruptMode.InterruptEdgeLevelLow and Port.InterruptMode.InterruptEdgeLevelHigh do not work and throw an exception.

AnanthAtSamraksh commented 9 years ago

InterruptEdgeLevelLow and InterruptEdgeLevelHigh are not supported on the device (.Now).

Refer CPU_GPIO_EnableInputPin2 in netmf_gpio.cpp

// Not supported on the device
else if(GPIO_INT_LEVEL_HIGH == IntEdge || GPIO_INT_LEVEL_LOW == IntEdge)
    return FALSE;

Any suggestions on how this can be communicated to the user?

Nathan-Stohs commented 9 years ago

I think GPIO_INT_EDGE_LOW (edge triggering) and GPIO_INT_LEVEL_HIGH (level triggering) are being confused. We support edge triggering but not level triggering.

Any suggestions on how this can be communicated to the user?

We already have (EDIT: from the MF GPIO PAL):

UINT8 CPU_GPIO_GetSupportedInterruptModes( GPIO_PIN pin )
{
    //return g_STM32F10x_Gpio_Driver.c_GPIO_InterruptMode;
    return ((1<<GPIO_INT_EDGE_LOW) | (1<<GPIO_INT_EDGE_HIGH ) | (1<<GPIO_INT_EDGE_BOTH));
}

Which, barring a logic error, signals to the PAL what modes we support. We don't include the level triggering bits and so by their absence we indicate to the PAL that we do not support it.

The edge triggering should be supported and work, however.

EDIT: At the HAL level, our hands are tied as to what C# exceptions happen. This happens at the PAL and above. We can of course extend, but overriding the basic core libraries and DLLs doesn't seem palatable to me.

AnanthAtSamraksh commented 9 years ago

The edge triggering should be supported and work, however.

Yes, edge triggering does work

I am going to add the below lines of code to the GPIO programs in test suite (just recording it here for future reference).

static Port.InterruptMode interruptMode = Port.InterruptMode.InterruptEdgeLevelLow;

Cpu.PinValidInterruptMode validInterruptModes = Microsoft.SPOT.Hardware.HardwareProvider.HwProvider.GetSupportedInterruptModes(GPIOPins.GPIO_PIN_PB15);
if (((int)validInterruptModes & (1 << (int)interruptMode)) == 0)
{
      throw new Exception("Invalid interrupt mode");
}
AnanthAtSamraksh commented 9 years ago

I believe it is all right if I close this ticket, as making changes in SPOT_Hardware (such as checking for interrupt modes) is not an ideal solution.