Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
static void thread1(const void * arg)
{
while (1) {
write_port(1, SET);
write_port(1, RESET);
}
}
static void thread2(const void * arg)
{
while (1) {
write_port(2, SET);
write_port(2, RESET);
}
}
Потому что FreeRTOS не система реального времени и может позволить себе такие вольности.
#define configMINIMAL_STACK_SIZE ((unsigned short)128)Означают что на таск выделяется 128*4=512 байт, а на всех 3000*4=12000 байт.
#define configTOTAL_HEAP_SIZE ((size_t)3000)
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE unsigned portLONG
typedef struct xTASK_PARAMTERS
{
pdTASK_CODE pvTaskCode;
const signed char * const pcName;
unsigned short usStackDepth;
void *pvParameters;
unsigned portBASE_TYPE uxPriority;
portSTACK_TYPE *puxStackBuffer;
xMemoryRegion xRegions[ portNUM_CONFIGURABLE_REGIONS ];
} xTaskParameters;
pxNewTCB->pxStack = ( portSTACK_TYPE * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( portSTACK_TYPE ) ), puxStackBuffer ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
( portSTACK_TYPE * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( portSTACK_TYPE ) ), puxStackBuffer );uint32_t stacksize; /* stack size requirements in bytes; 0 is default stack size */
/* A few bytes might be lost to byte aligning the heap start address. */
#define heapADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )
...
#if portBYTE_ALIGNMENT == 4
#define portBYTE_ALIGNMENT_MASK ( 0x0003 )
#endif
....
/* Keeps track of the number of free bytes remaining, but says nothing about
fragmentation. */
static size_t xFreeBytesRemaining = ( ( size_t ) heapADJUSTED_HEAP_SIZE ) & ( ( size_t ) ~portBYTE_ALIGNMENT_MASK );
size_t xPortGetFreeHeapSize( void )
{
return xFreeBytesRemaining;
}
STM32 и FreeRTOS. 1. Развлечение с потоками