# FREERTOS_UTILS

## Functions
s32 | FREERTOS_UTILS_PerfCounterInit (void)
u32 | FREERTOS_UTILS_PerfCounterGet (void)
s32 | FREERTOS_UTILS_RunTimeStats (void)

## Detailed Description

Utility functions for FreeRTOS

Contains functions for performance stat measurements as desribed under: http://www.freertos.org/index.html?http://www.freertos.org/rtos-run-time-stats.html

In order to enable performance measurements, add following definitions to your mios32_config.h file:

     #define configGENERATE_RUN_TIME_STATS           1
     #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS  FREERTOS_UTILS_PerfCounterInit
     #define portGET_RUN_TIME_COUNTER_VALUE          FREERTOS_UTILS_PerfCounterGet

Add following include statement to your Makefile:

     # For performance measurings
     include $(MIOS32_PATH)/modules/freertos_utils/freertos_utils.mk

Performance stats can be sent to the MIOS Terminal via:

       FREERTOS_UTILS_RunTimeStats();

e.g. when a special button has been pushed, or a special MIDI event has been received.

Example for a stat table sent to the MIOS Terminal:

     00000072321902 ms | Task                 Abs Time             % Time
     00000072321902 ms | ================================================
     00000072321902 ms |
     00000072321904 ms | Period1mS            113775               5
     00000072321905 ms | IDLE                 836250               42
     00000072321905 ms | MSD                  19461                <1
     00000072321905 ms | Hooks                69434                3
     00000072321905 ms | Hooks                260256               13
     00000072321905 ms | Period1mS_LP         387894               19
     00000072321905 ms | Period1S             34842                1
     00000072321906 ms | MIDI                 199942               10
     00000072321906 ms | Pattern              26228                1
     00000072321906 ms |

Note that this performance measurement method is expensive!!!
It should only be used for debugging purposes!

## Function Documentation

u32 FREERTOS_UTILS_PerfCounterGet | ( | void |  | ) |

Add this function via

     #define portGET_RUN_TIME_COUNTER_VALUE FREERTOS_UTILS_PerfCounterGet

to your mios32_config.h file

Returns:
  32bit counter value

s32 FREERTOS_UTILS_PerfCounterInit | ( | void |  | ) |

Add this function via

     #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS FREERTOS_UTILS_PerfCounterInit

to your mios32_config.h file

Optionally

     // which MIOS32 timer should be used for performance measurements (0..2)
     #define FREERTOS_UTILS_PERF_TIMER 2

     // at which interval should it be called (interval should be much less than 1 mS!)
     #define FREERTOS_UTILS_PERF_TIMER_PERIOD 10 // uS

Returns:
  < 0 if initialisation failed

Here is the call graph for this function:

s32 FREERTOS_UTILS_RunTimeStats | ( | void |  | ) |

Use this function to send the performance stats to the MIOS terminal via MIDI

Returns:
  < 0 if MIDI output failed

Here is the call graph for this function: