本文整理汇总了C++中xPortGetFreeHeapSize函数的典型用法代码示例。如果您正苦于以下问题:C++ xPortGetFreeHeapSize函数的具体用法?C++ xPortGetFreeHeapSize怎么用?C++ xPortGetFreeHeapSize使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xPortGetFreeHeapSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vApplicationIdleHook
void vApplicationIdleHook( void )
{
volatile size_t xFreeStackSpace;
/* This function is called on each cycle of the idle task. In this case it
does nothing useful, other than report the amount of FreeRTOS heap that
remains unallocated. */
xFreeStackSpace = xPortGetFreeHeapSize();
if( xFreeStackSpace > 100 )
{
/* By now, the kernel has allocated everything it is going to, so
if there is a lot of heap remaining unallocated then
the value of configTOTAL_HEAP_SIZE in FreeRTOSConfig.h can be
reduced accordingly. */
}
}
示例2: user_init
void user_init(void) {
lastTick = xTaskGetTickCount();
startMem = lastMem = xPortGetFreeHeapSize();
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
setbuf(stdin, NULL);
setbuf(stdout, NULL);
// this doesn't have enough stack!
//lispTask(NULL); return;
// for now run in a task, in order to allocate a bigger stack
// 1024 --> (fibo 13)
// 2048 --> (fibo 30) ???
xTaskCreate(lispTask, (signed char *)"lispTask", 2048, NULL, 2, NULL);
}
示例3: vApplicationIdleHook
void vApplicationIdleHook( void )
{
volatile size_t xFreeHeapSpace, xMinimumEverFreeHeapSpace;
/* This is just a trivial example of an idle hook. It is called on each
cycle of the idle task. It must *NOT* attempt to block. In this case the
idle task just queries the amount of FreeRTOS heap that remains. See the
memory management section on the http://www.FreeRTOS.org web site for memory
management options. If there is a lot of heap memory free then the
configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
RAM. */
xFreeHeapSpace = xPortGetFreeHeapSize();
xMinimumEverFreeHeapSpace = xPortGetMinimumEverFreeHeapSize();
/* Remove compiler warning about xFreeHeapSpace being set but never used. */
( void ) xFreeHeapSpace;
( void ) xMinimumEverFreeHeapSpace;
}
示例4: vApplicationIdleHook
void vApplicationIdleHook( void )
{
volatile size_t xFreeHeapSpace;
/* This is just a trivial example of an idle hook. It is called on each
cycle of the idle task. It must *NOT* attempt to block. In this case the
idle task just queries the amount of FreeRTOS heap that remains. See the
memory management section on the http://www.FreeRTOS.org web site for memory
management options. If there is a lot of heap memory free then the
configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
RAM. */
xFreeHeapSpace = xPortGetFreeHeapSize();
/* Remove compiler warning about xFreeHeapSpace being set but never used. */
( void ) xFreeHeapSpace;
#if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1
{
/* If the file system is only going to be accessed from one task then
F_FS_THREAD_AWARE can be set to 0 and the set of example files is
created before the RTOS scheduler is started. If the file system is
going to be access from more than one task then F_FS_THREAD_AWARE must
be set to 1 and the set of sample files are created from the idle task
hook function. */
#if F_FS_THREAD_AWARE == 1
{
static portBASE_TYPE xCreatedSampleFiles = pdFALSE;
/* Initialise the drive and file system, then create a few example
files. The output from this function just goes to the stdout window,
allowing the output to be viewed when the UDP command console is not
connected. */
if( xCreatedSampleFiles == pdFALSE )
{
vCreateAndVerifySampleFiles();
xCreatedSampleFiles = pdTRUE;
}
}
#endif
}
#endif
}
示例5: get_task_state
static int get_task_state(int argc, char **argv)
{
TaskStatus_t *pxTaskStatusArray;
volatile UBaseType_t uxArraySize, x;
uint32_t ulTotalRunTime, ulStatsAsPercentage;
uxArraySize = uxTaskGetNumberOfTasks();
pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
if( pxTaskStatusArray != NULL )
{
printf("任务名\t\tID\t优先级\t堆栈\tCPU使用率\r\n");
uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
if( ulTotalRunTime > 0 )
{
for( x = 0; x < uxArraySize; x++ )
{
ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime * 100;
if( ulStatsAsPercentage > 0UL )
{
printf("%-16s%-8d%-8d%-8d%d%%\r\n", pxTaskStatusArray[x].pcTaskName,pxTaskStatusArray[x].xTaskNumber,
pxTaskStatusArray[x].uxCurrentPriority, pxTaskStatusArray[x].usStackHighWaterMark, ulStatsAsPercentage);
vTaskDelay(100/portTICK_RATE_MS);
}
else
{
printf("%-16s%-8d%-8d%-8d<1%%\r\n", pxTaskStatusArray[x].pcTaskName,pxTaskStatusArray[x].xTaskNumber,
pxTaskStatusArray[x].uxCurrentPriority, pxTaskStatusArray[x].usStackHighWaterMark);
vTaskDelay(100/portTICK_RATE_MS);
}
}
}
vPortFree( pxTaskStatusArray );
}
printf("\r\n");
size_t freeHeapSize = xPortGetFreeHeapSize();
printf("the free heapsize is %d\r\n", freeHeapSize);
vTaskDelay(50/portTICK_RATE_MS);
return 0;
}
示例6: getStation
ICACHE_FLASH_ATTR struct shoutcast_info* getStation(uint8_t position) {
if (position > NBSTATIONS-1) {printf("getStation fails position=%d\n",position); return NULL;}
uint8_t* buffer = malloc(256);
while (buffer== NULL)
{
buffer = malloc(256);
if ( buffer == NULL ){
int i = 0;
do {
i++;
printf ("Heap size: %d\n",xPortGetFreeHeapSize( ));
vTaskDelay(10);
printf("getstation malloc fails for %d\n",256 );
}
while (i<10);
if (i >=10) { /*free(string);*/ return NULL;}
}
}
eeGetData((position+1)*256, buffer, 256);
return (struct shoutcast_info*)buffer;
}
示例7: updateStats
/**
* Called periodically to update the system stats
*/
static void updateStats()
{
static portTickType lastTickCount = 0;
SystemStatsData stats;
// Get stats and update
SystemStatsGet(&stats);
stats.FlightTime = xTaskGetTickCount() * portTICK_RATE_MS;
#if defined(ARCH_POSIX) || defined(ARCH_WIN32)
// POSIX port of FreeRTOS doesn't have xPortGetFreeHeapSize()
stats.HeapRemaining = 10240;
#else
stats.HeapRemaining = xPortGetFreeHeapSize();
#endif
// Get Irq stack status
stats.IRQStackRemaining = GetFreeIrqStackSize();
// When idleCounterClear was not reset by the idle-task, it means the idle-task did not run
if (idleCounterClear) {
idleCounter = 0;
}
portTickType now = xTaskGetTickCount();
if (now > lastTickCount) {
uint32_t dT = (xTaskGetTickCount() - lastTickCount) * portTICK_RATE_MS; // in ms
stats.CPULoad =
100 - (uint8_t) round(100.0 * ((float)idleCounter / ((float)dT / 1000.0)) / (float)IDLE_COUNTS_PER_SEC_AT_NO_LOAD);
} //else: TickCount has wrapped, do not calc now
lastTickCount = now;
idleCounterClear = 1;
#if defined(PIOS_INCLUDE_ADC) && defined(PIOS_ADC_USE_TEMP_SENSOR)
float temp_voltage = 3.3 * PIOS_ADC_PinGet(0) / ((1 << 12) - 1);
const float STM32_TEMP_V25 = 1.43; /* V */
const float STM32_TEMP_AVG_SLOPE = 4.3; /* mV/C */
stats.CPUTemp = (temp_voltage-STM32_TEMP_V25) * 1000 / STM32_TEMP_AVG_SLOPE + 25;
#endif
SystemStatsSet(&stats);
}
示例8: serial_task
static void serial_task(void *handle)
{
int i;
(void) handle;
portCHAR data;
vTasksRunning = TRUE;
i = 0;
for (;;)
{
debug_printf("%04i: Hello Task! (%04i bytes free heap memory)\n", i++,
xPortGetFreeHeapSize());
GPIOSetValue(LED_PORT, LED_BIT, LED_ON);
vTaskDelay(10 / portTICK_RATE_MS);
GPIOSetValue(LED_PORT, LED_BIT, LED_OFF);
while (vUSBRecvByte(&data, sizeof(data), 990))
UARTSendChar(data);
}
}
示例9: machine_info
STATIC mp_obj_t machine_info(uint n_args, const mp_obj_t *args) {
// FreeRTOS info
{
printf("---------------------------------------------\n");
printf("FreeRTOS\n");
printf("---------------------------------------------\n");
printf("Total heap: %u\n", configTOTAL_HEAP_SIZE);
printf("Free heap: %u\n", xPortGetFreeHeapSize());
printf("MpTask min free stack: %u\n", (unsigned int)uxTaskGetStackHighWaterMark((TaskHandle_t)mpTaskHandle));
printf("ServersTask min free stack: %u\n", (unsigned int)uxTaskGetStackHighWaterMark((TaskHandle_t)svTaskHandle));
printf("SlTask min free stack: %u\n", (unsigned int)uxTaskGetStackHighWaterMark(xSimpleLinkSpawnTaskHndl));
printf("IdleTask min free stack: %u\n", (unsigned int)uxTaskGetStackHighWaterMark(xTaskGetIdleTaskHandle()));
uint32_t *pstack = (uint32_t *)&_stack;
while (*pstack == 0x55555555) {
pstack++;
}
printf("MAIN min free stack: %u\n", pstack - ((uint32_t *)&_stack));
printf("---------------------------------------------\n");
}
return mp_const_none;
}
示例10: main
int main(int argc, char* argv[])
{
// At this stage the system clock should have already been configured
// at high speed.
#if !USE_WRAPPER
xTaskCreate(task_led4, (const char * ) "Led4", configMINIMAL_STACK_SIZE, NULL, TASK_LED4_PRIO,
NULL);
xTaskCreate(task_led3, (const char * ) "Led3", configMINIMAL_STACK_SIZE, NULL, TASK_LED3_PRIO,
&handle_led3);
#else
static TSK_T1 tsk_t1;
static TSK_T2 tsk_t2;
tsk_t1.link(tsk_t2);
#endif
volatile size_t size = xPortGetFreeHeapSize();
vTaskStartScheduler(); // should never return
}
示例11: prvLCDTask
static void prvLCDTask( void *pvParameters )
{
xQueueMessage xReceivedMessage;
long lLine = Line1;
const long lFontHeight = (((sFONT *)LCD_GetFont())->Height);
/* Buffer into which strings are formatted and placed ready for display on the
LCD. Note this is a static variable to prevent it being allocated on the task
stack, which is too small to hold such a variable. The stack size is configured
when the task is created. */
static char cBuffer[ 512 ];
/* This function is the only function that uses printf(). If printf() is
used from any other function then some sort of mutual exclusion on stdout
will be necessary.
This is also the only function that is permitted to access the LCD.
First print out the number of bytes that remain in the FreeRTOS heap. This
can be viewed in the terminal IO window within the IAR Embedded Workbench. */
printf( "%d bytes of heap space remain unallocated\n", xPortGetFreeHeapSize() );
for( ;; ) {
/* Wait for a message to be received. Using portMAX_DELAY as the block
time will result in an indefinite wait provided INCLUDE_vTaskSuspend is
set to 1 in FreeRTOSConfig.h, therefore there is no need to check the
function return value and the function will only return when a value
has been received. */
xQueueReceive( xLCDQueue, &xReceivedMessage, portMAX_DELAY );
/* Clear the LCD if no room remains for any more text output. */
if( lLine > Line9 ) {
LCD_Clear( Blue );
lLine = 0;
}
/* What is this message? What does it contain? */
switch( xReceivedMessage.cMessageID ) {
case mainMESSAGE_BUTTON_UP : /* The button poll task has just
informed this task that the up
button on the joystick input has
been pressed or released. */
sprintf( cBuffer, "Button up = %d", xReceivedMessage.lMessageValue );
break;
case mainMESSAGE_BUTTON_SEL : /* The select button interrupt
just informed this task that the
select button was pressed.
Generate a table of task run time
statistics and output this to
the terminal IO window in the IAR
embedded workbench. */
printf( "\nTask\t Abs Time\t %%Time\n*****************************************" );
vTaskGetRunTimeStats( cBuffer );
printf( cBuffer );
/* Also print out a message to
the LCD - in this case the
pointer to the string to print
is sent directly in the
lMessageValue member of the
message. This just demonstrates
a different communication
technique. */
sprintf( cBuffer, "%s", ( char * ) xReceivedMessage.lMessageValue );
break;
case mainMESSAGE_STATUS : /* The tick interrupt hook
function has just informed this
task of the system status.
Generate a string in accordance
with the status value. */
prvGenerateStatusMessage( cBuffer, xReceivedMessage.lMessageValue );
break;
default :
sprintf( cBuffer, "Unknown message" );
break;
}
/* Output the message that was placed into the cBuffer array within the
switch statement above. */
LCD_DisplayStringLine( lLine, ( uint8_t * ) cBuffer );
/* Move onto the next LCD line, ready for the next iteration of this
loop. */
lLine += lFontHeight;
}
}
示例12: vRs485Task
void vRs485Task(void *pvParameters)
{
int bufsize = 512;
uint8 buffer[bufsize];
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
uart3Init(9600/2);
//xComPortHandle porthandle = xSerialPortInitMinimal(9600,1024);
buffer[0]='W';
buffer[1]='A';
buffer[2]='R';
buffer[3]='E';
buffer[4]='F';
GPIO_ResetBits(GPIOB, GPIO_Pin_14);
int heapSize = 0;
while (1)
{
heapSize = xPortGetFreeHeapSize();
heapSize +=0;
if (AskConunter())
{
vTaskDelay(10);
}
else
{
rs485size = iecProcExitPacket(rs485buf);
GPIO_SetBits(GPIOB, GPIO_Pin_14);
vTaskDelay(1);
processBuffer8to7(rs485buf,rs485size);
uart3Write ((uint8*) rs485buf, rs485size);
vTaskDelay(300);
vTaskDelay(20);
}
}
/*
signed char bufvar = 0;
while (1)
{
int cnt = uart3Read(buffer,bufsize);
vTaskDelay(10);
GPIO_SetBits(GPIOB, GPIO_Pin_14);
vTaskDelay(2);
if(cnt>0)
{
uart3Write(buffer,cnt);
//vTaskDelay(10);
//uart3Write(&buffer[1],1);
//uart3Write(&buffer[2],1);
}
vTaskDelay(5);
GPIO_ResetBits(GPIOB, GPIO_Pin_14);
vTaskDelay(10);
}
*/
}
示例13: prvQueryHeapCommand
static BaseType_t prvQueryHeapCommand( char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString )
{
/* Remove compile time warnings about unused parameters, and check the
write buffer is not NULL. NOTE - for simplicity, this example assumes the
write buffer length is adequate, so does not check for buffer overflows. */
( void ) pcCommandString;
( void ) xWriteBufferLen;
configASSERT( pcWriteBuffer );
sprintf( pcWriteBuffer, "Current free heap %d bytes, minimum ever free heap %d bytes\r\n", ( int ) xPortGetFreeHeapSize(), ( int ) xPortGetMinimumEverFreeHeapSize() );
/* There is no more data to return after this single string, so return
pdFALSE. */
return pdFALSE;
}
示例14: cmd_get_telemetry_beacon
static retval_t cmd_get_telemetry_beacon(const subsystem_t *self, frame_t * iframe, frame_t * oframe) {
frame_put_u32(oframe, xPortGetFreeHeapSize());
FUTURE_HOOK_2(mm_cmd_get_telemetry_beacon, iframe, oframe);
return RV_SUCCESS;
}
示例15: ReadBootVersion
resp = ReadBootVersion(tempVal);
if(resp == IAP_CMD_SUCCESS)
{
printf("Boot Code Version: %u.%u\r\n", (uint8_t)((tempVal[0]>>8)&0xFF), (uint8_t)(tempVal[0]&0xFF));
}
printf("----------------------------\r\n");
printf("Task Name\tStack Usage\r\n");
printf("----------------------------\r\n");
printf("vTaskLed1\t%u/64\r\n", 64-uxTaskGetStackHighWaterMark(TaskList[0]));
printf("vConsole\t%u/300\r\n", 300-uxTaskGetStackHighWaterMark(TaskList[1]));
printf("vOLEDTask\t%u/200\r\n", 200-uxTaskGetStackHighWaterMark(TaskList[2]));
printf("vTimer\t\t%u/150\r\n", 150-uxTaskGetStackHighWaterMark(TaskList[3]));
printf("----------------------------\r\n");
printf("Free Heap Space: %u\r\n", xPortGetFreeHeapSize());
printf("Compile Time: %s, %s\r\n", __DATE__, __TIME__);
}
return 0;
}
//i2cscan
static int _F3_Handler (void)
{
i2c_probe_slaves(I2C0);
return 0;
}