/* called in each task but currently disabled */ void CheckStackUsage(xTaskHandle TaskHandle, tString *TaskName) { #if CHECK_STACK_USAGE portBASE_TYPE HighWater = uxTaskGetStackHighWaterMark(TaskHandle); if (HighWater < 20) PrintF("%s Water:%d", TaskName, HighWater); #endif }
void CheckStackAndQueueUsage(unsigned char Index) { portBASE_TYPE Water = uxTaskGetStackHighWaterMark(NULL); portBASE_TYPE QueLen = QueueHandles[Index]->uxMessagesWaiting; if (Water < 10 || QueLen > 8) PrintF("~%c S:%d Q:%u", Index == DISPLAY_QINDEX ? 'D' : 'W', Water, QueLen); }
void SystemStats(void){ char buf[120];//, buf2[300]; unsigned portBASE_TYPE Shoutcast, Vs, Heartbeat, lwIP, ETH, TP, WM; if (pdTRUE == xSemaphoreTake(xButton_pushed_Semaphore, 0)) { printf("\r\n-----------Run time stats-----------\r\n"); vTaskGetRunTimeStats((signed char*) buf); UART_PrintBuf(buf, strlen(buf)); // vTaskList((signed char*)buf2); // UART_PrintBuf (buf2, strlen(buf2)); printf("\r\n------------------------------------\r\n"); // Heartbeat = uxTaskGetStackHighWaterMark(NULL); Shoutcast = uxTaskGetStackHighWaterMark(xShoutcastTaskHandle); Vs = uxTaskGetStackHighWaterMark(xVsTskHandle); lwIP = uxTaskGetStackHighWaterMark(xLWIPTskHandler); ETH = uxTaskGetStackHighWaterMark(xETHTsk); TP = uxTaskGetStackHighWaterMark(xTouchPanelTskHandle); WM = uxTaskGetStackHighWaterMark(xWinMngTskHandle); printf("\r\n--------Tasks stack watermark-------\r\n"); printf("Hearbeat: %d\r\n", Heartbeat); printf("Shoutcast: %d\r\n", Shoutcast); printf("VS: %d\r\n", Vs); printf("lwIP: %d\r\n", lwIP); printf("ETH: %d\r\n", ETH); printf("TouchP: %d\r\n", TP); printf("WinMan: %d\r\n", WM); printf("\r\n------------------------------------\r\n"); } LED_Toggle(2); }
UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) { UBaseType_t uxReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); uxReturn = uxTaskGetStackHighWaterMark( xTask ); vPortResetPrivilege( xRunningPrivileged ); return uxReturn; }
UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) { UBaseType_t uxReturn; BaseType_t xRunningPrivileged = prvRaisePrivilege(); uxReturn = uxTaskGetStackHighWaterMark( xTask ); portRESET_PRIVILEGE( xRunningPrivileged ); return uxReturn; }
/** * * @brief Returns stack usage of a thread. * * @param[in] threadp pointer to instance of @p struct pios_thread * * @return stack usage in bytes * */ uint32_t PIOS_Thread_Get_Stack_Usage(struct pios_thread *threadp) { #if (INCLUDE_uxTaskGetStackHighWaterMark == 1) /* @note: This will fail when FreeRTOS TCB structure changes. */ return uxTaskGetStackHighWaterMark((xTaskHandle)threadp->task_handle) * 4; #else return 1024; #endif /* (INCLUDE_uxTaskGetStackHighWaterMark == 1) */ }
unsigned portBASE_TYPE MPU_uxTaskGetStackHighWaterMark( xTaskHandle xTask ) { unsigned portBASE_TYPE uxReturn; portBASE_TYPE xRunningPrivileged = prvRaisePrivilege(); uxReturn = uxTaskGetStackHighWaterMark( xTask ); portRESET_PRIVILEGE( xRunningPrivileged ); return uxReturn; }
/** * Update the status of all tasks */ void TaskMonitorUpdateAll(void) { #if defined(DIAGNOSTICS) TaskInfoData data; int n; // Lock xSemaphoreTakeRecursive(lock, portMAX_DELAY); #if ( configGENERATE_RUN_TIME_STATS == 1 ) uint32_t currentTime; uint32_t deltaTime; /* * Calculate the amount of elapsed run time between the last time we * measured and now. Scale so that we can convert task run times * directly to percentages. */ currentTime = portGET_RUN_TIME_COUNTER_VALUE(); deltaTime = ((currentTime - lastMonitorTime) / 100) ? : 1; /* avoid divide-by-zero if the interval is too small */ lastMonitorTime = currentTime; #endif // Update all task information for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n) { if (handles[n] != 0) { data.Running[n] = TASKINFO_RUNNING_TRUE; #if defined(ARCH_POSIX) || defined(ARCH_WIN32) data.StackRemaining[n] = 10000; #else data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4; #if ( configGENERATE_RUN_TIME_STATS == 1 ) /* Generate run time stats */ data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime; #endif #endif } else { data.Running[n] = TASKINFO_RUNNING_FALSE; data.StackRemaining[n] = 0; data.RunningTime[n] = 0; } } // Update object TaskInfoSet(&data); // Done xSemaphoreGiveRecursive(lock); #endif }
/********************************************************************* * * _cbSendTaskList() * * Function description * This function is part of the link between FreeRTOS and SYSVIEW. * Called from SystemView when asked by the host, it uses SYSVIEW * functions to send the entire task list to the host. */ static void _cbSendTaskList(void) { unsigned n; for (n = 0; n < _NumTasks; n++) { #if INCLUDE_uxTaskGetStackHighWaterMark // Report Task Stack High Watermark _aTasks[n].uStackHighWaterMark = uxTaskGetStackHighWaterMark((TaskHandle_t)_aTasks[n].xHandle); #endif SYSVIEW_SendTaskInfo((U32)_aTasks[n].xHandle, _aTasks[n].pcTaskName, (unsigned)_aTasks[n].uxCurrentPriority, (U32)_aTasks[n].pxStack, (unsigned)_aTasks[n].uStackHighWaterMark); } }
void vOLEDTask( void *pvParameters ) { xOLEDMessage xMessage; unsigned portLONG ulY, ulMaxY; static portCHAR cMessage[ mainMAX_MSG_LEN ]; extern volatile unsigned portLONG ulMaxJitter; unsigned portBASE_TYPE uxUnusedStackOnEntry; const unsigned portCHAR *pucImage; // Functions to access the OLED. void ( *vOLEDInit )( unsigned portLONG ) = NULL; void ( *vOLEDStringDraw )( const portCHAR *, unsigned portLONG, unsigned portLONG, unsigned portCHAR ) = NULL; void ( *vOLEDImageDraw )( const unsigned portCHAR *, unsigned portLONG, unsigned portLONG, unsigned portLONG, unsigned portLONG ) = NULL; void ( *vOLEDClear )( void ) = NULL; vOLEDInit = RIT128x96x4Init; vOLEDStringDraw = RIT128x96x4StringDraw; vOLEDImageDraw = RIT128x96x4ImageDraw; vOLEDClear = RIT128x96x4Clear; ulMaxY = mainMAX_ROWS_96; pucImage = pucBasicBitmap; // Just for demo purposes. uxUnusedStackOnEntry = uxTaskGetStackHighWaterMark( NULL ); ulY = ulMaxY; /* Initialise the OLED */ vOLEDInit( ulSSI_FREQUENCY ); while( 1 ) { // Wait for a message to arrive that requires displaying. xQueueReceive( xOLEDQueue, &xMessage, portMAX_DELAY ); // Write the message on the next available row. ulY += mainCHARACTER_HEIGHT; if( ulY >= ulMaxY ) { ulY = mainCHARACTER_HEIGHT; vOLEDClear(); } // Display the message sprintf( cMessage, "%s", xMessage.pcMessage); vOLEDStringDraw( cMessage, 0, ulY, mainFULL_SCALE ); } }
void vOLEDTask( void *pvParameters ) { xOLEDMessage xMessage; unsigned portLONG ulY, ulMaxY; static portCHAR cMessage[ mainMAX_MSG_LEN ]; extern volatile unsigned portLONG ulMaxJitter; unsigned portBASE_TYPE uxUnusedStackOnEntry, uxUnusedStackNow; const unsigned portCHAR *pucImage; /* Functions to access the OLED. The one used depends on the dev kit being used. */ /* tBoolean is defined as a unsigned char in hw_types.h */ void ( *vOLEDInit )( unsigned portCHAR ) = NULL; void ( *vOLEDStringDraw )( const portCHAR *, unsigned portLONG, unsigned portLONG ) = NULL; void ( *vOLEDImageDraw )( const unsigned portCHAR *, unsigned portLONG, unsigned portLONG, unsigned portLONG, unsigned portLONG ) = NULL; void ( *vOLEDClear )( void ) = NULL; /* Just for demo purposes. */ uxUnusedStackOnEntry = uxTaskGetStackHighWaterMark( NULL ); /* Point display functions to SSD driver functions */ vOLEDInit = Display96x16x1Init; vOLEDStringDraw = Display96x16x1StringDraw; vOLEDImageDraw = Display96x16x1ImageDraw; vOLEDClear = Display96x16x1Clear; ulMaxY = mainMAX_ROWS_16; pucImage = pucBasicBitmap; ulY = ulMaxY; /* Initialise the OLED and display a startup message. */ vOLEDInit( 1 ); vOLEDStringDraw( "POWERED BY FreeRTOS", 0, 0 ); vOLEDImageDraw( pucImage, 0, mainCHARACTER_HEIGHT + 1, bmpBITMAP_WIDTH, bmpBITMAP_HEIGHT ); for( ;; ) { /* Wait for a message to arrive that requires displaying. */ xQueueReceive( xOLEDQueue, &xMessage, portMAX_DELAY ); /* Write the message on the next available row. */ ulY += mainCHARACTER_HEIGHT; if( ulY >= ulMaxY ) { ulY = mainCHARACTER_HEIGHT; vOLEDClear(); vOLEDStringDraw( pcWelcomeMessage, 0, 0 ); } /* Display the message along with the maximum jitter time from the high priority time test. */ sprintf( cMessage, "%s [%uns]", xMessage.pcMessage, ulMaxJitter * mainNS_PER_CLOCK ); vOLEDStringDraw( cMessage, 0, ulY ); } }
/******************************************************************************* * TASK: taskShutdownWatchdog * * DESCRIPTIONS: * Watchdog for auto shutdown. * This task should be killed if the touch screen is touched before timeout. * *******************************************************************************/ void taskShutdownWatchdog (void *pvParameters) { portTickType xTimeoutPeriod; while (1) { // Read the stack watermark and record it if it's below threshold. unsigned portBASE_TYPE uxHighWaterMark = uxTaskGetStackHighWaterMark(NULL); if (uxHighWaterMark < MIN_STACK_WATERMARK) { xSystemError.bStackLowError = 1; // Only log it when the watermark value changed. static portBASE_TYPE uxPreviousWatermark = 0; if (uxHighWaterMark != uxPreviousWatermark) { vLogStackWatermark("Shutdown Watchdog Task", (unsigned short)uxHighWaterMark); } uxPreviousWatermark = uxHighWaterMark; } // Get the timeout period base on auto shutdown setting. switch (eAutoShutdown) { case AUTO_SHUTDOWN_1_MIN: xTimeoutPeriod = 60000 / portTICK_RATE_MS; break; case AUTO_SHUTDOWN_5_MIN: xTimeoutPeriod = 300000 / portTICK_RATE_MS; break; case AUTO_SHUTDOWN_10_MIN: xTimeoutPeriod = 600000 / portTICK_RATE_MS; break; case AUTO_SHUTDOWN_20_MIN: xTimeoutPeriod = 1200000 / portTICK_RATE_MS; break; case AUTO_SHUTDOWN_30_MIN: xTimeoutPeriod = 1800000 / portTICK_RATE_MS; break; case AUTO_SHUTDOWN_60_MIN: xTimeoutPeriod = 3600000 / portTICK_RATE_MS; break; case AUTO_SLEEP_NEVER: xTimeoutPeriod = portMAX_DELAY; break; } // Wait for timeout. vTaskDelay(xTimeoutPeriod); // After timeout, shut down if these conditions are met. // - Bluetooth is not connected. // - USB is not connected. if ( (BT_CONNECTED == 0) && (xSystemState.bUsbMode == 0) ) { // Shutting down. vPowerOff(); vTaskSuspend(NULL); // Program should stop here. } // Program will loop again if the shutdown conditions are not met. } }
void uartadapter_tcp_control_server_handler(void *param) { unsigned short port = UA_CONTROL_SOCKET_PORT; ua_printf(UA_DEBUG, "Uart Adapter: Start Tcp Control Server!"); uartadapter_tcpserver(port, 1); #if defined(INCLUDE_uxTaskGetStackHighWaterMark) && (INCLUDE_uxTaskGetStackHighWaterMark == 1) ua_printf(UA_DEBUG, "Min available stack size of %s = %d * %d bytes", __FUNCTION__, uxTaskGetStackHighWaterMark(NULL), sizeof(portBASE_TYPE)); #endif ua_printf(UA_DEBUG, "TCP: Tcp control server stopped!"); vTaskDelete(NULL); }
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; }
/** * Callback for tcpip_init() */ static void tcpip_init_cb(void *args){/*{{{*/ ip_addr_t ip_addr; ip_addr_t netmask; ip_addr_t gw_addr; BaseType_t retval; eth_int_q_handle = xQueueCreate(1, sizeof(uint32_t)); retval = xTaskCreate( eth_int_task, "eth_int", ETH_INT_STACK, NULL, tskIDLE_PRIORITY+ETH_PRIO, ð_int_task_handle); LOOP_ERRMSG(retval != pdPASS, "Could not start lwip eth_int task\n" ); #if XBH_IP4_STATIC ip_addr.addr = htonl(XBH_IP4_ADDR); netmask.addr = htonl(XBH_IP4_NETMASK); gw_addr.addr = 0; #else ip_addr.addr = 0; netmask.addr = 0; gw_addr.addr = 0; #endif netif_add(&lwip_netif, &ip_addr, &netmask, &gw_addr, NULL, tivaif_init, tcpip_input); //netif_add sets everything to defaults, so run after netif_add netif_set_hostname(&lwip_netif, XBH_HOSTNAME); netif_set_status_callback(&lwip_netif, link_status); netif_set_default(&lwip_netif); #if LWIP_IPV6 lwip_netif.ip6_autoconfig_enabled = 1; lwip_netif.output_ip6 = ethip6_output; //IPv6, enable linklocal addresses and SLAAC netif_create_ip6_linklocal_address(&lwip_netif, 1); netif_ip6_addr_set_state((&lwip_netif), 0, IP6_ADDR_TENTATIVE); #endif #if XBH_IP4_STATIC netif_set_up(&lwip_netif); #else dhcp_start(&lwip_netif); #endif #if DEBUG_STACK DEBUG_OUT("Stack Usage: %s: %d\n", __PRETTY_FUNCTION__, uxTaskGetStackHighWaterMark(NULL)); #endif }/*}}}*/
void Udpserverhandler(void *param) { /*here gives the udp demo code*/ vTaskDelay(1000); printf("\n\rUdp server test"); udpserver(); #if defined(INCLUDE_uxTaskGetStackHighWaterMark) && (INCLUDE_uxTaskGetStackHighWaterMark == 1) printf("\n\rMin available stack size of %s = %d * %d bytes", __FUNCTION__, uxTaskGetStackHighWaterMark(NULL), sizeof(portBASE_TYPE)); #endif printf("\n\rUDP: udp client stopped!"); udpserver_task = NULL; vTaskDelete(NULL); }
void cek_stack(void) { printf("Sisa stack masing2 task (bytes)\r\n"); garis_bawah(); printf(" Shell : %d\r\n", uxTaskGetStackHighWaterMark(hdl_shell)); printf(" Led : %d\r\n", uxTaskGetStackHighWaterMark(hdl_led)); #ifdef BOARD_TAMPILAN //#ifdef CARI_SUMBERNYA printf(" Tampilan : %d\r\n", uxTaskGetStackHighWaterMark(hdl_tampilan)); printf(" LCD : %d\r\n", uxTaskGetStackHighWaterMark(hdl_lcd)); #endif #if (TAMPILAN_MALINGPING == 1) //extern xTaskHandle hdl_proses_pm; matikan dulu, pm belum diaktifkan printf(" Tampilan : %d\r\n", uxTaskGetStackHighWaterMark(hdl_tampilan)); printf(" LCD : %d\r\n", uxTaskGetStackHighWaterMark(hdl_lcd)); #endif printf(" Ether : %d\r\n", uxTaskGetStackHighWaterMark(hdl_ether)); #ifdef PAKAI_SELENOID printf(" Relay : %d\r\n", uxTaskGetStackHighWaterMark(hdl_relay)); #endif #if defined(PAKAI_GSM_FTP) || defined(PAKAI_SMS) printf(" GSM : %d\r\n", uxTaskGetStackHighWaterMark(hdl_modem)); #endif #ifdef PAKAI_CRON printf(" CRON : %d\r\n", uxTaskGetStackHighWaterMark(hdl_cron)); #endif #ifdef AMBIL_PM // printf(" Proses PM: %d\r\n", uxTaskGetStackHighWaterMark(hdl_proses_pm)); #endif }
static void TcpClientHandler(void *param) { unsigned short port = 5001; vTaskDelay(1000); printf("\n\rTCP: Start tcp client!"); if(g_start_client) BsdTcpClient(g_server_ip, port); #if defined(INCLUDE_uxTaskGetStackHighWaterMark) && (INCLUDE_uxTaskGetStackHighWaterMark == 1) printf("\n\rMin available stack size of %s = %d * %d bytes\n\r", __FUNCTION__, uxTaskGetStackHighWaterMark(NULL), sizeof(portBASE_TYPE)); #endif printf("\n\rTCP: Tcp client stopped!"); g_client_task = NULL; vTaskDelete(NULL); }
static inline void mqtt_task() { struct Network network; char client_id[20]; uint8_t mqtt_buf[100]; uint8_t mqtt_readbuf[100]; MQTTPacket_connectData data = MQTTPacket_connectData_initializer; NewNetwork( &network ); strcpy(client_id, "esp-gizmo-ir"); if (ConnectNetwork(&network, config_get_mqtt_host(), config_get_mqtt_port()) != 0) { printf("Connect to MQTT server failed\n"); return; } NewMQTTClient(&mqtt_client, &network, 5000, mqtt_buf, 100, mqtt_readbuf, 100); data.willFlag = 0; data.MQTTVersion = 3; data.clientID.cstring = client_id; data.username.cstring = NULL; data.password.cstring = NULL; data.keepAliveInterval = 10; data.cleansession = 0; printf("Send MQTT connect ... \n"); if (MQTTConnect(&mqtt_client, &data) != 0) { printf("MQTT connect failed\n"); return; } const char *topic = config_get_cmd_topic(); printf("Sibscribe to topic: %s\n", topic); if (MQTTSubscribe(&mqtt_client, topic, QOS1, topic_received) != 0) { printf("Subscription failed\n"); return; } while (MQTTYield(&mqtt_client, 1000) != DISCONNECTED) { printf("free heap: %d bytes\n", xPortGetFreeHeapSize()); uint16_t free_stack = uxTaskGetStackHighWaterMark(xTaskGetCurrentTaskHandle()); printf("minimum free stack: %d bytes\n", free_stack); }; printf("Connection dropped, request restart\n"); }
void TcpServerHandler_test(void *param) { unsigned short port = 5555; vTaskDelay(10000); printf("\n\rTCP: Start tcp Server!"); g_start_server = 1; if(g_start_server) BsdTcpServer(port); #if defined(INCLUDE_uxTaskGetStackHighWaterMark) && (INCLUDE_uxTaskGetStackHighWaterMark == 1) printf("\n\rMin available stack size of %s = %d * %d bytes\n\r", __FUNCTION__, uxTaskGetStackHighWaterMark(NULL), sizeof(portBASE_TYPE)); #endif printf("\n\rTCP: Tcp server stopped!"); g_server_task = NULL; vTaskDelete(NULL); }
void TaskBase::print_status (emstream& ser_dev) { ser_dev.puts (pcTaskGetTaskName (handle)); ser_dev.putchar ('\t'); if (strlen ((const char*)(pcTaskGetTaskName (handle))) < 8) { ser_dev.putchar ('\t'); } ser_dev << (uint8_t)(uxTaskPriorityGet (handle)) << PMS ("\t") << get_state () #if (INCLUDE_uxTaskGetStackHighWaterMark == 1) << PMS ("\t") << uxTaskGetStackHighWaterMark(handle) << PMS ("/") << (size_t)(get_total_stack ()) << PMS ("\t") #endif << PMS ("\t") << runs; }
void vDTMFDetectTask( void *pvParameters ) { struct DTMFDetectTaskParam_t* params = (struct DTMFDetectTaskParam_t *)pvParameters; char output[50]; vPrintString( "DTMF Detector started\n" ); init_Wn(); for( ;; ) { BaseType_t status = xQueuePeek( params->sampQ, &s, portMAX_DELAY ); if(status == pdPASS) { #ifdef __DTMF_PERF__ UBaseType_t stack_max = uxTaskGetStackHighWaterMark( 0 ); TickType_t t0 = xTaskGetTickCount(); TickType_t t1; #endif int ii; for (ii=0; ii<DTMFSampleSize; ii++) { cs[ii].Re = (float)s[ii] / 16384.0f; cs[ii].Im = 0.0f; } xQueueReceive( params->sampQ, &s, portMAX_DELAY ); /* Do real work here */ fft(cs, DTMFSampleSize); // Need to ensure second arg is log2(DTMFSampleSize) pick_peaks(cs, 5.0f, &r.toneA, &r.toneB); r.code = decode_tones(r.toneA,r.toneB); #ifdef __DTMF_PERF__ t1 = xTaskGetTickCount(); printf("DTMF STACK %d TIME %d\n", stack_max, t1-t0); #endif // Send, but allow dropping if(r.code != ' ') { sprintf(output,"Detected code %c\r\n",r.code); uart_send_noblock(output,strlen(output)); printf("Detected code %c\n",r.code); } } } }
static void tcp_server_handler(void *param) { vTaskDelay(100); if(tcp_server_data.port == 0) tcp_server_data.port = DEFAULT_PORT; if(tcp_server_data.buf_size == 0) tcp_server_data.buf_size = SERVER_BUF_SIZE; printf("\n\rTCP: Start TCP server!"); tcp_server_func(tcp_server_data); #if defined(INCLUDE_uxTaskGetStackHighWaterMark) && (INCLUDE_uxTaskGetStackHighWaterMark == 1) printf("\n\rMin available stack size of %s = %d * %d bytes\n\r", __FUNCTION__, uxTaskGetStackHighWaterMark(NULL), sizeof(portBASE_TYPE)); #endif printf("\n\rTCP: TCP server stopped!"); g_tcp_server_task = NULL; vTaskDelete(NULL); }
void detect_task(void const *argu) { uint32_t detect_wake_time = osKernelSysTick(); while(1) { detect_time_ms = HAL_GetTick() - detect_time_last; detect_time_last = HAL_GetTick(); /* module offline detect */ module_offline_detect(); if (glb_err_exit == 1) { if (pc_glb_cnt++ > 50) pc_glb_cnt = 0; if (pc_glb_cnt < 15) g_err.beep_ctrl = g_err.beep_tune/2; else g_err.beep_ctrl = 0; } else { if (g_err.err_now != NULL) { //LED_G_OFF; module_offline_callback(); } else { g_err.beep_ctrl = 0; //LED_G_ON; } } beep_ctrl(g_err.beep_tune, g_err.beep_ctrl); detect_stack_surplus = uxTaskGetStackHighWaterMark(NULL); osDelayUntil(&detect_wake_time, DETECT_TASK_PERIOD); } }
/*---------------------------------------------------------------------------------------------------------*/ static void SW_UART_WRAPPER_Send_Task( void *aHandle ) { uint8_t *pData; xMessage_t xRxMessage; os_queue_t xQueue ; xQueue = os_create_queue( SW_UART_WRAPPER_CONFIG_MAX_QUEUE_LEN , sizeof(xMessage_t ) ); INSTANCE(aHandle)->xQueue = xQueue ; if( 0 == xQueue ) return ; for( ;; ) { if( OS_QUEUE_RECEIVE_SUCCESS == os_queue_receive_infinite_wait( xQueue , &( xRxMessage )) ) { pData = xRxMessage.pData; sw_uart_send_and_wait_for_end(INSTANCE(aHandle), os_delay_ms,pData,xRxMessage.len); #ifdef SW_UART_WRAPPER_CONFIG_USE_MALLOC free( pData ); #endif } #if ((1==INCLUDE_uxTaskGetStackHighWaterMark ) && (1==OS_FREE_RTOS)) { static size_t stackLeft,minStackLeft=0xffffffff; stackLeft = uxTaskGetStackHighWaterMark( NULL ); if(minStackLeft > stackLeft) { minStackLeft = stackLeft; PRINTF_DBG("%s stack left = %d \r\n" , __FUNCTION__ ,minStackLeft); } } #endif } }
void vShowAllTaskUnusedStack(void) { unsigned portSHORT usIndex; vDebugPrint(&TaskTokens[TASK_COMMAND], "********** Unused Stack Table ***********\n\r", 0, 0, 0); for (usIndex = 0; usIndex < NUM_TASKID; usIndex++) { if (TaskTokens[usIndex].pcTaskName != NULL) { vDebugPrint(&TaskTokens[TASK_COMMAND], "%16s\t\t%d\n\r", (unsigned portLONG)TaskTokens[usIndex].pcTaskName, (unsigned portLONG)uxTaskGetStackHighWaterMark(TaskHandles[usIndex]),0); } } }
void UTL_FreeRtosTaskStackCheck(void) { taskInfoArray[PrintTaskIndex].FreeEntries = uxTaskGetStackHighWaterMark(taskInfoArray[PrintTaskIndex].taskHandle); /* free, used, total */ PrintF("%s %d %d %d", (char*)pcTaskGetTaskName(taskInfoArray[PrintTaskIndex].taskHandle), taskInfoArray[PrintTaskIndex].FreeEntries, taskInfoArray[PrintTaskIndex].Depth - taskInfoArray[PrintTaskIndex].FreeEntries, taskInfoArray[PrintTaskIndex].Depth)); PrintTaskIndex ++; if (rintTaskIndex >= TaskIndex) { PrintTaskIndex = 3; CreateAndSendMessage(&Msg, QueryMemoryMsg, MSG_OPT_NONE); } }
static void prvTaskToDelete( void *pvParameters ) { /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; /* Check the enter and exit critical macros are working correctly. If the SVC priority is below configMAX_SYSCALL_INTERRUPT_PRIORITY then this will fault. */ taskENTER_CRITICAL(); taskEXIT_CRITICAL(); /* Exercise the API of various RTOS objects. */ prvExerciseEventGroupAPI(); prvExerciseSemaphoreAPI(); prvExerciseTaskNotificationAPI(); /* For code coverage test purposes it is deleted by the Idle task. */ configASSERT( uxTaskGetStackHighWaterMark( NULL ) > 0 ); vTaskSuspend( NULL ); }
void print_task_list (emstream* ser_dev) { // Print the first line with the top of the headings *ser_dev << PMS ("Task\t\t \t ") #if (INCLUDE_uxTaskGetStackHighWaterMark == 1) << PMS ("\tStack") #endif << endl; // Print the second line with the rest of the headings *ser_dev << PMS ("Name\t\tPri.\tState") #if (INCLUDE_uxTaskGetStackHighWaterMark == 1) << PMS ("\tFree/Total") #endif << PMS ("\tRuns") << endl; // Print the third line which shows separators between headers and data *ser_dev << PMS ("----\t\t----\t-----") #if (INCLUDE_uxTaskGetStackHighWaterMark == 1) << PMS ("\t----------") #endif << PMS ("\t----") << endl; // Now have the tasks each print out their status. Tasks form a linked list, so // we only need to get the last task started and it will call the next, etc. if (last_created_task_pointer != NULL) { last_created_task_pointer->print_status_in_list (ser_dev); } // Have the idle task print out its information *ser_dev << PMS ("IDLE\t\t0\t-\t") #if (INCLUDE_uxTaskGetStackHighWaterMark == 1) << uxTaskGetStackHighWaterMark (xTaskGetIdleTaskHandle ()) << PMS ("/") << configMINIMAL_STACK_SIZE << PMS ("\t\t") #endif #ifdef TASK_SETUP_AND_LOOP << PMS ("-") #endif << endl; }
/** * Task for feeding packets from ISR to lwIP * Loops forever blocking on queue waiting for next status from ISR * @param arg Unused */ static void eth_int_task(void* arg){/*{{{*/ uint32_t status; while(1){ //Loop waiting max time between loops until queue item received while(xQueueReceive(eth_int_q_handle, &status, portMAX_DELAY)!=pdPASS); tivaif_interrupt(&lwip_netif, status); // Reenable interrupts disabled in lwIP_eth_isr() MAP_EMACIntEnable(EMAC0_BASE, (EMAC_INT_PHY| EMAC_INT_RECEIVE| EMAC_INT_RX_NO_BUFFER| EMAC_INT_RX_STOPPED| EMAC_INT_TRANSMIT| EMAC_INT_TX_STOPPED)); #if DEBUG_STACK DEBUG_OUT("Stack Usage: %s: %d\n", __PRETTY_FUNCTION__, uxTaskGetStackHighWaterMark(NULL)); #endif } }/*}}}*/