mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-02 12:24:07 -04:00
This commit is contained in:
parent
eb69ddce43
commit
2981d9f5c1
2 changed files with 255 additions and 36 deletions
|
@ -48,6 +48,11 @@
|
|||
#include "lwip/mem.h"
|
||||
#include "lwip/stats.h"
|
||||
|
||||
/* Very crude mechanism used to determine if the critical section handling
|
||||
functions are being called from an interrupt context or not. This relies on
|
||||
the interrupt handler setting this variable manually. */
|
||||
portBASE_TYPE xInsideISR = pdFALSE;
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Routine: sys_mbox_new
|
||||
*---------------------------------------------------------------------------*
|
||||
|
@ -141,8 +146,18 @@ void sys_mbox_post( sys_mbox_t *pxMailBox, void *pxMessageToPost )
|
|||
err_t sys_mbox_trypost( sys_mbox_t *pxMailBox, void *pxMessageToPost )
|
||||
{
|
||||
err_t xReturn;
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
if( xQueueSend( *pxMailBox, &pxMessageToPost, 0UL ) == pdPASS )
|
||||
if( xInsideISR != pdFALSE )
|
||||
{
|
||||
xReturn = xQueueSendFromISR( *pxMailBox, &pxMessageToPost, &xHigherPriorityTaskWoken );
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = xQueueSend( *pxMailBox, &pxMessageToPost, ( portTickType ) 0 );
|
||||
}
|
||||
|
||||
if( xReturn == pdPASS )
|
||||
{
|
||||
xReturn = ERR_OK;
|
||||
}
|
||||
|
@ -200,6 +215,8 @@ unsigned long ulReturn;
|
|||
|
||||
if( ulTimeOut != 0UL )
|
||||
{
|
||||
configASSERT( xInsideISR == ( portBASE_TYPE ) 0 );
|
||||
|
||||
if( pdTRUE == xQueueReceive( *pxMailBox, &( *ppvBuffer ), ulTimeOut/ portTICK_RATE_MS ) )
|
||||
{
|
||||
xEndTime = xTaskGetTickCount();
|
||||
|
@ -249,13 +266,24 @@ u32_t sys_arch_mbox_tryfetch( sys_mbox_t *pxMailBox, void **ppvBuffer )
|
|||
{
|
||||
void *pvDummy;
|
||||
unsigned long ulReturn;
|
||||
long lResult;
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
if( ppvBuffer== NULL )
|
||||
{
|
||||
ppvBuffer = &pvDummy;
|
||||
}
|
||||
|
||||
if( pdTRUE == xQueueReceive( *pxMailBox, &( *ppvBuffer ), 0UL ) )
|
||||
if( xInsideISR != pdFALSE )
|
||||
{
|
||||
lResult = xQueueReceiveFromISR( *pxMailBox, &( *ppvBuffer ), &xHigherPriorityTaskWoken );
|
||||
}
|
||||
else
|
||||
{
|
||||
lResult = xQueueReceive( *pxMailBox, &( *ppvBuffer ), 0UL );
|
||||
}
|
||||
|
||||
if( lResult == pdPASS )
|
||||
{
|
||||
ulReturn = ERR_OK;
|
||||
}
|
||||
|
@ -441,7 +469,16 @@ void sys_mutex_free( sys_mutex_t *pxMutex )
|
|||
*---------------------------------------------------------------------------*/
|
||||
void sys_sem_signal( sys_sem_t *pxSemaphore )
|
||||
{
|
||||
xSemaphoreGive( *pxSemaphore );
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
if( xInsideISR != pdFALSE )
|
||||
{
|
||||
xSemaphoreGiveFromISR( *pxSemaphore, &xHigherPriorityTaskWoken );
|
||||
}
|
||||
else
|
||||
{
|
||||
xSemaphoreGive( *pxSemaphore );
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
|
@ -537,7 +574,10 @@ sys_thread_t xReturn;
|
|||
*---------------------------------------------------------------------------*/
|
||||
sys_prot_t sys_arch_protect( void )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
if( xInsideISR == pdFALSE )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
}
|
||||
return ( sys_prot_t ) 1;
|
||||
}
|
||||
|
||||
|
@ -555,7 +595,10 @@ sys_prot_t sys_arch_protect( void )
|
|||
void sys_arch_unprotect( sys_prot_t xValue )
|
||||
{
|
||||
(void) xValue;
|
||||
taskEXIT_CRITICAL();
|
||||
if( xInsideISR == pdFALSE )
|
||||
{
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue