cjb2002 wrote on Friday, February 01, 2008:
hi everybody,
here I am coding an ISR to tell uIP when to read data from an ethernet MAC.
here is the ISR:
-----------------------------------
void __attribute__ ((naked)) emac_interrupt( void ) ;
void emac_int_not_naked(void)
{
volatile u32 regValue = 0;
static portBASE_TYPE xTaskWoken = pdFALSE;
//leemos int status
regValue = MAC_INTSTATUS;
do
{
if (regValue == 0)
{
break;
}
if (regValue & MAC_INT_RXOVERRUN)
{
m_nic_write(MAC_INTCLEAR, MAC_INT_RXOVERRUN);
break;
}
if (regValue & MAC_INT_RXERROR)
{
m_nic_write(MAC_INTCLEAR, MAC_INT_RXERROR);
break;
}
if (regValue & MAC_INT_RXFINISHED)
{
m_nic_write(MAC_INTCLEAR, MAC_INT_RXFINISHED);
//p_priv->stats.rx_erros++;
//while ( MAC_RXPRODUCEINDEX != (MAC_RXCONSUMEINDEX - 1) );
}
if (regValue & MAC_INT_RXDONE)
{
m_nic_write(MAC_INTCLEAR, MAC_INT_RXDONE);
//wake up!
xTaskWoken = xSemaphoreGiveFromISR( xETH_RX_Sem, xTaskWoken );
}
if (regValue & MAC_INT_TXUNDERRUN)
{
m_nic_write(MAC_INTCLEAR, MAC_INT_TXUNDERRUN);
break;
}
if (regValue & MAC_INT_TXERROR)
{
m_nic_write(MAC_INTCLEAR, MAC_INT_TXERROR);
break;
}
if (regValue & MAC_INT_TXFINISHED)
{
m_nic_write(MAC_INTCLEAR, MAC_INT_TXFINISHED);
}
if (regValue & MAC_INT_TXDONE)
{
m_nic_write(MAC_INTCLEAR, MAC_INT_TXDONE);
}
} while (0);
VICVectAddr = 0; //clear
if( xTaskWoken )
{
portYIELD_FROM_ISR(); //sip, hay que levantar la tarea!
}
}
void __attribute__ ((naked)) emac_interrupt( void )
{
/* Save the context of the interrupted task. */
portSAVE_CONTEXT();
/* Call the handler. This must be a separate function to ensure the
stack frame is correctly set up. */
emac_int_not_naked();
/* Restore the context of whichever task will run next. */
portRESTORE_CONTEXT();
}
--------------------------------------------------
so then I just do this in the UIP task:
…
if ( xSemaphoreTake( xETH_RX_Sem, portMAX_DELAY ) != pdTRUE )
{
printf("B\n");
}
else
{
something();
}
…
it doesn’t matter if portMAX_DELAY is configured to undefinitely block or not.
I tested it and portYIELD_FROM_ISR() is called, but the task is not woken, and there are lower priorities task running, so I don’t know what’s wrong.
I’m using a LPC2468 in THUMB mode, but tried purely ARM mode and it’s the same behaviour.
any ideas?
thanks!