Merge pull request #58 from vas-dav/runtime-stats
clock: [#55] Overflow handling for FreeRTOS stats.
This commit is contained in:
commit
dc0dc1f095
@ -93,7 +93,8 @@
|
|||||||
#define configUSE_COUNTING_SEMAPHORES 1
|
#define configUSE_COUNTING_SEMAPHORES 1
|
||||||
#define configGENERATE_RUN_TIME_STATS 1
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
#define configRECORD_STACK_HIGH_ADDRESS 1
|
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||||
#define configUSE_TICKLESS_IDLE 1
|
#define configUSE_TICKLESS_IDLE 1
|
||||||
|
#define configRUN_TIME_COUNTER_TYPE uint64_t
|
||||||
|
|
||||||
|
|
||||||
/* Co-routine definitions. */
|
/* Co-routine definitions. */
|
||||||
@ -126,9 +127,10 @@ to exclude the API function. */
|
|||||||
* must set up LPC_SCT1.
|
* must set up LPC_SCT1.
|
||||||
*/
|
*/
|
||||||
void vConfigureTimerForRunTimeStats(void);
|
void vConfigureTimerForRunTimeStats(void);
|
||||||
|
configRUN_TIME_COUNTER_TYPE ulGetTimeForRunTimeStats(void);
|
||||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
||||||
/* The value is read directly from the counter register for efficiency and low overhead. */
|
/* The value is read directly from the counter register for efficiency and low overhead. */
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() LPC_SCT1->COUNT_U
|
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetTimeForRunTimeStats()
|
||||||
|
|
||||||
/* Cortex-M specific definitions. */
|
/* Cortex-M specific definitions. */
|
||||||
#ifdef __NVIC_PRIO_BITS
|
#ifdef __NVIC_PRIO_BITS
|
||||||
|
|||||||
@ -29,7 +29,7 @@ extern "C" {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function is used by FreeRTOS to configure the collection of
|
* @brief This function is used by FreeRTOS to configure the collection of
|
||||||
* time used by tasks.
|
* time used by tasks. (This timer is also used for logging timestamps.)
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
vConfigureTimerForRunTimeStats (void)
|
vConfigureTimerForRunTimeStats (void)
|
||||||
@ -55,6 +55,17 @@ extern "C" {
|
|||||||
LPC_SCT1->CONFIG = SCT_CONFIG_32BIT_COUNTER;
|
LPC_SCT1->CONFIG = SCT_CONFIG_32BIT_COUNTER;
|
||||||
LPC_SCT1->CTRL_U = SCT_CTRL_CLRCTR_L;
|
LPC_SCT1->CTRL_U = SCT_CTRL_CLRCTR_L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Used by FreeRTOS to collect runtime statistics.
|
||||||
|
* @paragraph FreeRTOS is unable to handle the counter overflow, so it must be done from our side.
|
||||||
|
* @return configRUN_TIME_COUNTER_TYPE
|
||||||
|
*/
|
||||||
|
configRUN_TIME_COUNTER_TYPE ulGetTimeForRunTimeStats(void)
|
||||||
|
{
|
||||||
|
return (configRUN_TIME_COUNTER_TYPE)(((double)(counter_overflows - 1) * max_counter_value) + LPC_SCT1->COUNT_U)
|
||||||
|
/ ((double)Chip_Clock_GetMainClockRate() / 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user