From 1f7fbb8005e5b75e911431c17c8436f8c7413cc8 Mon Sep 17 00:00:00 2001 From: lidun <1084178170@qq.com> Date: Mon, 8 Jan 2024 23:15:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=A8=E6=80=81=E5=86=85?= =?UTF-8?q?=E5=AD=98=E5=88=86=E9=85=8D=E6=9C=BA=E5=88=B6=EF=BC=8C=E5=9F=BA?= =?UTF-8?q?=E4=BA=8EFreeRTOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lidun <1084178170@qq.com> --- APPLICATION/MM/mm.c | 700 ++++++++++++++++++++++++++++++++++++ APPLICATION/MM/mm.h | 107 ++++++ APPLICATION/MM/mm_config.h | 23 ++ OBJ/App.bin | Bin 53480 -> 53480 bytes OBJ/DCBms.hex | 2 +- OBJ/LED.axf | Bin 836648 -> 838656 bytes OBJ/LED.build_log.htm | 33 +- OBJ/LED.hex | 2 +- OBJ/LED.htm | 22 +- OBJ/LED.lnp | 1 + OBJ/LED_Target 1.dep | 108 +++--- OBJ/adc.o | Bin 389908 -> 389928 bytes OBJ/ads1015.o | Bin 363004 -> 363024 bytes OBJ/app_pwr_manage.o | Bin 11216 -> 11236 bytes OBJ/bsp_can.o | Bin 368952 -> 368972 bytes OBJ/bsp_cpu_flash.o | Bin 346188 -> 346208 bytes OBJ/bsp_i2c_gpio.o | Bin 337232 -> 337252 bytes OBJ/can.o | Bin 419240 -> 419260 bytes OBJ/can_app.o | Bin 370364 -> 370384 bytes OBJ/canbusdrv.o | Bin 359224 -> 359244 bytes OBJ/candrvctrl.o | Bin 376756 -> 376776 bytes OBJ/cdz_data.o | Bin 40580 -> 40600 bytes OBJ/cdz_state.o | Bin 453372 -> 453392 bytes OBJ/chipid.o | Bin 336540 -> 336560 bytes OBJ/common.o | Bin 363292 -> 363312 bytes OBJ/core_cm3.o | Bin 12232 -> 12252 bytes OBJ/dc300.o | Bin 327744 -> 327764 bytes OBJ/delay.o | Bin 336212 -> 336232 bytes OBJ/err_code.o | Bin 37108 -> 37128 bytes OBJ/err_info_process.o | Bin 394700 -> 394720 bytes OBJ/kc.o | Bin 366040 -> 366060 bytes OBJ/led.o | Bin 347724 -> 347744 bytes OBJ/main.crf | Bin 390072 -> 392261 bytes OBJ/main.d | 3 + OBJ/main.o | Bin 409736 -> 413876 bytes OBJ/misc.o | Bin 330356 -> 330376 bytes OBJ/mm.crf | Bin 0 -> 11151 bytes OBJ/mm.d | 6 + OBJ/mm.o | Bin 0 -> 30676 bytes OBJ/porting.o | Bin 380104 -> 380124 bytes OBJ/rev_carmessage.o | Bin 377984 -> 378004 bytes OBJ/sen_dcumessage.o | Bin 391780 -> 391800 bytes OBJ/single_event_receiver.o | Bin 27604 -> 27624 bytes OBJ/sleep.o | Bin 413108 -> 413128 bytes OBJ/spi.o | Bin 344240 -> 344260 bytes OBJ/stm32f10x_adc.o | Bin 387028 -> 387048 bytes OBJ/stm32f10x_bkp.o | Bin 343936 -> 343956 bytes OBJ/stm32f10x_can.o | Bin 362564 -> 362584 bytes OBJ/stm32f10x_dma.o | Bin 350828 -> 350848 bytes OBJ/stm32f10x_exti.o | Bin 337248 -> 337268 bytes OBJ/stm32f10x_flash.o | Bin 373216 -> 373236 bytes OBJ/stm32f10x_gpio.o | Bin 350596 -> 350616 bytes OBJ/stm32f10x_it.o | Bin 333372 -> 333392 bytes OBJ/stm32f10x_iwdg.o | Bin 333232 -> 333252 bytes OBJ/stm32f10x_pwr.o | Bin 338264 -> 338284 bytes OBJ/stm32f10x_rcc.o | Bin 383460 -> 383480 bytes OBJ/stm32f10x_rtc.o | Bin 344000 -> 344020 bytes OBJ/stm32f10x_spi.o | Bin 364800 -> 364820 bytes OBJ/stm32f10x_tim.o | Bin 456068 -> 456088 bytes OBJ/stm32f10x_usart.o | Bin 366312 -> 366332 bytes OBJ/stm32f10x_wwdg.o | Bin 335680 -> 335700 bytes OBJ/sys.crf | Bin 322353 -> 322353 bytes OBJ/sys.o | Bin 363080 -> 363100 bytes OBJ/system_stm32f10x.o | Bin 329672 -> 329692 bytes OBJ/timer.o | Bin 337172 -> 337192 bytes OBJ/usart.o | Bin 522416 -> 522436 bytes SYSTEM/sys/sys.c | Bin 20480 -> 20480 bytes USER/LED.map | Bin 401408 -> 405504 bytes USER/LED.uvguix.14617 | 68 +--- USER/LED.uvoptx | 32 ++ USER/LED.uvprojx | Bin 32768 -> 32768 bytes USER/main.c | Bin 8192 -> 8192 bytes 72 files changed, 968 insertions(+), 139 deletions(-) create mode 100644 APPLICATION/MM/mm.c create mode 100644 APPLICATION/MM/mm.h create mode 100644 APPLICATION/MM/mm_config.h create mode 100644 OBJ/mm.crf create mode 100644 OBJ/mm.d create mode 100644 OBJ/mm.o diff --git a/APPLICATION/MM/mm.c b/APPLICATION/MM/mm.c new file mode 100644 index 0000000..6550f0f --- /dev/null +++ b/APPLICATION/MM/mm.c @@ -0,0 +1,700 @@ +#include "mm.h" + + +/*块不太小 */ +#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) +/* Assumes 8bit bytes!假设为8位 */ +#define heapBITS_PER_BYTE ( ( size_t ) 8 ) + +/* Max value that fits in a size_t type. size_t最大值 */ +#define heapSIZE_MAX ( ~( ( size_t ) 0 ) ) +/* Check if multiplying a and b will result in overflow. 检查a 和B 相乘是否会溢出*/ +#define heapMULTIPLY_WILL_OVERFLOW( a, b ) ( ( ( a ) > 0 ) && ( ( b ) > ( heapSIZE_MAX / ( a ) ) ) ) +/* Check if adding a and b will result in overflow. 检查a 和b相加是否会溢出*/ +#define heapADD_WILL_OVERFLOW( a, b ) ( ( a ) > ( heapSIZE_MAX - ( b ) ) ) + +/* BlockLink_t结构中的xBlockSize成员的最高有效位(MSB)用于追踪块的分配状态。 + 当设置了BlockLink_t结构中的xBlockSize成员的MSB时,该块被归属于应用程序。 + 而当该位为空闲时,该块仍然是空闲堆空间的一部分。 */ +#define heapBLOCK_ALLOCATED_BITMASK ( ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 ) ) //内存对齐使用 +#define heapBLOCK_SIZE_IS_VALID( xBlockSize ) ( ( ( xBlockSize ) & heapBLOCK_ALLOCATED_BITMASK ) == 0 ) +#define heapBLOCK_IS_ALLOCATED( pxBlock ) ( ( ( pxBlock->xBlockSize ) & heapBLOCK_ALLOCATED_BITMASK ) != 0 ) +#define heapALLOCATE_BLOCK( pxBlock ) ( ( pxBlock->xBlockSize ) |= heapBLOCK_ALLOCATED_BITMASK ) +#define heapFREE_BLOCK( pxBlock ) ( ( pxBlock->xBlockSize ) &= ~heapBLOCK_ALLOCATED_BITMASK ) + + + +static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];//堆内存大小分配 + +typedef struct A_BLOCK_LINK +{ + struct A_BLOCK_LINK * pxNextFreeBlock; /*<< The next free block in the list. 下一个空闲块*/ + size_t xBlockSize; /*<< The size of the free block.空闲块的大小 */ +} BlockLink_t; + +/* 将正在释放的内存块插入到空闲内存块列表中的正确位置。 + 如果内存块彼此相邻,被释放的块将与它前面的块和/或它后面的块合并。 */ + + + + + +static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert ); +static void prvHeapInit( void ); +/* 位于每个分配的内存块开头的结构的大小必须按正确的字节对齐。 */ + + +static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK ); +/* 创建两个列表链接来标记列表的开始和结束。*/ + +static BlockLink_t xStart; +static BlockLink_t * pxEnd = NULL;//如果不是NULL就是已经初始化话内存了,这个很重要 + + +/* 跟踪分配和释放内存的调用数量以及剩余空闲字节数,但没有说明碎片。* / */ + +static size_t xFreeBytesRemaining = 0U; +static size_t xMinimumEverFreeBytesRemaining = 0U; +static size_t xNumberOfSuccessfulAllocations = 0; + +static size_t xNumberOfSuccessfulFrees = 0; + + +/*-----------------------------------------------------------*/ + +void * pvPortMalloc( size_t xWantedSize ) +{ + BlockLink_t * pxBlock; + BlockLink_t * pxPreviousBlock; + BlockLink_t * pxNewBlockLink; + void * pvReturn = NULL; + size_t xAdditionalRequiredSize; + + + { + /* If this is the first call to malloc then the heap will require + * initialisation to setup the list of free blocks. */ + if( pxEnd == NULL ) + { + prvHeapInit(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + if( xWantedSize > 0 ) + { + /* The wanted size must be increased so it can contain a BlockLink_t + * structure in addition to the requested amount of bytes. Some + * additional increment may also be needed for alignment. */ + xAdditionalRequiredSize = xHeapStructSize + portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ); + + if( heapADD_WILL_OVERFLOW( xWantedSize, xAdditionalRequiredSize ) == 0 ) + { + xWantedSize += xAdditionalRequiredSize; + } + else + { + xWantedSize = 0; + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Check the block size we are trying to allocate is not so large that the + * top bit is set. The top bit of the block size member of the BlockLink_t + * structure is used to determine who owns the block - the application or + * the kernel, so it must be free. */ + if( heapBLOCK_SIZE_IS_VALID( xWantedSize ) != 0 ) + { + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) + { + /* Traverse the list from the start (lowest address) block until + * one of adequate size is found. */ + pxPreviousBlock = &xStart; + pxBlock = xStart.pxNextFreeBlock; + + while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) + { + pxPreviousBlock = pxBlock; + pxBlock = pxBlock->pxNextFreeBlock; + } + + /* If the end marker was reached then a block of adequate size + * was not found. */ + if( pxBlock != pxEnd ) + { + /* Return the memory space pointed to - jumping over the + * BlockLink_t structure at its start. */ + pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); + + /* This block is being returned for use so must be taken out + * of the list of free blocks. */ + pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; + + /* If the block is larger than required it can be split into + * two. */ + if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) + { + /* This block is to be split into two. Create a new + * block following the number of bytes requested. The void + * cast is used to prevent byte alignment warnings from the + * compiler. */ + pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); + configASSERT( ( ( ( size_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 ); + + /* Calculate the sizes of two blocks split from the + * single block. */ + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + + /* Insert the new block into the list of free blocks. */ + prvInsertBlockIntoFreeList( pxNewBlockLink ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + xFreeBytesRemaining -= pxBlock->xBlockSize; + + if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) + { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* The block is being returned - it is allocated and owned + * by the application and has no "next" block. */ + heapALLOCATE_BLOCK( pxBlock ); + pxBlock->pxNextFreeBlock = NULL; + xNumberOfSuccessfulAllocations++; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + traceMALLOC( pvReturn, xWantedSize ); + } + + + + + configASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) portBYTE_ALIGNMENT_MASK ) == 0 ); + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vPortFree( void * pv ) +{ + uint8_t * puc = ( uint8_t * ) pv; + BlockLink_t * pxLink; + + if( pv != NULL ) + { + /* 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; + + configASSERT( heapBLOCK_IS_ALLOCATED( pxLink ) != 0 ); + configASSERT( pxLink->pxNextFreeBlock == NULL ); + + if( heapBLOCK_IS_ALLOCATED( pxLink ) != 0 ) + { + if( pxLink->pxNextFreeBlock == NULL ) + { + /* The block is being returned to the heap - it is no longer + * allocated. */ + heapFREE_BLOCK( pxLink ); + #if ( configHEAP_CLEAR_MEMORY_ON_FREE == 1 ) + { + ( void ) memset( puc + xHeapStructSize, 0, pxLink->xBlockSize - xHeapStructSize ); + } + #endif + + + { + /* Add this block to the list of free blocks. */ + xFreeBytesRemaining += pxLink->xBlockSize; + traceFREE( pv, pxLink->xBlockSize ); + prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); + xNumberOfSuccessfulFrees++; + } + + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + } +} +/*-----------------------------------------------------------*/ + +size_t xPortGetFreeHeapSize( void ) +{ + return xFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +size_t xPortGetMinimumEverFreeHeapSize( void ) +{ + return xMinimumEverFreeBytesRemaining; +} +/*-----------------------------------------------------------*/ + +void vPortInitialiseBlocks( void ) +{ + /* This just exists to keep the linker quiet. */ +} +/*-----------------------------------------------------------*/ + +void * pvPortCalloc( size_t xNum, + size_t xSize ) +{ + void * pv = NULL; + + if( heapMULTIPLY_WILL_OVERFLOW( xNum, xSize ) == 0 ) + { + pv = pvPortMalloc( xNum * xSize ); + + if( pv != NULL ) + { + ( void ) memset( pv, 0, xNum * xSize ); + } + } + + return pv; +} +/*-----------------------------------------------------------*/ + +static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */ +{ + BlockLink_t * pxFirstFreeBlock; + uint8_t * pucAlignedHeap; + portPOINTER_SIZE_TYPE uxAddress; + size_t xTotalHeapSize = configTOTAL_HEAP_SIZE; + + /* Ensure the heap starts on a correctly aligned boundary. */ + uxAddress = ( portPOINTER_SIZE_TYPE ) ucHeap; + + if( ( uxAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) + { + uxAddress += ( portBYTE_ALIGNMENT - 1 ); + uxAddress &= ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ); + xTotalHeapSize -= uxAddress - ( portPOINTER_SIZE_TYPE ) ucHeap; + } + + 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 = ( ( portPOINTER_SIZE_TYPE ) pucAlignedHeap ) + xTotalHeapSize; + uxAddress -= xHeapStructSize; + uxAddress &= ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ); + pxEnd = ( BlockLink_t * ) 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 = ( BlockLink_t * ) pucAlignedHeap; + pxFirstFreeBlock->xBlockSize = ( size_t ) ( uxAddress - ( portPOINTER_SIZE_TYPE ) pxFirstFreeBlock ); + pxFirstFreeBlock->pxNextFreeBlock = pxEnd; + + /* Only one block exists - and it covers the entire usable heap space. */ + xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; + xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; +} +/*-----------------------------------------------------------*/ + +static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert ) /* PRIVILEGED_FUNCTION */ +{ + BlockLink_t * pxIterator; + uint8_t * puc; + + /* Iterate through the list until a block is found that has a higher address + * than the block being inserted. */ + for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) + { + /* Nothing to do here, just iterate to the right position. */ + } + + /* Do the block being inserted, and the block it is being inserted after + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxIterator; + + if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) + { + pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; + pxBlockToInsert = pxIterator; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } + + /* Do the block being inserted, and the block it is being inserted before + * make a contiguous block of memory? */ + puc = ( uint8_t * ) pxBlockToInsert; + + if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) + { + if( pxIterator->pxNextFreeBlock != pxEnd ) + { + /* Form one big block from the two blocks. */ + pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxEnd; + } + } + else + { + pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; + } + + /* If the block being inserted plugged a gab, so was merged with the block + * before and the block after, then it's pxNextFreeBlock pointer will have + * already been set, and should not be set here as that would make it point + * to itself. */ + if( pxIterator != pxBlockToInsert ) + { + pxIterator->pxNextFreeBlock = pxBlockToInsert; + } + else + { + mtCOVERAGE_TEST_MARKER(); + } +} +/*-----------------------------------------------------------*/ + +void vPortGetHeapStats( HeapStats_t * pxHeapStats ) +{ + BlockLink_t * pxBlock; + size_t xBlocks = 0, xMaxSize = 0, xMinSize = portMAX_DELAY; /* portMAX_DELAY used as a portable way of getting the maximum value. */ + + + { + pxBlock = xStart.pxNextFreeBlock; + + /* pxBlock will be NULL if the heap has not been initialised. The heap + * is initialised automatically when the first allocation is made. */ + if( pxBlock != NULL ) + { + while( pxBlock != pxEnd ) + { + /* Increment the number of blocks and record the largest block seen + * so far. */ + xBlocks++; + + if( pxBlock->xBlockSize > xMaxSize ) + { + xMaxSize = pxBlock->xBlockSize; + } + + if( pxBlock->xBlockSize < xMinSize ) + { + xMinSize = pxBlock->xBlockSize; + } + + /* Move to the next block in the chain until the last block is + * reached. */ + pxBlock = pxBlock->pxNextFreeBlock; + } + } + } + + + pxHeapStats->xSizeOfLargestFreeBlockInBytes = xMaxSize; + pxHeapStats->xSizeOfSmallestFreeBlockInBytes = xMinSize; + pxHeapStats->xNumberOfFreeBlocks = xBlocks; + + + { + pxHeapStats->xAvailableHeapSpaceInBytes = xFreeBytesRemaining; + pxHeapStats->xNumberOfSuccessfulAllocations = xNumberOfSuccessfulAllocations; + pxHeapStats->xNumberOfSuccessfulFrees = xNumberOfSuccessfulFrees; + pxHeapStats->xMinimumEverFreeBytesRemaining = xMinimumEverFreeBytesRemaining; + } + +} +/*-----------------------------------------------------------*/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/APPLICATION/MM/mm.h b/APPLICATION/MM/mm.h new file mode 100644 index 0000000..d158c5b --- /dev/null +++ b/APPLICATION/MM/mm.h @@ -0,0 +1,107 @@ +/* + * @Description: + * @Version: + * @Author: Arnold + * @Date: 2023-10-27 13:48:57 + * @LastEditTime: 2024-01-08 23:11:25 + */ +#ifndef __MM_H__ +#define __MM_H__ +#include +#include +#include +#include + + +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 4 * 1024 ) ) + + +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 8 +#define portNOP() __asm volatile ( "NOP" ) +#define mtCOVERAGE_TEST_MARKER() __asm volatile ( "NOP" ) +#define configTICK_RATE_HZ ( 1000 ) + + +#if portBYTE_ALIGNMENT == 32 + #define portBYTE_ALIGNMENT_MASK ( 0x001f ) +#elif portBYTE_ALIGNMENT == 16 + #define portBYTE_ALIGNMENT_MASK ( 0x000f ) +#elif portBYTE_ALIGNMENT == 8 + #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) +#elif portBYTE_ALIGNMENT == 4 + #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) +#elif portBYTE_ALIGNMENT == 2 + #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) +#elif portBYTE_ALIGNMENT == 1 + #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) +#else /* if portBYTE_ALIGNMENT == 32 */ + #error "Invalid portBYTE_ALIGNMENT definition" +#endif /* if portBYTE_ALIGNMENT == 32 */ + + +#if ( configUSE_16_BIT_TICKS == 1 ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#else + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL +#endif +#define portPOINTER_SIZE_TYPE uint64_t +/* It is a good idea to define configASSERT() while developing. configASSERT() + * uses the same semantics as the standard C assert() macro. */ +#define configASSERT( x ) \ + do \ + { \ + if( x ) \ + { \ + vFakeAssert( true, __FILE__, __LINE__ ); \ + } \ + else \ + { \ + vFakeAssert( false, __FILE__, __LINE__ ); \ + } \ + } while( 0 ) + +void vFakeAssert( bool x, + char * file, + int line ); + +/* Used to pass information about the heap out of vPortGetHeapStats(). */ +typedef struct xHeapStats +{ + size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ + size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ + size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ + size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ +} HeapStats_t; + +#ifndef traceMALLOC + #define traceMALLOC( pvAddress, uiSize ) +#endif + +#ifndef traceFREE + #define traceFREE( pvAddress, uiSize ) +#endif + + +/* #define vFakeAssert(x, file, line) if (!(x)) { \ + LogError("Assertion failed in file %s at line %d", file, line); \ + RecordAssertionFailure(); \ +} */ +#define vFakeAssert(x, file, line) if (!(x)) { } + +void * pvPortMalloc( size_t xWantedSize );//分配内存 +void vPortFree( void * pv );//释放内存 +size_t xPortGetFreeHeapSize( void );//获取当前可用堆内存的大小 +size_t xPortGetMinimumEverFreeHeapSize( void );//用于获取系统运行的最小空闲大小!!!! +void vPortInitialiseBlocks( void );//初始化任务控制块和任务堆栈内存,不需要显式调用 +void * pvPortCalloc( size_t xNum, //分配一定数量和大小的内存卡 + size_t xSize ); +void vPortGetHeapStats( HeapStats_t * pxHeapStats );//统计当前堆的情况 +#endif + + diff --git a/APPLICATION/MM/mm_config.h b/APPLICATION/MM/mm_config.h new file mode 100644 index 0000000..9f48ac1 --- /dev/null +++ b/APPLICATION/MM/mm_config.h @@ -0,0 +1,23 @@ +#ifndef __MM_Arnold_config_H_ + +#define __MM_Arnold_config_H_ +#include "mm.h" +#define MM_Malloc(x) pvPortMalloc(x) /* 分配内存 */ + +#define MM_Free(x) vPortFree(x) /* 释放内存 */ + +#define MM_GetFreeHeapSize() xPortGetFreeHeapSize() /*获取当前可用堆内存的大小 */ +#define MM_GetMinimumEverFreeHeapSize xPortGetMinimumEverFreeHeapSize() /*用于获取系统运行的最小空闲大小!!!! */ +#define MM_GetHeapStats(x) vPortGetHeapStats(x) /* 不建议使用 */ + + + + + +#endif + + + + + + diff --git a/OBJ/App.bin b/OBJ/App.bin index 689f11630a52732f47624064d74271c5a339e099..f5e63d190481ad7e9892f789013ee208596c1820 100644 GIT binary patch delta 16 YcmaE{komW8BI3l9k1d907g>>od5s; delta 16 YcmaE{komW8I3pR9k1d907gv*oB#j- diff --git a/OBJ/DCBms.hex b/OBJ/DCBms.hex index e00ca57..2723fe6 100644 --- a/OBJ/DCBms.hex +++ b/OBJ/DCBms.hex @@ -3958,7 +3958,7 @@ :104730003D070108C9050108000000000000000055 :104740000000000000000000010000008D060108CC :104750003D070108C9050108000000000000000035 -:1047600000000000000000004134305530330000EC +:1047600000000000000000004134305530340000EB :104770000000000001000000904A0108190B010828 :1047800001000000484A0108770B01080100000001 :10479000404A0108750B010801000000844A010825 diff --git a/OBJ/LED.axf b/OBJ/LED.axf index e14004f06a80d3b8e519ba75685c94f067da69c2..963fa3e17f9e6ab78ff51c69304781d5c6814a95 100644 GIT binary patch delta 13522 zcmb{2dz?*G|G@FR=fWAYX(ls0CWGUWh{3q!9vW)g8X<%y*P=`=KSE-=O&O(3=ok?u ziXLLz4!_6!65~!1o(L(1lqr{l=K1V%);fF5es#t_&%7S5^Sr;`?^=89wb$C~j4Yj6 zXTqF1GvbT%&M~wJIoTD=J$l{AS$p2e+N1L)#GADzG^xE_&vPjz?6@BP&ZgKf@21#r z-O%fKx0DZmNGEovLO6el@TVw$T>OdPPciSI3X!KfB>uaa7WfI%^72pNl!=tn1ZnGbVb^+1oB)#YtR7n>dV|FO;d|8a-; zXBqI`EB2gR!Iu@^#ys2wp37VEj;B{ToLYTyd@Y+q2x{(Ln&<99pX z5@+B_Or+JmtJPk~r&{fC4UwOSFUY(}gJ}eQAW%#cWMKJYJ(6sPkKqx99(d}f@VrvC zo%Mw|*1Et2#|7?s#*Bz87ZO{;Gj~K}S-qxbqu^;j??64-6F1WL(a`_VosZ~#)=i2Z ztLJ{6bSpc~v&{OK?a8q|7I<>4k1sqCZ}73hQ`P!7;7R7gbguAk>Cjr?VRUM(@awp@ z;)t5Ib@I;kapXHI_0GJ*W`1oNbW^sJqafeuwhyT9FY?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w27#r5hqit{qKAe@m>Re^j{IzL;dX& z4X^I6r5h(af$zT9*Nh7O%3;Pu5%9-^8~J>1Vub6TRWyE(<KR|l_{$B9Blh=eA=X*1^MAXOy_*~7 z?0AIk@7~flBg?l-HVS3DZHnk1WuEEioU3M6(Iyug+QZ z2*^?8U$@J7Pz&}Nf5}Si_8Bq0+yh3U|Et5sJWqV#O#8iE`Collection of Component Files used: * Component: ARM::CMSIS:CORE:5.1.1 -Build Time Elapsed: 00:00:05 +Build Time Elapsed: 00:00:06 diff --git a/OBJ/LED.hex b/OBJ/LED.hex index 16dadb8..565bec2 100644 --- a/OBJ/LED.hex +++ b/OBJ/LED.hex @@ -3190,7 +3190,7 @@ :104730003D070108C9050108000000000000000055 :104740000000000000000000010000008D060108CC :104750003D070108C9050108000000000000000035 -:1047600000000000000000004134305530330000EC +:1047600000000000000000004134305530340000EB :104770000000000001000000904A0108190B010828 :1047800001000000484A0108770B01080100000001 :10479000404A0108750B010801000000844A010825 diff --git a/OBJ/LED.htm b/OBJ/LED.htm index 07654ed..5f24e88 100644 --- a/OBJ/LED.htm +++ b/OBJ/LED.htm @@ -3,7 +3,7 @@ Static Call Graph - [..\OBJ\LED.axf]

Static Call Graph for image ..\OBJ\LED.axf


-

#<CALLGRAPH># ARM Linker, 5060750: Last Updated: Mon Jan 08 21:13:05 2024 +

#<CALLGRAPH># ARM Linker, 5060750: Last Updated: Mon Jan 08 23:15:29 2024

Maximum Stack Usage = 464 bytes + Unknown(Cycles, Untraceable Function Pointers)

Call chain for Maximum Stack Depth:

@@ -654,16 +654,16 @@ Global Symbols

[Stack]
  • Max Depth = 8
  • Call Chain = _double_round

[Called By]
  • >>   __aeabi_ddiv -
  • >>   _double_epilogue
  • >>   __aeabi_dadd +
  • >>   _double_epilogue

_double_epilogue (Thumb, 156 bytes, Stack size 32 bytes, depilogue.o(.text))

[Stack]

  • Max Depth = 40
  • Call Chain = _double_epilogue ⇒ _double_round
-
[Calls]