修复代码错误

This commit is contained in:
nhkefus
2025-03-11 14:10:51 +08:00
parent a7f6e9379a
commit 3422912129
576 changed files with 39303 additions and 1012 deletions

View File

@@ -15,12 +15,8 @@ VERSION := 8.2.0
$(NAME)_SOURCES := ver$(VERSION)/Source/portable/MemMang/heap_4.c
else
VERSION := 9.0.0
ifneq ($(filter $(HOST_MCU_FAMILY),MOC108),)
$(NAME)_SOURCES := ver$(VERSION)/Source/portable/MemMang/heap_4.c
else
$(NAME)_SOURCES := ver$(VERSION)/Source/portable/MemMang/heap_3.c
endif
endif
VERSION_MAJOR = $(word 1, $(subst ., ,$(VERSION)))
VERSION_MINOR = $(word 2, $(subst ., ,$(VERSION)))
@@ -75,9 +71,6 @@ Cortex-M4F_SOURCES := ver$(VERSION)/Source/portable/GCC/ARM_CM4F/port.c
Cortex-M4F_INCLUDES := ver$(VERSION)/Source/portable/GCC/ARM_CM4F
endif
ARM968E-S_SOURCES := ver$(VERSION)/Source/portable/GCC/ARM968E_S/port.c
ARM968E-S_INCLUDES := ver$(VERSION)/Source/portable/GCC/ARM968E_S
$(NAME)_SOURCES += $($(HOST_ARCH)_SOURCES)
GLOBAL_INCLUDES += $($(HOST_ARCH)_INCLUDES)

View File

@@ -163,19 +163,9 @@ int main( void )
return 0;
}
WEAK void mico_main(void)
{
}
static void application_thread_main( void *arg )
{
UNUSED_PARAMETER( arg );
/* Initialize after rtos is in initialized */
mico_main();
mico_rtos_init();
if ( MicoShouldEnterMFGMode( ) )
mico_system_qc_test( );
else
@@ -856,19 +846,6 @@ void vApplicationMallocFailedHook( void )
}
#if FreeRTOS_VERSION_MAJOR > 7
void rtos_suppress_and_sleep( unsigned long sleep_ms )
{
TickType_t missed_ticks = 0;
extern uint32_t platform_power_down_hook( unsigned long sleep_ms );
missed_ticks = platform_power_down_hook( sleep_ms );
vTaskStepTick( missed_ticks );
}
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -518,6 +518,9 @@ xTimeOutType xTimeOut;
{
traceQUEUE_SEND( pxQueue );
prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
#ifdef MXCHIP
event_rx_cb(pxQueue);
#endif
/* If there was a task waiting for data to arrive on the
queue then unblock it now. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
@@ -533,9 +536,6 @@ xTimeOutType xTimeOut;
}
taskEXIT_CRITICAL();
#ifdef MXCHIP
event_rx_cb(pxQueue);
#endif
/* Return to the original privilege level before exiting the
function. */

View File

View File

View File

View File

View File

View File

View File

@@ -643,7 +643,9 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
traceQUEUE_SEND( pxQueue );
xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
#ifdef MXCHIP
event_rx_cb(pxQueue);
#endif
#if ( configUSE_QUEUE_SETS == 1 )
{
if( pxQueue->pxQueueSetContainer != NULL )
@@ -728,9 +730,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
#endif /* configUSE_QUEUE_SETS */
taskEXIT_CRITICAL();
#ifdef MXCHIP
event_rx_cb(pxQueue);
#endif
return pdPASS;
}
else

0
mico-os/MiCO/RTOS/FreeRTOS/ver8.2.0/Source/readme.txt Normal file → Executable file
View File

View File

@@ -98,9 +98,7 @@
#define configUSE_TIMERS ( 1 )
#define configTIMER_TASK_PRIORITY ( 2 )
#define configTIMER_QUEUE_LENGTH ( 5 )
#ifndef configTIMER_TASK_STACK_DEPTH
#define configTIMER_TASK_STACK_DEPTH ( ( unsigned short ) (1024 / sizeof( portSTACK_TYPE )) )
#endif
/* Task */
#define configMAX_PRIORITIES ( 10 )
@@ -110,12 +108,6 @@
#define configIDLE_SHOULD_YIELD 1
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
#ifndef configUSE_TICKLESS_IDLE
#define configUSE_TICKLESS_IDLE (1)
#endif
extern void rtos_suppress_and_sleep( unsigned long sleep_ms );
#define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) rtos_suppress_and_sleep( xExpectedIdleTime )
/* Hooks */
#define configUSE_IDLE_HOOK 0
@@ -123,9 +115,7 @@ extern void rtos_suppress_and_sleep( unsigned long sleep_ms );
#define configUSE_MALLOC_FAILED_HOOK ( 1 )
/* Memory */
#ifndef configTOTAL_HEAP_SIZE
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 18 * 1024 ) )
#endif
/* Queue & Semaphore & Mutex */
#define configQUEUE_REGISTRY_SIZE 0

