Compare commits
No commits in common. "d48ccf161296e2aabba3b46e35579787f3f1bf27" and "5ad1d574ff17a44d17d57c53c2cb00befc972235" have entirely different histories.
d48ccf1612
...
5ad1d574ff
@ -30,16 +30,10 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize the main cycle counter and reset to 0. This also enables the core cycle counter
|
* @brief Initialize/Reset the main cycle counter to 0.
|
||||||
* This function can be called multiple times.
|
* This function can be called multiple times.
|
||||||
*/
|
*/
|
||||||
void main_and_core_cycle_counter_init(void);
|
void main_cycle_counter_init(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Reset the main cycle counter.
|
|
||||||
* @note This does not reset the core cycle counter
|
|
||||||
*/
|
|
||||||
void main_cycle_counter_reset(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Increment the main cycle counter by 1
|
* @brief Increment the main cycle counter by 1
|
||||||
@ -52,18 +46,6 @@ void main_cycle_counter_inc(void);
|
|||||||
*/
|
*/
|
||||||
uint64_t main_cycle_counter_get(void);
|
uint64_t main_cycle_counter_get(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Reset the core cycle counter to 0
|
|
||||||
*/
|
|
||||||
void core_cycle_counter_reset(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the current value of the core cycle counter
|
|
||||||
*
|
|
||||||
* @return uint32_t Counter value
|
|
||||||
*/
|
|
||||||
uint32_t core_cycle_counter_get(void);
|
|
||||||
|
|
||||||
#endif /* __MAIN_CYCLE_COUNTER_H__ */
|
#endif /* __MAIN_CYCLE_COUNTER_H__ */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include <reflow-controller/main-cycle-counter.h>
|
#include <reflow-controller/main-cycle-counter.h>
|
||||||
#include <helper-macros/helper-macros.h>
|
#include <helper-macros/helper-macros.h>
|
||||||
#include <stm32/stm32f4xx.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Variable storing the main cycle counter.
|
* @brief Variable storing the main cycle counter.
|
||||||
@ -34,22 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
static uint64_t IN_SECTION(.ccm.bss) main_cycle_counter;
|
static uint64_t IN_SECTION(.ccm.bss) main_cycle_counter;
|
||||||
|
|
||||||
void main_and_core_cycle_counter_init(void)
|
void main_cycle_counter_init(void)
|
||||||
{
|
|
||||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
|
||||||
|
|
||||||
/* Enable the core cycle counter if available on current processor */
|
|
||||||
if (!(DWT->CTRL & DWT_CTRL_NOCYCCNT_Msk)) {
|
|
||||||
/* Cycle counter is available. Enable */
|
|
||||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reset the counters to 0 */
|
|
||||||
main_cycle_counter_reset();
|
|
||||||
core_cycle_counter_reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void main_cycle_counter_reset(void)
|
|
||||||
{
|
{
|
||||||
main_cycle_counter = 0ULL;
|
main_cycle_counter = 0ULL;
|
||||||
}
|
}
|
||||||
@ -64,14 +48,4 @@ uint64_t main_cycle_counter_get(void)
|
|||||||
return main_cycle_counter;
|
return main_cycle_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void core_cycle_counter_reset(void)
|
|
||||||
{
|
|
||||||
DWT->CYCCNT = 0UL;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t core_cycle_counter_get(void)
|
|
||||||
{
|
|
||||||
return DWT->CYCCNT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -268,8 +268,8 @@ int main(void)
|
|||||||
/** - Print motd to shell */
|
/** - Print motd to shell */
|
||||||
shell_print_motd(shell_handle);
|
shell_print_motd(shell_handle);
|
||||||
|
|
||||||
/** - Set the main cycle counter to 0 and activate the core cycle counter if available */
|
/** - Set the main cycle counter to 0 */
|
||||||
main_and_core_cycle_counter_init();
|
main_cycle_counter_init();
|
||||||
|
|
||||||
/** - Do a loop over the following */
|
/** - Do a loop over the following */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -892,7 +892,7 @@ shellmatta_retCode_t shell_cmd_cycle_count(const shellmatta_handle_t handle, con
|
|||||||
|
|
||||||
|
|
||||||
counter = main_cycle_counter_get();
|
counter = main_cycle_counter_get();
|
||||||
core_cycle_count = core_cycle_counter_get();
|
core_cycle_count = DWT->CYCCNT;
|
||||||
if (hex) {
|
if (hex) {
|
||||||
shellmatta_printf(handle, "Main loop: 0x%016"PRIX64"\r\n", counter);
|
shellmatta_printf(handle, "Main loop: 0x%016"PRIX64"\r\n", counter);
|
||||||
shellmatta_printf(handle, "CPU cycles: 0x%08"PRIX32"\r\n", core_cycle_count);
|
shellmatta_printf(handle, "CPU cycles: 0x%08"PRIX32"\r\n", core_cycle_count);
|
||||||
@ -901,8 +901,8 @@ shellmatta_retCode_t shell_cmd_cycle_count(const shellmatta_handle_t handle, con
|
|||||||
shellmatta_printf(handle, "CPU cycles: %"PRIu32"\r\n", core_cycle_count);
|
shellmatta_printf(handle, "CPU cycles: %"PRIu32"\r\n", core_cycle_count);
|
||||||
}
|
}
|
||||||
if (clear) {
|
if (clear) {
|
||||||
main_cycle_counter_reset();
|
main_cycle_counter_init();
|
||||||
core_cycle_counter_reset();
|
DWT->CYCCNT = 0UL;
|
||||||
}
|
}
|
||||||
return SHELLMATTA_OK;
|
return SHELLMATTA_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user