Prusa MINI Firmware overview
cpu_utils.c File Reference

Utilities for CPU Load calculation. More...

#include "cpu_utils.h"
#include "FreeRTOS.h"
#include "task.h"

Functions

void vApplicationIdleHook (void)
 Application Idle Hook. More...
 
void vApplicationTickHook (void)
 Application Idle Hook. More...
 
void StartIdleMonitor (void)
 Start Idle monitor. More...
 
void EndIdleMonitor (void)
 Stop Idle monitor. More...
 
uint16_t osGetCPUUsage (void)
 Stop Idle monitor. More...
 

Variables

xTaskHandle xIdleHandle = NULL
 
__IO uint32_t osCPU_Usage = 0
 
uint32_t osCPU_IdleStartTime = 0
 
uint32_t osCPU_IdleSpentTime = 0
 
uint32_t osCPU_TotalIdleTime = 0
 

Detailed Description

Utilities for CPU Load calculation.

Author
MCD Application Team
Version
V1.1.0
Date
20-November-2014
Attention

© COPYRIGHT(c) 2014 STMicroelectronics

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ vApplicationIdleHook()

void vApplicationIdleHook ( void  )

Application Idle Hook.

Parameters
None
Return values
None
76 {
77  if( xIdleHandle == NULL )
78  {
79  /* Store the handle to the idle task. */
81  }
82 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vApplicationTickHook()

void vApplicationTickHook ( void  )

Application Idle Hook.

Parameters
None
Return values
None
90 {
91  static int tick = 0;
92 
93  if(tick ++ > CALCULATION_PERIOD)
94  {
95  tick = 0;
96 
97  if(osCPU_TotalIdleTime > 1000)
98  {
99  osCPU_TotalIdleTime = 1000;
100  }
103  }
104 }
Here is the caller graph for this function:

◆ StartIdleMonitor()

void StartIdleMonitor ( void  )

Start Idle monitor.

Parameters
None
Return values
None
112 {
114  {
116  }
117 }
Here is the call graph for this function:

◆ EndIdleMonitor()

void EndIdleMonitor ( void  )

Stop Idle monitor.

Parameters
None
Return values
None
125 {
127  {
128  /* Store the handle to the idle task. */
131  }
132 }
Here is the call graph for this function:

◆ osGetCPUUsage()

uint16_t osGetCPUUsage ( void  )

Stop Idle monitor.

Parameters
None
Return values
None
140 {
141  return (uint16_t)osCPU_Usage;
142 }
Here is the caller graph for this function:

Variable Documentation

◆ xIdleHandle

xTaskHandle xIdleHandle = NULL

◆ osCPU_Usage

__IO uint32_t osCPU_Usage = 0

◆ osCPU_IdleStartTime

uint32_t osCPU_IdleStartTime = 0

◆ osCPU_IdleSpentTime

uint32_t osCPU_IdleSpentTime = 0

◆ osCPU_TotalIdleTime

uint32_t osCPU_TotalIdleTime = 0
osCPU_TotalIdleTime
uint32_t osCPU_TotalIdleTime
Definition: cpu_utils.c:67
xIdleHandle
xTaskHandle xIdleHandle
Definition: cpu_utils.c:63
xTaskGetTickCountFromISR
PRIVILEGED_FUNCTION TickType_t xTaskGetTickCountFromISR(void)
Definition: tasks.c:2142
NULL
#define NULL
Definition: usbd_def.h:53
osCPU_IdleStartTime
uint32_t osCPU_IdleStartTime
Definition: cpu_utils.c:65
xTaskGetCurrentTaskHandle
PRIVILEGED_FUNCTION TaskHandle_t xTaskGetCurrentTaskHandle(void)
osCPU_IdleSpentTime
uint32_t osCPU_IdleSpentTime
Definition: cpu_utils.c:66
osCPU_Usage
__IO uint32_t osCPU_Usage
Definition: cpu_utils.c:64
CALCULATION_PERIOD
#define CALCULATION_PERIOD
Definition: cpu_utils.h:53