View File

@@ -76,7 +76,6 @@
* memory management pages of http://www.FreeRTOS.org for more information.
*/
#include <stdlib.h>
#include <string.h>
/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
all the API functions to use the MPU wrappers. That should only be done when
@@ -98,12 +97,6 @@ task.h is included from an application file. */
/* Assumes 8bit bytes! */
#define heapBITS_PER_BYTE ( ( size_t ) 8 )
#if CONFIG_USE_LINKER_HEAP
extern void *_heap_start;
extern void *_heap_end;
extern void *_heap_len;
#else
/* Allocate the memory for the heap. */
#if( configAPPLICATION_ALLOCATED_HEAP == 1 )
/* The application writer has already defined the array used for the RTOS
@@ -112,7 +105,6 @@ extern void *_heap_len;
#else
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
#endif /* configAPPLICATION_ALLOCATED_HEAP */
#endif
/* Define the linked list structure. This is used to link free blocks in order
of their memory address. */
@@ -160,11 +152,12 @@ static size_t xBlockAllocatedBit = 0;
/*-----------------------------------------------------------*/
static void *malloc_without_lock( size_t xWantedSize )
void *pvPortMalloc( size_t xWantedSize )
{
BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
void *pvReturn = NULL;
vTaskSuspendAll();
{
/* If this is the first call to malloc then the heap will require
initialisation to setup the list of free blocks. */
@@ -288,6 +281,7 @@ void *pvReturn = NULL;
traceMALLOC( pvReturn, xWantedSize );
}
( void ) xTaskResumeAll();
#if( configUSE_MALLOC_FAILED_HOOK == 1 )
{
@@ -306,21 +300,6 @@ void *pvReturn = NULL;
configASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) portBYTE_ALIGNMENT_MASK ) == 0 );
return pvReturn;
}
void *pvPortMalloc( size_t xWantedSize )
{
void *pvReturn = NULL;
if (xWantedSize == 0)
xWantedSize = 4;
vTaskSuspendAll();
pvReturn = malloc_without_lock(xWantedSize);
( void ) xTaskResumeAll();
return pvReturn;
}
/*-----------------------------------------------------------*/
void vPortFree( void *pv )
@@ -388,56 +367,7 @@ void vPortInitialiseBlocks( void )
/* This just exists to keep the linker quiet. */
}
/*-----------------------------------------------------------*/
#if CONFIG_USE_LINKER_HEAP
static void prvHeapInit( void )
{
BlockLink_t *pxFirstFreeBlock;
uint8_t *pucAlignedHeap;
size_t uxAddress;
size_t xTotalHeapSize = (size_t)&_heap_len;
/* Ensure the heap starts on a correctly aligned boundary. */
uxAddress = ( size_t ) &_heap_start;
if( ( uxAddress & portBYTE_ALIGNMENT_MASK ) != 0 )
{
uxAddress += ( portBYTE_ALIGNMENT - 1 );
uxAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK );
xTotalHeapSize -= uxAddress - ( size_t ) &_heap_start;
}
pucAlignedHeap = ( uint8_t * ) uxAddress;
/* xStart is used to hold a pointer to the first item in the list of free
blocks. The void cast is used to prevent compiler warnings. */
xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap;
xStart.xBlockSize = ( size_t ) 0;
/* pxEnd is used to mark the end of the list of free blocks and is inserted
at the end of the heap space. */
uxAddress = ( ( size_t ) pucAlignedHeap ) + xTotalHeapSize;
uxAddress -= xHeapStructSize;
uxAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK );
pxEnd = ( void * ) uxAddress;
pxEnd->xBlockSize = 0;
pxEnd->pxNextFreeBlock = NULL;
/* To start with there is a single free block that is sized to take up the
entire heap space, minus the space taken by pxEnd. */
pxFirstFreeBlock = ( void * ) pucAlignedHeap;
pxFirstFreeBlock->xBlockSize = uxAddress - ( size_t ) pxFirstFreeBlock;
pxFirstFreeBlock->pxNextFreeBlock = pxEnd;
/* Only one block exists - and it covers the entire usable heap space. */
xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize;
xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize;
/* Work out the position of the top bit in a size_t variable. */
xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 );
}
#else
static void prvHeapInit( void )
{
BlockLink_t *pxFirstFreeBlock;
@@ -484,7 +414,6 @@ size_t xTotalHeapSize = configTOTAL_HEAP_SIZE;
/* Work out the position of the top bit in a size_t variable. */
xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 );
}
#endif
/*-----------------------------------------------------------*/
static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert )
@@ -547,115 +476,3 @@ uint8_t *puc;
}
}
/*yhb added 2015-08-13*/
void *pvPortRealloc( void *pv, size_t xWantedSize )
{
uint8_t *puc = ( uint8_t * ) pv;
BlockLink_t *pxLink;
int presize, datasize;
void *pvReturn = NULL;
BlockLink_t *pxIterator, *pxPreviousBlock, *tmp;
if (pv == NULL)
return pvPortMalloc(xWantedSize);
/* The memory being freed will have an BlockLink_t structure immediately
before it. */
puc -= xHeapStructSize;
/* This casting is to keep the compiler from issuing warnings. */
pxLink = ( void * ) puc;
presize = (pxLink->xBlockSize & ~xBlockAllocatedBit);
datasize = presize - xHeapStructSize;
if (datasize >= xWantedSize) // have enough memory don't need realloc
return pv;
pxLink->xBlockSize &= ~xBlockAllocatedBit;
vTaskSuspendAll();
/* Add this block to the list of free blocks. */
xFreeBytesRemaining += pxLink->xBlockSize;
prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) );
pvReturn = malloc_without_lock(xWantedSize);
if (pvReturn != NULL) {
if (pvReturn != pv)
memcpy(pvReturn, pv, datasize);
} else { // if can't realloc such big memory, we should NOT put pv in free list.
//ll_printf("realloc FIX!!\r\n");
pxPreviousBlock = &xStart;
pxIterator = xStart.pxNextFreeBlock;
while( pxIterator != NULL )
{
if (pxIterator > pxLink) {
break;
}
if (pxIterator == pxLink) {// find pxLink at the begin
if (pxIterator->xBlockSize > presize) {
tmp = (BlockLink_t *)((uint8_t*)pxLink + presize);
tmp->xBlockSize = (pxIterator->xBlockSize - presize);
tmp->pxNextFreeBlock = pxIterator->pxNextFreeBlock;
pxPreviousBlock->pxNextFreeBlock = tmp;
} else {
pxPreviousBlock->pxNextFreeBlock = pxIterator->pxNextFreeBlock;
}
goto INSERTED;
}
if ((uint8_t*)pxIterator+pxIterator->xBlockSize == (uint8_t*)pxLink + presize) { // find pxLink at the end
pxIterator->xBlockSize -= presize;
goto INSERTED;
}
if ((uint8_t*)pxIterator+pxIterator->xBlockSize > (uint8_t*)pxLink + presize) { // find pxLink in the middle
pxPreviousBlock = pxIterator;
pxIterator = (BlockLink_t *)((uint8_t*)pxLink + presize);
pxIterator->xBlockSize = ((uint8_t*)pxPreviousBlock+pxPreviousBlock->xBlockSize)-
((uint8_t*)pxLink + presize);
tmp = pxPreviousBlock->pxNextFreeBlock;
pxPreviousBlock->pxNextFreeBlock = pxIterator;
pxPreviousBlock->xBlockSize = (uint8_t*)pxLink - (uint8_t*)pxPreviousBlock;
pxIterator->pxNextFreeBlock = tmp;
goto INSERTED;
}
pxPreviousBlock = pxIterator;
pxIterator = pxIterator->pxNextFreeBlock;
}
INSERTED:
pxLink->xBlockSize = presize|xBlockAllocatedBit;;
pxLink->pxNextFreeBlock = NULL;
xFreeBytesRemaining -= presize;
}
( void ) xTaskResumeAll();
return pvReturn;
}
#if CONFIG_USE_LINKER_HEAP
int heap_total_size(void)
{
return (int)&_heap_len;
}
#else
int heap_total_size(void)
{
return configTOTAL_HEAP_SIZE;
}
#endif
int vPortGetBlocks(void)
{
int blocks = 1;
BlockLink_t *pxIterator;
pxIterator = &xStart;
/* Iterate through the list until a block is found that has a higher address
than the block being inserted. */
while( pxIterator->pxNextFreeBlock)
{
blocks++;
pxIterator = pxIterator->pxNextFreeBlock;
}
return blocks;
}

View File

@@ -753,7 +753,9 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
traceQUEUE_SEND( pxQueue );
xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
#ifdef MXCHIP
event_rx_cb(pxQueue);
#endif
#if ( configUSE_QUEUE_SETS == 1 )
{
if( pxQueue->pxQueueSetContainer != NULL )
@@ -838,9 +840,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
#endif /* configUSE_QUEUE_SETS */
taskEXIT_CRITICAL();
#ifdef MXCHIP
event_rx_cb(pxQueue);
#endif
return pdPASS;
}
else